Package dev.galasa.framework.spi.creds
Class CredentialsOpaque
java.lang.Object
dev.galasa.framework.spi.creds.Credentials
dev.galasa.framework.spi.creds.AbstractCredentials
dev.galasa.framework.spi.creds.CredentialsOpaque
- All Implemented Interfaces:
ICredentials,ICredentialsOpaque
Implementation of ICredentialsOpaque that stores an opaque value
(e.g. a licence JAR file) in the Galasa Credentials Store.
The data is always stored and transmitted as a base64-encoded string.
-
Field Summary
Fields inherited from class dev.galasa.framework.spi.creds.AbstractCredentials
CREDS_PROPERTY_PREFIX -
Constructor Summary
ConstructorsConstructorDescriptionCredentialsOpaque(String base64Data) Constructor for plain-text creation (the value is already base64-encoded).CredentialsOpaque(SecretKeySpec key, String base64Data) Constructor for credentials loaded from storage (file/etcd). -
Method Summary
Modifier and TypeMethodDescriptionbyte[]getData()Returns the raw bytes of the opaque credential.Returns the opaque content as a base64-encoded string.toProperties(String credentialsId) Stores the opaque value base64-encoded under the property keysecure.credentials.<credentialsId>.data.Methods inherited from class dev.galasa.framework.spi.creds.AbstractCredentials
getDescription, getLastUpdatedByUser, getLastUpdatedTime, getMetadataProperties, setDescription, setLastUpdatedByUser, setLastUpdatedTimeMethods inherited from class dev.galasa.framework.spi.creds.Credentials
base64, decode, decrypt, decryptToStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.galasa.ICredentials
getDescription, getLastUpdatedByUser, getLastUpdatedTime, getMetadataProperties, setDescription, setLastUpdatedByUser, setLastUpdatedTime
-
Constructor Details
-
CredentialsOpaque
Constructor for plain-text creation (the value is already base64-encoded).- Parameters:
base64Data- the base64-encoded binary content- Throws:
CredentialsException- if the provided string is not valid base64
-
CredentialsOpaque
Constructor for credentials loaded from storage (file/etcd). When loaded from etcd the value may be encrypted; this constructor decrypts it first then base64-decodes to obtain the raw bytes.- Parameters:
key- the encryption key for decrypting etcd-stored credentialsbase64Data- the data (encrypted from etcd, or plain base64 from file)- Throws:
CredentialsException- if decryption or base64 decoding fails
-
-
Method Details
-
getData
public byte[] getData()Returns the raw bytes of the opaque credential.The returned array is decoded from the base64 value that was supplied when the secret was created (via
--secret-fileor--base64-secret).- Specified by:
getDatain interfaceICredentialsOpaque- Returns:
- the opaque content as a byte array; never
null
-
getEncodedData
Returns the opaque content as a base64-encoded string.This is the stored base64 value and is returned as-is in the
opaqueDatafield of theGET /secrets/{name}REST response. Callers can base64-decode it once to obtain the original raw bytes.- Specified by:
getEncodedDatain interfaceICredentialsOpaque- Returns:
- base64-encoded representation of the opaque data; never
null
-
toProperties
Stores the opaque value base64-encoded under the property keysecure.credentials.<credentialsId>.data.- Specified by:
toPropertiesin interfaceICredentials
-