Class GroovyOrgBuilder


  • @Scriptable
    public final class GroovyOrgBuilder
    extends Object
    Since:
    Intrexx 5.2.
    • Constructor Detail

      • GroovyOrgBuilder

        public GroovyOrgBuilder​(IProcessingContext p_ctx,
                                de.uplanet.lucy.server.session.ISessionManagerSupplier p_funSessionManager,
                                de.uplanet.lucy.server.usermanager.orgstructure.IOrgStructure p_org,
                                de.uplanet.lucy.server.usermanager.ds.IDsDbSchema p_schema,
                                de.uplanet.lucy.server.usermanager.ds.IDsRecordFactory p_dsRecFac,
                                DsClass p_dsUserClass,
                                IDsucObject p_dsucObject,
                                IDsucUser p_dsucUser,
                                IDsucSet p_dsucSet,
                                IDsucGetMembers p_dsucGetMembers,
                                Path p_dirUserImage,
                                de.uplanet.lucy.usermanager.ISecurityConfiguration p_securityConfiguration)
        Parameters:
        p_ctx - The processing context.
        p_funSessionManager - The session manager.
        p_org - The organizational structure.
        p_schema - The user management schema.
        p_dsRecFac - The user management record factory to be used.
        p_dsUserClass -
        p_dsucObject -
        p_dsucUser -
        p_dsucSet -
        p_dsucGetMembers -
        p_dirUserImage - The directory for user images.
        p_securityConfiguration - The security configuration to be used.
    • Method Detail

      • clearLocalUserCache

        public void clearLocalUserCache()
        Clears the local user cache.
      • withOrgStructure

        public Object withOrgStructure​(groovy.lang.Closure<?> p_closure)
        Work with the organizational structure.
        Parameters:
        p_closure - A closure.
        Returns:
        The closures return value, or null.
      • getOrgStructure

        public GroovyOrgStructureWrapper getOrgStructure()
        Get the organizational structure.
        Returns:
        The Groovy org structure.
      • invalidateOrgStructureAfterCommit

        public void invalidateOrgStructureAfterCommit()
        Invalidate the organizational structure after the current transaction has been committed.
        Throws:
        IllegalStateException - If the current thread does not have a transaction.
      • existsUser

        public boolean existsUser​(String p_strGuid)
                           throws SQLException
        Check if the specified user exists.

        The method returns false if the user exists but is deactivated.

        Parameters:
        p_strGuid - The user's unique identifier (GUID).
        Returns:
        true if the specified user exists, or false otherwise.
        Throws:
        SQLException - If a database error occurred.
        IllegalArgumentException - If the given user GUID is null or invalid.
      • existsUser

        public boolean existsUser​(String p_strGuid,
                                  boolean p_bIncludeDeactivated)
                           throws SQLException
        Check if the specified user exists.
        Parameters:
        p_strGuid - The user's unique identifier (GUID).
        p_bIncludeDeactivated - false if deactivated users should be ignored, or true otherwise.
        Returns:
        true if the specified user exists, or false otherwise.
        Throws:
        SQLException - If a database error occurred.
        IllegalArgumentException - If the given user GUID is null or invalid.
        Since:
        Intrexx 6.0.
      • getUser

        public GroovyUser getUser​(String p_strGuid)
                           throws SQLException,
                                  de.uplanet.lucy.usermanager.NotFoundException
        Get the user with the specified GUID.

        Note: Do not store this user object for later use by another thread or transaction.

        Parameters:
        p_strGuid - The user's unique identifier (GUID).
        Returns:
        The user found.
        Throws:
        SQLException - If a database error occurred.
        de.uplanet.lucy.usermanager.NotFoundException - If the requested user was deactivated or could not be found in the database.
        IllegalArgumentException - If the given user GUID is null or invalid.
      • getUser

        public GroovyUser getUser​(String p_strGuid,
                                  boolean p_bIncludeDeactivated)
                           throws SQLException,
                                  de.uplanet.lucy.usermanager.NotFoundException
        Get the user with the specified GUID.

        Note: Do not store this user object for later use by another thread or transaction.

        Parameters:
        p_strGuid - The user's unique identifier (GUID).
        p_bIncludeDeactivated - false if deactivated users should be ignored, or true otherwise.
        Returns:
        The user found.
        Throws:
        SQLException - If a database error occurred.
        de.uplanet.lucy.usermanager.NotFoundException - If the requested user was not found in the database.
        IllegalArgumentException - If the given user GUID is null or invalid.
        Since:
        Intrexx 6.0.
      • existsUser

        public boolean existsUser​(long p_lId)
                           throws SQLException
        Check if the specified user exists.

        The method returns false if the user exists but is deactivated.

        Parameters:
        p_lId - The user's integer identifier.
        Returns:
        true if the specified user exists, or false otherwise.
        Throws:
        SQLException - If a database error occurred.
        Since:
        Intrexx 6.0.
      • existsUser

        public boolean existsUser​(long p_lId,
                                  boolean p_bIncludeDeactivated)
                           throws SQLException
        Check if the specified user exists.
        Parameters:
        p_lId - The user's integer identifier.
        p_bIncludeDeactivated - false if deactivated users should be ignored, or true otherwise.
        Returns:
        true if the specified user exists, or false otherwise.
        Throws:
        SQLException - If a database error occurred.
        Since:
        Intrexx 6.0.
      • getUser

        public GroovyUser getUser​(long p_lId)
                           throws SQLException,
                                  de.uplanet.lucy.usermanager.NotFoundException
        Get the user with the specified integer ID.

        Note: Do not use this method except in cases where only the user's integer ID is known.

        Note: Do not store this user object for later use by another thread or transaction.

        Parameters:
        p_lId - The user's integer identifier.
        Returns:
        The user found.
        Throws:
        SQLException - If a database error occurred.
        de.uplanet.lucy.usermanager.NotFoundException - If the requested user was deactivated or not found in the database.
      • getUser

        public GroovyUser getUser​(long p_lId,
                                  boolean p_bIncludeDeactivated)
                           throws SQLException,
                                  de.uplanet.lucy.usermanager.NotFoundException
        Get the user with the specified integer ID.

        Note: Do not use this method except in cases where only the user's integer ID is known.

        Note: Do not store this user object for later use by another thread or transaction.

        Parameters:
        p_lId - The user's integer identifier.
        p_bIncludeDeactivated - false if deactivated users should be ignored, or true otherwise.
        Returns:
        The user found.
        Throws:
        SQLException - If a database error occurred.
        de.uplanet.lucy.usermanager.NotFoundException - If the requested user was not found in the database.
        Since:
        Intrexx 6.0.
      • existsUser

        public boolean existsUser​(String p_strLoginName,
                                  String p_strLoginDomain)
                           throws SQLException
        Check if the specified user exists.

        The method returns false if the user exists but is deactivated.

        Parameters:
        p_strLoginName - The login name.
        p_strLoginDomain - The login domain.
        Returns:
        true if the specified user exists, or false otherwise.
        Throws:
        SQLException - If a database error occurred.
      • existsUser

        public boolean existsUser​(String p_strLoginName,
                                  String p_strLoginDomain,
                                  boolean p_bIncludeDeactivated)
                           throws SQLException
        Check if the specified user exists.
        Parameters:
        p_strLoginName - The login name.
        p_strLoginDomain - The login domain.
        p_bIncludeDeactivated - false if deactivated users should be ignored, or true otherwise.
        Returns:
        true if the specified user exists, or false otherwise.
        Throws:
        SQLException - If a database error occurred.
        Since:
        Intrexx 6.0.
      • getUser

        public GroovyUser getUser​(String p_strLoginName,
                                  String p_strLoginDomain)
                           throws SQLException,
                                  de.uplanet.lucy.usermanager.NotFoundException
        Get the user with the specified login name and domain.

        Note: Do not store this user object for later use by another thread or transaction.

        Parameters:
        p_strLoginName - The login name.
        p_strLoginDomain - The login domain.
        Returns:
        The user found.
        Throws:
        SQLException - If a database error occurred.
        de.uplanet.lucy.usermanager.NotFoundException - If the requested user was deactivated or not found in the database.
        IllegalArgumentException - If p_strLoginName is null.
      • getUser

        public GroovyUser getUser​(String p_strLoginName,
                                  String p_strLoginDomain,
                                  boolean p_bIncludeDeactivated)
                           throws SQLException,
                                  de.uplanet.lucy.usermanager.NotFoundException
        Get the user with the specified login name and domain.

        Note: Do not store this user object for later use by another thread or transaction.

        Parameters:
        p_strLoginName - The login name.
        p_strLoginDomain - The login domain.
        p_bIncludeDeactivated - false if deactivated users should be ignored, or true otherwise.
        Returns:
        The user found.
        Throws:
        SQLException - If a database error occurred.
        de.uplanet.lucy.usermanager.NotFoundException - If the requested user was not found in the database.
        IllegalArgumentException - If p_strLoginName is null.
        Since:
        Intrexx 6.0.
      • deleteUser

        public void deleteUser​(String p_strGuid)
                        throws Exception
        Delete the user with the specified GUID.
        Parameters:
        p_strGuid - The user's unique identifier (GUID).
        Throws:
        Exception - If an error occurred.
      • createUser

        public GroovyUser createUser​(groovy.lang.Closure<?> p_closure)
                              throws de.uplanet.lucy.server.usermanager.groovy.OrgBuilderException,
                                     IOException,
                                     SQLException
        Create a new user.

        The given closure's delegate will be set to a GroovyUserWrapper object.

        Note: Do not store the returned user object for later use by another thread or transaction.

        Parameters:
        p_closure - The closure that sets the users properties.
        Returns:
        The newly created user.
        Throws:
        de.uplanet.lucy.server.usermanager.groovy.OrgBuilderException - If the user could not be created, e.g. if no name or loginName was provided, or an invalid container or membership was specified.
        SQLException - If an SQL error occurred.
        IOException - If an I/O error occurred.
      • deleteSet

        public void deleteSet​(String p_strGuid)
                       throws SQLException
        Delete the set with the specified GUID.
        Parameters:
        p_strGuid - The set's unique identifier (GUID).
        Throws:
        IllegalArgumentException - If no set was found for the GUID.
        SQLException - If an SQL error occurred.
      • deleteContainer

        public void deleteContainer​(String p_strGuid)
                             throws SQLException
        Delete the container with the specified GUID.
        Parameters:
        p_strGuid - The container's unique identifier (GUID).
        Throws:
        IllegalArgumentException - If no container was found for the GUID.
        SQLException - If an SQL error occurred.
      • createSet

        public GroovyDsSetNode createSet​(String p_strClassName,
                                         groovy.lang.Closure<?> p_closure)
                                  throws de.uplanet.lucy.server.usermanager.groovy.OrgBuilderException,
                                         SQLException
        Create a new set.

        The given closure's delegate will be set to a GroovyDsSetWrapper object.

        Note: Do not store the returned set object for later use by another thread or transaction.

        Parameters:
        p_strClassName - The name of the set class e.g. SET, GROUP or ROLE.
        p_closure - The closure that sets the sets properties.
        Returns:
        The newly created set.
        Throws:
        de.uplanet.lucy.server.usermanager.groovy.OrgBuilderException - If the user could not be created, e.g. if no name was provided, or an invalid container or membership was specified.
        SQLException - If an SQL error occurred.
      • createContainer

        public GroovyDsContainerNode createContainer​(String p_strClassName,
                                                     groovy.lang.Closure<?> p_closure)
                                              throws de.uplanet.lucy.server.usermanager.groovy.OrgBuilderException,
                                                     SQLException
        Create a new container.

        The given closure's delegate will be set to a GroovyDsContainerWrapper object.

        Note: Do not store the returned container object for later use by another thread or transaction.

        Parameters:
        p_strClassName - The name of the container class e.g. CONTAINER, ORGANIZATION or TENANT.
        p_closure - The closure that sets the containers properties.
        Returns:
        The newly created container.
        Throws:
        de.uplanet.lucy.server.usermanager.groovy.OrgBuilderException - If the user could not be created, e.g. if no name was provided, or an invalid container was specified.
        SQLException - If an SQL error occurred.
      • getEncryptedPassword

        public String getEncryptedPassword​(Map<String,​Object> p_params)
                                    throws Exception
        Derive an encrypted password suitable as an Intrexx user password stored in the user database.

        The password is derived as a secret 256 bit key using the PBKDF2 method with 10000 iterations.

      • password: The password to be encrypted.
      • salt (optional): A salt value for the user's password. If this parameter is not specified this method will randomly generate a standard salt value.

Parameters:
p_params - The named input parameters.
Returns:
The encrypted password.
Throws:
Exception
Since:
Intrexx 9.2.
See Also:
createSaltedPasswordHash(String)