com.bouncycastle.asn1.x509.PolicyQualifierInfo Maven / Gradle / Ivy
The newest version!
package com.bouncycastle.asn1.x509;
import com.bouncycastle.asn1.ASN1Encodable;
import com.bouncycastle.asn1.ASN1EncodableVector;
import com.bouncycastle.asn1.ASN1Sequence;
import com.bouncycastle.asn1.DEREncodable;
import com.bouncycastle.asn1.DERObject;
import com.bouncycastle.asn1.DERIA5String;
import com.bouncycastle.asn1.DERObjectIdentifier;
import com.bouncycastle.asn1.DERSequence;
/**
* Policy qualifiers, used in the X509V3 CertificatePolicies
* extension.
*
*
* PolicyQualifierInfo ::= SEQUENCE {
* policyQualifierId PolicyQualifierId,
* qualifier ANY DEFINED BY policyQualifierId }
*
*/
public class PolicyQualifierInfo
extends ASN1Encodable
{
private DERObjectIdentifier policyQualifierId;
private DEREncodable qualifier;
/**
* Creates a new PolicyQualifierInfo
instance.
*
* @param policyQualifierId a PolicyQualifierId
value
* @param qualifier the qualifier, defined by the above field.
*/
public PolicyQualifierInfo(
DERObjectIdentifier policyQualifierId,
DEREncodable qualifier)
{
this.policyQualifierId = policyQualifierId;
this.qualifier = qualifier;
}
/**
* Creates a new PolicyQualifierInfo
containing a
* cPSuri qualifier.
*
* @param cps the CPS (certification practice statement) uri as a
* String
.
*/
public PolicyQualifierInfo(
String cps)
{
policyQualifierId = PolicyQualifierId.id_qt_cps;
qualifier = new DERIA5String(cps);
}
/**
* Creates a new PolicyQualifierInfo
instance.
*
* @param as PolicyQualifierInfo
X509 structure
* encoded as an ASN1Sequence.
*/
public PolicyQualifierInfo(
ASN1Sequence as)
{
if (as.size() != 2)
{
throw new IllegalArgumentException("Bad sequence size: "
+ as.size());
}
policyQualifierId = DERObjectIdentifier.getInstance(as.getObjectAt(0));
qualifier = as.getObjectAt(1);
}
public static PolicyQualifierInfo getInstance(
Object as)
{
if (as instanceof PolicyQualifierInfo)
{
return (PolicyQualifierInfo)as;
}
else if (as instanceof ASN1Sequence)
{
return new PolicyQualifierInfo((ASN1Sequence)as);
}
throw new IllegalArgumentException("unknown object in getInstance.");
}
public DERObjectIdentifier getPolicyQualifierId()
{
return policyQualifierId;
}
public DEREncodable getQualifier()
{
return qualifier;
}
/**
* Returns a DER-encodable representation of this instance.
*
* @return a DERObject
value
*/
public DERObject toASN1Object()
{
ASN1EncodableVector dev = new ASN1EncodableVector();
dev.add(policyQualifierId);
dev.add(qualifier);
return new DERSequence(dev);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy