@Test public void validateShouldNotThrowExceptionIfChargingStationIdNull() { when(tokenRepository.findToken(IDENTIFYING_TOKEN.getToken(), null)).thenReturn(null); assertFalse(localAuthorization.validate(IDENTIFYING_TOKEN, CHARGING_STATION_ID).isValid()); }
@Override public IdentifyingToken validate(IdentifyingToken identifyingToken, @Nullable ChargingStationId chargingStationId) { LOG.debug("validate({}, {})", identifyingToken.getToken(), chargingStationId); String stationIdentifier = null; if (chargingStationId != null) { stationIdentifier = chargingStationId.getId(); } LocalToken localToken = tokenRepository.findToken(identifyingToken.getToken(), stationIdentifier); if (localToken != null) { if (localToken.isValid()) { LOG.debug("Token valid: {}", localToken.getHiddenId()); return new TextualToken(localToken.getHiddenId(), IdentifyingToken.AuthenticationStatus.ACCEPTED, null, localToken.getVisualId()); } else { LOG.debug("Token not valid: {}", localToken.getHiddenId()); } } else { LOG.debug("Token {} not found for charging station {}", identifyingToken.getToken(), chargingStationId); } return identifyingToken; }
LocalAuthorization implements AuthorizationProvider { @Override public IdentifyingToken validate(IdentifyingToken identifyingToken, @Nullable ChargingStationId chargingStationId) { LOG.debug("validate({}, {})", identifyingToken.getToken(), chargingStationId); String stationIdentifier = null; if (chargingStationId != null) { stationIdentifier = chargingStationId.getId(); } LocalToken localToken = tokenRepository.findToken(identifyingToken.getToken(), stationIdentifier); if (localToken != null) { if (localToken.isValid()) { LOG.debug("Token valid: {}", localToken.getHiddenId()); return new TextualToken(localToken.getHiddenId(), IdentifyingToken.AuthenticationStatus.ACCEPTED, null, localToken.getVisualId()); } else { LOG.debug("Token not valid: {}", localToken.getHiddenId()); } } else { LOG.debug("Token {} not found for charging station {}", identifyingToken.getToken(), chargingStationId); } return identifyingToken; } }
LocalAuthorization implements AuthorizationProvider { @Override public IdentifyingToken validate(IdentifyingToken identifyingToken, @Nullable ChargingStationId chargingStationId) { LOG.debug("validate({}, {})", identifyingToken.getToken(), chargingStationId); String stationIdentifier = null; if (chargingStationId != null) { stationIdentifier = chargingStationId.getId(); } LocalToken localToken = tokenRepository.findToken(identifyingToken.getToken(), stationIdentifier); if (localToken != null) { if (localToken.isValid()) { LOG.debug("Token valid: {}", localToken.getHiddenId()); return new TextualToken(localToken.getHiddenId(), IdentifyingToken.AuthenticationStatus.ACCEPTED, null, localToken.getVisualId()); } else { LOG.debug("Token not valid: {}", localToken.getHiddenId()); } } else { LOG.debug("Token {} not found for charging station {}", identifyingToken.getToken(), chargingStationId); } return identifyingToken; }  }
LocalAuthorization implements AuthorizationProvider { @Override public IdentifyingToken validate(IdentifyingToken identifyingToken, @Nullable ChargingStationId chargingStationId) { LOG.debug("validate({}, {})", identifyingToken.getToken(), chargingStationId); String stationIdentifier = null; if (chargingStationId != null) { stationIdentifier = chargingStationId.getId(); } LocalToken localToken = tokenRepository.findToken(identifyingToken.getToken(), stationIdentifier); if (localToken != null) { if (localToken.isValid()) { LOG.debug("Token valid: {}", localToken.getHiddenId()); return new TextualToken(localToken.getHiddenId(), IdentifyingToken.AuthenticationStatus.ACCEPTED, null, localToken.getVisualId()); } else { LOG.debug("Token not valid: {}", localToken.getHiddenId()); } } else { LOG.debug("Token {} not found for charging station {}", identifyingToken.getToken(), chargingStationId); } return identifyingToken; }  @Override IdentifyingToken validate(IdentifyingToken identifyingToken, @Nullable ChargingStationId chargingStationId); void setTokenRepository(TokenRepository tokenRepository); void setChargingStationRepository(ChargingStationRepository chargingStationRepository); }
LocalAuthorization implements AuthorizationProvider { @Override public IdentifyingToken validate(IdentifyingToken identifyingToken, @Nullable ChargingStationId chargingStationId) { LOG.debug("validate({}, {})", identifyingToken.getToken(), chargingStationId); String stationIdentifier = null; if (chargingStationId != null) { stationIdentifier = chargingStationId.getId(); } LocalToken localToken = tokenRepository.findToken(identifyingToken.getToken(), stationIdentifier); if (localToken != null) { if (localToken.isValid()) { LOG.debug("Token valid: {}", localToken.getHiddenId()); return new TextualToken(localToken.getHiddenId(), IdentifyingToken.AuthenticationStatus.ACCEPTED, null, localToken.getVisualId()); } else { LOG.debug("Token not valid: {}", localToken.getHiddenId()); } } else { LOG.debug("Token {} not found for charging station {}", identifyingToken.getToken(), chargingStationId); } return identifyingToken; }  @Override IdentifyingToken validate(IdentifyingToken identifyingToken, @Nullable ChargingStationId chargingStationId); void setTokenRepository(TokenRepository tokenRepository); void setChargingStationRepository(ChargingStationRepository chargingStationRepository);  }