java.lang.Object
com.irurueta.authserver.authorization.infrastructure.persistence.clients.RegisteredClientMapper

@Component public class RegisteredClientMapper extends Object
Maps the domain ClientRegistration onto Spring Authorization Server's RegisteredClient and back. The audiences, which the framework has no field for, travel as the "settings.client.audiences" custom client setting.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Name of the custom client setting that holds the audiences of the access tokens issued to the client.
    private static final String
    Authentication method that marks a public client.
    static final String
    Name of the custom client setting that holds the client's registered public JWK set as JSON, used to verify private_key_jwt assertions and self-signed certificates.
    static final String
    Name of the custom client setting that makes every user of the client complete a second factor.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    audiencesOf(org.springframework.security.oauth2.server.authorization.settings.ClientSettings settings)
    Reads the audiences custom setting.
    jwksOf(org.springframework.security.oauth2.server.authorization.settings.ClientSettings settings)
    Reads the registered JWK set custom setting.
    boolean
    mfaRequiredOf(org.springframework.security.oauth2.server.authorization.settings.ClientSettings settings)
    Reads the second-factor custom setting.
    private String
    signingAlgorithmNameOf(org.springframework.security.oauth2.server.authorization.settings.ClientSettings settings)
    Reads the token endpoint authentication signing algorithm.
    private org.springframework.security.oauth2.jose.jws.SignatureAlgorithm
    Resolves a JWS signature algorithm by name.
    org.springframework.security.oauth2.server.authorization.client.RegisteredClient
    toRegisteredClient(ClientRegistration registration, String id, Instant issuedAt, String secret)
    Maps a registration to a registered client.
    toRegistration(org.springframework.security.oauth2.server.authorization.client.RegisteredClient client)
    Maps a registered client to a registration.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • AUDIENCES_SETTING

      public static final String AUDIENCES_SETTING
      Name of the custom client setting that holds the audiences of the access tokens issued to the client.
      See Also:
    • MFA_REQUIRED_SETTING

      public static final String MFA_REQUIRED_SETTING
      Name of the custom client setting that makes every user of the client complete a second factor. It is only written and read here: everybody else asks ClientRegistration.mfaRequired() through the client port.
      See Also:
    • JWKS_SETTING

      public static final String JWKS_SETTING
      Name of the custom client setting that holds the client's registered public JWK set as JSON, used to verify private_key_jwt assertions and self-signed certificates.
      See Also:
    • AUTH_METHOD_NONE

      private static final String AUTH_METHOD_NONE
      Authentication method that marks a public client.
  • Constructor Details

    • RegisteredClientMapper

      public RegisteredClientMapper()
  • Method Details

    • toRegisteredClient

      public org.springframework.security.oauth2.server.authorization.client.RegisteredClient toRegisteredClient(ClientRegistration registration, String id, Instant issuedAt, String secret)
      Maps a registration to a registered client.
      Parameters:
      registration - the registration.
      id - internal identifier of the registered client.
      issuedAt - instant the client identifier was issued.
      secret - encoded secret, or null.
      Returns:
      the registered client.
      Throws:
      IllegalArgumentException - if the token endpoint signing algorithm is not a JWS signature algorithm.
    • toRegistration

      public ClientRegistration toRegistration(org.springframework.security.oauth2.server.authorization.client.RegisteredClient client)
      Maps a registered client to a registration. The framework keeps these collections as sets, so they are returned sorted to make the result deterministic. A client is confidential unless it authenticates with none.
      Parameters:
      client - the registered client.
      Returns:
      the registration.
    • audiencesOf

      public List<String> audiencesOf(org.springframework.security.oauth2.server.authorization.settings.ClientSettings settings)
      Reads the audiences custom setting.
      Parameters:
      settings - client settings.
      Returns:
      the audiences; empty when the setting is absent (the registration then defaults to the client id).
    • mfaRequiredOf

      public boolean mfaRequiredOf(org.springframework.security.oauth2.server.authorization.settings.ClientSettings settings)
      Reads the second-factor custom setting.
      Parameters:
      settings - client settings.
      Returns:
      true only when the setting is present and true.
    • jwksOf

      public String jwksOf(org.springframework.security.oauth2.server.authorization.settings.ClientSettings settings)
      Reads the registered JWK set custom setting.
      Parameters:
      settings - client settings.
      Returns:
      the JWK set JSON, or null when the setting is absent.
    • signingAlgorithmNameOf

      private String signingAlgorithmNameOf(org.springframework.security.oauth2.server.authorization.settings.ClientSettings settings)
      Reads the token endpoint authentication signing algorithm.
      Parameters:
      settings - client settings.
      Returns:
      the algorithm name, or null when none is set.
    • signingAlgorithmOf

      private org.springframework.security.oauth2.jose.jws.SignatureAlgorithm signingAlgorithmOf(String name)
      Resolves a JWS signature algorithm by name.
      Parameters:
      name - the algorithm name, for example RS256.
      Returns:
      the algorithm.
      Throws:
      IllegalArgumentException - if the name is not a JWS signature algorithm.