Example usage for com.liferay.portal.security.auth EmailAddressGeneratorFactory getInstance

List of usage examples for com.liferay.portal.security.auth EmailAddressGeneratorFactory getInstance

Introduction

In this page you can find the example usage for com.liferay.portal.security.auth EmailAddressGeneratorFactory getInstance.

Prototype

public static EmailAddressGenerator getInstance() 

Source Link

Usage

From source file:com.liferay.mail.messaging.MailMessageListener.java

License:Open Source License

protected InternetAddress filterInternetAddress(InternetAddress internetAddress) {

    EmailAddressGenerator emailAddressGenerator = EmailAddressGeneratorFactory.getInstance();

    if (emailAddressGenerator.isFake(internetAddress.getAddress())) {
        return null;
    }//from   w  w w  . j  a v  a  2 s.c o m

    String address = internetAddress.toString();

    for (char c : address.toCharArray()) {
        if ((c == CharPool.NEW_LINE) || (c == CharPool.RETURN)) {
            if (_log.isWarnEnabled()) {
                StringBundler sb = new StringBundler(4);

                sb.append("Email address ");
                sb.append(address);
                sb.append(" contains line break characters and will be ");
                sb.append("excluded from the email");

                _log.warn(sb.toString());
            }

            return null;
        }
    }

    return internetAddress;
}