public class WLAuthorizationManager
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
void |
clearAccessToken(AccessToken accessToken)
Clears the provided access token.
Note: When failing to access a resource with an obtained token, call the clearAccessToken method to clear the
invalid token before calling obtainAccessToken(String, WLAccessTokenListener) to obtain a new access token. |
java.net.URL |
getAuthorizationServerUrl()
Returns the URL of the current authorization server.
|
static WLAuthorizationManager |
getInstance()
Returns the singleton instance of the
WLAuthorizationManager class. |
java.lang.String |
getResourceScope(java.net.HttpURLConnection httpURLConnection)
Returns the scope of the protected resource for the provided HTTP connection.
Note: Call this method only for a connection for which isAuthorizationRequired(HttpURLConnection)
returns true, indicating that the target resource is protected. |
java.lang.String |
getResourceScope(java.util.Map headers)
Returns the scope of the protected resource for the provided response headers.
Note: Call this method only for response headers for which isAuthorizationRequired(int, Map)
returns true, indicating that the resource is protected. |
boolean |
isAuthorizationRequired(java.net.HttpURLConnection httpURLConnection)
Checks whether the provided HTTP connection represents a protected resource that requires authorization.
|
boolean |
isAuthorizationRequired(int status,
java.util.Map headers)
Checks whether the provided response status and headers represent a protected resource that requires authorization.
|
void |
login(java.lang.String securityCheck,
JSONObject credentials,
WLLoginResponseListener listener)
Logs into the specified security check.
|
void |
logout(java.lang.String securityCheck,
WLLogoutResponseListener listener)
Logs out of the specified security check.
|
void |
obtainAccessToken(java.lang.String scope,
WLAccessTokenListener listener)
Obtains an access token for the specified resource scope from the MobileFirst authorization server.
|
void |
setAuthorizationServerUrl(java.net.URL url)
Sets the URL of the authorization server.
|
void |
setLoginTimeout(int loginTimeout)
Sets the authorization flow time out.
|
public static WLAuthorizationManager getInstance()
WLAuthorizationManager class.WLAuthorizationManager.public java.lang.String getResourceScope(java.net.HttpURLConnection httpURLConnection)
isAuthorizationRequired(HttpURLConnection)
returns true, indicating that the target resource is protected.httpURLConnection - HTTP connection for a request to access a protected resource.WWW-Authenticate HTTP response header.public java.lang.String getResourceScope(java.util.Map headers)
isAuthorizationRequired(int, Map)
returns true, indicating that the resource is protected.headers - Response headers for a request to access a protected resource.WWW-Authenticate HTTP response header.public boolean isAuthorizationRequired(java.net.HttpURLConnection httpURLConnection)
httpURLConnection - HTTP connection for a request to access a resource.true if access to the target resource requires authorization, or false otherwise.public boolean isAuthorizationRequired(int status,
java.util.Map headers)
status - Response status code.headers - Response headers for a request to access a resource.true if access to the target resource requires authorization, or false otherwise.public void obtainAccessToken(java.lang.String scope,
WLAccessTokenListener listener)
scope - Scope for which to obtain the access token.listener - Access-token listener whose onSuccess or onFailure methods are called upon request completion.public void clearAccessToken(AccessToken accessToken)
clearAccessToken method to clear the
invalid token before calling obtainAccessToken(String, WLAccessTokenListener) to obtain a new access token.accessToken - Access token to clear.public void login(java.lang.String securityCheck,
JSONObject credentials,
WLLoginResponseListener listener)
securityCheck - Name of the security check to log into.credentials - Credentials for logging into the specified security check.listener - Login listener whose methods are called upon request completion.public void logout(java.lang.String securityCheck,
WLLogoutResponseListener listener)
securityCheck - Name of the security check to log out of.listener - Logout listener whose methods are called upon request completion.public void setLoginTimeout(int loginTimeout)
timeout - public void setAuthorizationServerUrl(java.net.URL url)
url - URL of the authorization server to set.public java.net.URL getAuthorizationServerUrl()