org.bouncycastle.asn1.cmp.CertRepMessage Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcprov-jdk16 Show documentation
Show all versions of bcprov-jdk16 Show documentation
The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.6.
package org.bouncycastle.asn1.cmp;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.DERObject;
import org.bouncycastle.asn1.DERSequence;
public class CertRepMessage
extends ASN1Encodable
{
private ASN1Sequence caPubs;
private ASN1Sequence response;
private CertRepMessage(ASN1Sequence seq)
{
int index = 0;
if (seq.size() > 1)
{
caPubs = ASN1Sequence.getInstance(seq.getObjectAt(index++));
}
response = ASN1Sequence.getInstance(seq.getObjectAt(index));
}
public static CertRepMessage getInstance(Object o)
{
if (o instanceof CertRepMessage)
{
return (CertRepMessage)o;
}
if (o instanceof ASN1Sequence)
{
return new CertRepMessage((ASN1Sequence)o);
}
throw new IllegalArgumentException("Invalid object: " + o.getClass().getName());
}
public CMPCertificate[] getCaPubs()
{
if (caPubs == null)
{
return null;
}
CMPCertificate[] results = new CMPCertificate[caPubs.size()];
for (int i = 0; i != results.length; i++)
{
results[i] = CMPCertificate.getInstance(caPubs.getObjectAt(i));
}
return results;
}
public CertResponse[] getResponse()
{
CertResponse[] results = new CertResponse[caPubs.size()];
for (int i = 0; i != results.length; i++)
{
results[i] = CertResponse.getInstance(caPubs.getObjectAt(i));
}
return results;
}
/**
*
* CertRepMessage ::= SEQUENCE {
* caPubs [1] SEQUENCE SIZE (1..MAX) OF CMPCertificate
* OPTIONAL,
* response SEQUENCE OF CertResponse
* }
*
* @return a basic ASN.1 object representation.
*/
public DERObject toASN1Object()
{
ASN1EncodableVector v = new ASN1EncodableVector();
if (caPubs != null)
{
v.add(caPubs);
}
v.add(response);
return new DERSequence(v);
}
}