Class ProfileServiceImpl
java.lang.Object
org.craftercms.profile.services.impl.ProfileServiceImpl
- All Implemented Interfaces:
ProfileService
Default implementation of
ProfileService.- Author:
- avasquez
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.craftercms.commons.security.permissions.PermissionEvaluator<AccessToken, AttributeDefinition> protected AuthenticationServiceprotected org.craftercms.commons.entitlements.validator.EntitlementValidatorstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected Stringprotected Stringprotected Stringprotected ProfileRepositorystatic final Stringstatic final Stringstatic final Patternstatic final Patternprotected Stringprotected Stringprotected Stringprotected org.craftercms.commons.security.permissions.PermissionEvaluator<AccessToken, String> protected TenantServiceprotected VerificationService -
Constructor Summary
ConstructorsConstructorDescriptionProfileServiceImpl(org.craftercms.commons.security.permissions.PermissionEvaluator<AccessToken, String> tenantPermissionEvaluator, org.craftercms.commons.security.permissions.PermissionEvaluator<AccessToken, AttributeDefinition> attributePermissionEvaluator, ProfileRepository profileRepository, VerificationService verificationService, String newProfileEmailFromAddress, String newProfileEmailSubject, String newProfileEmailTemplateName, String resetPwdEmailFromAddress, String resetPwdEmailSubject, String resetPwdEmailTemplateName, org.craftercms.commons.entitlements.validator.EntitlementValidator entitlementValidator) -
Method Summary
Modifier and TypeMethodDescriptionaddProfileAttachment(String profileId, String attachmentName, InputStream file) Saves a Profile AttachmentaddRoles(String profileId, Collection<String> roles, String... attributesToReturn) Assigns roles to the profile.changePassword(String resetTokenId, String newPassword, String... attributesToReturn) Changes a profile's password, after a reset request has been sent.protected voidcheckIfManageProfilesIsAllowed(String tenantName) protected voidcleanseAttributes(Tenant tenant, Map<String, Object> attributes) 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.createVerificationToken(String profileId) Creates a token that can be sent to the user in an email as a link.voiddeleteProfile(String profileId) Deletes a profile.voiddeleteVerificationToken(String tokenId) Deletes a verification token when it's not needed anymore (not necessary to call ifProfileService.verifyProfile(String, String...)orProfileService.changePassword(String, String, String...), since they already delete the token.disableProfile(String profileId, String... attributesToReturn) Disables a profile.enableProfile(String profileId, String... attributesToReturn) Enables a profile.protected ObjectescapeValue(Object value, String type) protected voidfilterAttributeIfReadNotAllowed(Tenant tenant, Iterator<String> attributeNamesIter, List<AttributeDefinition> attributeDefinitions) protected ProfilefilterAttributes(Profile profile, String[] attributesToReturn) protected voidfilterNonReadableAttributes(Iterable<Profile> profiles) protected voidfilterNonReadableAttributes(Profile profile) protected voidfilterNonReadableAttributes(Tenant tenant, Iterable<Profile> profiles) protected voidfilterNonReadableAttributes(Tenant tenant, Profile profile) protected AttributeDefinitionfindAttributeDefinition(List<AttributeDefinition> attributeDefinitions, String name) getAttributes(String profileId, String... attributesToReturn) Returns the attributes of a profile.protected StringgetFinalQuery(Tenant tenant, String query) protected ProfilegetNonNullProfile(String id, String... attributesToReturn) getProfile(String profileId, String... attributesToReturn) Returns the profile for the specified ID.getProfileAttachment(String attachmentId, String profileId) Given the Attachment Id and the Profile Id, gets the Actual Attachment.getProfileAttachmentInformation(String profileId, String attachmentId) Gets Profile attachment Information.getProfileAttachments(String profileId) List all Attachments for the given profile.getProfileByQuery(String tenantName, String query, String... attributesToReturn) Returns the single profile that matches the specified querygetProfileByTicket(String ticketId, String... attributesToReturn) Returns the profile for the specified ticket.getProfileByUsername(String tenantName, String username, String... attributesToReturn) Returns the user for the specified tenant and usernamelonggetProfileCount(String tenantName) Returns the number of profiles of the specified tenant.longgetProfileCountByQuery(String tenantName, String query) Returns the number of profiles that match the query for the specified tenant.getProfileRange(String tenantName, String sortBy, SortOrder sortOrder, Integer start, Integer count, String... attributesToReturn) Returns a range of profiles for the specified tenant.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.getProfilesByExistingAttribute(String tenantName, String attributeName, String sortBy, SortOrder sortOrder, String... attributesToReturn) Returns the list of profiles that have the given attribute, with any valuegetProfilesByIds(List<String> profileIds, String sortBy, SortOrder sortOrder, String... attributesToReturn) Returns a list of profiles for the specified list of IDs.getProfilesByQuery(String tenantName, String query, String sortBy, SortOrder sortOrder, Integer start, Integer count, String... attributesToReturn) Returns the profiles that match the specified query.getProfilesByRole(String tenantName, String role, String sortBy, SortOrder sortOrder, String... attributesToReturn) Returns a list of profiles for a specific role and tenant.protected TenantgetVerificationToken(String tokenId) Returns the verification token that corresponds to the given ID.protected booleanisAttributeActionAllowed(AttributeDefinition definition, AttributeAction action) protected voidrejectAttributeIfActionNotAllowed(Tenant tenant, String attributeName, AttributeAction action, List<AttributeDefinition> attributeDefinitions) protected voidrejectAttributesIfActionNotAllowed(String tenantName, Collection<String> attributeNames, AttributeAction action) protected voidrejectAttributesIfActionNotAllowed(Tenant tenant, Collection<String> attributeNames, AttributeAction action) removeAttributes(String profileId, Collection<String> attributeNames, String... attributesToReturn) Removes a list of attributes of a profile.removeRoles(String profileId, Collection<String> roles, String... attributesToReturn) Removes assigned roles from a 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.voidsetAuthenticationService(AuthenticationService authenticationService) setFailedLoginAttempts(String profileId, int failedAttempts, String... attributesToReturn) Sets the number of failed login attempts for the profile.setLastFailedLogin(String profileId, Date lastFailedLogin, String... attributesToReturn) Sets the date of the last failed login for the profile.voidsetTenantService(TenantService tenantService) voidsetValidAttachmentMimeTypes(String validAttachmentMimeTypes) Updates the attributes of a profile, by merging the specified attributes with the existing attributes.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.protected ProfileupdateProfile(String profileId, ProfileServiceImpl.UpdateCallback callback, String... attributesToReturn) protected voidvalidateQuery(Tenant tenant, String query) verifyProfile(String verificationTokenId, String... attributesToReturn) Sets the profile as verified if the verification token is valid.
-
Field Details
-
LOG_KEY_PROFILE_CREATED
- See Also:
-
LOG_KEY_PROFILE_UPDATED
- See Also:
-
LOG_KEY_PROFILE_VERIFIED
- See Also:
-
LOG_KEY_PROFILE_ENABLED
- See Also:
-
LOG_KEY_PROFILE_DISABLED
- See Also:
-
LOG_KEY_PROFILE_ROLES_ADDED
- See Also:
-
LOG_KEY_PROFILE_ROLES_REMOVED
- See Also:
-
LOG_KEY_PROFILE_ATTRIBS_UPDATED
- See Also:
-
LOG_KEY_PROFILE_ATTRIBS_REMOVED
- See Also:
-
LOG_KEY_PROFILE_DELETED
- See Also:
-
LOG_KEY_PASSWORD_CHANGED
- See Also:
-
ERROR_KEY_CREATE_PROFILE_ERROR
- See Also:
-
ERROR_KEY_GET_PROFILE_BY_QUERY_ERROR
- See Also:
-
ERROR_KEY_GET_PROFILE_ERROR
- See Also:
-
ERROR_KEY_UPDATE_PROFILE_ERROR
- See Also:
-
ERROR_KEY_DELETE_PROFILE_ERROR
- See Also:
-
ERROR_KEY_GET_PROFILE_COUNT_BY_QUERY_ERROR
- See Also:
-
ERROR_KEY_GET_PROFILES_BY_QUERY_ERROR
- See Also:
-
ERROR_KEY_GET_PROFILE_BY_USERNAME_ERROR
- See Also:
-
ERROR_KEY_GET_PROFILE_COUNT_ERROR
- See Also:
-
ERROR_KEY_GET_PROFILES_ERROR
- See Also:
-
ERROR_KEY_GET_PROFILE_RANGE_ERROR
- See Also:
-
ERROR_KEY_GET_PROFILES_BY_ROLE_ERROR
- See Also:
-
ERROR_KEY_GET_PROFILES_BY_EXISTING_ATTRIB_ERROR
- See Also:
-
ERROR_KEY_GET_PROFILES_BY_ATTRIB_VALUE_ERROR
- See Also:
-
ERROR_KEY_TENANT_NOT_ALLOWED
- See Also:
-
ERROR_KEY_WHERE_NOT_ALLOWED
- See Also:
-
ERROR_KEY_ATTRIBUTE_NOT_ALLOWED
- See Also:
-
ERROR_KEY_ENTITLEMENT_ERROR
- See Also:
-
QUERY_TENANT_PATTERN
-
QUERY_WHERE_PATTERN
-
QUERY_ATTRIBUTE_PATTERN_FORMAT
- See Also:
-
QUERY_FINAL_FORMAT
- See Also:
-
CLEANSE_SUPPORTED_TYPES
-
tenantPermissionEvaluator
protected org.craftercms.commons.security.permissions.PermissionEvaluator<AccessToken,String> tenantPermissionEvaluator -
attributePermissionEvaluator
protected org.craftercms.commons.security.permissions.PermissionEvaluator<AccessToken,AttributeDefinition> attributePermissionEvaluator -
profileRepository
-
tenantService
-
authenticationService
-
verificationService
-
validAttachmentMimeTypes
-
newProfileEmailFromAddress
-
newProfileEmailSubject
-
newProfileEmailTemplateName
-
resetPwdEmailFromAddress
-
resetPwdEmailSubject
-
resetPwdEmailTemplateName
-
entitlementValidator
protected org.craftercms.commons.entitlements.validator.EntitlementValidator entitlementValidator
-
-
Constructor Details
-
ProfileServiceImpl
public ProfileServiceImpl(org.craftercms.commons.security.permissions.PermissionEvaluator<AccessToken, String> tenantPermissionEvaluator, org.craftercms.commons.security.permissions.PermissionEvaluator<AccessToken, AttributeDefinition> attributePermissionEvaluator, ProfileRepository profileRepository, VerificationService verificationService, String newProfileEmailFromAddress, String newProfileEmailSubject, String newProfileEmailTemplateName, String resetPwdEmailFromAddress, String resetPwdEmailSubject, String resetPwdEmailTemplateName, org.craftercms.commons.entitlements.validator.EntitlementValidator entitlementValidator)
-
-
Method Details
-
setTenantService
-
setAuthenticationService
-
createProfile
public Profile createProfile(String tenantName, String username, String password, String email, boolean enabled, Set<String> roles, Map<String, Object> attributes, String verificationUrl) throws ProfileExceptionDescription copied from interface:ProfileServiceCreates a new profile for a specific tenant name.- Specified by:
createProfilein interfaceProfileService- Parameters:
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).- Returns:
- the newly created profile
- Throws:
ProfileException
-
updateProfile
public Profile updateProfile(String profileId, String username, String password, String email, Boolean enabled, Set<String> roles, Map<String, Object> attributes, String... attributesToReturn) throws ProfileExceptionDescription copied from interface:ProfileServiceUpdates the profile's info.- Specified by:
updateProfilein interfaceProfileService- Parameters:
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)- Returns:
- the updated profile
- Throws:
ProfileException
-
cleanseAttributes
-
escapeValue
-
verifyProfile
public Profile verifyProfile(String verificationTokenId, String... attributesToReturn) throws ProfileException Description copied from interface:ProfileServiceSets the profile as verified if the verification token is valid.- Specified by:
verifyProfilein interfaceProfileService- Parameters:
verificationTokenId- the verification token IDattributesToReturn- the names of the attributes to return with the profile (null to return all attributes)- Returns:
- the updated profile associated to the token
- Throws:
ProfileException
-
enableProfile
public Profile enableProfile(String profileId, String... attributesToReturn) throws ProfileException Description copied from interface:ProfileServiceEnables a profile.- Specified by:
enableProfilein interfaceProfileService- Parameters:
profileId- the profile's IDattributesToReturn- the names of the attributes to return with the profile (null to return all attributes)- Returns:
- the updated profile
- Throws:
ProfileException
-
setLastFailedLogin
public Profile setLastFailedLogin(String profileId, Date lastFailedLogin, String... attributesToReturn) throws ProfileException Description copied from interface:ProfileServiceSets the date of the last failed login for the profile.- Specified by:
setLastFailedLoginin interfaceProfileService- Parameters:
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)- Returns:
- the updated profile
- Throws:
ProfileException
-
setFailedLoginAttempts
public Profile setFailedLoginAttempts(String profileId, int failedAttempts, String... attributesToReturn) throws ProfileException Description copied from interface:ProfileServiceSets the number of failed login attempts for the profile.- Specified by:
setFailedLoginAttemptsin interfaceProfileService- Parameters:
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)- Returns:
- the updated profile
- Throws:
ProfileException
-
disableProfile
public Profile disableProfile(String profileId, String... attributesToReturn) throws ProfileException Description copied from interface:ProfileServiceDisables a profile.- Specified by:
disableProfilein interfaceProfileService- Parameters:
profileId- the profile's IDattributesToReturn- the names of the attributes to return with the profile (null to return all attributes)- Returns:
- the updated profile
- Throws:
ProfileException
-
addRoles
public Profile addRoles(String profileId, Collection<String> roles, String... attributesToReturn) throws ProfileException Description copied from interface:ProfileServiceAssigns roles to the profile.- Specified by:
addRolesin interfaceProfileService- Parameters:
profileId- the profile's IDroles- the roles to assignattributesToReturn- the names of the attributes to return with the profile (null to return all attributes)- Returns:
- the updated profile
- Throws:
ProfileException
-
removeRoles
public Profile removeRoles(String profileId, Collection<String> roles, String... attributesToReturn) throws ProfileException Description copied from interface:ProfileServiceRemoves assigned roles from a profile.- Specified by:
removeRolesin interfaceProfileService- Parameters:
profileId- the profile's IDroles- the roles to removeattributesToReturn- the names of the attributes to return with the profile (null to return all attributes)- Returns:
- the updated profile
- Throws:
ProfileException
-
getAttributes
public Map<String,Object> getAttributes(String profileId, String... attributesToReturn) throws ProfileException Description copied from interface:ProfileServiceReturns the attributes of a profile.- Specified by:
getAttributesin interfaceProfileService- Parameters:
profileId- the profile's IDattributesToReturn- the names of the attributes to return (null to return all attributes)- Returns:
- the profile's attributes
- Throws:
ProfileException
-
updateAttributes
public Profile updateAttributes(String profileId, Map<String, Object> attributes, String... attributesToReturn) throws ProfileExceptionDescription copied from interface:ProfileServiceUpdates the attributes of a profile, by merging the specified attributes with the existing attributes.- Specified by:
updateAttributesin interfaceProfileService- Parameters:
profileId- the profile's IDattributes- the new attributesattributesToReturn- the names of the attributes to return withe the profile (null to return all attributes)- Returns:
- the updated profile
- Throws:
ProfileException
-
removeAttributes
public Profile removeAttributes(String profileId, Collection<String> attributeNames, String... attributesToReturn) throws ProfileException Description copied from interface:ProfileServiceRemoves a list of attributes of a profile.- Specified by:
removeAttributesin interfaceProfileService- Parameters:
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)- Returns:
- the updated profile
- Throws:
ProfileException
-
deleteProfile
Description copied from interface:ProfileServiceDeletes a profile.- Specified by:
deleteProfilein interfaceProfileService- Parameters:
profileId- the profile's ID- Throws:
ProfileException
-
getProfileByQuery
public Profile getProfileByQuery(String tenantName, String query, String... attributesToReturn) throws ProfileException Description copied from interface:ProfileServiceReturns the single profile that matches the specified query- Specified by:
getProfileByQueryin interfaceProfileService- Parameters:
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)- Returns:
- the profile, or null if not found
- Throws:
ProfileException
-
getProfile
Description copied from interface:ProfileServiceReturns the profile for the specified ID.- Specified by:
getProfilein interfaceProfileService- Parameters:
profileId- the profile's IDattributesToReturn- the names of the attributes to return with the profile (null to return all attributes)- Returns:
- the profile, or null if not found
- Throws:
ProfileException
-
getProfileByUsername
public Profile getProfileByUsername(String tenantName, String username, String... attributesToReturn) throws ProfileException Description copied from interface:ProfileServiceReturns the user for the specified tenant and username- Specified by:
getProfileByUsernamein interfaceProfileService- Parameters:
tenantName- the tenant's nameusername- the profile's usernameattributesToReturn- the names of the attributes to return with the profile (null to return all attributes)- Returns:
- the profile, or null if not found
- Throws:
ProfileException
-
getProfileByTicket
public Profile getProfileByTicket(String ticketId, String... attributesToReturn) throws ProfileException Description copied from interface:ProfileServiceReturns the profile for the specified ticket.- Specified by:
getProfileByTicketin interfaceProfileService- Parameters:
ticketId- the ID ticket of the authenticated profileattributesToReturn- the names of the attributes to return with the profile (null to return all attributes)- Returns:
- the profile, or null if not found
- Throws:
ProfileException
-
getProfileCount
Description copied from interface:ProfileServiceReturns the number of profiles of the specified tenant.- Specified by:
getProfileCountin interfaceProfileService- Parameters:
tenantName- the tenant's name- Returns:
- the number of profiles of the specified tenant
- Throws:
ProfileException
-
getProfileCountByQuery
Description copied from interface:ProfileServiceReturns the number of profiles that match the query for the specified tenant.- Specified by:
getProfileCountByQueryin interfaceProfileService- Parameters:
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 application- Returns:
- the number of profiles of the specified tenant
- Throws:
ProfileException
-
getProfilesByQuery
public List<Profile> getProfilesByQuery(String tenantName, String query, String sortBy, SortOrder sortOrder, Integer start, Integer count, String... attributesToReturn) throws ProfileException Description copied from interface:ProfileServiceReturns the profiles that match the specified query.- Specified by:
getProfilesByQueryin interfaceProfileService- Parameters:
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)- Returns:
- the list of profiles found, or null if none match the query
- Throws:
ProfileException
-
getProfilesByIds
public List<Profile> getProfilesByIds(List<String> profileIds, String sortBy, SortOrder sortOrder, String... attributesToReturn) throws ProfileException Description copied from interface:ProfileServiceReturns a list of profiles for the specified list of IDs.- Specified by:
getProfilesByIdsin interfaceProfileService- Parameters:
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)- Returns:
- the list of profiles (can be smaller than the list of ids if some where not found)
- Throws:
ProfileException
-
getProfileRange
public List<Profile> getProfileRange(String tenantName, String sortBy, SortOrder sortOrder, Integer start, Integer count, String... attributesToReturn) throws ProfileException Description copied from interface:ProfileServiceReturns a range of profiles for the specified tenant.- Specified by:
getProfileRangein interfaceProfileService- Parameters:
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)- Returns:
- the list of profiles
- Throws:
ProfileException
-
getProfilesByRole
public List<Profile> getProfilesByRole(String tenantName, String role, String sortBy, SortOrder sortOrder, String... attributesToReturn) throws ProfileException Description copied from interface:ProfileServiceReturns a list of profiles for a specific role and tenant.- Specified by:
getProfilesByRolein interfaceProfileService- Parameters:
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)- Returns:
- the list of profiles
- Throws:
ProfileException
-
getProfilesByExistingAttribute
public List<Profile> getProfilesByExistingAttribute(String tenantName, String attributeName, String sortBy, SortOrder sortOrder, String... attributesToReturn) throws ProfileException Description copied from interface:ProfileServiceReturns the list of profiles that have the given attribute, with any value- Specified by:
getProfilesByExistingAttributein interfaceProfileService- Parameters:
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)- Returns:
- the list of profiles
- Throws:
ProfileException
-
getProfilesByAttributeValue
public List<Profile> getProfilesByAttributeValue(String tenantName, String attributeName, String attributeValue, String sortBy, SortOrder sortOrder, String... attributesToReturn) throws ProfileException Description copied from interface:ProfileServiceReturns the list of profiles that have the given attribute with the given value.- Specified by:
getProfilesByAttributeValuein interfaceProfileService- Parameters:
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)- Returns:
- the list of profiles
- Throws:
ProfileException
-
resetPassword
public Profile resetPassword(String profileId, String resetPasswordUrl, String... attributesToReturn) throws ProfileException Description copied from interface:ProfileServiceSends an email to the profile's user to indicate that the password needs to be reset.- Specified by:
resetPasswordin interfaceProfileService- Parameters:
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)- Returns:
- the updated profile
- Throws:
ProfileException
-
changePassword
public Profile changePassword(String resetTokenId, String newPassword, String... attributesToReturn) throws ProfileException Description copied from interface:ProfileServiceChanges a profile's password, after a reset request has been sent.- Specified by:
changePasswordin interfaceProfileService- Parameters:
resetTokenId- the reset token IDnewPassword- the new passwordattributesToReturn- the names of the attributes to return with the profile (null to return all attributes)- Returns:
- the updated profile
- Throws:
ProfileException
-
createVerificationToken
Description copied from interface:ProfileServiceCreates a token that can be sent to the user in an email as a link. After the user clicks the link, the token then can be passed toProfileService.verifyProfile(String, String...)orProfileService.changePassword(String, String, String...)to verify that the user agrees.- Specified by:
createVerificationTokenin interfaceProfileService- Parameters:
profileId- the profile ID of the user that needs to be contacted- Returns:
- the created token
- Throws:
ProfileException
-
getVerificationToken
Description copied from interface:ProfileServiceReturns the verification token that corresponds to the given ID.- Specified by:
getVerificationTokenin interfaceProfileService- Parameters:
tokenId- the token ID- Returns:
- the verification token, or null if not found
- Throws:
ProfileException
-
deleteVerificationToken
Description copied from interface:ProfileServiceDeletes a verification token when it's not needed anymore (not necessary to call ifProfileService.verifyProfile(String, String...)orProfileService.changePassword(String, String, String...), since they already delete the token.- Specified by:
deleteVerificationTokenin interfaceProfileService- Parameters:
tokenId- the ID of the token to delete- Throws:
ProfileException
-
addProfileAttachment
public ProfileAttachment addProfileAttachment(String profileId, String attachmentName, InputStream file) throws ProfileException Description copied from interface:ProfileServiceSaves a Profile Attachment- Specified by:
addProfileAttachmentin interfaceProfileService- Parameters:
profileId- Id of the profile owner of the attachment.attachmentName- File name of the Attachment;file- Actual File to be Attach.- Returns:
- A Profile Attachment Contains all the information of the Actual Attachment (including the id);
- Throws:
ProfileException- If attachment can not be saved;
-
getProfileAttachmentInformation
public ProfileAttachment getProfileAttachmentInformation(String profileId, String attachmentId) throws ProfileException Description copied from interface:ProfileServiceGets Profile attachment Information.- Specified by:
getProfileAttachmentInformationin interfaceProfileService- Parameters:
profileId- Profile owner of the Attachment.attachmentId- Attachment Id.- Returns:
- Null if Attachment Id does not exist or does not belong to the user.
- Throws:
ProfileException- If Attachment cannot be found.
-
getProfileAttachment
public InputStream getProfileAttachment(String attachmentId, String profileId) throws ProfileException Description copied from interface:ProfileServiceGiven the Attachment Id and the Profile Id, gets the Actual Attachment.- Specified by:
getProfileAttachmentin interfaceProfileService- Parameters:
attachmentId- Attachment Id to get.profileId- Profile Owner of the Attachment.- Returns:
- Null If Attachment Id does no exist or does not belong to the given profile. InputStream of the actual File.
- Throws:
ProfileException- If unable to get the Attachment.
-
getProfileAttachments
Description copied from interface:ProfileServiceList all Attachments for the given profile.- Specified by:
getProfileAttachmentsin interfaceProfileService- Parameters:
profileId- Profile to get all Attachments- Returns:
- The List of attachments that the profile has ,never null.
- Throws:
ProfileException- If unable to get Profile attachments.
-
checkIfManageProfilesIsAllowed
-
getNonNullProfile
protected Profile getNonNullProfile(String id, String... attributesToReturn) throws ProfileException - Throws:
ProfileException
-
getTenant
- Throws:
ProfileException
-
updateProfile
protected Profile updateProfile(String profileId, ProfileServiceImpl.UpdateCallback callback, String... attributesToReturn) throws ProfileException - Throws:
ProfileException
-
isAttributeActionAllowed
-
filterAttributes
-
filterNonReadableAttributes
- Throws:
ProfileException
-
filterNonReadableAttributes
- Throws:
ProfileException
-
filterNonReadableAttributes
- Throws:
ProfileException
-
filterNonReadableAttributes
protected void filterNonReadableAttributes(Tenant tenant, Iterable<Profile> profiles) throws ProfileException - Throws:
ProfileException
-
rejectAttributesIfActionNotAllowed
protected void rejectAttributesIfActionNotAllowed(String tenantName, Collection<String> attributeNames, AttributeAction action) throws ProfileException - Throws:
ProfileException
-
rejectAttributesIfActionNotAllowed
protected void rejectAttributesIfActionNotAllowed(Tenant tenant, Collection<String> attributeNames, AttributeAction action) throws ProfileException - Throws:
ProfileException
-
filterAttributeIfReadNotAllowed
protected void filterAttributeIfReadNotAllowed(Tenant tenant, Iterator<String> attributeNamesIter, List<AttributeDefinition> attributeDefinitions) throws org.craftercms.commons.security.exception.PermissionException, AttributeNotDefinedException - Throws:
org.craftercms.commons.security.exception.PermissionExceptionAttributeNotDefinedException
-
rejectAttributeIfActionNotAllowed
protected void rejectAttributeIfActionNotAllowed(Tenant tenant, String attributeName, AttributeAction action, List<AttributeDefinition> attributeDefinitions) throws org.craftercms.commons.security.exception.PermissionException, AttributeNotDefinedException - Throws:
org.craftercms.commons.security.exception.PermissionExceptionAttributeNotDefinedException
-
getFinalQuery
- Throws:
ProfileException
-
validateQuery
- Throws:
ProfileException
-
setValidAttachmentMimeTypes
-
findAttributeDefinition
protected AttributeDefinition findAttributeDefinition(List<AttributeDefinition> attributeDefinitions, String name)
-