Search in sources :

Example 1 with EmailAddressValidator

use of com.liferay.portal.security.auth.EmailAddressValidator in project liferay-ide by liferay.

the class UserLocalServiceImpl method validateEmailAddress.

protected void validateEmailAddress(long companyId, String emailAddress) throws PortalException, SystemException {
    if (Validator.isNull(emailAddress) && !PropsValues.USERS_EMAIL_ADDRESS_REQUIRED) {
        return;
    }
    EmailAddressValidator emailAddressValidator = EmailAddressValidatorFactory.getInstance();
    if (!emailAddressValidator.validate(companyId, emailAddress)) {
        throw new UserEmailAddressException();
    }
    String pop3User = PrefsPropsUtil.getString(PropsKeys.MAIL_SESSION_MAIL_POP3_USER, PropsValues.MAIL_SESSION_MAIL_POP3_USER);
    if (StringUtil.equalsIgnoreCase(emailAddress, pop3User)) {
        throw new ReservedUserEmailAddressException();
    }
    String[] reservedEmailAddresses = PrefsPropsUtil.getStringArray(companyId, PropsKeys.ADMIN_RESERVED_EMAIL_ADDRESSES, StringPool.NEW_LINE, PropsValues.ADMIN_RESERVED_EMAIL_ADDRESSES);
    for (String reservedEmailAddress : reservedEmailAddresses) {
        if (StringUtil.equalsIgnoreCase(emailAddress, reservedEmailAddress)) {
            throw new ReservedUserEmailAddressException();
        }
    }
}
Also used : UserEmailAddressException(com.liferay.portal.UserEmailAddressException) ReservedUserEmailAddressException(com.liferay.portal.ReservedUserEmailAddressException) DuplicateUserEmailAddressException(com.liferay.portal.DuplicateUserEmailAddressException) EmailAddressValidator(com.liferay.portal.security.auth.EmailAddressValidator) ReservedUserEmailAddressException(com.liferay.portal.ReservedUserEmailAddressException)

Aggregations

DuplicateUserEmailAddressException (com.liferay.portal.DuplicateUserEmailAddressException)1 ReservedUserEmailAddressException (com.liferay.portal.ReservedUserEmailAddressException)1 UserEmailAddressException (com.liferay.portal.UserEmailAddressException)1 EmailAddressValidator (com.liferay.portal.security.auth.EmailAddressValidator)1