com.jp.protection.priv.pro.integration
Class EmailLicensingFacadeDelivery

java.lang.Object
  extended by com.jp.protection.priv.pro.integration.EmailLicensingFacadeDelivery
All Implemented Interfaces:
LicensingFacadeDelivery

public class EmailLicensingFacadeDelivery
extends java.lang.Object
implements LicensingFacadeDelivery

E-mail implementation of the LicensingFacadeDelivery interface that delivers specified license by sending it as an e-mail message attachment


Nested Class Summary
static class EmailLicensingFacadeDelivery.ByteArrayDataSource
           
 
Field Summary
static java.lang.String ADDRESS_DELIMITER
           
protected  boolean fAllowFreeEmailAddresses
           
protected  LocalLicensingFacade fLocalLicensingFacade
           
static java.lang.String MAIL_PROPERTY_MAIL_FROM
           
static java.lang.String MAIL_PROPERTY_MAIL_USER
           
static java.lang.String MAIL_PROPERTY_SMTP_AUTH
           
static java.lang.String MAIL_PROPERTY_SMTP_HOST
           
static java.lang.String MAIL_PROPERTY_SMTP_PORT
           
(package private) static java.util.ResourceBundle res
           
 
Constructor Summary
EmailLicensingFacadeDelivery()
           
 
Method Summary
 LicensingFacadeResult checkEmailAddress(dev.entities.Customer aCustomer)
           
 LicensingFacadeResult deliver(LicensingFacadeSession aSession, License aLicense, dev.entities.Customer aCustomer)
          Delivers specified license by sending it as an e-mail message attachment
protected  void error(java.lang.Throwable ex)
           
protected  javax.mail.internet.InternetAddress[] getInternetAddresses(java.lang.String[] anInternetAddresses)
           
protected  com.jp.protection.utils.ProtectionLogger getLogger()
           
protected  javax.mail.Session getMailSession()
           
 java.lang.String getSentMessage(dev.entities.Customer aCustomer)
           
 java.lang.String getUnableToSendMessage(dev.entities.Customer aCustomer)
           
 void init(LocalLicensingFacade aLocalLicensingFacade)
          Initializes delivery object.
 boolean isAllowFreeEmailAddresses()
          Tests that usage of free e-mail addresses is allowed for licenses delivery.
protected  java.lang.String processTemplate(LicensingFacadeSession aSession, License aLicense, dev.entities.Customer aCustomer, java.lang.String aTemplate)
           
 boolean sendLicense(LicensingFacadeSession aSession, License aLicense, dev.entities.Customer aCustomer)
          Sends license to a customer to address specified in customer's information.
 boolean sendLicense(LicensingFacadeSession aSession, License aLicense, dev.entities.Customer aCustomer, java.lang.String aSubject, java.lang.String aText)
          Sends license to a customer to address specified in customer's information.
 boolean sendLicense(LicensingFacadeSession aSession, License aLicense, dev.entities.Customer aCustomer, java.lang.String aCC, java.lang.String aBCC, java.lang.String aSubject, java.lang.String aText)
          Sends license to a customer to address specified in customer's information.
 boolean sendLicense(LicensingFacadeSession aSession, License aLicense, dev.entities.Customer aCustomer, java.lang.String aCC, java.lang.String aBCC, java.lang.String aSubject, java.lang.String aText, java.lang.String aLicenseFileName)
          Sends license to a customer to address specified in customer's information.
 boolean sendMessage(java.lang.String[] aTo, java.lang.String[] aCc, java.lang.String[] aBcc, java.lang.String aFrom, java.lang.String aReplyTo, java.lang.String aSubject, java.lang.String aText, byte[] aLicenseBytes, java.lang.String aLicenseFileName)
           
 void setAllowFreeEmailAddresses(boolean aAllowFreeEmailAddresses)
          Specifies that usage of free e-mail addresses is allowed for licenses delivery.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

res

static java.util.ResourceBundle res

ADDRESS_DELIMITER

public static final java.lang.String ADDRESS_DELIMITER
See Also:
Constant Field Values

fAllowFreeEmailAddresses

protected boolean fAllowFreeEmailAddresses

fLocalLicensingFacade

protected LocalLicensingFacade fLocalLicensingFacade

MAIL_PROPERTY_SMTP_HOST

public static final java.lang.String MAIL_PROPERTY_SMTP_HOST
See Also:
Constant Field Values

MAIL_PROPERTY_MAIL_FROM

public static final java.lang.String MAIL_PROPERTY_MAIL_FROM
See Also:
Constant Field Values

MAIL_PROPERTY_MAIL_USER

public static final java.lang.String MAIL_PROPERTY_MAIL_USER
See Also:
Constant Field Values

MAIL_PROPERTY_SMTP_AUTH

public static final java.lang.String MAIL_PROPERTY_SMTP_AUTH
See Also:
Constant Field Values

MAIL_PROPERTY_SMTP_PORT

public static final java.lang.String MAIL_PROPERTY_SMTP_PORT
See Also:
Constant Field Values
Constructor Detail

EmailLicensingFacadeDelivery

public EmailLicensingFacadeDelivery()
Method Detail

deliver

public LicensingFacadeResult deliver(LicensingFacadeSession aSession,
                                     License aLicense,
                                     dev.entities.Customer aCustomer)
Delivers specified license by sending it as an e-mail message attachment

Specified by:
deliver in interface LicensingFacadeDelivery
Parameters:
aSession - a session object
aLicense - a license to be delivered
aCustomer - Customer customer information
Returns:
LicensingFacadeResult LicensingFacadeResult instance

isAllowFreeEmailAddresses

public boolean isAllowFreeEmailAddresses()
Tests that usage of free e-mail addresses is allowed for licenses delivery.

Returns:
true if usage of free e-mail addresses is allowed for licenses delivery; false otherwise.

setAllowFreeEmailAddresses

public void setAllowFreeEmailAddresses(boolean aAllowFreeEmailAddresses)
Specifies that usage of free e-mail addresses is allowed for licenses delivery.

Parameters:
aAllowFreeEmailAddresses - true if usage of free e-mail addresses is allowed for licenses delivery; false otherwise.

checkEmailAddress

public LicensingFacadeResult checkEmailAddress(dev.entities.Customer aCustomer)

error

protected void error(java.lang.Throwable ex)

getSentMessage

public java.lang.String getSentMessage(dev.entities.Customer aCustomer)

getUnableToSendMessage

public java.lang.String getUnableToSendMessage(dev.entities.Customer aCustomer)

sendLicense

public boolean sendLicense(LicensingFacadeSession aSession,
                           License aLicense,
                           dev.entities.Customer aCustomer)
                    throws javax.mail.MessagingException
Sends license to a customer to address specified in customer's information. It uses licensing facade configuration to obtain e-mail server properties and to get e-mail message attributes like CC, BCC, From, ReplyTo. It gets e-mail message's Subject and Text by expanding corresponding templates specified in licensing facade configuration.

Parameters:
aSession - a session object
aLicense - license to send
aCustomer - customer information
Returns:
true if license was sent; false otherwise
Throws:
javax.mail.MessagingException - in case of any error during sending

sendLicense

public boolean sendLicense(LicensingFacadeSession aSession,
                           License aLicense,
                           dev.entities.Customer aCustomer,
                           java.lang.String aSubject,
                           java.lang.String aText)
                    throws javax.mail.MessagingException
Sends license to a customer to address specified in customer's information. It uses licensing facade configuration to obtain e-mail server properties and to get e-mail message attributes like CC, BCC, From, ReplyTo. It gets e-mail message's Subject and Text by expanding corresponding templates specified as parameters.

Parameters:
aSession - a session object
aLicense - license to send
aCustomer - customer information
aSubject - e-mail message subject template
aText - e-mail message text template
Returns:
true if license was sent; false otherwise
Throws:
javax.mail.MessagingException - in case of any error during sending

sendLicense

public boolean sendLicense(LicensingFacadeSession aSession,
                           License aLicense,
                           dev.entities.Customer aCustomer,
                           java.lang.String aCC,
                           java.lang.String aBCC,
                           java.lang.String aSubject,
                           java.lang.String aText,
                           java.lang.String aLicenseFileName)
                    throws javax.mail.MessagingException
Sends license to a customer to address specified in customer's information. It uses licensing facade configuration to obtain e-mail server properties and to get e-mail message attributes From, ReplyTo. It gets e-mail message's Subject and Text by expanding corresponding templates specified as parameters.

Parameters:
aSession - a session object
aLicense - license to send
aCustomer - customer information
aSubject - e-mail message subject template
aText - e-mail message text template
aLicenseFileName - name of the license to attach
Returns:
true if license was sent; false otherwise
Throws:
javax.mail.MessagingException - in case of any error during sending

sendLicense

public boolean sendLicense(LicensingFacadeSession aSession,
                           License aLicense,
                           dev.entities.Customer aCustomer,
                           java.lang.String aCC,
                           java.lang.String aBCC,
                           java.lang.String aSubject,
                           java.lang.String aText)
                    throws javax.mail.MessagingException
Sends license to a customer to address specified in customer's information. It uses licensing facade configuration to obtain e-mail server properties and to get e-mail message attributes From, ReplyTo. It gets e-mail message's Subject and Text by expanding corresponding templates specified as parameters.

Parameters:
aSession - a session object
aLicense - license to send
aCustomer - customer information
aSubject - e-mail message subject template
aText - e-mail message text template
Returns:
true if license was sent; false otherwise
Throws:
javax.mail.MessagingException - in case of any error during sending

processTemplate

protected java.lang.String processTemplate(LicensingFacadeSession aSession,
                                           License aLicense,
                                           dev.entities.Customer aCustomer,
                                           java.lang.String aTemplate)

init

public void init(LocalLicensingFacade aLocalLicensingFacade)
Description copied from interface: LicensingFacadeDelivery
Initializes delivery object. Local licensing facade calls this methods during its instantiation

Specified by:
init in interface LicensingFacadeDelivery
Parameters:
aLocalLicensingFacade - licensing facade for which delivery object will be working for

getInternetAddresses

protected javax.mail.internet.InternetAddress[] getInternetAddresses(java.lang.String[] anInternetAddresses)
                                                              throws javax.mail.internet.AddressException
Throws:
javax.mail.internet.AddressException

sendMessage

public boolean sendMessage(java.lang.String[] aTo,
                           java.lang.String[] aCc,
                           java.lang.String[] aBcc,
                           java.lang.String aFrom,
                           java.lang.String aReplyTo,
                           java.lang.String aSubject,
                           java.lang.String aText,
                           byte[] aLicenseBytes,
                           java.lang.String aLicenseFileName)
                    throws javax.mail.MessagingException
Throws:
javax.mail.MessagingException

getMailSession

protected javax.mail.Session getMailSession()

getLogger

protected com.jp.protection.utils.ProtectionLogger getLogger()