Class KeySecret
- java.lang.Object
-
- jadex.platform.service.security.auth.AbstractAuthenticationSecret
-
- jadex.platform.service.security.auth.SharedSecret
-
- jadex.platform.service.security.auth.KeySecret
-
- All Implemented Interfaces:
java.lang.Cloneable
public class KeySecret extends SharedSecret
Authentication secret based on a shared key.
-
-
Field Summary
Fields Modifier and Type Field Description protected byte[]keyThe password.protected static intMIN_KEY_LENGTHKey length warning threshold.static java.lang.StringPREFIXPrefix used to encode secret type as strings.-
Fields inherited from class jadex.platform.service.security.auth.AbstractAuthenticationSecret
SECRET_TYPES
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static KeySecretcreateRandom()Creates a random shared key.static java.lang.StringcreateRandomAsString()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.voidsetKey(byte[] key)Sets the key.java.lang.StringtoString()Creates encoded secret.-
Methods inherited from class jadex.platform.service.security.auth.SharedSecret
canSign
-
Methods inherited from class jadex.platform.service.security.auth.AbstractAuthenticationSecret
clone, equals, fromKeyPair, fromString, fromString, hashCode, main
-
-
-
-
Field Detail
-
PREFIX
public static final java.lang.String PREFIX
Prefix used to encode secret type as strings.- See Also:
- Constant Field Values
-
MIN_KEY_LENGTH
protected static final int MIN_KEY_LENGTH
Key length warning threshold.- See Also:
- Constant Field Values
-
key
protected byte[] key
The password.
-
-
Method Detail
-
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:
deriveKeyin classSharedSecret- Parameters:
keysize- The target key size in bytes to generate.salt- Salt to use.df- Used derivation function.- Returns:
- Derived key.
-
toString
public java.lang.String toString()
Creates encoded secret.- Overrides:
toStringin classjava.lang.Object- Returns:
- Encoded secret.
-
createRandom
public static final KeySecret createRandom()
Creates a random shared key.- Returns:
- Random shared key.
-
createRandomAsString
public static final java.lang.String createRandomAsString()
Creates a random shared key.- Returns:
- Random shared key.
-
-