atg.droplet
Class CreditCardTagConverter

java.lang.Object
  extended by atg.droplet.CreditCardTagConverter
All Implemented Interfaces:
TagConverter

public class CreditCardTagConverter
extends java.lang.Object
implements TagConverter

This TagConverter can take an obnject that represents the number of a credit card and mask out parts of that number. This is used in display purposes where the users credit card should not be displayed to the screen. The following things can be configured for controlling what is masked out:

Here is an example of how to use this:

<valueof param="paymentGroup.creditCardNumber" CreditCard>no number</valueof>

You can also specify the masking character to use, the number of characters to not mask, and the size of each grouping of characters:
<valueof param="paymentGroup.creditCardNumber" CreditCard maskCharacter="#" numCharsUnmasked="6" groupingSize="2">no number</valueof>


Field Summary
static java.lang.String CLASS_VERSION
           
static java.lang.String NAME
           
 
Constructor Summary
CreditCardTagConverter()
          Empty Constructor
 
Method Summary
 java.lang.String convertObjectToString(DynamoHttpServletRequest pRequest, java.lang.Object pValue, java.util.Properties pAttributes)
          Convert the supplied credit card number to a string that is proper for displaying to the end user.
 java.lang.Object convertStringToObject(DynamoHttpServletRequest pRequest, java.lang.String pValue, java.util.Properties pAttributes)
          This just ensures that if the property is required that it has been supplied.
 java.lang.String formatCreditCard(java.lang.Object pCreditCard, java.util.Properties pAttributes)
          Format and return the credit card object so that it is suitable for display to the end user.
 java.lang.Integer getGroupingSize()
           
 java.lang.String getMaskChar()
           
 java.lang.String getName()
          Returns the name of this converter.
 java.lang.Integer getNumCharsUnmasked()
           
 TagAttributeDescriptor[] getTagAttributeDescriptors()
          Returns the list of TagAttributeDescriptors which are used by this converter.
 void setGroupingSize(java.lang.Integer pGroupingSize)
           
 void setMaskChar(java.lang.String pMaskChar)
           
 void setNumCharsUnmasked(java.lang.Integer pNumCharsUnmasked)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION

NAME

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

CreditCardTagConverter

public CreditCardTagConverter()
Empty Constructor

Method Detail

setMaskChar

public void setMaskChar(java.lang.String pMaskChar)

getMaskChar

public java.lang.String getMaskChar()

setNumCharsUnmasked

public void setNumCharsUnmasked(java.lang.Integer pNumCharsUnmasked)

getNumCharsUnmasked

public java.lang.Integer getNumCharsUnmasked()

setGroupingSize

public void setGroupingSize(java.lang.Integer pGroupingSize)

getGroupingSize

public java.lang.Integer getGroupingSize()

getName

public java.lang.String getName()
Returns the name of this converter. That is, what must be put into the various jhtml tags to be able to invoke this TagConverter. Remember that this value is case sensitive.

Specified by:
getName in interface TagConverter
Returns:
the name of the TagConverter

getTagAttributeDescriptors

public TagAttributeDescriptor[] getTagAttributeDescriptors()
Description copied from interface: TagConverter
Returns the list of TagAttributeDescriptors which are used by this converter. Each TagAttributeDescriptor describes an attribute which can be used by this TagConverter. Attributes can be optional and they can also be automatic. An automatic attribute implies the use of this converter if that attribute appears in the tag (e.g. date=".." implies the use of the DateTagConverter).

Specified by:
getTagAttributeDescriptors in interface TagConverter

convertObjectToString

public java.lang.String convertObjectToString(DynamoHttpServletRequest pRequest,
                                              java.lang.Object pValue,
                                              java.util.Properties pAttributes)
                                       throws TagConversionException
Convert the supplied credit card number to a string that is proper for displaying to the end user. This is done by taking the credit card number and masking out all the digits except for the last four. This resulting String is returned for display.

The character tat is used to mask out all of the digits is optionally supplied, but defaults to an 'X'.

Specified by:
convertObjectToString in interface TagConverter
Parameters:
pRequest - a value of type 'DynamoHttpServletRequest'
pValue - a value of type 'Object'
pAttributes - a value of type 'Properties'
Returns:
a value of type 'String'
Throws:
TagConversionException - if an error occurs

convertStringToObject

public java.lang.Object convertStringToObject(DynamoHttpServletRequest pRequest,
                                              java.lang.String pValue,
                                              java.util.Properties pAttributes)
                                       throws TagConversionException
This just ensures that if the property is required that it has been supplied. If it has not then an exception is thrown. Else, let the value pass through.

Specified by:
convertStringToObject in interface TagConverter
Parameters:
pRequest - the servlet request object
pValue - the credit card number
pAttributes - attributes passed in via jhtml
Returns:
the credit card number
Throws:
TagConversionException - if an error occurs

formatCreditCard

public java.lang.String formatCreditCard(java.lang.Object pCreditCard,
                                         java.util.Properties pAttributes)
Format and return the credit card object so that it is suitable for display to the end user.

If more characters are being masked than there are to be masked, it will default to masking all characters. A space will be inserted after each grouping, by default every fourth character in the string returned.

Parameters:
pCreditCard - an object that should represent the Credit Card number
pAttributes - attributes passed into TagConverter via jhtml
Returns:
the formatted Credit Card object