Class KeySecret
java.lang.Object
jadex.ipc.impl.security.authentication.AbstractAuthenticationSecret
jadex.ipc.impl.security.authentication.SharedSecret
jadex.ipc.impl.security.authentication.KeySecret
- All Implemented Interfaces:
Cloneable
Authentication secret based on a shared key.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected byte[]
The password.protected static final int
Key length warning threshold.static final String
Prefix used to encode secret type as strings.Fields inherited from class jadex.ipc.impl.security.authentication.AbstractAuthenticationSecret
SECRET_TYPES
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final KeySecret
Creates a random shared key.static final String
Creates a random shared key.byte[]
deriveKey
(int keysize, byte[] salt) Derives a key from the shared secret using a salt.byte[]
getKey()
Gets the key.void
setKey
(byte[] key) Sets the key.toString()
Creates encoded secret.Methods inherited from class jadex.ipc.impl.security.authentication.SharedSecret
canSign
Methods inherited from class jadex.ipc.impl.security.authentication.AbstractAuthenticationSecret
clone, equals, fromKeyPair, fromString, fromString, hashCode, main
-
Field Details
-
PREFIX
Prefix used to encode secret type as strings.- See Also:
-
MIN_KEY_LENGTH
protected static final int MIN_KEY_LENGTHKey length warning threshold.- See Also:
-
key
protected byte[] keyThe password.
-
-
Constructor Details
-
KeySecret
public KeySecret()Creates the secret. -
KeySecret
Creates the secret. -
KeySecret
public KeySecret(byte[] key) Creates the secret. -
KeySecret
public KeySecret(byte[] key, boolean warn) Creates the secret.
-
-
Method Details
-
getKey
public byte[] getKey()Gets the key.- Returns:
- The key.
-
setKey
public void setKey(byte[] key) Sets the key.- Parameters:
key
- The key.
-
deriveKey
public byte[] deriveKey(int keysize, byte[] salt) Derives a key from the shared secret using a salt.- Specified by:
deriveKey
in classSharedSecret
- Parameters:
keysize
- The target key size in bytes to generate.salt
- Salt to use.df
- Used derivation function.- Returns:
- Derived key.
-
toString
Creates encoded secret. -
createRandom
Creates a random shared key.- Returns:
- Random shared key.
-
createRandomAsString
Creates a random shared key.- Returns:
- Random shared key.
-