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 OAuth interaction between the client and the authorization server.
    • Method Detail

      • getResourceScope

        public 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 WLAuthorizationManager.isAuthorizationRequired(HttpURLConnection) returns true, indicating that the target resource is protected.
        Parameters:
        httpURLConnection - HTTP connection for a request to access a protected resource.
        Returns:
        The protecting scope of the target resource, as returned in the WWW-Authenticate HTTP response header.
      • getResourceScope

        public 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 WLAuthorizationManager.isAuthorizationRequired(int, Map) returns true, indicating that the resource is protected.
        Parameters:
        headers - Response headers for a request to access a protected resource.
        Returns:
        The protecting scope of the target resource, as returned in the WWW-Authenticate HTTP response header.
      • isAuthorizationRequired

        public boolean isAuthorizationRequired(java.net.HttpURLConnection httpURLConnection)
        Checks whether the provided HTTP connection represents a protected resource that requires authorization.
        Parameters:
        httpURLConnection - HTTP connection for a request to access a resource.
        Returns:
        true if access to the target resource requires authorization, or false otherwise.
      • isAuthorizationRequired

        public boolean isAuthorizationRequired(int status,
                                      java.util.Map headers)
        Checks whether the provided response status and headers represent a protected resource that requires authorization.
        Parameters:
        status - Response status code.
        headers - Response headers for a request to access a resource.
        Returns:
        true if access to the target resource requires authorization, or false otherwise.
      • obtainAccessToken

        public void obtainAccessToken(java.lang.String scope,
                             WLAccessTokenListener listener)
        Obtains an access token for the specified resource scope from the MobileFirst authorization server.
        Parameters:
        scope - Scope for which to obtain the access token.
        listener - Access-token listener whose onSuccess or onFailure methods are called upon request completion.
      • login

        public void login(java.lang.String securityCheck,
                 JSONObject credentials,
                 WLLoginResponseListener listener)
        Logs into the specified security check.
        Parameters:
        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.
      • logout

        public void logout(java.lang.String securityCheck,
                  WLLogoutResponseListener listener)
        Logs out of the specified security check.
        Parameters:
        securityCheck - Name of the security check to log out of.
        listener - Logout listener whose methods are called upon request completion.
      • setLoginTimeout

        public void setLoginTimeout(int timeOut)
        Sets the timeout value to Login API call . When this method is not called, the default timeout value is used .
        Parameters:
        timeOut - An integer timeout value in seconds .
      • setAuthorizationServerUrl

        public void setAuthorizationServerUrl(java.net.URL url)
        Sets the URL of the authorization server. When this method is not called, the MobileFirst Server URL is used.
        Parameters:
        url - URL of the authorization server to set.
      • getAuthorizationServerUrl

        public java.net.URL getAuthorizationServerUrl()
        Returns the URL of the current authorization server.
        Returns:
        The URL of the current authorization server.


© Copyright IBM Corp. 2006, 2015. All Rights Reserved.