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 AuthenticationService
protected org.craftercms.commons.entitlements.validator.EntitlementValidator
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
protected String
protected String
protected String
protected ProfileRepository
static final String
static final String
static final Pattern
static final Pattern
protected String
protected String
protected String
protected org.craftercms.commons.security.permissions.PermissionEvaluator<AccessToken,
String> protected TenantService
protected VerificationService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddProfileAttachment
(String profileId, String attachmentName, InputStream file) addRoles
(String profileId, Collection<String> roles, String... attributesToReturn) changePassword
(String resetTokenId, String newPassword, String... attributesToReturn) protected void
checkIfManageProfilesIsAllowed
(String tenantName) protected void
cleanseAttributes
(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) createVerificationToken
(String profileId) void
deleteProfile
(String profileId) void
deleteVerificationToken
(String tokenId) disableProfile
(String profileId, String... attributesToReturn) enableProfile
(String profileId, String... attributesToReturn) protected Object
escapeValue
(Object value, String type) protected void
filterAttributeIfReadNotAllowed
(Tenant tenant, Iterator<String> attributeNamesIter, List<AttributeDefinition> attributeDefinitions) protected Profile
filterAttributes
(Profile profile, String[] attributesToReturn) protected void
filterNonReadableAttributes
(Iterable<Profile> profiles) protected void
filterNonReadableAttributes
(Profile profile) protected void
filterNonReadableAttributes
(Tenant tenant, Iterable<Profile> profiles) protected void
filterNonReadableAttributes
(Tenant tenant, Profile profile) protected AttributeDefinition
findAttributeDefinition
(List<AttributeDefinition> attributeDefinitions, String name) getAttributes
(String profileId, String... attributesToReturn) protected String
getFinalQuery
(Tenant tenant, String query) protected Profile
getNonNullProfile
(String id, String... attributesToReturn) getProfile
(String profileId, String... attributesToReturn) getProfileAttachment
(String attachmentId, String profileId) getProfileAttachmentInformation
(String profileId, String attachmentId) getProfileAttachments
(String profileId) getProfileByQuery
(String tenantName, String query, String... attributesToReturn) getProfileByTicket
(String ticketId, String... attributesToReturn) getProfileByUsername
(String tenantName, String username, String... attributesToReturn) long
getProfileCount
(String tenantName) long
getProfileCountByQuery
(String tenantName, String query) getProfileRange
(String tenantName, String sortBy, SortOrder sortOrder, Integer start, Integer count, String... attributesToReturn) getProfilesByAttributeValue
(String tenantName, String attributeName, String attributeValue, String sortBy, SortOrder sortOrder, String... attributesToReturn) getProfilesByExistingAttribute
(String tenantName, String attributeName, String sortBy, SortOrder sortOrder, String... attributesToReturn) getProfilesByIds
(List<String> profileIds, String sortBy, SortOrder sortOrder, String... attributesToReturn) getProfilesByQuery
(String tenantName, String query, String sortBy, SortOrder sortOrder, Integer start, Integer count, String... attributesToReturn) getProfilesByRole
(String tenantName, String role, String sortBy, SortOrder sortOrder, String... attributesToReturn) protected Tenant
getVerificationToken
(String tokenId) protected boolean
isAttributeActionAllowed
(AttributeDefinition definition, AttributeAction action) protected void
rejectAttributeIfActionNotAllowed
(Tenant tenant, String attributeName, AttributeAction action, List<AttributeDefinition> attributeDefinitions) protected void
rejectAttributesIfActionNotAllowed
(String tenantName, Collection<String> attributeNames, AttributeAction action) protected void
rejectAttributesIfActionNotAllowed
(Tenant tenant, Collection<String> attributeNames, AttributeAction action) removeAttributes
(String profileId, Collection<String> attributeNames, String... attributesToReturn) removeRoles
(String profileId, Collection<String> roles, String... attributesToReturn) resetPassword
(String profileId, String resetPasswordUrl, String... attributesToReturn) void
setAttributePermissionEvaluator
(org.craftercms.commons.security.permissions.PermissionEvaluator<AccessToken, AttributeDefinition> attributePermissionEvaluator) void
setAuthenticationService
(AuthenticationService authenticationService) void
setEntitlementValidator
(org.craftercms.commons.entitlements.validator.EntitlementValidator entitlementValidator) setFailedLoginAttempts
(String profileId, int failedAttempts, String... attributesToReturn) setLastFailedLogin
(String profileId, Date lastFailedLogin, String... attributesToReturn) void
setNewProfileEmailFromAddress
(String newProfileEmailFromAddress) void
setNewProfileEmailSubject
(String newProfileEmailSubject) void
setNewProfileEmailTemplateName
(String newProfileEmailTemplateName) void
setProfileRepository
(ProfileRepository profileRepository) void
setResetPwdEmailFromAddress
(String resetPwdEmailFromAddress) void
setResetPwdEmailSubject
(String resetPwdEmailSubject) void
setResetPwdEmailTemplateName
(String resetPwdEmailTemplateName) void
setTenantPermissionEvaluator
(org.craftercms.commons.security.permissions.PermissionEvaluator<AccessToken, String> tenantPermissionEvaluator) void
setTenantService
(TenantService tenantService) void
setValidAttachmentMimeTypes
(String validAttachmentMimeTypes) void
setVerificationService
(VerificationService verificationService) updateProfile
(String profileId, String username, String password, String email, Boolean enabled, Set<String> roles, Map<String, Object> attributes, String... attributesToReturn) protected Profile
updateProfile
(String profileId, ProfileServiceImpl.UpdateCallback callback, String... attributesToReturn) protected void
validateQuery
(Tenant tenant, String query) verifyProfile
(String verificationTokenId, String... attributesToReturn)
-
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()
-
-
Method Details
-
setTenantPermissionEvaluator
public void setTenantPermissionEvaluator(org.craftercms.commons.security.permissions.PermissionEvaluator<AccessToken, String> tenantPermissionEvaluator) -
setAttributePermissionEvaluator
public void setAttributePermissionEvaluator(org.craftercms.commons.security.permissions.PermissionEvaluator<AccessToken, AttributeDefinition> attributePermissionEvaluator) -
setProfileRepository
-
setTenantService
-
setAuthenticationService
-
setVerificationService
-
setNewProfileEmailFromAddress
-
setNewProfileEmailSubject
-
setNewProfileEmailTemplateName
-
setResetPwdEmailFromAddress
-
setResetPwdEmailSubject
-
setResetPwdEmailTemplateName
-
setEntitlementValidator
public void setEntitlementValidator(org.craftercms.commons.entitlements.validator.EntitlementValidator entitlementValidator) -
createProfile
public Profile createProfile(String tenantName, String username, String password, String email, boolean enabled, Set<String> roles, Map<String, Object> attributes, String verificationUrl) throws ProfileException- Specified by:
createProfile
in interfaceProfileService
- 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 ProfileException- Specified by:
updateProfile
in interfaceProfileService
- Throws:
ProfileException
-
cleanseAttributes
-
escapeValue
-
verifyProfile
public Profile verifyProfile(String verificationTokenId, String... attributesToReturn) throws ProfileException - Specified by:
verifyProfile
in interfaceProfileService
- Throws:
ProfileException
-
enableProfile
public Profile enableProfile(String profileId, String... attributesToReturn) throws ProfileException - Specified by:
enableProfile
in interfaceProfileService
- Throws:
ProfileException
-
setLastFailedLogin
public Profile setLastFailedLogin(String profileId, Date lastFailedLogin, String... attributesToReturn) throws ProfileException - Specified by:
setLastFailedLogin
in interfaceProfileService
- Throws:
ProfileException
-
setFailedLoginAttempts
public Profile setFailedLoginAttempts(String profileId, int failedAttempts, String... attributesToReturn) throws ProfileException - Specified by:
setFailedLoginAttempts
in interfaceProfileService
- Throws:
ProfileException
-
disableProfile
public Profile disableProfile(String profileId, String... attributesToReturn) throws ProfileException - Specified by:
disableProfile
in interfaceProfileService
- Throws:
ProfileException
-
addRoles
public Profile addRoles(String profileId, Collection<String> roles, String... attributesToReturn) throws ProfileException - Specified by:
addRoles
in interfaceProfileService
- Throws:
ProfileException
-
removeRoles
public Profile removeRoles(String profileId, Collection<String> roles, String... attributesToReturn) throws ProfileException - Specified by:
removeRoles
in interfaceProfileService
- Throws:
ProfileException
-
getAttributes
public Map<String,Object> getAttributes(String profileId, String... attributesToReturn) throws ProfileException - Specified by:
getAttributes
in interfaceProfileService
- Throws:
ProfileException
-
updateAttributes
public Profile updateAttributes(String profileId, Map<String, Object> attributes, String... attributesToReturn) throws ProfileException- Specified by:
updateAttributes
in interfaceProfileService
- Throws:
ProfileException
-
removeAttributes
public Profile removeAttributes(String profileId, Collection<String> attributeNames, String... attributesToReturn) throws ProfileException - Specified by:
removeAttributes
in interfaceProfileService
- Throws:
ProfileException
-
deleteProfile
- Specified by:
deleteProfile
in interfaceProfileService
- Throws:
ProfileException
-
getProfileByQuery
public Profile getProfileByQuery(String tenantName, String query, String... attributesToReturn) throws ProfileException - Specified by:
getProfileByQuery
in interfaceProfileService
- Throws:
ProfileException
-
getProfile
- Specified by:
getProfile
in interfaceProfileService
- Throws:
ProfileException
-
getProfileByUsername
public Profile getProfileByUsername(String tenantName, String username, String... attributesToReturn) throws ProfileException - Specified by:
getProfileByUsername
in interfaceProfileService
- Throws:
ProfileException
-
getProfileByTicket
public Profile getProfileByTicket(String ticketId, String... attributesToReturn) throws ProfileException - Specified by:
getProfileByTicket
in interfaceProfileService
- Throws:
ProfileException
-
getProfileCount
- Specified by:
getProfileCount
in interfaceProfileService
- Throws:
ProfileException
-
getProfileCountByQuery
- Specified by:
getProfileCountByQuery
in interfaceProfileService
- Throws:
ProfileException
-
getProfilesByQuery
public List<Profile> getProfilesByQuery(String tenantName, String query, String sortBy, SortOrder sortOrder, Integer start, Integer count, String... attributesToReturn) throws ProfileException - Specified by:
getProfilesByQuery
in interfaceProfileService
- Throws:
ProfileException
-
getProfilesByIds
public List<Profile> getProfilesByIds(List<String> profileIds, String sortBy, SortOrder sortOrder, String... attributesToReturn) throws ProfileException - Specified by:
getProfilesByIds
in interfaceProfileService
- Throws:
ProfileException
-
getProfileRange
public List<Profile> getProfileRange(String tenantName, String sortBy, SortOrder sortOrder, Integer start, Integer count, String... attributesToReturn) throws ProfileException - Specified by:
getProfileRange
in interfaceProfileService
- Throws:
ProfileException
-
getProfilesByRole
public List<Profile> getProfilesByRole(String tenantName, String role, String sortBy, SortOrder sortOrder, String... attributesToReturn) throws ProfileException - Specified by:
getProfilesByRole
in interfaceProfileService
- Throws:
ProfileException
-
getProfilesByExistingAttribute
public List<Profile> getProfilesByExistingAttribute(String tenantName, String attributeName, String sortBy, SortOrder sortOrder, String... attributesToReturn) throws ProfileException - Specified by:
getProfilesByExistingAttribute
in interfaceProfileService
- Throws:
ProfileException
-
getProfilesByAttributeValue
public List<Profile> getProfilesByAttributeValue(String tenantName, String attributeName, String attributeValue, String sortBy, SortOrder sortOrder, String... attributesToReturn) throws ProfileException - Specified by:
getProfilesByAttributeValue
in interfaceProfileService
- Throws:
ProfileException
-
resetPassword
public Profile resetPassword(String profileId, String resetPasswordUrl, String... attributesToReturn) throws ProfileException - Specified by:
resetPassword
in interfaceProfileService
- Throws:
ProfileException
-
changePassword
public Profile changePassword(String resetTokenId, String newPassword, String... attributesToReturn) throws ProfileException - Specified by:
changePassword
in interfaceProfileService
- Throws:
ProfileException
-
createVerificationToken
- Specified by:
createVerificationToken
in interfaceProfileService
- Throws:
ProfileException
-
getVerificationToken
- Specified by:
getVerificationToken
in interfaceProfileService
- Throws:
ProfileException
-
deleteVerificationToken
- Specified by:
deleteVerificationToken
in interfaceProfileService
- Throws:
ProfileException
-
addProfileAttachment
public ProfileAttachment addProfileAttachment(String profileId, String attachmentName, InputStream file) throws ProfileException - Specified by:
addProfileAttachment
in interfaceProfileService
- Throws:
ProfileException
-
getProfileAttachmentInformation
public ProfileAttachment getProfileAttachmentInformation(String profileId, String attachmentId) throws ProfileException - Specified by:
getProfileAttachmentInformation
in interfaceProfileService
- Throws:
ProfileException
-
getProfileAttachment
public InputStream getProfileAttachment(String attachmentId, String profileId) throws ProfileException - Specified by:
getProfileAttachment
in interfaceProfileService
- Throws:
ProfileException
-
getProfileAttachments
- Specified by:
getProfileAttachments
in interfaceProfileService
- Throws:
ProfileException
-
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.PermissionException
AttributeNotDefinedException
-
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.PermissionException
AttributeNotDefinedException
-
getFinalQuery
- Throws:
ProfileException
-
validateQuery
- Throws:
ProfileException
-
setValidAttachmentMimeTypes
-
findAttributeDefinition
protected AttributeDefinition findAttributeDefinition(List<AttributeDefinition> attributeDefinitions, String name)
-