Class CredentialsOpaque

All Implemented Interfaces:
ICredentials, ICredentialsOpaque

public class CredentialsOpaque extends AbstractCredentials implements 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.
  • Constructor Details

    • CredentialsOpaque

      public CredentialsOpaque(String base64Data) throws CredentialsException
      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

      public CredentialsOpaque(SecretKeySpec key, String base64Data) throws CredentialsException
      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 credentials
      base64Data - 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-file or --base64-secret).

      Specified by:
      getData in interface ICredentialsOpaque
      Returns:
      the opaque content as a byte array; never null
    • getEncodedData

      public String getEncodedData()
      Returns the opaque content as a base64-encoded string.

      This is the stored base64 value and is returned as-is in the opaqueData field of the GET /secrets/{name} REST response. Callers can base64-decode it once to obtain the original raw bytes.

      Specified by:
      getEncodedData in interface ICredentialsOpaque
      Returns:
      base64-encoded representation of the opaque data; never null
    • toProperties

      public Properties toProperties(String credentialsId)
      Stores the opaque value base64-encoded under the property key secure.credentials.<credentialsId>.data.
      Specified by:
      toProperties in interface ICredentials