com.shephertz.app42.paas.sdk.jme.user
Class UserService

java.lang.Object
  extended by com.shephertz.app42.paas.sdk.jme.user.UserService

public class UserService
extends java.lang.Object

Creates User for the App. App42 Cloud API's provides a complete User Management for any mobile or web app. It supports User registration, retrieval, state management e.g. lock, delete and Authentication. Along with User Management the platform provides API's for persistent SessionManagement

See Also:
SessionService, User, App42Response

Constructor Summary
UserService(java.lang.String apiKey, java.lang.String secretKey, java.lang.String baseURL)
          This is a constructor that takes
 
Method Summary
 User assignRoles(java.lang.String uName, java.util.Vector roleList)
          Assign Roles to the existing User
 App42Response authenticate(java.lang.String uName, java.lang.String pwd)
          Authenticate user based on userName and password
 App42Response changeUserPassword(java.lang.String uName, java.lang.String oldPwd, java.lang.String newPwd)
          Changes the password for user based on the userName.
 User createOrUpdateProfile(User user)
          Creates or Updates User Profile.
 User createUser(java.lang.String uName, java.lang.String pwd, java.lang.String emailAddress)
          Create a User with userName, password & emailAddress
 User createUser(java.lang.String uName, java.lang.String pwd, java.lang.String emailAddress, java.util.Vector roleList)
          Create a User with userName, password & emailAddress and assigns the roles to the created User
 App42Response deleteUser(java.lang.String userName)
          Deletes a particular user based on userName.
 java.util.Vector getAllUsers()
          Gets the details of all users
 java.util.Vector getAllUsers(java.lang.Integer max, java.lang.Integer offset)
          Gets all users by Paging
 App42Response getAllUsersCount()
          Gets the count of all the users
 java.util.Vector getLockedUsers()
          Gets the details of all the locked users
 java.util.Vector getLockedUsers(java.lang.Integer max, java.lang.Integer offset)
          Gets the details of all the locked users By paging.
 App42Response getLockedUsersCount()
          Gets the count of all the locked users
 User getRolesByUser(java.lang.String userName)
          Get the roles from the specified User
 User getUser(java.lang.String userName)
          Gets the User details based on userName
 User getUserByEmailId(java.lang.String emailId)
          Gets user details based on emailId
 java.util.Vector getUsersByProfileData(User.Profile profileData)
          Gets the list of Users based on Profile Data
 java.util.Vector getUsersByRole(java.lang.String role)
          Get all the Users who have the specified role assigned
 User lockUser(java.lang.String uName)
          Locks the user based on the userName.
 App42Response resetUserPassword(java.lang.String uName, java.lang.String pwd)
          Updates the User password based on userName.
 App42Response revokeAllRoles(java.lang.String userName)
          Revokes all the roles from the user.
 App42Response revokeRole(java.lang.String userName, java.lang.String role)
          Revokes the specified role from the user.
 User unlockUser(java.lang.String uName)
          Unlocks the user based on the userName.
 User updateEmail(java.lang.String uName, java.lang.String emailAddress)
          Updates the User's Email Address based on userName.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserService

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

Parameters:
apiKey -
secretKey -
baseURL -
Method Detail

assignRoles

public User assignRoles(java.lang.String uName,
                        java.util.Vector roleList)
                 throws App42Exception
Assign Roles to the existing User

Parameters:
uName - - Name of the User to whom the roles have to be assigned
roleList - - List of roles to be added to User
Returns:
The created User object with assigned roles.
Throws:
App42Exception

authenticate

public App42Response authenticate(java.lang.String uName,
                                  java.lang.String pwd)
                           throws App42Exception
Authenticate user based on userName and password

Parameters:
uName - - UserName which should be unique for the App
pwd - - Password for the User
Throws:
App42Exception - if authentication fails or username/password is blank or null

changeUserPassword

public App42Response changeUserPassword(java.lang.String uName,
                                        java.lang.String oldPwd,
                                        java.lang.String newPwd)
                                 throws App42Exception
Changes the password for user based on the userName.

Parameters:
uName - - UserName which should be unique for the App
oldPwd - - Old Password for the user for authentication
newPwd - - New Password for the user to change
Throws:
App42Exception

createOrUpdateProfile

public User createOrUpdateProfile(User user)
                           throws App42Exception
Creates or Updates User Profile. First time the Profile for the user is created and in future calls user profile will be updated. This will always update the profile with new value passed in profile object. Call to this method should have all the values you want to retain in user profile object, otherwise old values of profile will get updated with null. Method only updates the profile of user, passing email/password in user object does not have any significance for this method call.

Parameters:
user - - User for which profile has to be updated, this should contain the userName and profile object in it.
Throws:
App42Exception
See Also:
User.Profile

createUser

public User createUser(java.lang.String uName,
                       java.lang.String pwd,
                       java.lang.String emailAddress)
                throws App42Exception
Create a User with userName, password & emailAddress

Parameters:
uName - - Name of the User
pwd - - Password for the User
emailAddress - - Email address of the user
Returns:
The created User object.
Throws:
App42Exception

createUser

public User createUser(java.lang.String uName,
                       java.lang.String pwd,
                       java.lang.String emailAddress,
                       java.util.Vector roleList)
                throws App42Exception
Create a User with userName, password & emailAddress and assigns the roles to the created User

Parameters:
uName - - Name of the User
pwd - - Password for the User
emailAddress - - Email address of the user
roleList - - List of roles to be assigned to User
Returns:
The created User object with role list.
Throws:
App42Exception

deleteUser

public App42Response deleteUser(java.lang.String userName)
                         throws App42Exception
Deletes a particular user based on userName.

Parameters:
userName - - UserName which should be unique for the App
Throws:
App42Exception

getAllUsers

public java.util.Vector getAllUsers()
                             throws App42Exception
Gets the details of all users

Returns:
the List that contains all User Object
Throws:
App42Exception

getAllUsers

public java.util.Vector getAllUsers(java.lang.Integer max,
                                    java.lang.Integer offset)
                             throws App42Exception
Gets all users by Paging

Parameters:
max - - Maximum number of records to be fetched
offset - - From where the records are to be fetched
Returns:
the List that contains all User Object
Throws:
App42Exception

getAllUsersCount

public App42Response getAllUsersCount()
                               throws App42Exception
Gets the count of all the users

Returns:
the count of all User exists
Throws:
App42Exception

getLockedUsers

public java.util.Vector getLockedUsers()
                                throws App42Exception
Gets the details of all the locked users

Returns:
the list containing locked User Objects
Throws:
App42Exception

getLockedUsers

public java.util.Vector getLockedUsers(java.lang.Integer max,
                                       java.lang.Integer offset)
                                throws App42Exception
Gets the details of all the locked users By paging.

Parameters:
max - - Maximum number of records to be fetched
offset - - From where the records are to be fetched
Returns:
the List containing locked User Objects
Throws:
App42Exception

getLockedUsersCount

public App42Response getLockedUsersCount()
                                  throws App42Exception
Gets the count of all the locked users

Returns:
the count of locked User exists
Throws:
App42Exception

getRolesByUser

public User getRolesByUser(java.lang.String userName)
                    throws App42Exception
Get the roles from the specified User

Parameters:
userName - - Name of the User for whom roles have to be retrieved
Returns:
User Object containing the role information
Throws:
App42Exception

getUser

public User getUser(java.lang.String userName)
             throws App42Exception
Gets the User details based on userName

Parameters:
userName - - Name of the User to retrieve
Returns:
User Object containing the profile information
Throws:
App42Exception

getUserByEmailId

public User getUserByEmailId(java.lang.String emailId)
                      throws App42Exception
Gets user details based on emailId

Parameters:
emailId - - EmailId of the user to be retrieved
Returns:
User Object
Throws:
App42Exception

getUsersByProfileData

public java.util.Vector getUsersByProfileData(User.Profile profileData)
                                       throws App42Exception
Gets the list of Users based on Profile Data

Parameters:
profileData - - Profile Data key/value for which Users need to be retrieved
Returns:
List of User Object for the specified profile data
Throws:
App42Exception

getUsersByRole

public java.util.Vector getUsersByRole(java.lang.String role)
                                throws App42Exception
Get all the Users who have the specified role assigned

Parameters:
role - - Role for which Users needs to be retrieved
Returns:
List of User Object for that particular role
Throws:
App42Exception

lockUser

public User lockUser(java.lang.String uName)
              throws App42Exception
Locks the user based on the userName. Apps can use these feature to lock a user because of reasons specific to their usercase e.g. If payment not received and the App wants the user to be inactive

Parameters:
uName - - UserName which should be unique for the App
Throws:
App42Exception

resetUserPassword

public App42Response resetUserPassword(java.lang.String uName,
                                       java.lang.String pwd)
                                throws App42Exception
Updates the User password based on userName. Username cannot be updated.

Parameters:
uName - - UserName which should be unique for the App
pwd - - Password to be reset
Throws:
App42Exception

revokeAllRoles

public App42Response revokeAllRoles(java.lang.String userName)
                             throws App42Exception
Revokes all the roles from the user.

Parameters:
userName - - Name of the User from whom Roles have to be revoked
Throws:
App42Exception

revokeRole

public App42Response revokeRole(java.lang.String userName,
                                java.lang.String role)
                         throws App42Exception
Revokes the specified role from the user.

Parameters:
userName - - UserName from whom the role has to be revoked
role - - Role that has to be revoked
Throws:
App42Exception

unlockUser

public User unlockUser(java.lang.String uName)
                throws App42Exception
Unlocks the user based on the userName. App developers can use this feature to unlock a user because of reasons specific to their usercase e.g. When payment received, the App developer wants the user to be active.

Parameters:
uName - - UserName which should be unique for the App
Throws:
App42Exception

updateEmail

public User updateEmail(java.lang.String uName,
                        java.lang.String emailAddress)
                 throws App42Exception
Updates the User's Email Address based on userName. Note: Only email can be updated. Username cannot be updated.

Parameters:
uName - - UserName which should be unique for the App
emailAddress - - Email address of the user
Throws:
App42Exception