com.worklight.wlclient.api
Class WLAuthorizationManager
- java.lang.Object
-
- com.worklight.wlclient.api.WLAuthorizationManager
-
public class WLAuthorizationManager extends java.lang.Object
This class manages the entire OAuth flow, from client registration to token generation.
-
-
Method Summary
Methods Modifier and Type Method and Description void
addCachedAuthorizationHeader(org.apache.http.client.methods.HttpUriRequest request)
Adds the cached authorization header to the given HTTP request object.void
addCachedAuthorizationHeader(java.net.URLConnection urlConnection)
Adds the cached authorization header to the given URL connection object.org.json.JSONObject
getAppIdentity()
Retrieves the application identity, or null if one is not currently available.WLAuthorizationPersistencePolicy
getAuthorizationPersistencePolicy()
Deprecated.In MobileFirst Platform 7.1, persisting authorization headers on the client side has no effect, since the MobileFirst server persists the security data across sessions. Gets the current authorization header persistence policy.java.lang.String
getAuthorizationScope(org.apache.http.HttpResponse response)
Returns the scope that is required by the resource that produced the given response.java.lang.String
getAuthorizationScope(java.lang.String authenticationHeader)
Returns the scope that is required by the resource that produced the given response.java.lang.String
getCachedAuthorizationHeader()
Retrieves the cached authorization header.org.json.JSONObject
getDeviceIdentity()
Retrieves the device identity, or null if one is not currently available.static WLAuthorizationManager
getInstance()
Gets the singleton instance ofWLAuthorizationManager
.org.json.JSONObject
getUserIdentity()
Retrieves the user identity, or null if one is not currently available.boolean
isAuthorizationRequired(org.apache.http.HttpResponse response)
Checks whether the response is a MobileFirst Platform OAuth error.boolean
isAuthorizationRequired(int status, java.lang.String authenticationHeader)
Checks whether the response is a MobileFirst Platform OAuth error.void
obtainAuthorizationHeader(java.lang.String scope, WLResponseListener listener)
Explicit call to obtain the authorization header.void
setAuthorizationPersistencePolicy(WLAuthorizationPersistencePolicy policy)
Deprecated.In MobileFirst Platform 7.1, persisting authorization headers on the client side has no effect, since the MobileFirst server persists the security data across sessions. Sets the authorization header persistence policy.
-
-
-
Method Detail
-
getInstance
public static WLAuthorizationManager getInstance()
Gets the singleton instance ofWLAuthorizationManager
.
-
setAuthorizationPersistencePolicy
@Deprecated public void setAuthorizationPersistencePolicy(WLAuthorizationPersistencePolicy policy)
Deprecated. In MobileFirst Platform 7.1, persisting authorization headers on the client side has no effect, since the MobileFirst server persists the security data across sessions. Sets the authorization header persistence policy.- Parameters:
policy
- Policy
-
getAuthorizationPersistencePolicy
@Deprecated public WLAuthorizationPersistencePolicy getAuthorizationPersistencePolicy()
Deprecated. In MobileFirst Platform 7.1, persisting authorization headers on the client side has no effect, since the MobileFirst server persists the security data across sessions. Gets the current authorization header persistence policy.
-
getAuthorizationScope
public java.lang.String getAuthorizationScope(org.apache.http.HttpResponse response)
Returns the scope that is required by the resource that produced the given response.This method expects to be given only response objects for which the method
isAuthorizationRequired(HttpResponse)
returns true.- Parameters:
response
- HTTP response object- Returns:
- String representing the scope required by the resource.
-
getAuthorizationScope
public java.lang.String getAuthorizationScope(java.lang.String authenticationHeader)
Returns the scope that is required by the resource that produced the given response.This method expects to be given only headers from response objects for which the method
isAuthorizationRequired(HttpResponse)
returns true.
- Parameters:
authenticationHeader
- Value of the authentication header- Returns:
- String representing the scope required by the resource.
-
getAppIdentity
public org.json.JSONObject getAppIdentity()
Retrieves the application identity, or null if one is not currently available.- Returns:
- JSONObject containing the application identity.
-
getDeviceIdentity
public org.json.JSONObject getDeviceIdentity()
Retrieves the device identity, or null if one is not currently available.- Returns:
- JSONObject containing the device identity.
-
getUserIdentity
public org.json.JSONObject getUserIdentity()
Retrieves the user identity, or null if one is not currently available.- Returns:
- JSONObject containing the user identity.
-
isAuthorizationRequired
public boolean isAuthorizationRequired(org.apache.http.HttpResponse response)
Checks whether the response is a MobileFirst Platform OAuth error.- Parameters:
response
- HTTP response object- Returns:
- true if the response is a MobileFirst Platform OAuth error, or false otherwise.
-
isAuthorizationRequired
public boolean isAuthorizationRequired(int status, java.lang.String authenticationHeader)
Checks whether the response is a MobileFirst Platform OAuth error.- Parameters:
status
- HTTP statusauthenticationHeader
- Value of the authentication header- Returns:
- true if the response is a MobileFirst Platform OAuth error, or false otherwise.
-
addCachedAuthorizationHeader
public void addCachedAuthorizationHeader(java.net.URLConnection urlConnection)
Adds the cached authorization header to the given URL connection object.- Parameters:
urlConnection
- URL connection to which to add header.
-
addCachedAuthorizationHeader
public void addCachedAuthorizationHeader(org.apache.http.client.methods.HttpUriRequest request)
Adds the cached authorization header to the given HTTP request object.- Parameters:
request
- HTTP request object to which to add header.
-
obtainAuthorizationHeader
public void obtainAuthorizationHeader(java.lang.String scope, WLResponseListener listener)
Explicit call to obtain the authorization header.- Parameters:
scope
- Scope required.listener
-WLResponseListener
whoseonSuccess
oronFailure
methods are called when the request finishes.
-
getCachedAuthorizationHeader
public java.lang.String getCachedAuthorizationHeader()
Retrieves the cached authorization header.If there is no cached header this method returns an empty string.
- Returns:
- String containing cached authorization header.
-
-