Package com.iizix.server.oauth
Class OAuthSession
- java.lang.Object
- com.iizix.server.oauth.OAuthSession
public class OAuthSession extends java.lang.Object
The OAuth 1.0a or 2.0 session that handles authentication.- Author:
- Christopher Mindus
Constructor Summary
Constructors Constructor Description OAuthSession(IOAuthCallbackProvider callbackProvider)
Constructs a new authentication session with a callback provider.OAuthSession(IAppSessionGyro appGyro)
Constructs a new authentication session for the application session.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose()
Disposes of the session and cleans up.void
disposeBlocked()
Disposes of the session because of a blocked pop-up window.void
disposeUserCancel()
Disposes of the session because of a user cancel action.AppSessionGyro
getAppSessionGyro()
Returns the application session gyro instance.java.lang.String
getAuthenticationCode()
Returns the authentication code, null for error or not authenticated (yet).java.lang.String
getCallbackURL()
Returns this server's callback URL used to complete the authentication by means of redirecting the client in the end to it.IOAuthListener.Code
getCompletionCode()
Gets the authentication completion "error" code.java.lang.String
getErrorCode()
Gets the error code returned in the callback reply, normally converted to a Code.java.lang.String
getErrorDescription()
Gets the error description string in case of failure.java.lang.String
getErrorURI()
Returns the error URI, null if none is present.java.lang.String
getOAuth1Token()
For an OAuth 1.0a session, get the oauth_token used to identify the session.AbstractOAuthService
getService()
Returns the service for the session.java.lang.String
getState()
Gets the state string that uniquely identifies the session in the server.boolean
isOAuth2()
Checks if this authentication session is of OAuth 2.0 type.
Constructor Detail
OAuthSession
public OAuthSession(IAppSessionGyro appGyro)
Constructs a new authentication session for the application session.- Parameters:
appGyro
- The application session.- Throws:
java.lang.IllegalStateException
- If authentication engine is not initialized.java.lang.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:
java.lang.IllegalStateException
- If called outside of the Designer or if authentication engine is not initialized.java.lang.NullPointerException
- If callbackProvider is null.
Method Detail
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.0afalse
is returned. - Throws:
java.lang.IllegalStateException
- If the session authentication type is not yet defined.
getOAuth1Token
public java.lang.String getOAuth1Token()
For an OAuth 1.0a session, get the oauth_token used to identify the session.- Returns:
- The oauth_token.
- Throws:
java.lang.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 java.lang.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 java.lang.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 java.lang.String getAuthenticationCode()
Returns the authentication code, null for error or not authenticated (yet).- Returns:
- The code, null otherwise.
getErrorURI
public java.lang.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 java.lang.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 java.lang.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.