Class AbstractPasswordFilePrincipalDatabase<U extends org.apache.qpid.server.security.auth.database.PasswordPrincipal>

    • Field Detail

      • DEFAULT_ENCODING

        protected static final java.lang.String DEFAULT_ENCODING
        See Also:
        Constant Field Values
    • Method Detail

      • open

        public final void open​(java.io.File passwordFile)
                        throws java.io.IOException
        Specified by:
        open in interface PrincipalDatabase
        Throws:
        java.io.IOException
      • setPassword

        public final void setPassword​(java.security.Principal principal,
                                      javax.security.auth.callback.PasswordCallback callback)
                               throws javax.security.auth.login.AccountNotFoundException
        SASL Callback Mechanism - sets the Password in the PasswordCallback based on the value in the PasswordFile If you want to change the password for a user, use updatePassword instead.
        Specified by:
        setPassword in interface PrincipalDatabase
        Parameters:
        principal - The Principal to set the password for
        callback - The PasswordCallback to call setPassword on
        Throws:
        javax.security.auth.login.AccountNotFoundException - If the Principal cannot be found in this Database
      • lookupPassword

        protected final char[] lookupPassword​(java.lang.String name)
        Looks up the password for a specified user in the password file.
        Parameters:
        name - The principal name to lookup
        Returns:
        a char[] for use in SASL.
      • compareCharArray

        protected boolean compareCharArray​(char[] a,
                                           char[] b)
      • updatePassword

        public boolean updatePassword​(java.security.Principal principal,
                                      char[] password)
                               throws javax.security.auth.login.AccountNotFoundException
        Changes the password for the specified user
        Specified by:
        updatePassword in interface PrincipalDatabase
        Parameters:
        principal - to change the password for
        password - plaintext password to set the password too
        Returns:
        True if change was successful
        Throws:
        javax.security.auth.login.AccountNotFoundException - If the given principal doesn't exist in the Database
      • createUserFromFileData

        protected abstract U createUserFromFileData​(java.lang.String[] result)
      • getLogger

        protected abstract org.slf4j.Logger getLogger()
      • savePasswordFile

        protected void savePasswordFile()
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • createUserFromPassword

        protected abstract U createUserFromPassword​(java.security.Principal principal,
                                                    char[] passwd)
      • reload

        public void reload()
                    throws java.io.IOException
        Description copied from interface: PrincipalDatabase
        Reload the database to its ensure contents are up to date
        Specified by:
        reload in interface PrincipalDatabase
        Throws:
        java.io.IOException - If there was an error reloading the database
      • getUsers

        public java.util.List<java.security.Principal> getUsers()
        Specified by:
        getUsers in interface PrincipalDatabase
      • getUser

        public java.security.Principal getUser​(java.lang.String username)
        Description copied from interface: PrincipalDatabase
        Get the principal from the database with the given username
        Specified by:
        getUser in interface PrincipalDatabase
        Parameters:
        username - of the principal to lookup
        Returns:
        The Principal object for the given username or null if not found.
      • deletePrincipal

        public boolean deletePrincipal​(java.security.Principal principal)
                                throws javax.security.auth.login.AccountNotFoundException
        Description copied from interface: PrincipalDatabase
        Delete a principal
        Specified by:
        deletePrincipal in interface PrincipalDatabase
        Parameters:
        principal - The principal to delete
        Returns:
        True on a successful creation
        Throws:
        javax.security.auth.login.AccountNotFoundException - If the given principal doesn't exist in the Database
      • createPrincipal

        public boolean createPrincipal​(java.security.Principal principal,
                                       char[] password)
        Description copied from interface: PrincipalDatabase
        Create a new principal in the database
        Specified by:
        createPrincipal in interface PrincipalDatabase
        Parameters:
        principal - The principal to create
        password - The password to set for the principal
        Returns:
        True on a successful creation