Class SolidOidcSession

java.lang.Object
com.janeirodigital.sai.authentication.SolidOidcSession
All Implemented Interfaces:
AuthorizedSession, Serializable

public class SolidOidcSession extends Object implements AuthorizedSession
Implementation of AuthorizedSession for Solid-OIDC. Must use SolidOidcSession.Builder for session creation.
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Builder for SolidOidcSession instances.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected static com.nimbusds.oauth2.sdk.dpop.DPoPProofFactory
    getDPoPProofFactory(com.nimbusds.jose.jwk.ECKey ecJwk)
    Gets a DPoP proof factory that can be used for generate DPoP proofs for requests made by the session.
    protected static com.nimbusds.jose.jwk.ECKey
    getEllipticCurveKey(com.nimbusds.jose.jwk.Curve curve)
     
    protected static com.nimbusds.jwt.SignedJWT
    getProof(com.nimbusds.oauth2.sdk.dpop.DPoPProofFactory proofFactory, com.janeirodigital.sai.httputils.HttpMethod method, URI uri)
    Gets the required DPoP proof that must be created for each request based on the method and target uri.
    protected static com.nimbusds.oauth2.sdk.token.Tokens
    obtainTokens(URI oidcTokenEndpoint, com.nimbusds.oauth2.sdk.id.ClientID clientId, com.nimbusds.oauth2.sdk.AuthorizationGrant grant, com.nimbusds.oauth2.sdk.dpop.DPoPProofFactory proofFactory)
    Post a token request to the token endpoint provided in oidcProviderMetadata.
    void
    Refreshes the tokens associated with the session.
    toHttpHeaders(com.janeirodigital.sai.httputils.HttpMethod method, URI uri)
    Generates a map of HTTP Authorization headers that can be use to make authorized requests using the session.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.janeirodigital.sai.authentication.AuthorizedSession

    getAccessToken, getApplicationId, getId, getOidcProviderId, getRefreshToken, getSocialAgentId
  • Constructor Details

  • Method Details

    • toHttpHeaders

      public Map<String,String> toHttpHeaders(com.janeirodigital.sai.httputils.HttpMethod method, URI uri) throws SaiAuthenticationException
      Generates a map of HTTP Authorization headers that can be use to make authorized requests using the session. DPoP requires a proof to be created for each request based on the method and target uri.
      Specified by:
      toHttpHeaders in interface AuthorizedSession
      Parameters:
      method - HTTP method of the request
      uri - Target URI of the request
      Returns:
      Map of HTTP Authorization headers
      Throws:
      SaiAuthenticationException
    • refresh

      public void refresh() throws SaiAuthenticationException
      Refreshes the tokens associated with the session. Session must have been established as refreshable upon creation.
      Specified by:
      refresh in interface AuthorizedSession
      Throws:
      SaiAuthenticationException
    • getProof

      protected static com.nimbusds.jwt.SignedJWT getProof(com.nimbusds.oauth2.sdk.dpop.DPoPProofFactory proofFactory, com.janeirodigital.sai.httputils.HttpMethod method, URI uri) throws SaiAuthenticationException
      Gets the required DPoP proof that must be created for each request based on the method and target uri.
      Parameters:
      proofFactory - DPoP proof factory
      method - HTTP method of the request
      uri - Target URI of the request
      Returns:
      DPoP proof
      Throws:
      SaiAuthenticationException
    • getEllipticCurveKey

      protected static com.nimbusds.jose.jwk.ECKey getEllipticCurveKey(com.nimbusds.jose.jwk.Curve curve) throws SaiAuthenticationException
      Throws:
      SaiAuthenticationException
    • getDPoPProofFactory

      protected static com.nimbusds.oauth2.sdk.dpop.DPoPProofFactory getDPoPProofFactory(com.nimbusds.jose.jwk.ECKey ecJwk) throws SaiAuthenticationException
      Gets a DPoP proof factory that can be used for generate DPoP proofs for requests made by the session.
      Parameters:
      ecJwk - Elliptic Curve JWK
      Returns:
      DPoPProofFactory
      Throws:
      SaiAuthenticationException
    • obtainTokens

      protected static com.nimbusds.oauth2.sdk.token.Tokens obtainTokens(URI oidcTokenEndpoint, com.nimbusds.oauth2.sdk.id.ClientID clientId, com.nimbusds.oauth2.sdk.AuthorizationGrant grant, com.nimbusds.oauth2.sdk.dpop.DPoPProofFactory proofFactory) throws SaiAuthenticationException
      Post a token request to the token endpoint provided in oidcProviderMetadata. Used in both the initial token request as well as in subsequent token refreshes.
      Parameters:
      oidcTokenEndpoint - URI of the oidc token endpoint
      clientId - client identifier
      grant - authorization grant
      proofFactory - DPoP proof factory
      Returns:
      Tokens object containing requested tokens
      Throws:
      SaiAuthenticationException