Package org.opensaml.security.credential

# Class CredentialSupport

java.lang.Object
org.opensaml.security.credential.CredentialSupport

public final class CredentialSupport extends Object
Helper methods for working with `Credential` instances.

## Constructor Summary

Constructors
Modifier
Constructor
Description
`private`
`CredentialSupport()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`static Key`
`extractDecryptionKey(Credential credential)`
Extract the decryption key from the credential.
`static Key`
`extractEncryptionKey(Credential credential)`
Extract the encryption key from the credential.
`static Key`
`extractSigningKey(Credential credential)`
Extract the signing key from the credential.
`static Key`
`extractVerificationKey(Credential credential)`
Extract the verification key from the credential.
`static BasicX509Credential`
`getSimpleCredential(X509Certificate cert, PrivateKey privateKey)`
Get a simple, minimal credential containing an end-entity X.509 certificate, and optionally a private key.
`static BasicCredential`
`getSimpleCredential(PublicKey publicKey, PrivateKey privateKey)`
Get a simple, minimal credential containing a public key, and optionally a private key.
`static BasicCredential`
`getSimpleCredential(SecretKey secretKey)`
Get a simple, minimal credential containing a secret (symmetric) key.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### CredentialSupport

private CredentialSupport()
Constructor.

## Method Details

### extractEncryptionKey

@Nullable public static Key extractEncryptionKey(@Nonnull 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(@Nonnull 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(@Nonnull 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(@Nonnull 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