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 thisSQLPrincipal
.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.
-
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 thename
isnull
.
-
-
Method Details
-
getName
public java.lang.String getName()Returns the name of this principal.- Specified by:
getName
in interfacejava.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 interfacejava.security.Principal
- Overrides:
toString
in classjava.lang.Object
- Returns:
- The principal's name.
-
hashCode
public int hashCode()Returns a hash code for this principal.- Specified by:
hashCode
in interfacejava.security.Principal
- Overrides:
hashCode
in classjava.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 interfacejava.security.Principal
- Overrides:
equals
in classjava.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 thisSQLPrincipal
.- Specified by:
destroy
in interfacejavax.security.auth.Destroyable
-