Class VerificationServiceImpl
- java.lang.Object
-
- org.craftercms.profile.services.impl.VerificationServiceImpl
-
- All Implemented Interfaces:
VerificationService
public class VerificationServiceImpl extends Object implements VerificationService
Default implementation ofVerificationService
.- Author:
- avasquez
-
-
Field Summary
Fields Modifier and Type Field Description protected org.craftercms.commons.mail.EmailFactory
emailFactory
static String
ERROR_KEY_CREATE_TOKEN_ERROR
static String
ERROR_KEY_DELETE_TOKEN_ERROR
static String
ERROR_KEY_EMAIL_ERROR
static String
ERROR_KEY_GET_TOKEN_ERROR
static String
LOG_KEY_EMAIL_SENT
static String
LOG_KEY_TOKEN_CREATED
static String
LOG_KEY_TOKEN_DELETED
protected org.craftercms.commons.security.permissions.PermissionEvaluator<AccessToken,String>
permissionEvaluator
protected int
tokenMaxAge
protected VerificationTokenRepository
tokenRepository
static String
VERIFICATION_LINK_TEMPLATE_ARG
-
Constructor Summary
Constructors Constructor Description VerificationServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkIfManageProfilesIsAllowed(String tenantName)
VerificationToken
createToken(Profile profile)
Creates a new verification token.protected String
createVerificationUrl(String verificationBaseUrl, String tokenId)
void
deleteToken(String tokenId)
Deletes the token corresponding the specified ID.VerificationToken
getToken(String tokenId)
Returns the token that corresponds to the specified IDvoid
sendEmail(VerificationToken token, Profile profile, String verificationBaseUrl, String from, String subject, String templateName)
Creates a verification token and sends the user an email with the token for verification.void
setEmailFactory(org.craftercms.commons.mail.EmailFactory emailFactory)
void
setPermissionEvaluator(org.craftercms.commons.security.permissions.PermissionEvaluator<AccessToken,String> permissionEvaluator)
void
setTokenMaxAge(int tokenMaxAge)
void
setTokenRepository(VerificationTokenRepository tokenRepository)
-
-
-
Field Detail
-
VERIFICATION_LINK_TEMPLATE_ARG
public static final String VERIFICATION_LINK_TEMPLATE_ARG
- See Also:
- Constant Field Values
-
LOG_KEY_TOKEN_CREATED
public static final String LOG_KEY_TOKEN_CREATED
- See Also:
- Constant Field Values
-
LOG_KEY_EMAIL_SENT
public static final String LOG_KEY_EMAIL_SENT
- See Also:
- Constant Field Values
-
LOG_KEY_TOKEN_DELETED
public static final String LOG_KEY_TOKEN_DELETED
- See Also:
- Constant Field Values
-
ERROR_KEY_CREATE_TOKEN_ERROR
public static final String ERROR_KEY_CREATE_TOKEN_ERROR
- See Also:
- Constant Field Values
-
ERROR_KEY_GET_TOKEN_ERROR
public static final String ERROR_KEY_GET_TOKEN_ERROR
- See Also:
- Constant Field Values
-
ERROR_KEY_DELETE_TOKEN_ERROR
public static final String ERROR_KEY_DELETE_TOKEN_ERROR
- See Also:
- Constant Field Values
-
ERROR_KEY_EMAIL_ERROR
public static final String ERROR_KEY_EMAIL_ERROR
- See Also:
- Constant Field Values
-
permissionEvaluator
protected org.craftercms.commons.security.permissions.PermissionEvaluator<AccessToken,String> permissionEvaluator
-
tokenRepository
protected VerificationTokenRepository tokenRepository
-
emailFactory
protected org.craftercms.commons.mail.EmailFactory emailFactory
-
tokenMaxAge
protected int tokenMaxAge
-
-
Method Detail
-
setPermissionEvaluator
public void setPermissionEvaluator(org.craftercms.commons.security.permissions.PermissionEvaluator<AccessToken,String> permissionEvaluator)
-
setTokenRepository
public void setTokenRepository(VerificationTokenRepository tokenRepository)
-
setEmailFactory
public void setEmailFactory(org.craftercms.commons.mail.EmailFactory emailFactory)
-
setTokenMaxAge
public void setTokenMaxAge(int tokenMaxAge)
-
createToken
public VerificationToken createToken(Profile profile) throws ProfileException
Description copied from interface:VerificationService
Creates a new verification token. The token can be later transmitted to the client through email, for example.- Specified by:
createToken
in interfaceVerificationService
- Parameters:
profile
- the profile to create the token for- Throws:
ProfileException
-
sendEmail
@Async public void sendEmail(VerificationToken token, Profile profile, String verificationBaseUrl, String from, String subject, String templateName) throws ProfileException
Description copied from interface:VerificationService
Creates a verification token and sends the user an email with the token for verification.- Specified by:
sendEmail
in interfaceVerificationService
- Parameters:
token
- the verification token to sendprofile
- the profile of the userverificationBaseUrl
- the URL the user should click to verify the new profilefrom
- the from addresssubject
- the subject of the emailtemplateName
- the template name of the email- Throws:
ProfileException
-
getToken
public VerificationToken getToken(String tokenId) throws ProfileException
Description copied from interface:VerificationService
Returns the token that corresponds to the specified ID- Specified by:
getToken
in interfaceVerificationService
- Parameters:
tokenId
- the token ID, sent in the verification email- Returns:
- the verification token object associated to the ID
- Throws:
ProfileException
-
deleteToken
public void deleteToken(String tokenId) throws ProfileException
Description copied from interface:VerificationService
Deletes the token corresponding the specified ID.- Specified by:
deleteToken
in interfaceVerificationService
- Parameters:
tokenId
- the ID of the token to delete- Throws:
ProfileException
-
createVerificationUrl
protected String createVerificationUrl(String verificationBaseUrl, String tokenId)
-
checkIfManageProfilesIsAllowed
protected void checkIfManageProfilesIsAllowed(String tenantName)
-
-