public interface ProfileService
Modifier and Type | Method and Description |
---|---|
ProfileAttachment |
addProfileAttachment(String profileId,
String attachmentName,
InputStream file)
Saves a Profile Attachment
|
Profile |
addRoles(String profileId,
Collection<String> roles,
String... attributesToReturn)
Assigns roles to the profile.
|
Profile |
changePassword(String resetTokenId,
String newPassword,
String... attributesToReturn)
Changes a profile's password, after a reset request has been sent.
|
Profile |
createProfile(String tenantName,
String username,
String password,
String email,
boolean enabled,
Set<String> roles,
Map<String,Object> attributes,
String verificationUrl)
Creates a new profile for a specific tenant name.
|
VerificationToken |
createVerificationToken(String profileId)
Creates a token that can be sent to the user in an email as a link.
|
void |
deleteProfile(String profileId)
Deletes a profile.
|
void |
deleteVerificationToken(String tokenId)
Deletes a verification token when it's not needed anymore (not necessary to call if
verifyProfile(String, String...) or changePassword(String, String, String...) , since they
already delete the token. |
Profile |
disableProfile(String profileId,
String... attributesToReturn)
Disables a profile.
|
Profile |
enableProfile(String profileId,
String... attributesToReturn)
Enables a profile.
|
Map<String,Object> |
getAttributes(String profileId,
String... attributesToReturn)
Returns the attributes of a profile.
|
Profile |
getProfile(String profileId,
String... attributesToReturn)
Returns the profile for the specified ID.
|
InputStream |
getProfileAttachment(String attachmentId,
String profileId)
Given the Attachment Id and the Profile Id, gets the Actual Attachment.
|
ProfileAttachment |
getProfileAttachmentInformation(String profileId,
String attachmentId)
Gets Profile attachment Information.
|
List<ProfileAttachment> |
getProfileAttachments(String profileId)
List all Attachments for the given profile.
|
Profile |
getProfileByQuery(String tenantName,
String query,
String... attributesToReturn)
Returns the single profile that matches the specified query
|
Profile |
getProfileByTicket(String ticketId,
String... attributesToReturn)
Returns the profile for the specified ticket.
|
Profile |
getProfileByUsername(String tenantName,
String username,
String... attributesToReturn)
Returns the user for the specified tenant and username
|
long |
getProfileCount(String tenantName)
Returns the number of profiles of the specified tenant.
|
long |
getProfileCountByQuery(String tenantName,
String query)
Returns the number of profiles that match the query for the specified tenant.
|
List<Profile> |
getProfileRange(String tenantName,
String sortBy,
SortOrder sortOrder,
Integer start,
Integer count,
String... attributesToReturn)
Returns a range of profiles for the specified tenant.
|
List<Profile> |
getProfilesByAttributeValue(String tenantName,
String attributeName,
String attributeValue,
String sortBy,
SortOrder sortOrder,
String... attributesToReturn)
Returns the list of profiles that have the given attribute with the given value.
|
List<Profile> |
getProfilesByExistingAttribute(String tenantName,
String attributeName,
String sortBy,
SortOrder sortOrder,
String... attributesToReturn)
Returns the list of profiles that have the given attribute, with any value
|
List<Profile> |
getProfilesByIds(List<String> profileIds,
String sortBy,
SortOrder sortOrder,
String... attributesToReturn)
Returns a list of profiles for the specified list of IDs.
|
List<Profile> |
getProfilesByQuery(String tenantName,
String query,
String sortBy,
SortOrder sortOrder,
Integer start,
Integer count,
String... attributesToReturn)
Returns the profiles that match the specified query.
|
List<Profile> |
getProfilesByRole(String tenantName,
String role,
String sortBy,
SortOrder sortOrder,
String... attributesToReturn)
Returns a list of profiles for a specific role and tenant.
|
VerificationToken |
getVerificationToken(String tokenId)
Returns the verification token that corresponds to the given ID.
|
Profile |
removeAttributes(String profileId,
Collection<String> attributeNames,
String... attributesToReturn)
Removes a list of attributes of a profile.
|
Profile |
removeRoles(String profileId,
Collection<String> roles,
String... attributesToReturn)
Removes assigned roles from a profile.
|
Profile |
resetPassword(String profileId,
String resetPasswordUrl,
String... attributesToReturn)
Sends an email to the profile's user to indicate that the password needs to be reset.
|
Profile |
setFailedLoginAttempts(String profileId,
int failedAttempts,
String... attributesToReturn)
Sets the number of failed login attempts for the profile.
|
Profile |
setLastFailedLogin(String profileId,
Date lastFailedLogin,
String... attributesToReturn)
Sets the date of the last failed login for the profile.
|
Profile |
updateAttributes(String profileId,
Map<String,Object> attributes,
String... attributesToReturn)
Updates the attributes of a profile, by merging the specified attributes with the existing attributes.
|
Profile |
updateProfile(String profileId,
String username,
String password,
String email,
Boolean enabled,
Set<String> roles,
Map<String,Object> attributes,
String... attributesToReturn)
Updates the profile's info.
|
Profile |
verifyProfile(String verificationTokenId,
String... attributesToReturn)
Sets the profile as verified if the verification token is valid.
|
Profile createProfile(String tenantName, String username, String password, String email, boolean enabled, Set<String> roles, Map<String,Object> attributes, String verificationUrl) throws ProfileException
tenantName
- the name of the tenant to add the profile tousername
- the profile's usernamepassword
- the profile's passwordemail
- the profile's emailenabled
- if the profile should be enabled or notroles
- the profile's roles (optional)attributes
- the additional attributes to add to the profile (optional)verificationUrl
- the URL (sans token) the user needs to go in case it needs to verify the created
profile (verification depends on tenant) (optional).ProfileException
Profile updateProfile(String profileId, String username, String password, String email, Boolean enabled, Set<String> roles, Map<String,Object> attributes, String... attributesToReturn) throws ProfileException
profileId
- the profile's IDusername
- the new username for the profile, or null if it shouldn't be updatedpassword
- the new password for the profile, or null if it shouldn't be updatedemail
- the new email for the profile, or null if it shouldn't be updatedenabled
- if the profile should be enabled or not, or null if it shouldn't be updatedroles
- the new roles for the profile, or null if the roles shouldn't be updatedattributes
- the attributes to update, or null if no attribute should be updatedattributesToReturn
- the names of the attributes to return (null to return all attributes)ProfileException
Profile verifyProfile(String verificationTokenId, String... attributesToReturn) throws ProfileException
verificationTokenId
- the verification token IDattributesToReturn
- the names of the attributes to return with the profile (null to return
all attributes)ProfileException
Profile enableProfile(String profileId, String... attributesToReturn) throws ProfileException
profileId
- the profile's IDattributesToReturn
- the names of the attributes to return with the profile (null to return
all attributes)ProfileException
Profile setLastFailedLogin(String profileId, Date lastFailedLogin, String... attributesToReturn) throws ProfileException
profileId
- the profile's IDlastFailedLogin
- the date of the last failed loginattributesToReturn
- the names of the attributes to return with the profile (null to return
all attributes)ProfileException
Profile setFailedLoginAttempts(String profileId, int failedAttempts, String... attributesToReturn) throws ProfileException
profileId
- the profile's IDfailedAttempts
- the number of failed login attemptsattributesToReturn
- the names of the attributes to return with the profile (null to return
all attributes)ProfileException
Profile disableProfile(String profileId, String... attributesToReturn) throws ProfileException
profileId
- the profile's IDattributesToReturn
- the names of the attributes to return with the profile (null to return
all attributes)ProfileException
Profile addRoles(String profileId, Collection<String> roles, String... attributesToReturn) throws ProfileException
profileId
- the profile's IDroles
- the roles to assignattributesToReturn
- the names of the attributes to return with the profile (null to return
all attributes)ProfileException
Profile removeRoles(String profileId, Collection<String> roles, String... attributesToReturn) throws ProfileException
profileId
- the profile's IDroles
- the roles to removeattributesToReturn
- the names of the attributes to return with the profile (null to return
all attributes)ProfileException
Map<String,Object> getAttributes(String profileId, String... attributesToReturn) throws ProfileException
profileId
- the profile's IDattributesToReturn
- the names of the attributes to return (null to return all attributes)ProfileException
Profile updateAttributes(String profileId, Map<String,Object> attributes, String... attributesToReturn) throws ProfileException
profileId
- the profile's IDattributes
- the new attributesattributesToReturn
- the names of the attributes to return withe the profile (null to return all
attributes)ProfileException
Profile removeAttributes(String profileId, Collection<String> attributeNames, String... attributesToReturn) throws ProfileException
profileId
- the profile's IDattributeNames
- the names of the attributes to removeattributesToReturn
- the names of the attributes to return withe the profile (null to return all
attributes)ProfileException
void deleteProfile(String profileId) throws ProfileException
profileId
- the profile's IDProfileException
Profile getProfileByQuery(String tenantName, String query, String... attributesToReturn) throws ProfileException
tenantName
- the tenant's namequery
- the Mongo query used to search for the profiles. Must not contain the $where
operator, the tenant's name (already specified) or any non-readable attribute
by the applicationattributesToReturn
- the names of the attributes to return with the profile (null to return all
attributes)ProfileException
Profile getProfile(String profileId, String... attributesToReturn) throws ProfileException
profileId
- the profile's IDattributesToReturn
- the names of the attributes to return with the profile (null to return all
attributes)ProfileException
Profile getProfileByUsername(String tenantName, String username, String... attributesToReturn) throws ProfileException
tenantName
- the tenant's nameusername
- the profile's usernameattributesToReturn
- the names of the attributes to return with the profile (null to return all
attributes)ProfileException
Profile getProfileByTicket(String ticketId, String... attributesToReturn) throws ProfileException
ticketId
- the ID ticket of the authenticated profileattributesToReturn
- the names of the attributes to return with the profile (null to return all
attributes)ProfileException
long getProfileCount(String tenantName) throws ProfileException
tenantName
- the tenant's nameProfileException
long getProfileCountByQuery(String tenantName, String query) throws ProfileException
tenantName
- the tenant's namequery
- the Mongo query used to search for the profiles. Must not contain the $where
operator, the tenant's name (already specified) or any non-readable attribute
by the applicationProfileException
List<Profile> getProfilesByQuery(String tenantName, String query, String sortBy, SortOrder sortOrder, Integer start, Integer count, String... attributesToReturn) throws ProfileException
tenantName
- the tenant's namequery
- the Mongo query used to search for the profiles. Must not contain the $where
operator, the tenant's name (already specified) or any non-readable attribute
by the applicationsortBy
- profile attribute to sort the list by (optional)sortOrder
- the sort order (either ASC or DESC) (optional)start
- from the entire list of results, the position where the actual results should start
(useful for pagination) (optional)count
- the number of profiles to return (optional)attributesToReturn
- the names of the attributes to return with the profile (null to return all
attributes)ProfileException
List<Profile> getProfilesByIds(List<String> profileIds, String sortBy, SortOrder sortOrder, String... attributesToReturn) throws ProfileException
profileIds
- the IDs of the profiles to look forsortBy
- profile attribute to sort the list by (optional)sortOrder
- the sort order (either ASC or DESC) (optional)attributesToReturn
- the names of the attributes to return for each profile (null to return all
attributes)ProfileException
List<Profile> getProfileRange(String tenantName, String sortBy, SortOrder sortOrder, Integer start, Integer count, String... attributesToReturn) throws ProfileException
tenantName
- the tenant's namesortBy
- profile attribute to sort the list by (optional)sortOrder
- the sort order (either ASC or DESC) (optional)start
- from the entire list of results, the position where the actual results should start
(useful for pagination) (optional)count
- the number of profiles to return (optional)attributesToReturn
- the names of the attributes to return for each profile (null to return all
attributes)ProfileException
List<Profile> getProfilesByRole(String tenantName, String role, String sortBy, SortOrder sortOrder, String... attributesToReturn) throws ProfileException
tenantName
- the tenant's namerole
- the role's namesortBy
- profile attribute to sort the list by (optional)sortOrder
- the sort order (either ASC or DESC) (optional)attributesToReturn
- the names of the attributes to return for each profile (null to return all
attributes)ProfileException
List<Profile> getProfilesByExistingAttribute(String tenantName, String attributeName, String sortBy, SortOrder sortOrder, String... attributesToReturn) throws ProfileException
tenantName
- the tenant's nameattributeName
- the name of the attribute profiles must havesortBy
- profile attribute to sort the list by (optional)sortOrder
- the sort order (either ASC or DESC) (optional)attributesToReturn
- the names of the attributes to return for each profile (null to return all
attributes)ProfileException
List<Profile> getProfilesByAttributeValue(String tenantName, String attributeName, String attributeValue, String sortBy, SortOrder sortOrder, String... attributesToReturn) throws ProfileException
tenantName
- the tenant's nameattributeName
- the name of the attribute profiles must haveattributeValue
- the value of the attribute profiles must havesortBy
- profile attribute to sort the list by (optional)sortOrder
- the sort order (either ASC or DESC) (optional)attributesToReturn
- the names of the attributes to return for each profile (null to return all
attributes)ProfileException
Profile resetPassword(String profileId, String resetPasswordUrl, String... attributesToReturn) throws ProfileException
profileId
- the profile's IDresetPasswordUrl
- the base URL to use to build the final URL the profile will use to reset
their password.attributesToReturn
- the names of the attributes to return with the profile (null to return all
attributes)ProfileException
Profile changePassword(String resetTokenId, String newPassword, String... attributesToReturn) throws ProfileException
resetTokenId
- the reset token IDnewPassword
- the new passwordattributesToReturn
- the names of the attributes to return with the profile (null to return all
attributes)ProfileException
VerificationToken createVerificationToken(String profileId) throws ProfileException
verifyProfile(String, String...)
or changePassword(String, String,
String...)
to verify that the user agrees.profileId
- the profile ID of the user that needs to be contactedProfileException
VerificationToken getVerificationToken(String tokenId) throws ProfileException
tokenId
- the token IDProfileException
void deleteVerificationToken(String tokenId) throws ProfileException
verifyProfile(String, String...)
or changePassword(String, String, String...)
, since they
already delete the token.tokenId
- the ID of the token to deleteProfileException
ProfileAttachment addProfileAttachment(String profileId, String attachmentName, InputStream file) throws ProfileException
profileId
- Id of the profile owner of the attachment.attachmentName
- File name of the Attachment;file
- Actual File to be Attach.ProfileException
- If attachment can not be saved;ProfileAttachment getProfileAttachmentInformation(String profileId, String attachmentId) throws ProfileException
profileId
- Profile owner of the Attachment.attachmentId
- Attachment Id.ProfileException
- If Attachment cannot be found.InputStream getProfileAttachment(String attachmentId, String profileId) throws ProfileException
attachmentId
- Attachment Id to get.profileId
- Profile Owner of the Attachment.ProfileService
- If unable to get the Attachment.ProfileException
List<ProfileAttachment> getProfileAttachments(String profileId) throws ProfileException
profileId
- Profile to get all AttachmentsProfileException
- If unable to get Profile attachments.Copyright © 2021 CrafterCMS. All rights reserved.