@Test(expected = IllegalStateException.class) public void testOidcNotEnabledCreateState() throws Exception { final OidcService service = getServiceWithNoOidcSupport(); service.createState(TEST_REQUEST_IDENTIFIER); }
public State createState(final String oidcRequestIdentifier) { if (!isOidcEnabled()) { throw new IllegalStateException(OPEN_ID_CONNECT_SUPPORT_IS_NOT_CONFIGURED); } final CacheKey oidcRequestIdentifierKey = new CacheKey(oidcRequestIdentifier); final State state = new State(generateStateValue()); try { synchronized (stateLookupForPendingRequests) { final State cachedState = stateLookupForPendingRequests.get(oidcRequestIdentifierKey, () -> state); if (!timeConstantEqualityCheck(state.getValue(), cachedState.getValue())) { throw new IllegalStateException("An existing login request is already in progress."); } } } catch (ExecutionException e) { throw new IllegalStateException("Unable to store the login request state."); } return state; }
OidcService { public State createState(final String oidcRequestIdentifier) { if (!isOidcEnabled()) { throw new IllegalStateException(OPEN_ID_CONNECT_SUPPORT_IS_NOT_CONFIGURED); } final CacheKey oidcRequestIdentifierKey = new CacheKey(oidcRequestIdentifier); final State state = new State(generateStateValue()); try { synchronized (stateLookupForPendingRequests) { final State cachedState = stateLookupForPendingRequests.get(oidcRequestIdentifierKey, () -> state); if (!timeConstantEqualityCheck(state.getValue(), cachedState.getValue())) { throw new IllegalStateException("An existing login request is already in progress."); } } } catch (ExecutionException e) { throw new IllegalStateException("Unable to store the login request state."); } return state; } }
OidcService { public State createState(final String oidcRequestIdentifier) { if (!isOidcEnabled()) { throw new IllegalStateException(OPEN_ID_CONNECT_SUPPORT_IS_NOT_CONFIGURED); } final CacheKey oidcRequestIdentifierKey = new CacheKey(oidcRequestIdentifier); final State state = new State(generateStateValue()); try { synchronized (stateLookupForPendingRequests) { final State cachedState = stateLookupForPendingRequests.get(oidcRequestIdentifierKey, () -> state); if (!timeConstantEqualityCheck(state.getValue(), cachedState.getValue())) { throw new IllegalStateException("An existing login request is already in progress."); } } } catch (ExecutionException e) { throw new IllegalStateException("Unable to store the login request state."); } return state; } OidcService(final OidcIdentityProvider identityProvider);  OidcService(final OidcIdentityProvider identityProvider, final int duration, final TimeUnit units); }
OidcService { public State createState(final String oidcRequestIdentifier) { if (!isOidcEnabled()) { throw new IllegalStateException(OPEN_ID_CONNECT_SUPPORT_IS_NOT_CONFIGURED); } final CacheKey oidcRequestIdentifierKey = new CacheKey(oidcRequestIdentifier); final State state = new State(generateStateValue()); try { synchronized (stateLookupForPendingRequests) { final State cachedState = stateLookupForPendingRequests.get(oidcRequestIdentifierKey, () -> state); if (!timeConstantEqualityCheck(state.getValue(), cachedState.getValue())) { throw new IllegalStateException("An existing login request is already in progress."); } } } catch (ExecutionException e) { throw new IllegalStateException("Unable to store the login request state."); } return state; } OidcService(final OidcIdentityProvider identityProvider);  OidcService(final OidcIdentityProvider identityProvider, final int duration, final TimeUnit units); boolean isOidcEnabled(); URI getAuthorizationEndpoint(); URI getEndSessionEndpoint(); Scope getScope(); String getClientId(); State createState(final String oidcRequestIdentifier); boolean isStateValid(final String oidcRequestIdentifier, final State proposedState); RefreshToken exchangeAuthorizationCode(final String oidcRequestIdentifier, final AuthorizationGrant authorizationGrant); String getJwtFromOIDCTokens(OIDCTokens oidcTokens); OIDCTokens exchangeOIDCToken(AuthorizationGrant authorizationGrant); OIDCTokenResponse exchangeOIDCToken(RefreshToken refreshToken); String getJwt(final String oidcRequestIdentifier); }
OidcService { public State createState(final String oidcRequestIdentifier) { if (!isOidcEnabled()) { throw new IllegalStateException(OPEN_ID_CONNECT_SUPPORT_IS_NOT_CONFIGURED); } final CacheKey oidcRequestIdentifierKey = new CacheKey(oidcRequestIdentifier); final State state = new State(generateStateValue()); try { synchronized (stateLookupForPendingRequests) { final State cachedState = stateLookupForPendingRequests.get(oidcRequestIdentifierKey, () -> state); if (!timeConstantEqualityCheck(state.getValue(), cachedState.getValue())) { throw new IllegalStateException("An existing login request is already in progress."); } } } catch (ExecutionException e) { throw new IllegalStateException("Unable to store the login request state."); } return state; } OidcService(final OidcIdentityProvider identityProvider);  OidcService(final OidcIdentityProvider identityProvider, final int duration, final TimeUnit units); boolean isOidcEnabled(); URI getAuthorizationEndpoint(); URI getEndSessionEndpoint(); Scope getScope(); String getClientId(); State createState(final String oidcRequestIdentifier); boolean isStateValid(final String oidcRequestIdentifier, final State proposedState); RefreshToken exchangeAuthorizationCode(final String oidcRequestIdentifier, final AuthorizationGrant authorizationGrant); String getJwtFromOIDCTokens(OIDCTokens oidcTokens); OIDCTokens exchangeOIDCToken(AuthorizationGrant authorizationGrant); OIDCTokenResponse exchangeOIDCToken(RefreshToken refreshToken); String getJwt(final String oidcRequestIdentifier);  }