Class ClientRegistration

java.lang.Object
com.codename1.backend.security.oauth2.client.ClientRegistration

public final class ClientRegistration extends Object

This server as a client of one identity provider: the id and secret the provider issued it, the scopes it asks for, and where the provider's endpoints are.

ClientRegistration google = CommonOAuth2Provider.GOOGLE.getBuilder("google")
        .clientId(id).clientSecret(secret).build();
ClientRegistration own = ClientRegistration.withRegistrationId("acme")
        .clientId("web").clientSecret(secret)
        .issuerUri("https://id.example.com")
        .scope("openid", "profile", "email").build();

A registration that names an issuerUri and not the endpoints has them read from the issuer's metadata the first time a user signs in through it.

  • Field Details

    • FORM_POST

      public static final String FORM_POST
      The response_mode that has the provider answer with a form the browser posts, rather than a redirect.
      See Also:
  • Method Details

    • withRegistrationId

      public static ClientRegistration.Builder withRegistrationId(String registrationId)
      A registration under this id, which is the last part of the two paths a sign-in through it uses.
    • withClientRegistration

      public static ClientRegistration.Builder withClientRegistration(ClientRegistration registration)
      A builder that starts as a copy of registration.
    • getRegistrationId

      public String getRegistrationId()
    • getClientId

      public String getClientId()
    • getClientSecret

      public String getClientSecret()
      The fixed secret, or null when there is none or it is supplied; see resolveClientSecret().
    • resolveClientSecret

      public String resolveClientSecret() throws IOException
      The secret to send now: the fixed one, or what the supplier gives.
      Throws:
      IOException
    • getClientAuthenticationMethod

      public ClientAuthenticationMethod getClientAuthenticationMethod()
    • getAuthorizationGrantType

      public AuthorizationGrantType getAuthorizationGrantType()
    • getRedirectUri

      public String getRedirectUri()
      Where the provider sends the user back: an address, or a template with {baseUrl} and {registrationId} in it.
    • getScopes

      public Set<String> getScopes()
    • getClientName

      public String getClientName()
      What a login page calls this provider.
    • getResponseMode

      public String getResponseMode()
      FORM_POST, or null for the provider's default, a redirect.
    • getProviderDetails

      public ClientRegistration.ProviderDetails getProviderDetails()
    • toString

      public String toString()
      Description copied from class: Object
      Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode())
      Overrides:
      toString in class Object