Package org.pgpainless.util
Class Passphrase
- java.lang.Object
-
- org.pgpainless.util.Passphrase
-
public class Passphrase extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description java.lang.Object
lock
-
Constructor Summary
Constructors Constructor Description Passphrase(char[] chars)
Passphrase for keys etc.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Overwrite the char array with spaces and mark thePassphrase
as invalidated.static Passphrase
emptyPassphrase()
Represents aPassphrase
instance that represents no password.boolean
equals(java.lang.Object obj)
static Passphrase
fromPassword(java.lang.String password)
Create aPassphrase
from aString
.char[]
getChars()
Return a copy of the underlying char array.int
hashCode()
boolean
isEmpty()
Return true if the passphrase represents no password.boolean
isValid()
Return true if the passphrase has not yet been cleared.
-
-
-
Method Detail
-
fromPassword
public static Passphrase fromPassword(@Nonnull java.lang.String password)
Create aPassphrase
from aString
.- Parameters:
password
- password- Returns:
- passphrase
-
clear
public void clear()
Overwrite the char array with spaces and mark thePassphrase
as invalidated.
-
getChars
@Nullable public char[] getChars()
Return a copy of the underlying char array. A return value ofnull
represents no password.- Returns:
- passphrase chars.
- Throws:
java.lang.IllegalStateException
- in case the password has been cleared at this point.
-
isValid
public boolean isValid()
Return true if the passphrase has not yet been cleared.- Returns:
- valid
-
isEmpty
public boolean isEmpty()
Return true if the passphrase represents no password.- Returns:
- empty
-
emptyPassphrase
public static Passphrase emptyPassphrase()
Represents aPassphrase
instance that represents no password.- Returns:
- empty passphrase
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
-