Class AuthorizationURLBuilder

java.lang.Object
org.gcube.common.iam.AuthorizationURLBuilder

public final class AuthorizationURLBuilder extends Object
Builds the URL of the authorization endpoint the browser is redirected to in the authorization code flow (response type code), with optional PKCE (S256). The code received on the redirect URI is exchanged for the tokens with D4ScienceIAMClient.authenticateWithCode(String, String, String, String, String). Obtained from D4ScienceIAMClient.authorizationURL(String, String).
  • Method Details

    • scope

      public AuthorizationURLBuilder scope(String scope)
      Parameters:
      scope - the requested scopes as standard space separated list
      Returns:
      this builder
    • state

      public AuthorizationURLBuilder state(String state)
      Parameters:
      state - the opaque value to check on the redirect URI (CSRF protection)
      Returns:
      this builder
    • nonce

      public AuthorizationURLBuilder nonce(String nonce)
      Parameters:
      nonce - the value that will be bound to the ID token
      Returns:
      this builder
    • codeChallengeS256

      public AuthorizationURLBuilder codeChallengeS256(String codeVerifier)
      Enables PKCE with the S256 method.
      Parameters:
      codeVerifier - the code verifier (see newCodeVerifier()), to be kept by the caller and passed to D4ScienceIAMClient.authenticateWithCode(String, String, String, String, String)
      Returns:
      this builder
    • param

      public AuthorizationURLBuilder param(String name, String value)
      Adds (or replaces) any other authorization request parameter (e.g. prompt, login_hint, kc_idp_hint).
      Parameters:
      name - the parameter name
      value - the parameter value, a null value removes the parameter
      Returns:
      this builder
    • build

      public String build()
      Returns:
      the authorization URL, with all the parameters URL encoded
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • newCodeVerifier

      public static String newCodeVerifier()
      Returns:
      a new random PKCE code verifier (43 characters, URL safe)
    • codeChallengeS256Of

      public static String codeChallengeS256Of(String codeVerifier)
      Parameters:
      codeVerifier - the PKCE code verifier
      Returns:
      the S256 code challenge of the verifier: base64url(sha256(verifier))