org.spongycastle.asn1.x509.qualified.QCStatement Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scprov-jdk15 Show documentation
Show all versions of scprov-jdk15 Show documentation
Spongy Castle is a package-rename (org.bouncycastle.* to org.spongycastle.*) of Bouncy Castle intended for Android.
Android ships with a stripped-down version of Bouncy Castle - this causes classloader collisions if you try to add
an alternative (updated/complete) Bouncy Castle jar.
This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.5.
package org.spongycastle.asn1.x509.qualified;
import java.util.Enumeration;
import org.spongycastle.asn1.ASN1Encodable;
import org.spongycastle.asn1.ASN1Sequence;
import org.spongycastle.asn1.ASN1EncodableVector;
import org.spongycastle.asn1.DERObject;
import org.spongycastle.asn1.DERObjectIdentifier;
import org.spongycastle.asn1.DERSequence;
/**
* The QCStatement object.
*
* QCStatement ::= SEQUENCE {
* statementId OBJECT IDENTIFIER,
* statementInfo ANY DEFINED BY statementId OPTIONAL}
*
*/
public class QCStatement
extends ASN1Encodable
implements ETSIQCObjectIdentifiers, RFC3739QCObjectIdentifiers
{
DERObjectIdentifier qcStatementId;
ASN1Encodable qcStatementInfo;
public static QCStatement getInstance(
Object obj)
{
if (obj == null || obj instanceof QCStatement)
{
return (QCStatement)obj;
}
if (obj instanceof ASN1Sequence)
{
return new QCStatement(ASN1Sequence.getInstance(obj));
}
throw new IllegalArgumentException("unknown object in getInstance");
}
public QCStatement(
ASN1Sequence seq)
{
Enumeration e = seq.getObjects();
// qcStatementId
qcStatementId = DERObjectIdentifier.getInstance(e.nextElement());
// qcstatementInfo
if (e.hasMoreElements())
{
qcStatementInfo = (ASN1Encodable) e.nextElement();
}
}
public QCStatement(
DERObjectIdentifier qcStatementId)
{
this.qcStatementId = qcStatementId;
this.qcStatementInfo = null;
}
public QCStatement(
DERObjectIdentifier qcStatementId,
ASN1Encodable qcStatementInfo)
{
this.qcStatementId = qcStatementId;
this.qcStatementInfo = qcStatementInfo;
}
public DERObjectIdentifier getStatementId()
{
return qcStatementId;
}
public ASN1Encodable getStatementInfo()
{
return qcStatementInfo;
}
public DERObject toASN1Object()
{
ASN1EncodableVector seq = new ASN1EncodableVector();
seq.add(qcStatementId);
if (qcStatementInfo != null)
{
seq.add(qcStatementInfo);
}
return new DERSequence(seq);
}
}