Class UserProfileHandler

    • Constructor Detail

      • UserProfileHandler

        public UserProfileHandler()
    • Method Detail

      • getById

        public UserProfile getById​(UserContext uc,
                                   Long id)
        Description copied from interface: IUserProfileHandler
        Reads the entity with the given ID. Hibernate proxy fields may be initialized if requested.
        Specified by:
        getById in interface IUserProfileHandler
        Parameters:
        uc - user context for accessing the database
        id - of the entity
        Returns:
        the entity with the given ID with possibly initialized hibernate fields.
      • update

        public UserProfile update​(UserContext uc,
                                  UserProfile entity)
        Description copied from interface: IUserProfileHandler
        Updates the given user profile and returns the updated entity. Hibernate proxy fields may be initialized if requested.
        Specified by:
        update in interface IUserProfileHandler
        Parameters:
        uc - user context for accessing the database
        entity - to update
        Returns:
        the updated entity with possibly initialized hibernate fields.
      • getByLoginId

        public UserProfile getByLoginId​(UserContext uc,
                                        String loginId)
        Description copied from interface: IUserProfileHandler
        Finds the user profile by the given login ID. This ID may be the users primary email address or user name.
        Specified by:
        getByLoginId in interface IUserProfileHandler
        Parameters:
        uc - user context for accessing the database
        loginId - primary email address (case irrelevant) or user name of the user profile.
        Returns:
        The user profile for the given login ID or null.
      • getByVerifiedEmailAddress

        public UserProfile getByVerifiedEmailAddress​(UserContext uc,
                                                     String email)
        Description copied from interface: IUserProfileHandler
        Finds the user profile with the given verified email address.
        Specified by:
        getByVerifiedEmailAddress in interface IUserProfileHandler
        Parameters:
        uc - User context for database transactions.
        email - of the user profile (case irrelevant).
        Returns:
        The user profile with the given verified email or null.
      • getByVerifiedPrimaryEmailAddress

        public UserProfile getByVerifiedPrimaryEmailAddress​(UserContext uc,
                                                            String email)
        Description copied from interface: IUserProfileHandler
        Finds the user profile with the given verified primary email address.
        Specified by:
        getByVerifiedPrimaryEmailAddress in interface IUserProfileHandler
        Parameters:
        uc - User context for database transactions.
        email - of the user profile (case irrelevant).
        Returns:
        The user profile with the given verified primary email or null.
      • getByUserName

        public UserProfile getByUserName​(UserContext uc,
                                         String userName)
        Description copied from interface: IUserProfileHandler
        Finds the user profile with the given user name
        Specified by:
        getByUserName in interface IUserProfileHandler
        Parameters:
        uc - Current user context for database transactions.
        userName - of the user profile
        Returns:
        The user profile with the given user name or null.
      • getByVerifiedCallback

        public UserProfile getByVerifiedCallback​(UserContext uc,
                                                 String identifier,
                                                 String callbackUuid)
        Description copied from interface: IUserProfileHandler
        Finds the user profile by the given callback information. The callback information includes the client name which identifies the SystemAuthenticator or the authenticator type and the user identity identifier.
        Specified by:
        getByVerifiedCallback in interface IUserProfileHandler
        Parameters:
        uc - User context for database transactions.
        identifier - Identifier of the user identity.
        callbackUuid - Identifies the SystemAuthenticator or the authenticator type.
        Returns:
        The user profile matching the callback information.
      • getByUuid

        public UserProfile getByUuid​(UserContext uc,
                                     UUID uuid)
        Description copied from interface: IUserProfileHandler
        Finds the user credentials with the given UUID.
        Specified by:
        getByUuid in interface IUserProfileHandler
        Parameters:
        uc - User context for database transactions.
        uuid - of the user profile.
        Returns:
        The user profile with the given UUID.
      • getByUserProfile

        public UserProfile getByUserProfile​(UserContext uc,
                                            org.pac4j.core.profile.UserProfile pac4jProfile)
        Description copied from interface: IUserProfileHandler
        Finds the formcycle user profile for the given pac4j profile.
        Specified by:
        getByUserProfile in interface IUserProfileHandler
        Parameters:
        uc - User context for database transactions.
        pac4jProfile - pac4j user profile to find the formcycle user profile for.
        Returns:
        The user profile for the Pac4J profile, if any.
      • findUniqueUserName

        @NotBlank
        public @NotBlank String findUniqueUserName​(UserContext uc,
                                                   String candidate,
                                                   UserProfile exclude)
        Description copied from interface: IUserProfileHandler
        Finds a unique user name for the given candidate. If the candidate is not unique a random number will be appended.
        Specified by:
        findUniqueUserName in interface IUserProfileHandler
        Parameters:
        uc - user context for database transactions.
        candidate - desired user name.
        exclude - user profile to be excluded from search.
        Returns:
        a unique user name.
      • isUserNameExisiting

        public boolean isUserNameExisiting​(UserContext uc,
                                           String name)
        Description copied from interface: IUserProfileHandler
        Checks if the given user name exists within the system.
        Specified by:
        isUserNameExisiting in interface IUserProfileHandler
        Parameters:
        uc - user context for database transactions.
        name - user name to check.
        Returns:
        true if the user name exists already and false otherwise.
      • validateUserLogin

        public UserProfile validateUserLogin​(UserContext uc,
                                             String loginId,
                                             String password)
        Description copied from interface: IUserProfileHandler
        Validates the given user credentials and returns the user profile if successfull.
        Specified by:
        validateUserLogin in interface IUserProfileHandler
        Parameters:
        uc - User context for database transactions.
        loginId - user name or primary email address of the user.
        password - password for the user profile.
        Returns:
        user profile if validation was successful. null otherwise.
      • addDirectClientAuthorization

        public UserProfile addDirectClientAuthorization​(UserContext uc,
                                                        UserProfile userProfile,
                                                        DirectClientAuthorization authorization)
        Description copied from interface: IUserProfileHandler
        Adds the given client authorizations to the user profile. If the user profile already has an authorization to client than the authorizations will be merged, meaning that all roles and user groups will be added to the existing client authorization of the user profile.
        Specified by:
        addDirectClientAuthorization in interface IUserProfileHandler
        Parameters:
        uc - User context for database transactions.
        userProfile - to add the direct client authorization to.
        authorization - to add.
        Returns:
        the updated user profile or null if an error occurred and the client authorization could not be added.
      • mergeUserProfiles

        @NotNull
        public @NotNull UserProfile mergeUserProfiles​(UserContext uc,
                                                      UserProfile main,
                                                      UserProfile toBeMerged)
        Description copied from interface: IUserProfileHandler
        Merges the a profile into another. Emails, identities, authorizations, permissions, roles, credentials, files will be added / merged. The custom user properties won't be affected. The profile that will be merged into the other profile will be deleted when the merge has completed.
        Specified by:
        mergeUserProfiles in interface IUserProfileHandler
        Parameters:
        uc - User context for database transactions.
        main - to be extended by merging another profile into it.
        toBeMerged - profile that will be merged into the main profile. This profile will be deleted when the merge has completed.
        Returns:
        the extended user profile.
      • acceptDirectClientAuthorization

        public UserProfile acceptDirectClientAuthorization​(UserContext uc,
                                                           UserProfile profile,
                                                           DirectClientAuthorization authorization)
        Description copied from interface: IUserProfileHandler
        Adds the given client authorization to the given profile and accepts it. If an authorization for the client already exists than the authorizations will be merged.
        Specified by:
        acceptDirectClientAuthorization in interface IUserProfileHandler
        Parameters:
        uc - User context for database transactions
        profile - User profile to add the client authorization to.
        authorization - Client authorization to add
        Returns:
        The user profile with the added client authorization.
      • canBeDeleted

        public boolean canBeDeleted​(UserContext uc,
                                    UserProfile profile)
        Description copied from interface: IUserProfileHandler
        Checks whether or not the user profile can be deleted. User profiles can't be deleted if they are the only admin of existing clients. If the user profile can't be deleted the given user context will contain a set of clients for which the user profile is the only client admin.
        Specified by:
        canBeDeleted in interface IUserProfileHandler
        Parameters:
        uc - User context for database transactions.
        profile - to check.
        Returns:
        true id the user profile can be deleted (is not the single admin of any existing clients) and false otherwise.