Package org.opensaml.security.credential

# Class BasicCredential

java.lang.Object
org.opensaml.security.credential.AbstractCredential
org.opensaml.security.credential.BasicCredential

All Implemented Interfaces:
  `Credential`, `MutableCredential`

Direct Known Subclasses:
  `BasicKeyAgreementCredential`, `BasicX509Credential`

public class BasicCredential extends AbstractCredential implements MutableCredential
A basic implementation of `Credential`.

## Constructor Summary

Constructors
Constructor
Description
`BasicCredential()`
Default constructor.
`BasicCredential(PublicKey publicKey)`
Constructor.
`BasicCredential(PublicKey publicKey, PrivateKey privateKey)`
Constructor.
`BasicCredential(SecretKey secretKey)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`Class<? extends Credential>`
`getCredentialType()`
Get the primary type of the credential instance.
`void`
`setEntityId(String newEntityId)`
Sets the ID of the entity this credential is for.
`void`
`setPrivateKey(PrivateKey newPrivateKey)`
Sets the private key for this credential.
`void`
`setPublicKey(PublicKey newPublicKey)`
Sets the public key for this credential.
`void`
`setSecretKey(SecretKey newSecretKey)`
Sets the secret key for this credential.
`void`
`setUsageType(UsageType newUsageType)`
Sets the usage type for this credential.

### Methods inherited from class org.opensaml.security.credential.AbstractCredential

`getCredentialContextSet, getEntityId, getKeyNames, getPrivateKey, getPublicKey, getSecretKey, getUsageType`

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

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

### Methods inherited from interface org.opensaml.security.credential.Credential

`getCredentialContextSet, getEntityId, getKeyNames, getPrivateKey, getPublicKey, getSecretKey, getUsageType`

## Constructor Details

### BasicCredential

public BasicCredential()
Default constructor.

### BasicCredential

public BasicCredential(@Nonnull PublicKey publicKey)
Constructor.

Parameters:
  `publicKey` - the credential public key

### BasicCredential

public BasicCredential(@Nonnull PublicKey publicKey, @Nullable PrivateKey privateKey)
Constructor.

Parameters:
  `publicKey` - the credential public key
  `privateKey` - the credential private key

### BasicCredential

public BasicCredential(@Nonnull SecretKey secretKey)
Constructor.

Parameters:
  `secretKey` - the credential secret key

## Method Details

### getCredentialType

@Nonnull public 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.

Specified by:
  `getCredentialType` in interface `Credential`
Returns:
  the credential type

### setEntityId

public void setEntityId(@Nullable String newEntityId)
Sets the ID of the entity this credential is for.

Specified by:
  `setEntityId` in interface `MutableCredential`
Overrides:
  `setEntityId` in class `AbstractCredential`
Parameters:
  `newEntityId` - ID of the entity this credential is for

### setUsageType

public void setUsageType(@Nonnull UsageType newUsageType)
Sets the usage type for this credential.

Specified by:
  `setUsageType` in interface `MutableCredential`
Overrides:
  `setUsageType` in class `AbstractCredential`
Parameters:
  `newUsageType` - usage type for this credential

### setPublicKey

public void setPublicKey(@Nonnull PublicKey newPublicKey)
Sets the public key for this credential.

Specified by:
  `setPublicKey` in interface `MutableCredential`
Overrides:
  `setPublicKey` in class `AbstractCredential`
Parameters:
  `newPublicKey` - public key for this credential

### setPrivateKey

public void setPrivateKey(@Nonnull PrivateKey newPrivateKey)
Sets the private key for this credential.

Specified by:
  `setPrivateKey` in interface `MutableCredential`
Overrides:
  `setPrivateKey` in class `AbstractCredential`
Parameters:
  `newPrivateKey` - private key for this credential

### setSecretKey

public void setSecretKey(@Nonnull SecretKey newSecretKey)
Sets the secret key for this credential.

Specified by:
  `setSecretKey` in interface `MutableCredential`
Overrides:
  `setSecretKey` in class `AbstractCredential`
Parameters:
  `newSecretKey` - secret key for this credential