Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic auth not working - sending null byte array for password field #299

Open
FaheemBhatti opened this issue Dec 8, 2023 · 2 comments
Open

Comments

@FaheemBhatti
Copy link

I'm using a Java library for my ocpp operations. groupId of pom dependencies: eu.chargetime.ocpp.

Right now I'm trying to implement the authenticateSession method from ServerEvents, so that anytime a wallbox requests a connection to our backend, we validate the input password that comes as byte array. However, for some reason in most of the wallboxes that my company owns the password field comes as null, despite adding a password in the authorizationKey text field of their UI-s.

How do you usually handle the basic auth workflow for such cases? Has anyone ever faced a similar issue and how have you managed to resolve it?

I am attaching my code snippet for ServerEventConfig.java

	public ServerEvents createServerCoreImpl() {
		return getNewServerEventsImpl();
	}

	private ServerEvents getNewServerEventsImpl() {
		return new ServerEvents() {

			@Override
			public void newSession(UUID sessionIndex, SessionInformation information) {
				log.info("New session " + sessionIndex + ": " + information.getIdentifier());
				log.info("InetSocketAddress: " + information.getAddress());
				log.info("Soap to URL: " + information.getSOAPtoURL());
				sessionHandler.addSession(information.getIdentifier(), sessionIndex);
				SessionDetail sessionDetailsToStore =  sessionHandler.buildWebSocketSession(information.getIdentifier().substring(1) , sessionIndex.toString());
				sessionHandler.storeSessionInSessionCollection(sessionDetailsToStore);
				executePostSessionActions(sessionIndex);
			}

			@Override
			public void lostSession(UUID sessionIndex) {
				LocalDateTime eventTimestamp = LocalDateTime.now();
				String identifier = sessionHandler.getCpIdBySessionId(sessionIndex);
				log.info("Session " + sessionIndex + " having identifier: " + identifier + " lost connection");
				String connectorId = sessionHandler.getCpIdBySessionId(sessionIndex);
				sessionHandler.deleteSession(connectorId, sessionIndex);
				sessionHandler.deleteSessionFromDb(sessionIndex.toString());
				sessionHandler.handlerConnectorStatusOnConnectionLost(connectorId, eventTimestamp);
			}

			@Override
			public void authenticateSession(SessionInformation information, String username, byte[] password) throws AuthenticationException
			{
				
				log.info(username);
				log.info(password.toString());
			}
		};
	}

Thank you in advance:)

@jmluy
Copy link
Contributor

jmluy commented Dec 13, 2023

Is it the same case as #240?

@bantu
Copy link
Contributor

bantu commented Jan 24, 2024

Is your password the expected length? See #240 (comment) as indicated by @jmluy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants