org.bouncycastle.cms.KeyAgreeRecipientId Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcpkix-lts8on Show documentation
Show all versions of bcpkix-lts8on Show documentation
The Bouncy Castle Java APIs for CMS, PKCS, EAC, TSP, CMP, CRMF, OCSP, and certificate generation. This jar contains APIs for JDK 1.8 and up. The APIs are designed primarily to be used in conjunction with the BC LTS provider but may also be used with other providers providing cryptographic services.
package org.bouncycastle.cms;
import java.math.BigInteger;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.cert.selector.X509CertificateHolderSelector;
public class KeyAgreeRecipientId
extends RecipientId
{
private X509CertificateHolderSelector baseSelector;
private KeyAgreeRecipientId(X509CertificateHolderSelector baseSelector)
{
super(keyAgree);
this.baseSelector = baseSelector;
}
/**
* Construct a key agree recipient ID with the value of a public key's subjectKeyId.
*
* @param subjectKeyId a subjectKeyId
*/
public KeyAgreeRecipientId(byte[] subjectKeyId)
{
this(null, null, subjectKeyId);
}
/**
* Construct a key agree recipient ID based on the issuer and serial number of the recipient's associated
* certificate.
*
* @param issuer the issuer of the recipient's associated certificate.
* @param serialNumber the serial number of the recipient's associated certificate.
*/
public KeyAgreeRecipientId(X500Name issuer, BigInteger serialNumber)
{
this(issuer, serialNumber, null);
}
public KeyAgreeRecipientId(X500Name issuer, BigInteger serialNumber, byte[] subjectKeyId)
{
this(new X509CertificateHolderSelector(issuer, serialNumber, subjectKeyId));
}
public X500Name getIssuer()
{
return baseSelector.getIssuer();
}
public BigInteger getSerialNumber()
{
return baseSelector.getSerialNumber();
}
public byte[] getSubjectKeyIdentifier()
{
return baseSelector.getSubjectKeyIdentifier();
}
public int hashCode()
{
return baseSelector.hashCode();
}
public boolean equals(
Object o)
{
if (!(o instanceof KeyAgreeRecipientId))
{
return false;
}
KeyAgreeRecipientId id = (KeyAgreeRecipientId)o;
return this.baseSelector.equals(id.baseSelector);
}
public Object clone()
{
return new KeyAgreeRecipientId(baseSelector);
}
public boolean match(Object obj)
{
if (obj instanceof KeyAgreeRecipientInformation)
{
return ((KeyAgreeRecipientInformation)obj).getRID().equals(this);
}
return baseSelector.match(obj);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy