Class OidcAuthServiceOperations

java.lang.Object
dev.getelements.elements.service.auth.oidc.OidcAuthServiceOperations

public class OidcAuthServiceOperations extends Object
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    claimAsString(com.auth0.jwt.interfaces.DecodedJWT jwt, String claimName)
    Reads a claim as a string, tolerating a bare null from Payload.getClaim(String) — a real DecodedJWT never returns null there (a missing claim comes back as a NullClaim whose asString() 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.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)
     
    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.
    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 (if expectedAudience is non-null) and nonce (if expectedNonce is non-null) claims.
    static Map<String,String>
    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.ApplicationDao
     
    jakarta.ws.rs.client.Client
     
    long
     
    dev.getelements.elements.sdk.service.name.NameService
     
    dev.getelements.elements.sdk.dao.OidcAuthSchemeDao
     
    dev.getelements.elements.sdk.dao.ProfileDao
     
    dev.getelements.elements.sdk.dao.SessionDao
     
    long
     
    void
    setApplicationDao(dev.getelements.elements.sdk.dao.ApplicationDao applicationDao)
     
    void
    setClient(jakarta.ws.rs.client.Client client)
     
    void
    setJwksRefreshIntervalSeconds(long jwksRefreshIntervalSeconds)
     
    void
    setNameService(dev.getelements.elements.sdk.service.name.NameService nameService)
     
    void
    setOidcAuthSchemeDao(dev.getelements.elements.sdk.dao.OidcAuthSchemeDao oidcAuthSchemeDao)
     
    void
    setProfileDao(dev.getelements.elements.sdk.dao.ProfileDao profileDao)
     
    void
    setSessionDao(dev.getelements.elements.sdk.dao.SessionDao SessionDao)
     
    void
    setSessionTimeoutSeconds(long sessionTimeoutSeconds)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 (if expectedAudience is non-null) and nonce (if expectedNonce is 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 as null) 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 validate
      scheme - the scheme to validate against
      expectedAudience - the expected 'aud' claim value, or null to skip the check
      expectedNonce - the expected 'nonce' claim value, or null to 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)
      Parameters:
      decodedJWT - the already-validated, decoded JWT
      scheme - the scheme the token was validated against
      userMapper - resolves/creates the User for 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

      public static String claimAsString(com.auth0.jwt.interfaces.DecodedJWT jwt, String claimName)
      Reads a claim as a string, tolerating a bare null from Payload.getClaim(String) — a real DecodedJWT never returns null there (a missing claim comes back as a NullClaim whose asString() 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 calling getClaim(...) .asString() directly.
      Parameters:
      jwt - the decoded id_token
      claimName - the claim name
      Returns:
      the claim's string value, or null if absent
    • extractProfileClaims

      public static Map<String,String> 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. Used to snapshot a linked scheme's reported profile data onto User.getLinkedAccountProfiles().
      Parameters:
      jwt - the decoded id_token
      Returns:
      a map of present profile claim names to their string values; empty if none are present