Package org.wso2.carbon.user.api
Interface UserStoreManager
-
public interface UserStoreManagerThe interface to read data from a user store. Implement this interface in your UserStoreManager class and add the class to the class path. Provide the class name in the configuration file and the framework will pick the new code that reads user information from the store.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description voidaddRememberMe(String userName, String token)Adding a remember me tokenvoidaddRole(String roleName, String[] userList, Permission[] permissions)Adds a role to the system.voidaddRole(String roleName, String[] userList, Permission[] permissions, boolean isSharedRole)Adds a role to the system.voidaddUser(String userName, Object credential, String[] roleList, Map<String,String> claims, String profileName)Add a user to the user storevoidaddUser(String userName, Object credential, String[] roleList, Map<String,String> claims, String profileName, boolean requirePasswordChange)Add a user to the user storebooleanauthenticate(String userName, Object credential)Given the user name and a credential object, the implementation code must validate whether the user is authenticated.voiddeleteRole(String roleName)Delete the role with the given role namevoiddeleteUser(String userName)Delete the user with the given user namevoiddeleteUserClaimValue(String userName, String claimURI, String profileName)Delete a single user claim valuevoiddeleteUserClaimValues(String userName, String[] claims, String profileName)Delete many user claim values.String[]getAllProfileNames()Get all the profile names in the systemClaimManagergetClaimManager()Provides the handler to ClaimManager implementation.PropertiesgetDefaultUserStoreProperties()Get the list of properties required by the User Store Manager, with default valuesString[]getHybridRoles()Gets a list of hybrid roles Hybrid role contains a set of user names in a read only user store.DategetPasswordExpirationTime(String username)Gets the password expiration time of a given userString[]getProfileNames(String userName)Get all profile namesMap<String,String>getProperties(Tenant tenant)Gets the properties of the Tenant.String[]getRoleListOfUser(String userName)Get roles of a user.String[]getRoleNames()Get all role namesintgetTenantId()This will get the tenant id associated with the user store managerintgetTenantId(String username)This method works only if the tenant is super tenant.StringgetUserClaimValue(String userName, String claim, String profileName)Get user claim value in the profile.Claim[]getUserClaimValues(String userName, String profileName)Get all claim values of the user in the profile.Map<String,String>getUserClaimValues(String userName, String[] claims, String profileName)Get user claim values in the profile.intgetUserId(String username)Deprecated.String[]getUserListOfRole(String roleName)booleanisExistingRole(String roleName)Checks whether the role name is in the user storebooleanisExistingRole(String roleName, boolean isShared)Checks whether the role name is in the user storebooleanisExistingUser(String userName)Checks whether the user is in the user storedefault booleanisLocalUserStore()Get whether the userstore is a local userstore.booleanisMultipleProfilesAllowed()This method is to check whether multiple profiles are allowed with a particular user-store.booleanisReadOnly()Checks whether this realm connects to a read only user storebooleanisSCIMEnabled()To signal whether underlying user store supports SCIM attributes.booleanisValidRememberMeToken(String userName, String token)Checking the validity of the remember me tokenString[]listUsers(String filter, int maxItemLimit)Retrieves a list of user names upto a maximum limitvoidsetUserClaimValue(String userName, String claimURI, String claimValue, String profileName)Set a single user claim valuevoidsetUserClaimValues(String userName, Map<String,String> claims, String profileName)Set many user claim valuesvoidupdateCredential(String userName, Object newCredential, Object oldCredential)Update the credential/password of the uservoidupdateCredentialByAdmin(String userName, Object newCredential)Update credential/password by the admin of another uservoidupdateRoleListOfUser(String userName, String[] deletedRoles, String[] newRoles)Updates roles of a uservoidupdateRoleName(String roleName, String newRoleName)Update the role name of given rolevoidupdateUserListOfRole(String roleName, String[] deletedUsers, String[] newUsers)Updates users in a Role
-
-
-
Method Detail
-
authenticate
boolean authenticate(String userName, Object credential) throws UserStoreException
Given the user name and a credential object, the implementation code must validate whether the user is authenticated.- Parameters:
userName- The user namecredential- The credential of a user- Returns:
- If the value is true the provided credential match with the user name. False is returned for invalid credential, invalid user name and mismatching credential with user name.
- Throws:
UserStoreException- An unexpected exception has occurred
-
listUsers
String[] listUsers(String filter, int maxItemLimit) throws UserStoreException
Retrieves a list of user names upto a maximum limit- Parameters:
filter- The string to filter out usermaxItemLimit- The max item limit. If -1 then system maximum limit will be used. If the given value is greater than the system configured max limit it will be reseted to the system configured max limit.- Returns:
- An array of user names
- Throws:
UserStoreException
-
isExistingUser
boolean isExistingUser(String userName) throws UserStoreException
Checks whether the user is in the user store- Parameters:
userName- The user name- Returns:
- Returns true if user name is found else returns false.
- Throws:
UserStoreException
-
isExistingRole
boolean isExistingRole(String roleName, boolean isShared) throws UserStoreException
Checks whether the role name is in the user store- Parameters:
roleName-- Returns:
- Throws:
UserStoreException
-
isExistingRole
boolean isExistingRole(String roleName) throws UserStoreException
Checks whether the role name is in the user store- Parameters:
roleName-- Returns:
- Throws:
UserStoreException
-
getRoleNames
String[] getRoleNames() throws UserStoreException
Get all role names- Returns:
- An array of all role names
- Throws:
UserStoreException
-
getProfileNames
String[] getProfileNames(String userName) throws UserStoreException
Get all profile names- Parameters:
userName- The user name- Returns:
- An array of profile names the user has.
- Throws:
UserStoreException
-
getRoleListOfUser
String[] getRoleListOfUser(String userName) throws UserStoreException
Get roles of a user.- Parameters:
userName- The user name- Returns:
- An array of role names that user belongs.
- Throws:
UserStoreException
-
getUserListOfRole
String[] getUserListOfRole(String roleName) throws UserStoreException
- Throws:
UserStoreException
-
getUserClaimValue
String getUserClaimValue(String userName, String claim, String profileName) throws UserStoreException
Get user claim value in the profile.- Parameters:
userName- The user nameclaim- The claim URIprofileName- The profile name, can be null. If null the default profile is considered.- Returns:
- The value
- Throws:
UserStoreException
-
getUserClaimValues
Map<String,String> getUserClaimValues(String userName, String[] claims, String profileName) throws UserStoreException
Get user claim values in the profile.- Parameters:
userName- The user nameclaims- The claim URIprofileName- The profile name, can be null. If null the default profile is considered.- Returns:
- A map containing name value pairs
- Throws:
UserStoreException
-
getUserClaimValues
Claim[] getUserClaimValues(String userName, String profileName) throws UserStoreException
Get all claim values of the user in the profile.- Parameters:
userName- The user nameprofileName- The profile name, can be null. If null the default profile is considered.- Returns:
- An array of claims
- Throws:
UserStoreException
-
getAllProfileNames
String[] getAllProfileNames() throws UserStoreException
Get all the profile names in the system- Returns:
- An array of all profile names
- Throws:
UserStoreException
-
isReadOnly
boolean isReadOnly() throws UserStoreExceptionChecks whether this realm connects to a read only user store- Returns:
- Returns true of the user store is read only. Returns false if the user store allows modifications.
- Throws:
UserStoreException
-
addUser
void addUser(String userName, Object credential, String[] roleList, Map<String,String> claims, String profileName) throws UserStoreException
Add a user to the user store- Parameters:
userName- User name of the usercredential- The credential/password of the userroleList- The roles that user belongsclaims- Properties of the userprofileName- The name of the profile where claims should be added- Throws:
UserStoreException
-
addUser
void addUser(String userName, Object credential, String[] roleList, Map<String,String> claims, String profileName, boolean requirePasswordChange) throws UserStoreException
Add a user to the user store- Parameters:
userName- User name of the usercredential- The credential/password of the userroleList- The roles that user belongsclaims- Properties of the userprofileName- The name of the profile where claims should be addedrequirePasswordChange- Require the password change within next 24 hours- Throws:
UserStoreException
-
updateCredential
void updateCredential(String userName, Object newCredential, Object oldCredential) throws UserStoreException
Update the credential/password of the user- Parameters:
userName- The user namenewCredential- The new credential/passwordoldCredential- The old credential/password- Throws:
UserStoreException
-
updateCredentialByAdmin
void updateCredentialByAdmin(String userName, Object newCredential) throws UserStoreException
Update credential/password by the admin of another user- Parameters:
userName- The user namenewCredential- The new credential- Throws:
UserStoreException
-
deleteUser
void deleteUser(String userName) throws UserStoreException
Delete the user with the given user name- Parameters:
userName- The user name- Throws:
UserStoreException
-
addRole
void addRole(String roleName, String[] userList, Permission[] permissions, boolean isSharedRole) throws UserStoreException
Adds a role to the system.- Parameters:
roleName- The role name.userList- the list of the users.permissions- The permissions of the role.isSharedRole- Whether the added role is a shared role or not- Throws:
UserStoreException
-
addRole
void addRole(String roleName, String[] userList, Permission[] permissions) throws UserStoreException
Adds a role to the system.- Parameters:
roleName- The role name.userList- the list of the users.permissions- The permissions of the role.isSharedRole- Whether the added role is a shared role or not- Throws:
UserStoreException
-
deleteRole
void deleteRole(String roleName) throws UserStoreException
Delete the role with the given role name- Parameters:
roleName- The role name- Throws:
UserStoreException
-
updateUserListOfRole
void updateUserListOfRole(String roleName, String[] deletedUsers, String[] newUsers) throws UserStoreException
Updates users in a Role- Parameters:
roleName- The role name to be updateddeletedUsers- The array of user names to be deletednewUsers- The array of of user names to be added- Throws:
UserStoreException
-
updateRoleListOfUser
void updateRoleListOfUser(String userName, String[] deletedRoles, String[] newRoles) throws UserStoreException
Updates roles of a user- Parameters:
userName- The user name of the user where role list is updateddeletedRoles- The array of role names to be addednewRoles- The array of role names to be added- Throws:
UserStoreException
-
setUserClaimValue
void setUserClaimValue(String userName, String claimURI, String claimValue, String profileName) throws UserStoreException
Set a single user claim value- Parameters:
userName- The user nameclaimURI- The claim URIclaimValue- The valueprofileName- The profile name, can be null. If null the default profile is considered.- Throws:
UserStoreException
-
setUserClaimValues
void setUserClaimValues(String userName, Map<String,String> claims, String profileName) throws UserStoreException
Set many user claim values- Parameters:
userName- The user nameclaims- Map of claim URIs against valuesprofileName- The profile name, can be null. If null the default profile is considered.- Throws:
UserStoreException
-
deleteUserClaimValue
void deleteUserClaimValue(String userName, String claimURI, String profileName) throws UserStoreException
Delete a single user claim value- Parameters:
userName- The user nameclaimURI- Name of the claimprofileName- The profile name, can be null. If null the default profile is considered.- Throws:
UserStoreException
-
deleteUserClaimValues
void deleteUserClaimValues(String userName, String[] claims, String profileName) throws UserStoreException
Delete many user claim values.- Parameters:
userName- The user nameclaims- URIs of the claims to be deleted.profileName- The profile name, can be null. If null the default profile is considered.- Throws:
UserStoreException
-
getHybridRoles
String[] getHybridRoles() throws UserStoreException
Gets a list of hybrid roles Hybrid role contains a set of user names in a read only user store.- Returns:
- Throws:
UserStoreException
-
getPasswordExpirationTime
Date getPasswordExpirationTime(String username) throws UserStoreException
Gets the password expiration time of a given user- Parameters:
username- The user name- Returns:
- The password expiration time
- Throws:
UserStoreException
-
getUserId
int getUserId(String username) throws UserStoreException
Deprecated.Returns the user id if available- Parameters:
username- The user name- Returns:
- Throws:
UserStoreException
-
getTenantId
int getTenantId(String username) throws UserStoreException
This method works only if the tenant is super tenant. If the realm is not super tenant's this method should throw exception- Parameters:
username- The user name- Returns:
- Throws:
UserStoreException
-
getTenantId
int getTenantId() throws UserStoreExceptionThis will get the tenant id associated with the user store manager- Returns:
- the tenant id of the authorization manager
- Throws:
UserStoreException- if the operation failed
-
getProperties
Map<String,String> getProperties(Tenant tenant) throws UserStoreException
Gets the properties of the Tenant.- Parameters:
tenant-- Returns:
- Throws:
UserStoreException
-
updateRoleName
void updateRoleName(String roleName, String newRoleName) throws UserStoreException
Update the role name of given role- Parameters:
roleName-newRoleName-- Throws:
UserStoreException
-
isMultipleProfilesAllowed
boolean isMultipleProfilesAllowed()
This method is to check whether multiple profiles are allowed with a particular user-store. For an example, currently, JDBC user store supports multiple profiles and where as ApacheDS does not allow.- Returns:
- boolean
-
addRememberMe
void addRememberMe(String userName, String token) throws UserStoreException
Adding a remember me token- Parameters:
userName- - User nametoken- - The token to be stored- Throws:
UserStoreException
-
isValidRememberMeToken
boolean isValidRememberMeToken(String userName, String token) throws UserStoreException
Checking the validity of the remember me token- Parameters:
userName- TODOtoken- TODO- Returns:
- Throws:
UserStoreException
-
getClaimManager
ClaimManager getClaimManager() throws UserStoreException
Provides the handler to ClaimManager implementation.- Returns:
- Throws:
UserStoreException
-
isSCIMEnabled
boolean isSCIMEnabled() throws UserStoreExceptionTo signal whether underlying user store supports SCIM attributes.- Returns:
- Throws:
UserStoreException
-
getDefaultUserStoreProperties
Properties getDefaultUserStoreProperties()
Get the list of properties required by the User Store Manager, with default values- Returns:
-
isLocalUserStore
default boolean isLocalUserStore()
Get whether the userstore is a local userstore. By default, returns true.- Returns:
- true if the userstore is a local userstore.
-
-