Package org.opensaml.security.credential

# Interface Credential

All Known Subinterfaces:
  `KeyAgreementCredential`, `MutableCredential`, `X509Credential`

All Known Implementing Classes:
  `AbstractCredential`, `BasicCredential`, `BasicKeyAgreementCredential`, `BasicX509Credential`, `KeyStoreX509CredentialAdapter`, `ServletRequestX509CredentialAdapter`, `X509KeyManagerX509CredentialAdapter`

public interface Credential
A credential for an entity. A particular credential may contain either asymmetric key information (a public key and optionally the corresponding private key), or a symmetric (secret) key, but never both. With asymmetric key-based credentials, local entity credentials will usually contain both a public and private key while peer credentials will normally contain only a public key.

## Method Summary

Modifier and Type
Method
Description
`CredentialContextSet`
`getCredentialContextSet()`
Get the set of credential context information, which provides additional information specific to the contexts in which the credential was resolved.
`Class<? extends Credential>`
`getCredentialType()`
Get the primary type of the credential instance.
`String`
`getEntityId()`
The unique ID of the entity this credential is for.
`Collection<String>`
`getKeyNames()`
Gets key names for this credential.
`PrivateKey`
`getPrivateKey()`
Gets the private key for the entity if there is one.
`PublicKey`
`getPublicKey()`
Gets the public key for the entity.
`SecretKey`
`getSecretKey()`
Gets the secret key for this entity.
`UsageType`
`getUsageType()`
Gets usage type of this credential.

## Method Details

### getEntityId

@Nullable String getEntityId()
The unique ID of the entity this credential is for.

Returns:
  unique ID of the entity this credential is for

### getUsageType

@Nullable UsageType getUsageType()
Gets usage type of this credential.

Returns:
  usage type of this credential

### getKeyNames

@Nonnull Collection<String> getKeyNames()
Gets key names for this credential. These names may be used to reference a key(s) exchanged through an out-of-band agreement. Implementations may or may not implement means to resolve these names into keys retrievable through the `getPublicKey()`, `getPrivateKey()` or `getSecretKey()` methods.

Returns:
  key names for this credential

### getPublicKey

@Nullable PublicKey getPublicKey()
Gets the public key for the entity.

Returns:
  public key for the entity

### getPrivateKey

@Nullable PrivateKey getPrivateKey()
Gets the private key for the entity if there is one.

Returns:
  the private key for the entity

### getSecretKey

@Nullable SecretKey getSecretKey()
Gets the secret key for this entity.

Returns:
  secret key for this entity

### getCredentialContextSet

@Nullable CredentialContextSet getCredentialContextSet()
Get the set of credential context information, which provides additional information specific to the contexts in which the credential was resolved.

Returns:
  set of resolution contexts of the credential

### getCredentialType

@Nonnull Class<? extends Credential> getCredentialType()
Get the primary type of the credential instance. This will usually be the primary sub-interface of `Credential` implemented by an implementation.

Returns:
  the credential type