Package org.opensaml.security.messaging

# Class ServletRequestX509CredentialAdapter

java.lang.Object
org.opensaml.security.credential.AbstractCredential
org.opensaml.security.messaging.ServletRequestX509CredentialAdapter

All Implemented Interfaces:
  `Credential`, `X509Credential`

public class ServletRequestX509CredentialAdapter extends AbstractCredential implements X509Credential
An adapter that exposes the X.509 certificates contained in the servlet request attribute.

## Field Summary

Fields
Modifier and Type
Field
Description
`private X509Certificate`
`cert`
The entity certificate.
`private List<X509Certificate>`
`certChain`
The certificate chain.
`static final String`
`JAKARTA_X509_CERT_REQUEST_ATTRIBUTE`
Servlet request attribute to pull certificate info from.
`static final String`
`X509_CERT_REQUEST_ATTRIBUTE`
Servlet request attribute to pull certificate info from.

## Constructor Summary

Constructors
Constructor
Description
`ServletRequestX509CredentialAdapter(ServletRequest request)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`Class<? extends Credential>`
`getCredentialType()`
Get the primary type of the credential instance.
`Collection<X509CRL>`
`getCRLs()`
Gets a collection of CRLs associated with the credential.
`X509Certificate`
`getEntityCertificate()`
Gets the public key certificate for the entity.
`Collection<X509Certificate>`
`getEntityCertificateChain()`
Gets an immutable collection of certificates in the entity's trust chain.
`PublicKey`
`getPublicKey()`
Gets the public key for the entity.

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

`getCredentialContextSet, getEntityId, getKeyNames, getPrivateKey, getSecretKey, getUsageType, setEntityId, setPrivateKey, setPublicKey, setSecretKey, setUsageType`

### 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, getSecretKey, getUsageType`

## Field Details

### X509_CERT_REQUEST_ATTRIBUTE

@Nonnull @NotEmpty public static final String X509_CERT_REQUEST_ATTRIBUTE
Servlet request attribute to pull certificate info from.

See Also:
  - Constant Field Values

### JAKARTA_X509_CERT_REQUEST_ATTRIBUTE

@Nonnull @NotEmpty public static final String JAKARTA_X509_CERT_REQUEST_ATTRIBUTE
Servlet request attribute to pull certificate info from.

See Also:
  - Constant Field Values

### cert

@Nonnull private X509Certificate cert
The entity certificate.

### certChain

@Nonnull private List<X509Certificate> certChain
The certificate chain.

## Constructor Details

### ServletRequestX509CredentialAdapter

public ServletRequestX509CredentialAdapter(@Nonnull ServletRequest request) throws SecurityException
Constructor.

Parameters:
  `request` - the servlet request
Throws:
  `SecurityException` - if request does not contain an X.509 client certificate in request attribute 'jakarta.servlet.request.X509Certificate'

## 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

### getEntityCertificate

@Nonnull public X509Certificate getEntityCertificate()
Gets the public key certificate for the entity. The public key of this certificate will be the same key obtained from `Credential.getPublicKey()`.

Specified by:
  `getEntityCertificate` in interface `X509Credential`
Returns:
  the public key certificate for the entity

### getEntityCertificateChain

@Nonnull @Unmodifiable @NotLive public Collection<X509Certificate> getEntityCertificateChain()
Gets an immutable collection of certificates in the entity's trust chain. The entity certificate is contained within this list. No specific ordering of the certificates is guaranteed.

Specified by:
  `getEntityCertificateChain` in interface `X509Credential`
Returns:
  entities certificate chain

### getCRLs

@Nullable @Unmodifiable @NotLive public Collection<X509CRL> getCRLs()
Gets a collection of CRLs associated with the credential.

Specified by:
  `getCRLs` in interface `X509Credential`
Returns:
  CRLs associated with the credential

### getPublicKey

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

Specified by:
  `getPublicKey` in interface `Credential`
Overrides:
  `getPublicKey` in class `AbstractCredential`
Returns:
  public key for the entity