@Test(expected = IllegalStateException.class) public void testOidcNotEnabledValidateState() throws Exception { final OidcService service = getServiceWithNoOidcSupport(); service.isStateValid(TEST_REQUEST_IDENTIFIER, new State(TEST_STATE)); }
public boolean isStateValid(final String oidcRequestIdentifier, final State proposedState) { if (!isOidcEnabled()) { throw new IllegalStateException(OPEN_ID_CONNECT_SUPPORT_IS_NOT_CONFIGURED); } if (proposedState == null) { throw new IllegalArgumentException("Proposed state must be specified."); } final CacheKey oidcRequestIdentifierKey = new CacheKey(oidcRequestIdentifier); synchronized (stateLookupForPendingRequests) { final State state = stateLookupForPendingRequests.getIfPresent(oidcRequestIdentifierKey); if (state != null) { stateLookupForPendingRequests.invalidate(oidcRequestIdentifierKey); } return state != null && timeConstantEqualityCheck(state.getValue(), proposedState.getValue()); } }
OidcService { public boolean isStateValid(final String oidcRequestIdentifier, final State proposedState) { if (!isOidcEnabled()) { throw new IllegalStateException(OPEN_ID_CONNECT_SUPPORT_IS_NOT_CONFIGURED); } if (proposedState == null) { throw new IllegalArgumentException("Proposed state must be specified."); } final CacheKey oidcRequestIdentifierKey = new CacheKey(oidcRequestIdentifier); synchronized (stateLookupForPendingRequests) { final State state = stateLookupForPendingRequests.getIfPresent(oidcRequestIdentifierKey); if (state != null) { stateLookupForPendingRequests.invalidate(oidcRequestIdentifierKey); } return state != null && timeConstantEqualityCheck(state.getValue(), proposedState.getValue()); } } }
OidcService { public boolean isStateValid(final String oidcRequestIdentifier, final State proposedState) { if (!isOidcEnabled()) { throw new IllegalStateException(OPEN_ID_CONNECT_SUPPORT_IS_NOT_CONFIGURED); } if (proposedState == null) { throw new IllegalArgumentException("Proposed state must be specified."); } final CacheKey oidcRequestIdentifierKey = new CacheKey(oidcRequestIdentifier); synchronized (stateLookupForPendingRequests) { final State state = stateLookupForPendingRequests.getIfPresent(oidcRequestIdentifierKey); if (state != null) { stateLookupForPendingRequests.invalidate(oidcRequestIdentifierKey); } return state != null && timeConstantEqualityCheck(state.getValue(), proposedState.getValue()); } } OidcService(final OidcIdentityProvider identityProvider);  OidcService(final OidcIdentityProvider identityProvider, final int duration, final TimeUnit units); }
OidcService { public boolean isStateValid(final String oidcRequestIdentifier, final State proposedState) { if (!isOidcEnabled()) { throw new IllegalStateException(OPEN_ID_CONNECT_SUPPORT_IS_NOT_CONFIGURED); } if (proposedState == null) { throw new IllegalArgumentException("Proposed state must be specified."); } final CacheKey oidcRequestIdentifierKey = new CacheKey(oidcRequestIdentifier); synchronized (stateLookupForPendingRequests) { final State state = stateLookupForPendingRequests.getIfPresent(oidcRequestIdentifierKey); if (state != null) { stateLookupForPendingRequests.invalidate(oidcRequestIdentifierKey); } return state != null && timeConstantEqualityCheck(state.getValue(), proposedState.getValue()); } } 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 boolean isStateValid(final String oidcRequestIdentifier, final State proposedState) { if (!isOidcEnabled()) { throw new IllegalStateException(OPEN_ID_CONNECT_SUPPORT_IS_NOT_CONFIGURED); } if (proposedState == null) { throw new IllegalArgumentException("Proposed state must be specified."); } final CacheKey oidcRequestIdentifierKey = new CacheKey(oidcRequestIdentifier); synchronized (stateLookupForPendingRequests) { final State state = stateLookupForPendingRequests.getIfPresent(oidcRequestIdentifierKey); if (state != null) { stateLookupForPendingRequests.invalidate(oidcRequestIdentifierKey); } return state != null && timeConstantEqualityCheck(state.getValue(), proposedState.getValue()); } } 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);  }