Class OidcAuthServiceOperations
java.lang.Object
dev.getelements.elements.service.auth.oidc.OidcAuthServiceOperations
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringclaimAsString(com.auth0.jwt.interfaces.DecodedJWT jwt, String claimName) Reads a claim as a string, tolerating a barenullfromPayload.getClaim(String)— a realDecodedJWTnever returns null there (a missing claim comes back as aNullClaimwhoseasString()is null), but a mocked one used in tests can return a bare null for an unstubbed claim name.dev.getelements.elements.sdk.model.session.SessionCreationcreateOrUpdateUserWithToken(dev.getelements.elements.sdk.model.session.OidcSessionRequest oidcSessionRequest, BiFunction<com.auth0.jwt.interfaces.DecodedJWT, dev.getelements.elements.sdk.model.auth.OidcAuthScheme, dev.getelements.elements.sdk.model.user.User> userMapper) dev.getelements.elements.sdk.model.session.SessionCreationcreateOrUpdateUserWithVerifiedToken(com.auth0.jwt.interfaces.DecodedJWT decodedJWT, dev.getelements.elements.sdk.model.auth.OidcAuthScheme scheme, BiFunction<com.auth0.jwt.interfaces.DecodedJWT, dev.getelements.elements.sdk.model.auth.OidcAuthScheme, dev.getelements.elements.sdk.model.user.User> userMapper) Maps and creates/updates the user and session for an already-validated JWT.com.auth0.jwt.interfaces.DecodedJWTdecodeAndVerify(String idToken, dev.getelements.elements.sdk.model.auth.OidcAuthScheme scheme, String expectedAudience, String expectedNonce) Decodes and validates a possessed id_token against the given scheme, additionally checking the audience (ifexpectedAudienceis non-null) and nonce (ifexpectedNonceis non-null) claims.extractProfileClaims(com.auth0.jwt.interfaces.DecodedJWT jwt) Extracts whichever standard OIDC profile-scope claims are actually present in the given token, keyed by their raw claim name.dev.getelements.elements.sdk.dao.ApplicationDaojakarta.ws.rs.client.Clientlongdev.getelements.elements.sdk.service.name.NameServicedev.getelements.elements.sdk.dao.OidcAuthSchemeDaodev.getelements.elements.sdk.dao.ProfileDaodev.getelements.elements.sdk.dao.SessionDaolongvoidsetApplicationDao(dev.getelements.elements.sdk.dao.ApplicationDao applicationDao) voidsetClient(jakarta.ws.rs.client.Client client) voidsetJwksRefreshIntervalSeconds(long jwksRefreshIntervalSeconds) voidsetNameService(dev.getelements.elements.sdk.service.name.NameService nameService) voidsetOidcAuthSchemeDao(dev.getelements.elements.sdk.dao.OidcAuthSchemeDao oidcAuthSchemeDao) voidsetProfileDao(dev.getelements.elements.sdk.dao.ProfileDao profileDao) voidsetSessionDao(dev.getelements.elements.sdk.dao.SessionDao SessionDao) voidsetSessionTimeoutSeconds(long sessionTimeoutSeconds)
-
Constructor Details
-
OidcAuthServiceOperations
public OidcAuthServiceOperations()
-
-
Method Details
-
createOrUpdateUserWithToken
public dev.getelements.elements.sdk.model.session.SessionCreation createOrUpdateUserWithToken(dev.getelements.elements.sdk.model.session.OidcSessionRequest oidcSessionRequest, BiFunction<com.auth0.jwt.interfaces.DecodedJWT, dev.getelements.elements.sdk.model.auth.OidcAuthScheme, dev.getelements.elements.sdk.model.user.User> userMapper) -
decodeAndVerify
public com.auth0.jwt.interfaces.DecodedJWT decodeAndVerify(String idToken, dev.getelements.elements.sdk.model.auth.OidcAuthScheme scheme, String expectedAudience, String expectedNonce) Decodes and validates a possessed id_token against the given scheme, additionally checking the audience (ifexpectedAudienceis non-null) and nonce (ifexpectedNonceis non-null) claims. Shared by the direct id_token path (createOrUpdateUserWithToken(dev.getelements.elements.sdk.model.session.OidcSessionRequest, java.util.function.BiFunction<com.auth0.jwt.interfaces.DecodedJWT, dev.getelements.elements.sdk.model.auth.OidcAuthScheme, dev.getelements.elements.sdk.model.user.User>), which passes both asnull) and the browser-redirect callback path, which passes the provider's client id and the attempt's bound nonce.- Parameters:
idToken- the id_token to decode and validatescheme- the scheme to validate againstexpectedAudience- the expected 'aud' claim value, ornullto skip the checkexpectedNonce- the expected 'nonce' claim value, ornullto skip the check- Returns:
- the decoded, validated JWT
-
createOrUpdateUserWithVerifiedToken
public dev.getelements.elements.sdk.model.session.SessionCreation createOrUpdateUserWithVerifiedToken(com.auth0.jwt.interfaces.DecodedJWT decodedJWT, dev.getelements.elements.sdk.model.auth.OidcAuthScheme scheme, BiFunction<com.auth0.jwt.interfaces.DecodedJWT, dev.getelements.elements.sdk.model.auth.OidcAuthScheme, dev.getelements.elements.sdk.model.user.User> userMapper) Maps and creates/updates the user and session for an already-validated JWT. Callers that have already validated the token (e.g. viadecodeAndVerify(java.lang.String, dev.getelements.elements.sdk.model.auth.OidcAuthScheme, java.lang.String, java.lang.String)) use this directly rather than re-validating throughcreateOrUpdateUserWithToken(dev.getelements.elements.sdk.model.session.OidcSessionRequest, java.util.function.BiFunction<com.auth0.jwt.interfaces.DecodedJWT, dev.getelements.elements.sdk.model.auth.OidcAuthScheme, dev.getelements.elements.sdk.model.user.User>).- Parameters:
decodedJWT- the already-validated, decoded JWTscheme- the scheme the token was validated againstuserMapper- resolves/creates theUserfor the token- Returns:
- the created session
-
getClient
public jakarta.ws.rs.client.Client getClient() -
setClient
@Inject public void setClient(jakarta.ws.rs.client.Client client) -
getNameService
public dev.getelements.elements.sdk.service.name.NameService getNameService() -
setNameService
@Inject public void setNameService(dev.getelements.elements.sdk.service.name.NameService nameService) -
getProfileDao
public dev.getelements.elements.sdk.dao.ProfileDao getProfileDao() -
setProfileDao
@Inject public void setProfileDao(dev.getelements.elements.sdk.dao.ProfileDao profileDao) -
getSessionDao
public dev.getelements.elements.sdk.dao.SessionDao getSessionDao() -
setSessionDao
@Inject public void setSessionDao(dev.getelements.elements.sdk.dao.SessionDao SessionDao) -
getApplicationDao
public dev.getelements.elements.sdk.dao.ApplicationDao getApplicationDao() -
setApplicationDao
@Inject public void setApplicationDao(dev.getelements.elements.sdk.dao.ApplicationDao applicationDao) -
getSessionTimeoutSeconds
public long getSessionTimeoutSeconds() -
setSessionTimeoutSeconds
@Inject public void setSessionTimeoutSeconds(@Named("dev.getelements.elements.session.timeout.seconds") long sessionTimeoutSeconds) -
getOidcAuthSchemeDao
public dev.getelements.elements.sdk.dao.OidcAuthSchemeDao getOidcAuthSchemeDao() -
setOidcAuthSchemeDao
@Inject public void setOidcAuthSchemeDao(dev.getelements.elements.sdk.dao.OidcAuthSchemeDao oidcAuthSchemeDao) -
getJwksRefreshIntervalSeconds
public long getJwksRefreshIntervalSeconds() -
setJwksRefreshIntervalSeconds
@Inject public void setJwksRefreshIntervalSeconds(@Named("dev.getelements.elements.oidc.jwks.refresh.seconds") long jwksRefreshIntervalSeconds) -
claimAsString
Reads a claim as a string, tolerating a barenullfromPayload.getClaim(String)— a realDecodedJWTnever returns null there (a missing claim comes back as aNullClaimwhoseasString()is null), but a mocked one used in tests can return a bare null for an unstubbed claim name. All claim reads in this package should go through this rather than callinggetClaim(...) .asString()directly.- Parameters:
jwt- the decoded id_tokenclaimName- the claim name- Returns:
- the claim's string value, or
nullif absent
-
extractProfileClaims
Extracts whichever standard OIDC profile-scope claims are actually present in the given token, keyed by their raw claim name. Used to snapshot a linked scheme's reported profile data ontoUser.getLinkedAccountProfiles().- Parameters:
jwt- the decoded id_token- Returns:
- a map of present profile claim names to their string values; empty if none are present
-