atg.userprofiling
Class ProfileTools

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.userprofiling.ProfileTools
All Implemented Interfaces:
NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener
Direct Known Subclasses:
CommerceProfileTools

public class ProfileTools
extends GenericService

A general set of tools which help manipulate profiles.

The class atg.userprofiling.Profile, used in many methods as a parameter, is the class which represents the instance of the session-scoped Profile object, located at the Nucleus path /atg/userprofiling/Profile. The methods which contain this parameter signature should only be used when it is required to manipulate the session-scoped Profile object. Typically one will have a property reference to the object or resolve the object through the request. Developers should not needlessly construct new Profile instances (i.e. Profile p = new Profile()) and pass it as a parameter. Remember this object is only a placeholder to put in the component tree. The _real_ profile is an atg.repository.RepositoryItem instance, which is wrapped through the dataSource property of the atg.userprofiling.Profile class.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
static java.lang.String DPS_VERSION
          Full Product Version Identifier
static java.lang.String DPS_VERSION_NUM
          Version number for this product
protected  atg.userprofiling.PasswordGenerator mPasswordGenerator
           
protected  atg.security.PasswordRuleChecker mPasswordRuleChecker
           
protected  atg.security.PreviousNPasswordManager mPreviousNPasswordManager
           
 
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
ProfileTools()
          Constructs an instanceof ProfileTools
 
Method Summary
 void addMultiPropertyValues(java.lang.String pPropertyName, RepositoryItem pSourceItem, RepositoryItem pTargetItem)
          Adds a specific multi-valued property's values from the given source user to the given target user
 boolean assumeSecurityIdentity(Profile pProfile)
          Takes the given profile and makes the current Thread's User have the persona of this profile.
 boolean assumeSecurityIdentity(Profile pProfile, IdentityManager pIdentityManager)
          Takes the given profile and IdentityManager and makes the current Thread's User have the persona of this profile.
 java.util.Collection buildPropertyUpdatesForDictionary(RepositoryItem pItem, java.util.Dictionary pValues)
          Builds a collection of PropertyUpdate objects that reflect the updates in the value dictionary.
protected  java.util.Collection buildPropertyUpdatesForRepositoryFormList(RepositoryItem pItemWithMultiValuedProperty, RepositoryFormList pRepositoryFormList)
          Builds a collection of PropertyUpdate objects for the updates in the RepositoryFormList.
protected  java.util.Collection buildPropertyUpdatesForRepositoryFormMap(RepositoryItem pItem, RepositoryFormMap pRepositoryFormMap)
          Builds a collection of PropertyUpdate objects for the updates in the RepositoryFormMap.
 void buildUpdateMessage(RepositoryItem repItem, java.util.Dictionary newValues, java.util.Vector propertyUpdatesVector, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Operation called to set up the event data to be fired in the postUpdateUser method.
 void buildUpdateMessage(RepositoryItem repItem, RepositoryItemDescriptor pItemDescriptor, java.util.Dictionary newValues, java.util.Vector propertyUpdatesVector, java.lang.String pPropertyPath, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Operation called to set up the event data to be fired in the postUpdateUser method.
 void changePassword(RepositoryItem pProfile, java.lang.String pNewPassword, java.lang.String pConfirmNewPassword, java.lang.String pConfirmOldPassword, boolean pMustConfirmNewPassword, boolean pMustConfirmOldPassword)
          Changes the password for the profile, if certain criteria are met: If requiring a confirmation password, then pNewPassword and pConfirmPassword must match.
 boolean createNewUser(java.lang.String pUserType, Profile pProfile)
          Creates a new user and loads it into the session-scoped Profile object.
 boolean createNewUser(java.lang.String pProfileId, java.lang.String pUserType, Profile pProfile)
          Creates a new user and loads it into the Profile object.
protected  atg.userprofiling.PropertyUpdate createPropertyUpdate(int pUpdateType, java.lang.String pPropertyName, java.lang.String pOldValue, java.lang.String pNewValue)
          Creates a property update object using the values provided.
 void doStartService()
          Called after the service has been created, placed into the naming hierarchy, and initialized with its configured property values.
 java.lang.String formatMultiValueUpdateString(java.lang.String pPropertyName, java.lang.String pKey, java.lang.Object pReferencedObject)
          Creates a formatted string that denotes an item within a multi-valued property(collection, map or object []).
protected  Query generateEmailQuery(java.lang.String pEmail, QueryBuilder pQueryBuilder)
          Deprecated. As of DPS 5.5, this method has been moved to RepositoryProfileItemFinder. If you call this method, you should change your code to instead call getProfileItemFinder().generateEmailQuery. If you override this method in this class, you should instead override the RepositoryProfileItemFinder component's method.
protected  Query generateLoginQuery(java.lang.String pLogin, java.lang.String pPassword, QueryBuilder pQueryBuilder)
          Deprecated. As of DPS 5.5, this method has been moved to RepositoryProfileItemFinder. If you call this method, you should change your code to instead call getProfileItemFinder().generateLoginQuery. If you override this method in this class, you should instead override the RepositoryProfileItemFinder component's method.
protected  Query generateNameQuery(java.lang.String pFirstName, java.lang.String pLastName, QueryBuilder pQueryBuilder)
          Deprecated. As of DPS 5.5, this method has been moved to RepositoryProfileItemFinder. If you call this method, you should change your code to instead call getProfileItemFinder().generateNameQuery. If you override this method in this class, you should instead override the RepositoryProfileItemFinder component's method.
 java.lang.String generateNewPasswordForProfile(RepositoryItem pProfile)
          Creates a randomly generated password for the profile.
 java.lang.Boolean getAutoLogin(Profile pProfile)
          Gets the auto-login property of the given profile.
 CookieManager getCookieManager()
          Returns property CookieManager
 java.lang.String getDefaultProfileType()
          Returns property DefaultProfileType
 atg.repository.nucleus.RepositoryGroupContainer getGroupContainer()
          Returns property GroupContainer
 RepositoryItem getItem(java.lang.String pLogin, java.lang.String pPassword)
          Returns a RepositoryItem which represents a profile.
 RepositoryItem getItem(java.lang.String pLogin, java.lang.String pPassword, java.lang.String pProfileType)
          Returns a RepositoryItem which represents a profile.
 RepositoryItem getItemFromEmail(java.lang.String pEmail)
          Returns a RepositoryItem which represents a profile.
 RepositoryItem getItemFromEmail(java.lang.String pEmail, java.lang.String pProfileType)
          Returns a RepositoryItem which represents a profile.
 RepositoryItem[] getItems(java.lang.String pFirstName, java.lang.String pLastName)
          Returns an list of RepositoryItems which represents profiles found for the first and last names entered.
 RepositoryItem[] getItems(java.lang.String pFirstName, java.lang.String pLastName, java.lang.String pProfileType)
          Returns an list of RepositoryItems which represents profiles found for the first and last names entered.
 RepositoryItem[] getItemsFromEmail(java.lang.String pEmail)
          Returns a RepositoryItem which represents a profile.
 RepositoryItem[] getItemsFromEmail(java.lang.String pEmail, java.lang.String pProfileType)
          Returns a RepositoryItem which represents a profile.
 java.lang.String getLoggingIdentifier()
           
 java.lang.String getLogin(RepositoryItem pProfile)
          Gets the login of the given profile.
 atg.userdirectory.UserDirectoryLoginUserAuthority getLoginUserAuthority()
          Returns property UserAuthority
 MutableRepositoryItem getMutableItem(RepositoryItem pItem)
          Gets the mutable form of the given repository item, assuming that there is one.
 java.lang.String getPassword(RepositoryItem pProfile)
          Gets the password of the given profile.
 atg.userprofiling.PasswordGenerator getPasswordGenerator()
           
 atg.security.PasswordRuleChecker getPasswordRuleChecker()
           
 atg.security.PreviousNPasswordManager getPreviousNPasswordManager()
           
 ProfileEventTrigger getProfileEventTrigger()
          Returns property ProfileEventTrigger
 RepositoryProfileItemFinder getProfileItemFinder()
          Returns property PropertyManager
 MutableRepository getProfileRepository()
          Returns property ProfileRepository
 PropertyManager getPropertyManager()
          Returns property PropertyManager
 java.lang.Integer getSecurityStatus(Profile pProfile)
          Gets the security status of the given profile, if there is such a property
 UserLoginManager getUserLoginManager()
          Returns the value of the property LoginUserAuthority.
 boolean isAutoLoginSecurityStatus(int pSecurityStatus)
          Returns true if the given security status indicates an auto login
 boolean isEnableSecurityStatus()
           
 boolean isValidCredentials(java.lang.String pLogin, java.lang.String pCleartextPassword)
          Determines if the given login and cleartext password represent a valid pair of credentials for a user, according to a configured IdentityManager.
 boolean isValidCredentials(java.lang.String pLogin, java.lang.String pCleartextPassword, IdentityManager pIdentityManager)
          Determines if the given login and cleartext password represent a valid pair of credentials for a user.
 boolean isValidCredentialsEncrypted(java.lang.String pLogin, java.lang.String pEncryptedPassword, java.lang.String pHashKey)
          This method validates the given credentials, assuming that the given password has been encrypted according to the profile password hasher algorithm, and further encrypted using the given pHashKey.
 boolean locateUserFromEmail(java.lang.String pEmail, Profile pProfile)
          A query is built to look for users with the given email.
 boolean locateUserFromEmail(java.lang.String pEmail, Profile pProfile, java.lang.String pProfileType)
          A query is built to look for users with the given email.
 boolean locateUserFromId(java.lang.String pId, Profile pProfile)
          A profile is attempted to be loaded by their user id.
 boolean locateUserFromId(java.lang.String pId, Profile pProfile, java.lang.String pProfileType)
          A profile is attempted to be loaded by their user id.
 boolean locateUserFromLogin(java.lang.String pLogin, Profile pProfile)
          A query is built to look for users with the given login.
 boolean locateUserFromLogin(java.lang.String pLogin, Profile pProfile, java.lang.String pProfileType)
          A query is built to look for users with the given login.
 boolean locateUserFromLogin(java.lang.String pLogin, java.lang.String pPassword, Profile pProfile)
          A query is built to look for users with the given login and password.
 boolean locateUserFromLogin(java.lang.String pLogin, java.lang.String pPassword, Profile pProfile, java.lang.String pProfileType)
          A query is built to look for users with the given login and password.
static void main(java.lang.String[] pArgs)
          Print out the version of DPS
 void prefixPropertyNames(java.util.Collection pPropertyUpdates, java.lang.String pPropertyNamePrefix)
          Iterates through the property updates and modifies the propertyName property to be prefixed by the pPropertyNamePrefix.
 void propagateLocale(Profile pProfile, atg.servlet.RequestLocale pRequestLocale, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Tests to see if the locale of the profile and the locale of the current request are different, and if so, whether or not the caller should change the locale to that of the profile's
 boolean revokeSecurityIdentity()
          Revokes the identity(ies) of the current user.
 boolean revokeSecurityIdentity(IdentityManager pIdentityManager)
          Takes the given IdentityManager and revokes the managed User's persona(s) i.e.
 void sendEmailToUser(MutableRepositoryItem pProfile, boolean pRunInSeparateThread, boolean pPersist, TemplateEmailSender pTemplateEmailSender, TemplateEmailInfo pTemplateEmailInfo, java.util.Map pTemplateParameters)
          Sends email to the user using the provided email template and parameters.
 void setAutoLoginSecurityStatus(Profile pProfile, ProfileRequest pProfileRequest)
          Sets the security status property of the profile.
 void setCookieManager(CookieManager pCookieManager)
          Sets property CookieManager
 void setDefaultProfileType(java.lang.String pDefaultProfileType)
          Sets property DefaultProfileType
 void setEnableSecurityStatus(boolean pEnableSecurityStatus)
           
 void setGroupContainer(atg.repository.nucleus.RepositoryGroupContainer pGroupContainer)
          Sets property GroupContainer
 void setLoginSecurityStatus(Profile pProfile, DynamoHttpServletRequest pRequest)
          Sets the security status property of the profile.
 void setLoginUserAuthority(atg.userdirectory.UserDirectoryLoginUserAuthority pUserAuthority)
          Sets property UserAuthority
 void setPasswordGenerator(atg.userprofiling.PasswordGenerator pPasswordGenerator)
          Sets the property PasswordGenerator
 void setPasswordRuleChecker(atg.security.PasswordRuleChecker pPasswordRuleChecker)
          Sets the property PasswordRuleChecker
 void setPreviousNPasswordManager(atg.security.PreviousNPasswordManager pPreviousNPasswordManager)
          Sets the property PreviousNPasswordManager
 void setProfileEventTrigger(ProfileEventTrigger pProfileEventTrigger)
          Sets property ProfileEventTrigger
 void setProfileItemFinder(RepositoryProfileItemFinder pProfileItemFinder)
          Sets property ProfileItemFinder
 void setProfileRepository(MutableRepository pProfileRepository)
          Sets property ProfileRepository
 void setPropertyManager(PropertyManager pPropertyManager)
          Sets property PropertyManager
 void setSecurityStatus(Profile pProfile, int pValue)
          Sets the security status property of the profile.
 void setUserLoginManager(UserLoginManager pUserLoginManager)
          Sets the property LoginUserAuthority.
 boolean shouldSendProfileCookies(Profile pProfile)
          Determines if profile cookies should be sent to the given profile's web client
 java.lang.String toString()
           
 void updateProperties(java.util.Dictionary pPropertyTable, RepositoryItem pItem)
          Attempts to update the profile with the given set of changed property values.
 void updateProperty(java.lang.String pPropertyName, java.lang.Object pPropertyValue, RepositoryItem pItem)
          Attempts to update the named property for the profile.
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, 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, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string


DPS_VERSION_NUM

public static final java.lang.String DPS_VERSION_NUM
Version number for this product

See Also:
Constant Field Values

DPS_VERSION

public static final java.lang.String DPS_VERSION
Full Product Version Identifier

See Also:
Constant Field Values

mPasswordGenerator

protected atg.userprofiling.PasswordGenerator mPasswordGenerator

mPreviousNPasswordManager

protected atg.security.PreviousNPasswordManager mPreviousNPasswordManager

mPasswordRuleChecker

protected atg.security.PasswordRuleChecker mPasswordRuleChecker
Constructor Detail

ProfileTools

public ProfileTools()
Constructs an instanceof ProfileTools

Method Detail

setPasswordGenerator

public void setPasswordGenerator(atg.userprofiling.PasswordGenerator pPasswordGenerator)
Sets the property PasswordGenerator


getPasswordGenerator

public atg.userprofiling.PasswordGenerator getPasswordGenerator()
Returns:
The value of the property PasswordGenerator

setProfileRepository

public void setProfileRepository(MutableRepository pProfileRepository)
Sets property ProfileRepository


getProfileRepository

public MutableRepository getProfileRepository()
Returns property ProfileRepository


setDefaultProfileType

public void setDefaultProfileType(java.lang.String pDefaultProfileType)
Sets property DefaultProfileType


getDefaultProfileType

public java.lang.String getDefaultProfileType()
Returns property DefaultProfileType


setCookieManager

public void setCookieManager(CookieManager pCookieManager)
Sets property CookieManager


getCookieManager

public CookieManager getCookieManager()
Returns property CookieManager


setPropertyManager

public void setPropertyManager(PropertyManager pPropertyManager)
Sets property PropertyManager


getPropertyManager

public PropertyManager getPropertyManager()
Returns property PropertyManager


setProfileItemFinder

public void setProfileItemFinder(RepositoryProfileItemFinder pProfileItemFinder)
Sets property ProfileItemFinder


getProfileItemFinder

public RepositoryProfileItemFinder getProfileItemFinder()
Returns property PropertyManager


setProfileEventTrigger

public void setProfileEventTrigger(ProfileEventTrigger pProfileEventTrigger)
Sets property ProfileEventTrigger


getProfileEventTrigger

public ProfileEventTrigger getProfileEventTrigger()
Returns property ProfileEventTrigger


setGroupContainer

public void setGroupContainer(atg.repository.nucleus.RepositoryGroupContainer pGroupContainer)
Sets property GroupContainer


getGroupContainer

public atg.repository.nucleus.RepositoryGroupContainer getGroupContainer()
Returns property GroupContainer


setLoginUserAuthority

public void setLoginUserAuthority(atg.userdirectory.UserDirectoryLoginUserAuthority pUserAuthority)
Sets property UserAuthority


getLoginUserAuthority

public atg.userdirectory.UserDirectoryLoginUserAuthority getLoginUserAuthority()
Returns property UserAuthority


setUserLoginManager

public void setUserLoginManager(UserLoginManager pUserLoginManager)
Sets the property LoginUserAuthority.


getUserLoginManager

public UserLoginManager getUserLoginManager()
Returns the value of the property LoginUserAuthority.


setPreviousNPasswordManager

public void setPreviousNPasswordManager(atg.security.PreviousNPasswordManager pPreviousNPasswordManager)
Sets the property PreviousNPasswordManager


getPreviousNPasswordManager

public atg.security.PreviousNPasswordManager getPreviousNPasswordManager()
Returns:
The value of the property PreviousNPasswordManager.

setPasswordRuleChecker

public void setPasswordRuleChecker(atg.security.PasswordRuleChecker pPasswordRuleChecker)
Sets the property PasswordRuleChecker


getPasswordRuleChecker

public atg.security.PasswordRuleChecker getPasswordRuleChecker()
Returns:
The value of the property PasswordRuleChecker.

doStartService

public void doStartService()
                    throws ServiceException
Called after the service has been created, placed into the naming hierarchy, and initialized with its configured property values. Makes sure all the required properties have been set in the .properties file.

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

createNewUser

public boolean createNewUser(java.lang.String pUserType,
                             Profile pProfile)
Creates a new user and loads it into the session-scoped Profile object. This method uses the MutableRepository.createItem method and sets the Profile.dataSource property to the newly constructed RepositoryItem.
NOTE: Only use this method when modifying the session-scoped Profile instance, located at /atg/userprofiling/Profile.

Parameters:
pUserType - the type of profile to construct, which maps to an ItemDescriptor type
pProfile - the session-scoped Profile instance
Returns:
true if the desired user was created and loaded into the profile

createNewUser

public boolean createNewUser(java.lang.String pProfileId,
                             java.lang.String pUserType,
                             Profile pProfile)
Creates a new user and loads it into the Profile object. This method uses the MutableRepository.createItem method and sets the Profile.dataSource property to the newly constructed RepositoryItem.

Parameters:
pProfileId - The id of the profile to create. It's the caller's responsibility to ensure this is a valid profile id.
pUserType - the type of profile to construct, which maps to an ItemDescriptor type
pProfile - the Profile instance to load the new created user item.
Returns:
true if the desired user was created and loaded into the profile

locateUserFromLogin

public boolean locateUserFromLogin(java.lang.String pLogin,
                                   java.lang.String pPassword,
                                   Profile pProfile)
A query is built to look for users with the given login and password. If a user is found then the dataSource property of the session-scoped Profile is updated to point to the found user.
NOTE: Only use this method when modifying the session-scoped Profile instance, located at /atg/userprofiling/Profile.

Parameters:
pLogin - the login name of the user to find
pPassword - the matching password of the user to load
pProfile - the session-scoped Profile instance
Returns:
true if the desired user was found and loaded into the profile

locateUserFromLogin

public boolean locateUserFromLogin(java.lang.String pLogin,
                                   java.lang.String pPassword,
                                   Profile pProfile,
                                   java.lang.String pProfileType)
A query is built to look for users with the given login and password. If a user is found then the dataSource property of the session-scoped Profile is updated to point to the found user.
NOTE: Only use this method when modifying the session-scoped Profile instance, located at /atg/userprofiling/Profile.

Parameters:
pLogin - the login name of the user to find
pPassword - the matching password of the user to load
pProfile - the session-scoped Profile instance
pProfileType - the name of item descriptor to use to look for the profile
Returns:
true if the desired user was found and loaded into the profile

locateUserFromLogin

public boolean locateUserFromLogin(java.lang.String pLogin,
                                   Profile pProfile)
A query is built to look for users with the given login. If a user is found then the dataSource property of the session-scoped Profile is updated to point to the found user.
NOTE: Only use this method when modifying the session-scoped Profile instance, located at /atg/userprofiling/Profile.

Parameters:
pLogin - the login name of the user to find
pProfile - the session-scoped Profile instance
Returns:
true if the desired user was found and loaded into the profile

locateUserFromLogin

public boolean locateUserFromLogin(java.lang.String pLogin,
                                   Profile pProfile,
                                   java.lang.String pProfileType)
A query is built to look for users with the given login. If a user is found then the dataSource property of the session-scoped Profile is updated to point to the found user.
NOTE: Only use this method when modifying the session-scoped Profile instance, located at /atg/userprofiling/Profile.

Parameters:
pLogin - the login name of the user to find
pProfile - the session-scoped Profile instance
pProfileType - the name of item descriptor to use to look for the profile
Returns:
true if the desired user was found and loaded into the profile

locateUserFromId

public boolean locateUserFromId(java.lang.String pId,
                                Profile pProfile)
A profile is attempted to be loaded by their user id. If a user is found then the dataSource property of the session-scoped Profile is updated to point to the found user.
NOTE: Only use this method when modifying the session-scoped Profile instance, located at /atg/userprofiling/Profile.

Parameters:
pId - the user id of the profile to load
pProfile - the session-scoped Profile instance
Returns:
true if the desired user was found and loaded into the profile

locateUserFromId

public boolean locateUserFromId(java.lang.String pId,
                                Profile pProfile,
                                java.lang.String pProfileType)
A profile is attempted to be loaded by their user id. If a user is found then the dataSource property of the session-scoped Profile is updated to point to the found user.
NOTE: Only use this method when modifying the session-scoped Profile instance, located at /atg/userprofiling/Profile.

Parameters:
pId - the user id of the profile to load
pProfile - the session-scoped Profile instance
pProfileType - the name of item descriptor to use to look for the profile
Returns:
true if the desired user was found and loaded into the profile

locateUserFromEmail

public boolean locateUserFromEmail(java.lang.String pEmail,
                                   Profile pProfile)
A query is built to look for users with the given email. If a user is found then the dataSource property of the session-scoped Profile is updated to point to the found user. Note that if multiple users exist with the same email address, only one of them will be found.
NOTE: Only use this method when modifying the session-scoped Profile instance, located at /atg/userprofiling/Profile.

Parameters:
pEmail - the email address of the user to find
pProfile - the session-scoped Profile instance
Returns:
true if the desired user was found and loaded into the profile

locateUserFromEmail

public boolean locateUserFromEmail(java.lang.String pEmail,
                                   Profile pProfile,
                                   java.lang.String pProfileType)
A query is built to look for users with the given email. If a user is found then the dataSource property of the session-scoped Profile is updated to point to the found user. Note that if multiple users exist with the same email address, only one of them will be found.
NOTE: Only use this method when modifying the session-scoped Profile instance, located at /atg/userprofiling/Profile.

Parameters:
pEmail - the email address of the user to find
pProfile - the session-scoped Profile instance
pProfileType - the name of item descriptor to use to look for the profile
Returns:
true if the desired user was found and loaded into the profile

updateProperty

public void updateProperty(java.lang.String pPropertyName,
                           java.lang.Object pPropertyValue,
                           RepositoryItem pItem)
                    throws RepositoryException
Attempts to update the named property for the profile. This method is a convenience method which encapsulates using the MutableRepository API. It should not be used if you need to update several properties all at once.

Parameters:
pPropertyName - the name of the property
pPropertyValue - the value of the property to change
pItem - the profile to update
Throws:
RepositoryException - if there was a problem updating the profile

updateProperties

public void updateProperties(java.util.Dictionary pPropertyTable,
                             RepositoryItem pItem)
                      throws RepositoryException
Attempts to update the profile with the given set of changed property values. This is a convenience method which allows multiple properties to be updated together through the MutableRepository API. However this convenience comes at a cost: a developer needs to construct a Hashtable object for every update. That can be an expensive operation. It is recommeded only to use this method if a developer happens to have a Dictionary of key-value pairs already constructed from another operation. It is more efficient to use the MutableRepository API directly.

Parameters:
pPropertyTable - a dictionary of property names and new property values
pItem - the profile to update
Throws:
RepositoryException - if there was a problem updating the profile

getItem

public RepositoryItem getItem(java.lang.String pLogin,
                              java.lang.String pPassword)
Returns a RepositoryItem which represents a profile. This object can be used directly to display/manipulate the profile attributes and it can be used as a value in the session-scope Profile's dataSource property. A query is built using the supplied login to find the data source. If the pPassword parameter is not null then an extra constraint is added to the query operation to make sure the correct password is given.

Parameters:
pLogin - what the user claims is their login
pPassword - the user's password
Returns:
The RepositoryItem which represents the user's profile or null if a match is not found.

generateLoginQuery

protected Query generateLoginQuery(java.lang.String pLogin,
                                   java.lang.String pPassword,
                                   QueryBuilder pQueryBuilder)
                            throws RepositoryException
Deprecated. As of DPS 5.5, this method has been moved to RepositoryProfileItemFinder. If you call this method, you should change your code to instead call getProfileItemFinder().generateLoginQuery. If you override this method in this class, you should instead override the RepositoryProfileItemFinder component's method.

Return the Query which will be executed to find the person with the given login and password. If both pLogin and pPassword is not null, then the query returned if of the form: (login == pLogin) AND (password == pPassword). If the password is null then just (login == pLogin) is returned.

Throws:
RepositoryException
See Also:
RepositoryProfileItemFinder.generateLoginQuery

getItem

public RepositoryItem getItem(java.lang.String pLogin,
                              java.lang.String pPassword,
                              java.lang.String pProfileType)
Returns a RepositoryItem which represents a profile. This object can be used directly to display/manipulate the profile attributes and it can be used as a value in the session-scope Profile's dataSource property. A query is built using the supplied login to find the data source. If the pPassword parameter is not null then an extra constraint is added to the query operation to make sure the correct password is given.

Parameters:
pLogin - what the user claims is their login
pPassword - the user's password
pProfileType - the name of item descriptor to use to look for the profile
Returns:
The RepositoryItem which represents the user's profile. Null if match is not found.

getItems

public RepositoryItem[] getItems(java.lang.String pFirstName,
                                 java.lang.String pLastName)
Returns an list of RepositoryItems which represents profiles found for the first and last names entered. The objects can be used to access information on users.

Parameters:
pFirstName - the first name to query on
pLastName - the last name to query on
Returns:
The RepositoryItem [] which that match the first and last names entered. Null returned if no matches found.

getItems

public RepositoryItem[] getItems(java.lang.String pFirstName,
                                 java.lang.String pLastName,
                                 java.lang.String pProfileType)
Returns an list of RepositoryItems which represents profiles found for the first and last names entered. The objects can be used to access information on users.

Parameters:
pFirstName - the first name to query on
pLastName - the last name to query on
Returns:
The RepositoryItem [] which that match the first and last names entered. Null returned if no matches found.

generateNameQuery

protected Query generateNameQuery(java.lang.String pFirstName,
                                  java.lang.String pLastName,
                                  QueryBuilder pQueryBuilder)
                           throws RepositoryException
Deprecated. As of DPS 5.5, this method has been moved to RepositoryProfileItemFinder. If you call this method, you should change your code to instead call getProfileItemFinder().generateNameQuery. If you override this method in this class, you should instead override the RepositoryProfileItemFinder component's method.

Return the Query which will be executed to find the persons with the given first and last names. If both the first and last names are not null, then the query returned will be of the form: (firstName == pFirstName) AND (lastName == pLastName). If the firstName is null then just (lastName == pLLastName) is returned.

Throws:
RepositoryException
See Also:
RepositoryProfileItemFinder.generateNameQuery

getItemFromEmail

public RepositoryItem getItemFromEmail(java.lang.String pEmail)
Returns a RepositoryItem which represents a profile. This object can be used directly to display/manipulate the profile attributes and it can be used as a value in the session-scope Profile's dataSource property. A query is built using the supplied email to find the data source. Note that if multiple users exist with the same email address, only one of them will be returned.

Parameters:
pEmail - the email address of the user to find
Returns:
The RepositoryItem which represents the user's profile.

getItemFromEmail

public RepositoryItem getItemFromEmail(java.lang.String pEmail,
                                       java.lang.String pProfileType)
Returns a RepositoryItem which represents a profile. This object can be used directly to display/manipulate the profile attributes and it can be used as a value in the session-scope Profile's dataSource property. A query is built using the supplied email to find the data source. Note that if multiple users exist with the same email address, only one of them will be returned.

Parameters:
pEmail - the email address of the user to find
pProfileType - the name of item descriptor to use to look for the profile
Returns:
The RepositoryItem which represents the user's profile. Null returned if no match is found.

getItemsFromEmail

public RepositoryItem[] getItemsFromEmail(java.lang.String pEmail)
Returns a RepositoryItem which represents a profile. This object can be used directly to display/manipulate the profile attributes and it can be used as a value in the session-scope Profile's dataSource property. A query is built using the supplied email to find the data source. Note that if multiple users exist with the same email address, only one of them will be returned.

Parameters:
pEmail - the email address of the user to find
Returns:
The RepositoryItem [] which represents the user's profile. Null returned if no match is found.

getItemsFromEmail

public RepositoryItem[] getItemsFromEmail(java.lang.String pEmail,
                                          java.lang.String pProfileType)
Returns a RepositoryItem which represents a profile. This object can be used directly to display/manipulate the profile attributes and it can be used as a value in the session-scope Profile's dataSource property. A query is built using the supplied email to find the data source. Note that if multiple users exist with the same email address, only one of them will be returned.

Parameters:
pEmail - the email address of the user to find
pProfileType - the name of item descriptor to use to look for the profile
Returns:
The RepositoryItem [] which represents the user's profile. Null returned if no match is found.

generateEmailQuery

protected Query generateEmailQuery(java.lang.String pEmail,
                                   QueryBuilder pQueryBuilder)
                            throws RepositoryException
Deprecated. As of DPS 5.5, this method has been moved to RepositoryProfileItemFinder. If you call this method, you should change your code to instead call getProfileItemFinder().generateEmailQuery. If you override this method in this class, you should instead override the RepositoryProfileItemFinder component's method.

Return the Query which will be executed to find the person with the given email address.

Throws:
RepositoryException
See Also:
RepositoryProfileItemFinder.generateEmailQuery

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getLoggingIdentifier

public java.lang.String getLoggingIdentifier()

main

public static void main(java.lang.String[] pArgs)
Print out the version of DPS


setEnableSecurityStatus

public void setEnableSecurityStatus(boolean pEnableSecurityStatus)

isEnableSecurityStatus

public boolean isEnableSecurityStatus()

setLoginSecurityStatus

public void setLoginSecurityStatus(Profile pProfile,
                                   DynamoHttpServletRequest pRequest)
                            throws RepositoryException
Sets the security status property of the profile. This is to be called from situations where the user has actually supplied his password.

Parameters:
pProfile - the profile to update
pRequest - the request.
Throws:
RepositoryException

setAutoLoginSecurityStatus

public void setAutoLoginSecurityStatus(Profile pProfile,
                                       ProfileRequest pProfileRequest)
                                throws RepositoryException
Sets the security status property of the profile.

Parameters:
pProfile - the profile to update
pProfileRequest - used only when pExplicit is false. we use it to get the request source
Throws:
RepositoryException

isAutoLoginSecurityStatus

public boolean isAutoLoginSecurityStatus(int pSecurityStatus)
Returns true if the given security status indicates an auto login

Parameters:
pSecurityStatus - the security status to examine
Returns:
true if pSecurityStatus indicates an auto login, false otherwise

setSecurityStatus

public void setSecurityStatus(Profile pProfile,
                              int pValue)
                       throws RepositoryException
Sets the security status property of the profile.

Parameters:
pProfile - the profile to update
pValue - what to set the property value to.
Throws:
RepositoryException

buildUpdateMessage

public void buildUpdateMessage(RepositoryItem repItem,
                               java.util.Dictionary newValues,
                               java.util.Vector propertyUpdatesVector,
                               DynamoHttpServletRequest pRequest,
                               DynamoHttpServletResponse pResponse)
                        throws RepositoryException
Operation called to set up the event data to be fired in the postUpdateUser method.

Parameters:
repItem - the item as it is in the repository before the update
newValues - the dictionary containing the updated profile properties
propertyUpdatesVector - a place to hold the updated properties as we recurse
pRequest - the servlet's request
pResponse - the servlet's response
Throws:
RepositoryException

buildUpdateMessage

public void buildUpdateMessage(RepositoryItem repItem,
                               RepositoryItemDescriptor pItemDescriptor,
                               java.util.Dictionary newValues,
                               java.util.Vector propertyUpdatesVector,
                               java.lang.String pPropertyPath,
                               DynamoHttpServletRequest pRequest,
                               DynamoHttpServletResponse pResponse)
                        throws RepositoryException
Operation called to set up the event data to be fired in the postUpdateUser method.

Parameters:
repItem - the item as it is in the repository before the update
newValues - the dictionary containing the updated profile properties
propertyUpdatesVector - a place to hold the updated properties as we recurse
pRequest - the servlet's request
pResponse - the servlet's response
Throws:
RepositoryException

assumeSecurityIdentity

public boolean assumeSecurityIdentity(Profile pProfile)
Takes the given profile and makes the current Thread's User have the persona of this profile. This version of the method uses the IdentityManager configured for the UserLoginManager, and as such, requires a request to get it.

Parameters:
pProfile - the profile of the persona the current user is to be associated with
Returns:
true if the current Thread's User has had its personae altered to include the given pProfile, false otherwise

assumeSecurityIdentity

public boolean assumeSecurityIdentity(Profile pProfile,
                                      IdentityManager pIdentityManager)
Takes the given profile and IdentityManager and makes the current Thread's User have the persona of this profile. This version of the method uses the IdentityManager configured for the UserLoginManager, and as such, requires a request to get it.

Parameters:
pProfile - the profile of the persona the current user is to be associated with
pIdentityManager - the service that holds references to the current user and the user authority needed to make the persona association
Returns:
true if the current Thread's User has had its personae altered to include the given pProfile, false otherwise

revokeSecurityIdentity

public boolean revokeSecurityIdentity()
Revokes the identity(ies) of the current user. The current user is specified as the current session's User object. If this method is not called in the context of a request, then a runtime exception is thrown. This version of the method will use the identity manager for the current session, associated with the userLoginManager property of this component

Returns:
true if the current Thread's User has had its personae altered to remove all current identities, false otherwise

revokeSecurityIdentity

public boolean revokeSecurityIdentity(IdentityManager pIdentityManager)
Takes the given IdentityManager and revokes the managed User's persona(s) i.e. setting it to null.

Parameters:
pIdentityManager - the service that holds references to the current user and the user authority needed to revoke all associated personas
Returns:
true if the current Thread's User has had its personae altered to remove all current identities, false otherwise

shouldSendProfileCookies

public boolean shouldSendProfileCookies(Profile pProfile)
Determines if profile cookies should be sent to the given profile's web client

Parameters:
pProfile - the profile of the user to send the cookies to
pRequest - the current request
pResponse - the current response
Returns:
true if the cookieManager is not null, is configured to send cookies, and pProfile does not have an autoLogin property or the autoLogin property is set to true.

isValidCredentials

public boolean isValidCredentials(java.lang.String pLogin,
                                  java.lang.String pCleartextPassword)
Determines if the given login and cleartext password represent a valid pair of credentials for a user, according to a configured IdentityManager. This method must be called within the context of a session, since it resolves an IdentityManager used to validate the credentials

Parameters:
pLogin - the login of the person to validate
pCleartextPassword - the unencrypted password of the person to validate
Returns:
true if the given password validates the identity of the user represented by the given login

isValidCredentials

public boolean isValidCredentials(java.lang.String pLogin,
                                  java.lang.String pCleartextPassword,
                                  IdentityManager pIdentityManager)
Determines if the given login and cleartext password represent a valid pair of credentials for a user. This method must be called within the context of a session, since the given IdentityManager must have access to the current session's User

Parameters:
pLogin - the login of the person to validate
pCleartextPassword - the unencrypted password of the person to validate
pIdentityManager - the identity manager used to validate the given credentials
Returns:
true if the given password validates the identity of the user represented by the given login

isValidCredentialsEncrypted

public boolean isValidCredentialsEncrypted(java.lang.String pLogin,
                                           java.lang.String pEncryptedPassword,
                                           java.lang.String pHashKey)
This method validates the given credentials, assuming that the given password has been encrypted according to the profile password hasher algorithm, and further encrypted using the given pHashKey.

Parameters:
pLogin - the login to validate
pEncryptedPassword - a password encrypted using the algorithm configured by the propertyManager.passwordHasher property, and further encrypted with the given pHashKey
pHashKey - the hashkey used to further encrypt a password hashed according to the algorithm configured by propertyManager.passwordHasher
Returns:
true if the given login/password are valid

getSecurityStatus

public java.lang.Integer getSecurityStatus(Profile pProfile)
                                    throws PropertyNotFoundException
Gets the security status of the given profile, if there is such a property

Parameters:
pProfile - the profile to get the security status of
Returns:
the security status of the given profile. This status must be defined as an Integer in your profile repository. If your repository does not define it as such, do not use this method.
Throws:
PropertyNotFoundException

getLogin

public java.lang.String getLogin(RepositoryItem pProfile)
                          throws PropertyNotFoundException
Gets the login of the given profile. The login property is identified by the name specified by propertyManager.loginPropertyName

Parameters:
pProfile - the profile to get the login of
Returns:
the value of the profile's login. This value must be specified as a string in the profile repository. If your repository does not define it as such, do not use this method.
Throws:
PropertyNotFoundException

getPassword

public java.lang.String getPassword(RepositoryItem pProfile)
                             throws PropertyNotFoundException
Gets the password of the given profile. The password property is identified by the name specified by propertyManager.passwordPropertyName

Parameters:
pProfile - the profile to get the login of
Returns:
the value of the profile's password. This value must be specified as a string in the profile repository. If your repository does not define it as such, do not use this method.
Throws:
PropertyNotFoundException

getAutoLogin

public java.lang.Boolean getAutoLogin(Profile pProfile)
                               throws PropertyNotFoundException
Gets the auto-login property of the given profile. The auto-login property is identified by the name specified by propertyManager.autoLoginPropertyName. This property must be specified as a boolean in the profile repository

Parameters:
pProfile - the profile to get the auto-login of
Returns:
the value of the pProfile's auto-login property. This property must be defined as a Boolean in your profile repository. If your repository does not define it as such, do not use this method.
Throws:
PropertyNotFoundException

propagateLocale

public void propagateLocale(Profile pProfile,
                            atg.servlet.RequestLocale pRequestLocale,
                            DynamoHttpServletRequest pRequest,
                            DynamoHttpServletResponse pResponse)
Tests to see if the locale of the profile and the locale of the current request are different, and if so, whether or not the caller should change the locale to that of the profile's

Parameters:
pProfile - the profile whose locale will be used
pRequestLocale - the request locale that could be altered according to the profile's locale property
pRequest - the current request
pResponse - the current response

getMutableItem

public MutableRepositoryItem getMutableItem(RepositoryItem pItem)
                                     throws RepositoryException
Gets the mutable form of the given repository item, assuming that there is one. If the item is already a MutableRepositoryItem, then it is cast and returned. Otherwise, the profile repository is asked to retrieve the item

Parameters:
pItem - the item to return in mutable form
Returns:
pItem in mutable form
Throws:
RepositoryException - if an error occurs trying to get the item for update

addMultiPropertyValues

public void addMultiPropertyValues(java.lang.String pPropertyName,
                                   RepositoryItem pSourceItem,
                                   RepositoryItem pTargetItem)
                            throws PropertyNotFoundException
Adds a specific multi-valued property's values from the given source user to the given target user

Parameters:
pPropertyName - the name of a multi-valued property whose values will be copied from the source user and added to the target user
pSourceItem - the user to copy values from
pTargetItem - the user to copy values to
Throws:
PropertyNotFoundException

buildPropertyUpdatesForDictionary

public java.util.Collection buildPropertyUpdatesForDictionary(RepositoryItem pItem,
                                                              java.util.Dictionary pValues)
Builds a collection of PropertyUpdate objects that reflect the updates in the value dictionary.

Parameters:
pItem - the item for which the changes in the dictionary apply
pValues - the value dictionary.
Returns:
a collection of PropertyUpdate objects

buildPropertyUpdatesForRepositoryFormMap

protected java.util.Collection buildPropertyUpdatesForRepositoryFormMap(RepositoryItem pItem,
                                                                        RepositoryFormMap pRepositoryFormMap)
Builds a collection of PropertyUpdate objects for the updates in the RepositoryFormMap.

Parameters:
pItem - the item for which the changes in the map apply
pRepositoryFormMap - the RepositoryFormMap.
Returns:
a collection of PropertyUpdate objects

buildPropertyUpdatesForRepositoryFormList

protected java.util.Collection buildPropertyUpdatesForRepositoryFormList(RepositoryItem pItemWithMultiValuedProperty,
                                                                         RepositoryFormList pRepositoryFormList)
Builds a collection of PropertyUpdate objects for the updates in the RepositoryFormList.

Note that ReposioryFormList is used for Sets, Lists and Object[]

Parameters:
pItemWithMultiValuedProperty - the item for which has the multi-valued property that is being updated.
pRepositoryFormList - the RepositoryFormList.
Returns:
a collection of PropertyUpdate objects

formatMultiValueUpdateString

public java.lang.String formatMultiValueUpdateString(java.lang.String pPropertyName,
                                                     java.lang.String pKey,
                                                     java.lang.Object pReferencedObject)
Creates a formatted string that denotes an item within a multi-valued property(collection, map or object []). This method is used to format the multi-valued property update details for ItemUpdateAgentEvents and audit logging. (i.e. mypropertyname[key:value])

Parameters:
pPropertyName - the property name where the object was contained
pKey - the map key. This is only used for maps.
pReferencedObject - the object referenced by the property
Returns:
the formatted string that denotes the property to item relationship

createPropertyUpdate

protected atg.userprofiling.PropertyUpdate createPropertyUpdate(int pUpdateType,
                                                                java.lang.String pPropertyName,
                                                                java.lang.String pOldValue,
                                                                java.lang.String pNewValue)
Creates a property update object using the values provided.

Parameters:
pUpdateType - the type of update
pPropertyName - the property name affected by the udpate
pOldValue - the old value of the property
pNewValue - the new value of the property
Returns:
a PropertyUpdate object

prefixPropertyNames

public void prefixPropertyNames(java.util.Collection pPropertyUpdates,
                                java.lang.String pPropertyNamePrefix)
Iterates through the property updates and modifies the propertyName property to be prefixed by the pPropertyNamePrefix.

Parameters:
pPropertyNamePrefix -
pPropertyName -

generateNewPasswordForProfile

public java.lang.String generateNewPasswordForProfile(RepositoryItem pProfile)
                                               throws RepositoryException
Creates a randomly generated password for the profile.

Updates the profile's password property.

Updates the profile's generatedPassword boolean property.

The caller is responsible for transaction demarcation.

Parameters:
pProfile - the affected profile
Returns:
the new clear text password
Throws:
RepositoryException
See Also:
PasswordGenerator#generatePassword()

changePassword

public void changePassword(RepositoryItem pProfile,
                           java.lang.String pNewPassword,
                           java.lang.String pConfirmNewPassword,
                           java.lang.String pConfirmOldPassword,
                           boolean pMustConfirmNewPassword,
                           boolean pMustConfirmOldPassword)
                    throws atg.userprofiling.PasswordChangeException,
                           RepositoryException,
                           PropertyNotFoundException
Changes the password for the profile, if certain criteria are met:

sendEmailToUser

public void sendEmailToUser(MutableRepositoryItem pProfile,
                            boolean pRunInSeparateThread,
                            boolean pPersist,
                            TemplateEmailSender pTemplateEmailSender,
                            TemplateEmailInfo pTemplateEmailInfo,
                            java.util.Map pTemplateParameters)
                     throws TemplateEmailException
Sends email to the user using the provided email template and parameters.

Parameters:
pProfile - the affected user profile
pRunInSeparateThread - determines if the email is sent in a separate thread
pPersist - determines if the email is persisted before it is sent
pTemplateEmailInfo - the template used to generate the email.
pTemplateEmailSender - the template email sender object that is used to send the templated email.
pTemplateParameters - a map of template parameters that are associated with the pTemplateEmailInfoImpl
Throws:
TemplateEmailException