Class OAuthTokenResponse

java.lang.Object
org.apache.sling.auth.oauth_client.OAuthTokenResponse

@NotNull public class OAuthTokenResponse extends Object
Encapsulates the response to a token request.

This class has two top-level states:

  1. has a valid access token: hasValidToken() returns true, and getTokenValue() returns the token value.
  2. does not have a valid access token: hasValidToken() returns false, and getRedirectUri() returns the URI to redirect the user to.

Methods generally throw IllegalStateException if they are called in an unexpected state and do not return null values.

  • Constructor Details

    • OAuthTokenResponse

      public OAuthTokenResponse(@NotNull @NotNull Optional<String> token, @NotNull @NotNull ClientConnection connection, @NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull String redirectPath)
  • Method Details

    • hasValidToken

      public boolean hasValidToken()
      Returns true if a valid access token is present and false otherwise
      Returns:
      true if a valid access token is present
    • getTokenValue

      @NotNull public @NotNull String getTokenValue()
      Returns a valid access token value and throws an IllegalStateException otherwise
      Returns:
      a valid access token value
      Throws:
      IllegalStateException - if no access token is present
    • getRedirectUri

      @NotNull public @NotNull URI getRedirectUri()
      Returns the URI to redirect the user to in order to start the OAuth flow
      Returns:
      the URI to redirect the user to
      Throws:
      IllegalStateException - if an access token is present