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 bcutil-fips Show documentation
Show all versions of bcutil-fips Show documentation
The Bouncy Castle Java APIs for ASN.1 extension and utility APIs used to support bcpkix and bctls with the BC FIPS provider. The APIs may also be used with other providers although if being used in a FIPS context it is the responsibility of the user to ensure that any other providers used are FIPS certified and used appropriately.
/***************************************************************/
/****** DO NOT EDIT THIS CLASS bc-java SOURCE FILE ******/
/***************************************************************/
package org.bouncycastle.asn1.cmp;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.ASN1TaggedObject;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.DERTaggedObject;
public class CertRepMessage
extends ASN1Object
{
private ASN1Sequence caPubs;
private ASN1Sequence response;
private CertRepMessage(ASN1Sequence seq)
{
int index = 0;
if (seq.size() > 1)
{
caPubs = ASN1Sequence.getInstance((ASN1TaggedObject)seq.getObjectAt(index++), true);
}
response = ASN1Sequence.getInstance(seq.getObjectAt(index));
}
public static CertRepMessage getInstance(Object o)
{
if (o instanceof CertRepMessage)
{
return (CertRepMessage)o;
}
if (o != null)
{
return new CertRepMessage(ASN1Sequence.getInstance(o));
}
return null;
}
public CertRepMessage(CMPCertificate[] caPubs, CertResponse[] response)
{
if (response == null)
{
throw new IllegalArgumentException("'response' cannot be null");
}
if (caPubs != null)
{
ASN1EncodableVector v = new ASN1EncodableVector();
for (int i = 0; i < caPubs.length; i++)
{
v.add(caPubs[i]);
}
this.caPubs = new DERSequence(v);
}
{
ASN1EncodableVector v = new ASN1EncodableVector();
for (int i = 0; i < response.length; i++)
{
v.add(response[i]);
}
this.response = new DERSequence(v);
}
}
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[response.size()];
for (int i = 0; i != results.length; i++)
{
results[i] = CertResponse.getInstance(response.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 ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector();
if (caPubs != null)
{
v.add(new DERTaggedObject(true, 1, caPubs));
}
v.add(response);
return new DERSequence(v);
}
}