atg.clicktoconnect
Class C2CTokenGenerator

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.clicktoconnect.C2CTokenGenerator
All Implemented Interfaces:
atg.naming.AbsoluteNameable, NameContextBindingListener, NameContextElement, atg.naming.NameContextParentable, NameResolver, AdminableService, atg.nucleus.Configured, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener

public class C2CTokenGenerator
extends GenericService

This class generates unique tokens that can be used to indentify individual connections.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
static char ENCODING_PAD
           
static char[] ENCODING_REPLACEMENTS
           
static java.lang.String TOKEN_DELIMITER
           
static int TOKEN_DELIMITER_COUNT
           
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
C2CTokenGenerator()
           
 
Method Summary
 void doStartService()
          Perform one-time startup operations
protected  java.lang.String generateChecksum(java.lang.String pToken)
          Generates a checksum for a token.
 java.lang.String generateToken()
          Generates a unique token that can be used to identify a connection.
 java.lang.String getAlgorithm()
          Returns the name of the digest algorithm used to detect tampering.
 long getAndIncrementConnectionCounter()
          Returns the next number in a sequence, guaranteeing never to return the same number twice.
 C2CManager getClickToConnectManager()
           
 java.lang.String getHashKey()
          Returns the hash key to use to prevent tampering with connection tokens.
 java.lang.String getTokenPrefix()
          Returns the server instance and session portions of a connection token pre-assembled for the current session
 void setAlgorithm(java.lang.String pAlgorithm)
          Changes the name of the digest algorithm used to detect tampering.
 void setClickToConnectManager(C2CManager pClickToConnectManager)
          The component that manages ClickToConnect sessions
 void setHashKey(java.lang.String pHashKey)
          Sets the hash key to use to prevent tampering with connection tokens.
 void setTokenPrefix(java.lang.String pTokenPrefix)
          Sets the server instance and session portions of a connection token pre-assembled for the current session
 boolean validateToken(java.lang.String pToken)
          Validates a candidate connection token.
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static final java.lang.String CLASS_VERSION
Class version string

See Also:
Constant Field Values

TOKEN_DELIMITER

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

TOKEN_DELIMITER_COUNT

public static final int TOKEN_DELIMITER_COUNT
See Also:
Constant Field Values

ENCODING_PAD

public static final char ENCODING_PAD
See Also:
Constant Field Values

ENCODING_REPLACEMENTS

public static final char[] ENCODING_REPLACEMENTS
Constructor Detail

C2CTokenGenerator

public C2CTokenGenerator()
Method Detail

getAlgorithm

public java.lang.String getAlgorithm()
Returns the name of the digest algorithm used to detect tampering.

Returns:
the algorithm name

setAlgorithm

public void setAlgorithm(java.lang.String pAlgorithm)
Changes the name of the digest algorithm used to detect tampering.

Parameters:
pAlgorithm - the algorithm name

getClickToConnectManager

public C2CManager getClickToConnectManager()
Returns:
The component that manages ClickToConnect sessions

setClickToConnectManager

public void setClickToConnectManager(C2CManager pClickToConnectManager)
The component that manages ClickToConnect sessions

Parameters:
pClickToConnectManager - the management component

getHashKey

public java.lang.String getHashKey()
Returns the hash key to use to prevent tampering with connection tokens.

Returns:
the hash key

setHashKey

public void setHashKey(java.lang.String pHashKey)
Sets the hash key to use to prevent tampering with connection tokens.

Parameters:
pHashKey - the hash key

getTokenPrefix

public java.lang.String getTokenPrefix()
Returns the server instance and session portions of a connection token pre-assembled for the current session

Returns:
the token prefix for the current session

setTokenPrefix

public void setTokenPrefix(java.lang.String pTokenPrefix)
Sets the server instance and session portions of a connection token pre-assembled for the current session

Parameters:
pTokenPrefix - the token prefix for the current session

generateToken

public java.lang.String generateToken()
Generates a unique token that can be used to identify a connection.

Returns:
the token string

getAndIncrementConnectionCounter

public long getAndIncrementConnectionCounter()
Returns the next number in a sequence, guaranteeing never to return the same number twice.


validateToken

public boolean validateToken(java.lang.String pToken)
Validates a candidate connection token. The token must contain a base section and a checksum separated by our standard delimiter. The candidate checksum must match a freshly computed checksum.

Parameters:
pToken - the token to be validated
Returns:
true if the token is valid, false if invalid

generateChecksum

protected java.lang.String generateChecksum(java.lang.String pToken)
Generates a checksum for a token. The input token should include a trailing delimiter.

Parameters:
pToken - the token to be checksummed
Returns:
the checksum

doStartService

public void doStartService()
                    throws ServiceException
Perform one-time startup operations

Overrides:
doStartService in class GenericService
Throws:
ServiceException - if the Service had a problem starting up