com.shephertz.app42.paas.sdk.jme.session
Class SessionService

java.lang.Object
  extended by com.shephertz.app42.paas.sdk.jme.session.SessionService

public class SessionService
extends java.lang.Object

The Session Manager manages user sessions on the server side. It is a persistent Session Manager. It allows to save attributes in the session and retrieve them. This Session Manager is especially useful for Mobile/Device Apps which want to do session management.

See Also:
Session

Constructor Summary
SessionService(java.lang.String apiKey, java.lang.String secretKey, java.lang.String baseURL)
          This is a constructor that takes
 
Method Summary
 Session getAllAttributes(java.lang.String sessionId)
          Gets all the attributes for a given session id
 Session getAttribute(java.lang.String sessionId, java.lang.String attributeName)
          Gets the attribute value in a session whose session id is provided.
 Session getSession(java.lang.String uName)
          Create Session for the User.
 Session getSession(java.lang.String uName, boolean isCreate)
          Create User Session based on the isCreate boolean parameter.
 App42Response invalidate(java.lang.String sessionId)
          Invalidate a session based on the session id.
 App42Response removeAllAttributes(java.lang.String sessionId)
          Removes all the attributes for a given session id
 App42Response removeAttribute(java.lang.String sessionId, java.lang.String attributeName)
          Removes the attribute from a session whose session id is provided.
 Session setAttribute(java.lang.String sessionId, java.lang.String attributeName, java.lang.String attributeValue)
          Sets attribute in a session whose session id is provided.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SessionService

public SessionService(java.lang.String apiKey,
                      java.lang.String secretKey,
                      java.lang.String baseURL)
This is a constructor that takes

Parameters:
apiKey -
secretKey -
baseURL -
Method Detail

getAllAttributes

public Session getAllAttributes(java.lang.String sessionId)
                         throws App42Exception
Gets all the attributes for a given session id

Parameters:
sessionId - - The session id for which the attribute has to be fetched
Returns:
Session object containing all the attributes and values which are stored for the session id
Throws:
App42Exception

getAttribute

public Session getAttribute(java.lang.String sessionId,
                            java.lang.String attributeName)
                     throws App42Exception
Gets the attribute value in a session whose session id is provided.

Parameters:
sessionId - - The session id for which the attribute has to be fetched
attributeName - - The attribute key that has to be fetched
Returns:
Session object containing the attribute and value which is stored for the session id and attribute name
Throws:
App42Exception

getSession

public Session getSession(java.lang.String uName)
                   throws App42Exception
Create Session for the User. If the session does not exist it will create a new session

Parameters:
uName - - UserName for which the session has to be created.
Returns:
Session object containing the session id of the created session. This id has to be used for storing or retrieving attributes.
Throws:
App42Exception

getSession

public Session getSession(java.lang.String uName,
                          boolean isCreate)
                   throws App42Exception
Create User Session based on the isCreate boolean parameter. If isCreate is true and there is an existing session for the user, the existing session is returned. If there is no existing session for the user a new one is created. If isCreate is false and there is an existing session, the existing session is returned if there is no existing session new one is not created

Parameters:
uName - - UserName for which the session has to be created.
isCreate - - A boolean value for specifying if an existing session is not there, should a new one is to be created or not.
Returns:
Session object containing the session id of the created session. This id has to be used for storing or retrieving attributes.
Throws:
App42Exception

invalidate

public App42Response invalidate(java.lang.String sessionId)
                         throws App42Exception
Invalidate a session based on the session id. All the attributes store in the session will be lost.

Parameters:
sessionId - - The session id for which the session has to be invalidated.
Returns:
App42Response if invalidated successfully
Throws:
App42Exception

removeAllAttributes

public App42Response removeAllAttributes(java.lang.String sessionId)
                                  throws App42Exception
Removes all the attributes for a given session id

Parameters:
sessionId - - The session id for which the attributes has to be removed
Returns:
App42Response if removed successfully
Throws:
App42Exception

removeAttribute

public App42Response removeAttribute(java.lang.String sessionId,
                                     java.lang.String attributeName)
                              throws App42Exception
Removes the attribute from a session whose session id is provided.

Parameters:
sessionId - - The session id for which the attribute has to be removed
attributeName - - The attribute key that has to be removed
Returns:
App42Response if removed successfully
Throws:
App42Exception

setAttribute

public Session setAttribute(java.lang.String sessionId,
                            java.lang.String attributeName,
                            java.lang.String attributeValue)
                     throws App42Exception
Sets attribute in a session whose session id is provided. Attributes are stored in a key value pair.

Parameters:
sessionId - - Session id for which the attribute has to be saved.
attributeName - - The attribute key that needs to be stored
attributeValue - - The attribute value that needs to be stored
Returns:
Session object containing the attribute and value which is stored
Throws:
App42Exception