Class SQLPrincipal

java.lang.Object
org.proto4j.redis.sql.SQLPrincipal
All Implemented Interfaces:
java.nio.file.attribute.UserPrincipal, java.security.Principal, javax.security.auth.Destroyable

public class SQLPrincipal
extends java.lang.Object
implements java.nio.file.attribute.UserPrincipal, javax.security.auth.Destroyable
A user principal identified by a username or account name.

This principal object should be destroyed after successful initiating a new database connection. In order to wipe the stored password from memory.

Since:
1.0
See Also:
UserPrincipal, Destroyable
  • Constructor Summary

    Constructors 
    Constructor Description
    SQLPrincipal​(java.lang.String name, char[] password)
    Creates a principal.
  • Method Summary

    Modifier and Type Method Description
    void destroy()
    Destroy the password of this SQLPrincipal.
    boolean equals​(java.lang.Object obj)
    Compares this principal to the specified object.
    java.lang.String getName()
    Returns the name of this principal.
    char[] getPassword()
    Returns the password of this principal.
    int hashCode()
    Returns a hash code for this principal.
    java.lang.String toString()
    Returns a string representation of this principal.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface javax.security.auth.Destroyable

    isDestroyed

    Methods inherited from interface java.security.Principal

    implies
  • Constructor Details

    • SQLPrincipal

      public SQLPrincipal​(java.lang.String name, char[] password)
      Creates a principal.
      Parameters:
      name - The principal's string name.
      password - The principal's password used for authentication
      Throws:
      java.lang.NullPointerException - If the name is null.
  • Method Details

    • getName

      public java.lang.String getName()
      Returns the name of this principal.
      Specified by:
      getName in interface java.security.Principal
      Returns:
      The principal's name.
    • getPassword

      public char[] getPassword()
      Returns the password of this principal.
      Returns:
      The principal's password.
    • toString

      public java.lang.String toString()
      Returns a string representation of this principal.
      Specified by:
      toString in interface java.security.Principal
      Overrides:
      toString in class java.lang.Object
      Returns:
      The principal's name.
    • hashCode

      public int hashCode()
      Returns a hash code for this principal.
      Specified by:
      hashCode in interface java.security.Principal
      Overrides:
      hashCode in class java.lang.Object
      Returns:
      The principal's hash code.
    • equals

      public boolean equals​(java.lang.Object obj)
      Compares this principal to the specified object.
      Specified by:
      equals in interface java.security.Principal
      Overrides:
      equals in class java.lang.Object
      Parameters:
      obj - The object to compare this principal against.
      Returns:
      true if they are equal; false otherwise.
    • destroy

      public void destroy()
      Destroy the password of this SQLPrincipal.
      Specified by:
      destroy in interface javax.security.auth.Destroyable