Class AuthDefines.SessionKey
java.lang.Object
br.net.dd.netherwingcore.common.cryptography.authentication.AuthDefines.SessionKey
- Enclosing class:
AuthDefines
Represents a session key with a fixed length of 40 bytes.
Provides methods to create, retrieve, and update the session key while ensuring its validity.
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor that initializes the session key with an empty byte array of fixed lengthAuthDefines.SESSION_KEY_LENGTH.SessionKey(byte[] key) Constructs a session key with the given byte array. -
Method Summary
-
Constructor Details
-
SessionKey
public SessionKey()Default constructor that initializes the session key with an empty byte array of fixed lengthAuthDefines.SESSION_KEY_LENGTH. -
SessionKey
public SessionKey(byte[] key) Constructs a session key with the given byte array. The array must have a length ofAuthDefines.SESSION_KEY_LENGTH.- Parameters:
key- The byte array representing the session key.- Throws:
IllegalArgumentException- If the length of the byte array does not matchAuthDefines.SESSION_KEY_LENGTH.
-
-
Method Details
-
getKey
public byte[] getKey()Retrieves a copy of the session key. Protects the internal representation of the key by returning a copy.- Returns:
- A copy of the session key as a byte array.
-
setKey
public void setKey(byte[] newKey) Updates the current session key with a new byte array. The new byte array must have a length ofAuthDefines.SESSION_KEY_LENGTH.- Parameters:
newKey- The new byte array representing the session key.- Throws:
IllegalArgumentException- If the length of the byte array does not matchAuthDefines.SESSION_KEY_LENGTH.
-