
org.spongycastle.asn1.cmc.ModCertTemplate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core Show documentation
Show all versions of core Show documentation
Spongy Castle is a package-rename (org.bouncycastle.* to org.spongycastle.*) of Bouncy Castle
intended for the Android platform. Android unfortunately ships with a stripped-down version of
Bouncy Castle, which prevents easy upgrades - Spongy Castle overcomes this and provides a full,
up-to-date version of the Bouncy Castle cryptographic libs.
The newest version!
package org.spongycastle.asn1.cmc;
import org.spongycastle.asn1.ASN1Boolean;
import org.spongycastle.asn1.ASN1EncodableVector;
import org.spongycastle.asn1.ASN1Object;
import org.spongycastle.asn1.ASN1Primitive;
import org.spongycastle.asn1.ASN1Sequence;
import org.spongycastle.asn1.DERSequence;
import org.spongycastle.asn1.crmf.CertTemplate;
/**
*
* id-cmc-modCertTemplate OBJECT IDENTIFIER ::= {id-cmc 31}
*
* ModCertTemplate ::= SEQUENCE {
* pkiDataReference BodyPartPath,
* certReferences BodyPartList,
* replace BOOLEAN DEFAULT TRUE,
* certTemplate CertTemplate
* }
*
*/
public class ModCertTemplate
extends ASN1Object
{
private final BodyPartPath pkiDataReference;
private final BodyPartList certReferences;
private final boolean replace;
private final CertTemplate certTemplate;
public ModCertTemplate(BodyPartPath pkiDataReference, BodyPartList certReferences, boolean replace, CertTemplate certTemplate)
{
this.pkiDataReference = pkiDataReference;
this.certReferences = certReferences;
this.replace = replace;
this.certTemplate = certTemplate;
}
private ModCertTemplate(ASN1Sequence seq)
{
if (seq.size() != 4 && seq.size() != 3)
{
throw new IllegalArgumentException("incorrect sequence size");
}
this.pkiDataReference = BodyPartPath.getInstance(seq.getObjectAt(0));
this.certReferences = BodyPartList.getInstance(seq.getObjectAt(1));
if (seq.size() == 4)
{
this.replace = ASN1Boolean.getInstance(seq.getObjectAt(2)).isTrue();
this.certTemplate = CertTemplate.getInstance(seq.getObjectAt(3));
}
else
{
this.replace = true;
this.certTemplate = CertTemplate.getInstance(seq.getObjectAt(2));
}
}
public static ModCertTemplate getInstance(Object o)
{
if (o instanceof ModCertTemplate)
{
return (ModCertTemplate)o;
}
if (o != null)
{
return new ModCertTemplate(ASN1Sequence.getInstance(o));
}
return null;
}
public BodyPartPath getPkiDataReference()
{
return pkiDataReference;
}
public BodyPartList getCertReferences()
{
return certReferences;
}
public boolean isReplacingFields()
{
return replace;
}
public CertTemplate getCertTemplate()
{
return certTemplate;
}
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(pkiDataReference);
v.add(certReferences);
if (!replace)
{
v.add(ASN1Boolean.getInstance(replace));
}
v.add(certTemplate);
return new DERSequence(v);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy