com.feedhenry.sdk.api
Class FHAuthRequest

java.lang.Object
  extended by com.feedhenry.sdk.FHRemote
      extended by com.feedhenry.sdk.api.FHAuthRequest
All Implemented Interfaces:
FHAct

public class FHAuthRequest
extends FHRemote

The request for calling the authentication function. Example:

 FHAuthRequest authRequest = FH.buildAuthRequest();
  // This is an oAuth auth policy. Setting a presenting activity will allow the library to automatically handle the interaction between the user and the oAuth provider.
  // You also need to add the following code to your application's AndroidManifest.xml file (inside the <application> element):
  // <activity android:name="com.feedhenry.sdk.oauth.FHOAuthIntent" />;
  authRequest.setPresentingActivity(this); 
  authRequest.setAuthPolicyId("MyGooglePolicy");
  authRequest.executeAsync(new FHActCallback() {    
    public void success(FHResponse resp) {
      Log.d("FHAuthActivity", "user sessionToken = "+ resp.getJson().getString("sessionToken"));
    }
    
    public void fail(FHResponse resp) {
      Log.d("FHAuthActivity", resp.getErrorMessage());
   }
  });
 
 


Field Summary
protected static java.lang.String LOG_TAG
           
 
Fields inherited from class com.feedhenry.sdk.FHRemote
mCallback, mContext, mProperties, mUDID, PATH_PREFIX
 
Constructor Summary
FHAuthRequest(android.content.Context context, java.util.Properties pProps)
          Constructor
 
Method Summary
protected  org.apache.http.Header[] buildHeaders(org.apache.http.Header[] pHeaders)
           
 void executeAsync(FHActCallback pCallback)
          Execute the request asynchronously.
protected  java.lang.String getPath()
           
protected  JSONObject getRequestArgs()
           
 void setAuthPolicyId(java.lang.String pPolicyId)
          Set the policy id for this auth request
 void setAuthUser(java.lang.String pPolicyId, java.lang.String pUserName, java.lang.String pPassword)
          Set the user name for the auth request.
 void setPresentingActivity(android.content.Context pActivity)
          If the auth policy type is OAuth, user need to enter their username and password for the OAuth provider.
 
Methods inherited from class com.feedhenry.sdk.FHRemote
executeAsync, getApiURl, setCallback, setUDID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_TAG

protected static java.lang.String LOG_TAG
Constructor Detail

FHAuthRequest

public FHAuthRequest(android.content.Context context,
                     java.util.Properties pProps)
Constructor

Parameters:
pProps - the app configurations
Method Detail

setAuthPolicyId

public void setAuthPolicyId(java.lang.String pPolicyId)
Set the policy id for this auth request

Parameters:
pPolicyId - the auth policy id. It is required for all the auth requests

setAuthUser

public void setAuthUser(java.lang.String pPolicyId,
                        java.lang.String pUserName,
                        java.lang.String pPassword)
Set the user name for the auth request. Only required if the auth policy type is FeedHenry or LDAP.

Parameters:
pPolicyId - the auth policy id
pUserName - the user name
pPassword - the password

getPath

protected java.lang.String getPath()
Specified by:
getPath in class FHRemote

getRequestArgs

protected JSONObject getRequestArgs()
Specified by:
getRequestArgs in class FHRemote

setPresentingActivity

public void setPresentingActivity(android.content.Context pActivity)
If the auth policy type is OAuth, user need to enter their username and password for the OAuth provider. If an Activity instance is provided, the SDK will automatically handle this (By presenting the OAuth login page in a WebView and back to the application once the authentication process is finished). If it's not provided, the application need to handle the OAuth process itself.

Parameters:
pActivity - the parent Activity instance to invoke the WebView

executeAsync

public void executeAsync(FHActCallback pCallback)
                  throws java.lang.Exception
Description copied from interface: FHAct
Execute the request asynchronously. Execute the pCallback function when it finishes.

Specified by:
executeAsync in interface FHAct
Overrides:
executeAsync in class FHRemote
Parameters:
pCallback - the callback function
Throws:
java.lang.Exception

buildHeaders

protected org.apache.http.Header[] buildHeaders(org.apache.http.Header[] pHeaders)
                                         throws java.lang.Exception
Specified by:
buildHeaders in class FHRemote
Throws:
java.lang.Exception