com.ibm.commerce.member.syncbeans

Class UserSyncBean



  • public class UserSyncBean
    extends MemberSyncBean
    A synchronization bean (sync bean) that allows client code to interact with user data without having to worry about the underlying persistence layer: WebSphere Commerce database or an LDAP server. The user sync bean makes use of the following sync helper data object classes by default, to read from and write to the WebSphere Commerce user tables:
    • UserDO: USERS table
    • UserRegistryDO: USERREG table
    • UserDemographicsDO: USERDEMO table
    • SelfAddressDO: ADDRESS table (self-address only)
    • BusinessProfileDO: BUSPROF table
    • UserProfileDO: USERPROF table
    • MemberAttributesDO: MBRATTRVAL table
    VMMProxy is used to read from and write to LDAP, using Virtual Member Manager (VMM). VMM is a component of WebSphere Application Server (WAS) that's used when WAS security is configured to use the federated user repository.

    If WebSphere Commerce is configured to use its own database as the master member profile repository, then the sync beans will only interact with WebSphere Commerce member tables. If on the other hand, WebSphere Commerce is configured to use an LDAP server as the master profile repository, the sync beans will persist member data to LDAP as well as the WebSphere Commerce database. During a read operation, the sync bean's properties are first populated based on the data in the database. Then, if the data on the LDAP server has been updated since the last synchronization, any LDAP properties that are configured to be synchronized will overwrite the existing property values. The ldapentry.xml configuration file controls which properties are synchronized between WebSphere Commerce and LDAP, and in which direction:

    • LDAP to WebSphere Commerce
    • WebSphere Commerce to LDAP
    • Bidirectional
    • LDAP only
    • Field Detail

      • COPYRIGHT

        public static final java.lang.String COPYRIGHT
        The IBM Copyright notice field.
        See Also:
        Constant Field Values
    • Constructor Detail

      • UserSyncBean

        public UserSyncBean(TypedProperty tpCreate)
                     throws ECException,
                            java.rmi.RemoteException,
                            javax.persistence.NoResultException
        Constructor that creates a new user in the database and LDAP. It is called by the user registration commands when creating a new user.
        Parameters:
        tpCreate - The properties of the new user.
        Throws:
        ECException
        java.rmi.RemoteException
        javax.persistence.NoResultException
    • Method Detail

      • getTransactionCachedUserSyncBean

        public static final UserSyncBean getTransactionCachedUserSyncBean(java.lang.String astrUserId)
                                                                   throws java.rmi.RemoteException,
                                                                          javax.persistence.NoResultException,
                                                                          ECException
        Returns a UserSyncBean from the transaction cache, or, if it is not there, then creates a new UserSyncBean, and places it in the transaction cache. As the returned bean is in the transaction cache, and may be used by other callers, the caller should not call any setters on the returned bean.
        Parameters:
        astrUserId - the user Id for the bean.
        Returns:
        the user sync bean for the specified user.
        Throws:
        java.rmi.RemoteException
        javax.persistence.NoResultException
        ECException
      • clearTransactionCachedUserSyncBean

        public static final void clearTransactionCachedUserSyncBean()
        Clear the UserSyncBean that in the transaction cache. This method help to expose the clear cache when AddressUpdate/AddressAdd/AddressDelete are executed.
      • isMigrationEnabled

        public static boolean isMigrationEnabled()
        Returns whether or not existing users in the database should be migrated to LDAP during logon or update of the user profile. It's based on the MigrateUsersFromWCSdb setting in the instance configuration file.
        Returns:
        true if MigrateUsersFromWCSdb equals ON; false otherwise.
      • findByLogonId

        public static UserSyncBean findByLogonId(java.lang.String strLogonId)
                                          throws java.rmi.RemoteException,
                                                 javax.persistence.NoResultException,
                                                 ECException
        Finds a user by logon ID.

        If user data is stored only in the database, this finder method will lookup the user using the "logonId" field in the USERREG table.

        If LDAP is the master repository for user profile data, the logonId field in the database will contain the DN in lower case. Thus, if the input logon ID is a DN string, findByCommerceDN() will be called. However, if the input logon ID is a short name (non-DN) and the user is found in LDAP, then the user will be found in the database using the "DN" field of the USERS table. If the user has been updated in LDAP since the last synchronization, the database will be updated with the most recent values from LDAP.

        Parameters:
        strLogonId - The logon ID.
        Returns:
        an instance of UserSyncBean.
        Throws:
        java.rmi.RemoteException
        javax.persistence.NoResultException
        ECException
      • findByMemberId

        public static UserSyncBean findByMemberId(java.lang.String strMemberId)
                                           throws java.rmi.RemoteException,
                                                  javax.persistence.NoResultException,
                                                  ECException
        Finds a user by member ID. If the user does not exist in LDAP, it will not be persisted there by this finder, since we do not have access to the password.
        Parameters:
        strMemberId - The member ID of the user.
        Returns:
        the UserSyncBean instance.
        Throws:
        java.rmi.RemoteException
        javax.persistence.NoResultException
        ECException
      • findInLDAPByLogonId

        public static commonj.sdo.DataObject findInLDAPByLogonId(java.lang.String astrLogonId)
                                                          throws java.rmi.RemoteException,
                                                                 javax.persistence.NoResultException,
                                                                 ECException
        Finds a user in LDAP by logon ID. The parent organization and member group information of the user are not returned.
        Parameters:
        astrLogonId - The logon ID of the user.
        Returns:
        a VMM entity data object representing the user.
        Throws:
        java.rmi.RemoteException
        javax.persistence.NoResultException
        ECException
      • getRoles

        public java.lang.Integer[] getRoles()
                                     throws javax.persistence.NoResultException
        Returns a list of role IDs that the user has.
        Returns:
        a list of role IDs that the user has.
        Throws:
        javax.persistence.NoResultException
      • getRoles

        public java.lang.Integer[] getRoles(java.lang.String astrOrgEntityId)
                                     throws javax.persistence.NoResultException
        Returns a list of roles that the user has in the specified organization
        Parameters:
        astrOrgEntityId - Organization ID where the user has roles.
        Returns:
        A list of roles that the user has in the specified organization.
        Throws:
        javax.persistence.NoResultException
      • getRolesForOrgEntityAndAncestors

        public java.lang.Integer[] getRolesForOrgEntityAndAncestors(java.lang.String astrOrgEntityId)
                                                             throws javax.persistence.NoResultException
        Gets all roles assigned to this user for the specified organization and all of the organization's ancestor organizations.
        Parameters:
        astrOrgEntityId - The organization ID.
        Returns:
        The list of roles assigned to this user for the specified organization and all of the organization's ancestor organizations.
        Throws:
        javax.persistence.NoResultException
      • getAncestors

        public java.lang.Long[] getAncestors()
                                      throws javax.persistence.NoResultException
        Returns a list of orgEntity IDs of the ancestors.
        Returns:
        a list of orgEntity IDs of the ancestors.
        Throws:
        javax.persistence.NoResultException
      • updatePasswordInLDAP

        public void updatePasswordInLDAP(java.lang.String strLogonPassword)
                                  throws ECException,
                                         java.rmi.RemoteException,
                                         javax.persistence.NoResultException
        Updates the user's password in LDAP.
        Parameters:
        strLogonPassword - Logon password
        Throws:
        ECException
        java.rmi.RemoteException
        javax.persistence.NoResultException
      • findByCommerceDN

        public static UserSyncBean findByCommerceDN(java.lang.String strCommerceDN)
                                             throws java.rmi.RemoteException,
                                                    javax.persistence.NoResultException,
                                                    ECException
        Finds a user based on the distinguished name of the user in the Commerce database.
        Parameters:
        strCommerceDN - Distinguished name of the user in the Commerce database.
        Returns:
        an instance of the UserSyncBean.
        Throws:
        java.rmi.RemoteException
        javax.persistence.NoResultException
        ECException
      • findByLDAPDN

        public static UserSyncBean findByLDAPDN(java.lang.String strLDAPDN)
                                         throws java.rmi.RemoteException,
                                                javax.persistence.NoResultException,
                                                ECException
        Finds a user based on the distinguished name of the user in LDAP.
        Parameters:
        strLDAPDN - Distinguished name of the user in LDAP.
        Returns:
        the UserSyncBean instance
        Throws:
        java.rmi.RemoteException
        javax.persistence.NoResultException
        ECException