Class CredentialSupport


  • public final class CredentialSupport
    extends Object
    Helper methods for working with Credential instances.
    • Constructor Detail

      • CredentialSupport

        private CredentialSupport()
        Constructor.
    • Method Detail

      • extractEncryptionKey

        @Nullable
        public static Key extractEncryptionKey​(@Nullable
                                               Credential credential)
        Extract the encryption key from the credential.
        Parameters:
        credential - the credential containing the encryption key
        Returns:
        the encryption key (either a public key or a secret (symmetric) key
      • extractDecryptionKey

        @Nullable
        public static Key extractDecryptionKey​(@Nullable
                                               Credential credential)
        Extract the decryption key from the credential.
        Parameters:
        credential - the credential containing the decryption key
        Returns:
        the decryption key (either a private key or a secret (symmetric) key
      • extractSigningKey

        @Nullable
        public static Key extractSigningKey​(@Nullable
                                            Credential credential)
        Extract the signing key from the credential.
        Parameters:
        credential - the credential containing the signing key
        Returns:
        the signing key (either a private key or a secret (symmetric) key
      • extractVerificationKey

        @Nullable
        public static Key extractVerificationKey​(@Nullable
                                                 Credential credential)
        Extract the verification key from the credential.
        Parameters:
        credential - the credential containing the verification key
        Returns:
        the verification key (either a public key or a secret (symmetric) key
      • getSimpleCredential

        @Nonnull
        public static BasicCredential getSimpleCredential​(@Nonnull
                                                          SecretKey secretKey)
        Get a simple, minimal credential containing a secret (symmetric) key.
        Parameters:
        secretKey - the symmetric key to wrap
        Returns:
        a credential containing the secret key specified
      • getSimpleCredential

        @Nonnull
        public static BasicCredential getSimpleCredential​(@Nonnull
                                                          PublicKey publicKey,
                                                          @Nullable
                                                          PrivateKey privateKey)
        Get a simple, minimal credential containing a public key, and optionally a private key.
        Parameters:
        publicKey - the public key to wrap
        privateKey - the private key to wrap, which may be null
        Returns:
        a credential containing the key(s) specified
      • getSimpleCredential

        @Nonnull
        public static BasicX509Credential getSimpleCredential​(@Nonnull
                                                              X509Certificate cert,
                                                              @Nullable
                                                              PrivateKey privateKey)
        Get a simple, minimal credential containing an end-entity X.509 certificate, and optionally a private key.
        Parameters:
        cert - the end-entity certificate to wrap
        privateKey - the private key to wrap, which may be null
        Returns:
        a credential containing the certificate and key specified