Class OAuthSession

java.lang.Object
com.iizix.server.oauth.OAuthSession

public class OAuthSession extends Object
The OAuth 1.0a or 2.0 session that handles authentication.
Author:
Christopher Mindus
  • Constructor Details

    • OAuthSession

      public OAuthSession(IAppSessionGyro appGyro)
      Constructs a new authentication session for the application session.
      Parameters:
      appGyro - The application session.
      Throws:
      IllegalStateException - If authentication engine is not initialized.
      NullPointerException - If appGyro is null.
    • OAuthSession

      public OAuthSession(IOAuthCallbackProvider callbackProvider)
      Constructs a new authentication session with a callback provider. Do not call this method from the Server, only the Designer is supported.
      Parameters:
      callbackProvider - The callback provider.
      Throws:
      IllegalStateException - If called outside of the Designer or if authentication engine is not initialized.
      NullPointerException - If callbackProvider is null.
  • Method Details

    • isOAuth2

      public boolean isOAuth2()
      Checks if this authentication session is of OAuth 2.0 type.
      Returns:
      If session is of OAuth 2.0 true is returned, otherwise for OAuth 1.0a false is returned.
      Throws:
      IllegalStateException - If the session authentication type is not yet defined.
    • getOAuth1Token

      public String getOAuth1Token()
      For an OAuth 1.0a session, get the oauth_token used to identify the session.
      Returns:
      The oauth_token.
      Throws:
      IllegalStateException - If the session authentication type is not OAuth 1.0a.
    • getAppSessionGyro

      public AppSessionGyro getAppSessionGyro()
      Returns the application session gyro instance.
      Returns:
      The instance (always non-null in Server), null in the Designer.
    • getCallbackURL

      public String getCallbackURL()
      Returns this server's callback URL used to complete the authentication by means of redirecting the client in the end to it.
      Returns:
      The URL of this server with additional authentication path.
    • getState

      public String getState()
      Gets the state string that uniquely identifies the session in the server.
      Returns:
      The unique session state (UUID).
    • getCompletionCode

      public IOAuthListener.Code getCompletionCode()
      Gets the authentication completion "error" code.
      Returns:
      The code.
    • getAuthenticationCode

      public String getAuthenticationCode()
      Returns the authentication code, null for error or not authenticated (yet).
      Returns:
      The code, null otherwise.
    • getErrorURI

      public String getErrorURI()
      Returns the error URI, null if none is present. It is optionally set by the service in question.
      Returns:
      The error URI, or null if not present.
    • getErrorCode

      public String getErrorCode()
      Gets the error code returned in the callback reply, normally converted to a Code.
      Returns:
      The OAuth error code returned, or null if not present.
    • getErrorDescription

      public String getErrorDescription()
      Gets the error description string in case of failure.
      Returns:
      The error string, or null for no error.
    • getService

      public final AbstractOAuthService getService()
      Returns the service for the session.
      Returns:
      The authentication service, or null if authentication has not yet begun.
    • disposeBlocked

      public void disposeBlocked()
      Disposes of the session because of a blocked pop-up window. The listener is notified, if any.
    • disposeUserCancel

      public void disposeUserCancel()
      Disposes of the session because of a user cancel action.
    • dispose

      public void dispose()
      Disposes of the session and cleans up.