P
- the type of these PBE parameters.S
- the type of the key strength.public abstract class AbstractPbeParameters<P extends AbstractPbeParameters<P,S>,S extends KeyStrength> extends AbstractSecretKey<P> implements PbeParameters<P,S>
StandardCharsets.UTF_8
.
Subclasses need to be serializable with Object(Out|In)putStream
and
XML(En|De)coder
.
Subclasses do not need to be safe for multi-threading.
Constructor and Description |
---|
AbstractPbeParameters() |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj)
Returns
true if and only if this safe key deeply equals the
given object. |
S |
getKeyStrength()
Returns the cipher key strength.
|
int |
getKeyStrengthBits()
Returns the cipher key strength in bits.
|
char[] |
getPassword()
Returns a protective copy of the password char array.
|
int |
hashCode()
Returns a hash code which is consistent with
Key.equals(Object) . |
void |
reset()
Wipes the secret data from memory and resets all properties to their
initial state.
|
void |
setKeyStrength(S keyStrength)
Sets the cipher key strength.
|
void |
setKeyStrengthBits(int bits)
Sets the cipher key strength in bits.
|
void |
setPassword(char[] password)
Copies and stores the given password char array for deriving the cipher
key.
|
String |
toString()
Returns a string representation of this object for logging and debugging
purposes.
|
clone, finalize, getSecret, isSecretSet, setSecret
getAllKeyStrengths
public boolean equals(Object obj)
Key
true
if and only if this safe key deeply equals the
given object.
A safe key equals another object if and only if the other object
has the same runtime class and all its properties compare deeply equal.equals
in interface Key<P extends AbstractPbeParameters<P,S>>
equals
in class AbstractSecretKey<P extends AbstractPbeParameters<P,S>>
@CheckForNull public S getKeyStrength()
PbeParameters
getKeyStrength
in interface PbeParameters<P extends AbstractPbeParameters<P,S>,S extends KeyStrength>
public int getKeyStrengthBits()
@Nullable public char[] getPassword()
PbeParameters
getPassword
in interface PbeParameters<P extends AbstractPbeParameters<P,S>,S extends KeyStrength>
public int hashCode()
Key
Key.equals(Object)
.
This method is provided for completeness only - you should actually
never use secret keys as hash map keys because of their mutable
properties!hashCode
in interface Key<P extends AbstractPbeParameters<P,S>>
hashCode
in class AbstractSecretKey<P extends AbstractPbeParameters<P,S>>
public void reset()
Key
reset
in interface Key<P extends AbstractPbeParameters<P,S>>
reset
in class AbstractSecretKey<P extends AbstractPbeParameters<P,S>>
public void setKeyStrength(@CheckForNull S keyStrength)
PbeParameters
setKeyStrength
in interface PbeParameters<P extends AbstractPbeParameters<P,S>,S extends KeyStrength>
keyStrength
- the cipher key strength.public void setKeyStrengthBits(int bits)
java.beans.XMLEncoder
.bits
- the cipher key strength in bits.IllegalArgumentException
- if an unknown bit size is provided.PbeParameters.getAllKeyStrengths()
public void setPassword(@CheckForNull char[] password)
PbeParameters
setPassword
in interface PbeParameters<P extends AbstractPbeParameters<P,S>,S extends KeyStrength>
password
- the password char array for deriving the cipher key.public String toString()
AbstractSecretKey
toString
in class AbstractSecretKey<P extends AbstractPbeParameters<P,S>>
Copyright © 2012–2018 Schlichtherle IT Services. All rights reserved.