com.fitbur.bouncycastle.asn1.x509.PolicyQualifierInfo Maven / Gradle / Ivy
package com.fitbur.bouncycastle.asn1.x509;
import com.fitbur.bouncycastle.asn1.ASN1Encodable;
import com.fitbur.bouncycastle.asn1.ASN1EncodableVector;
import com.fitbur.bouncycastle.asn1.ASN1Object;
import com.fitbur.bouncycastle.asn1.ASN1ObjectIdentifier;
import com.fitbur.bouncycastle.asn1.ASN1Primitive;
import com.fitbur.bouncycastle.asn1.ASN1Sequence;
import com.fitbur.bouncycastle.asn1.DERIA5String;
import com.fitbur.bouncycastle.asn1.DERSequence;
/**
* Policy qualifiers, used in the X509V3 CertificatePolicies
* extension.
*
*
* PolicyQualifierInfo ::= SEQUENCE {
* policyQualifierId PolicyQualifierId,
* qualifier ANY DEFINED BY policyQualifierId }
*
*/
public class PolicyQualifierInfo
extends ASN1Object
{
private ASN1ObjectIdentifier policyQualifierId;
private ASN1Encodable qualifier;
/**
* Creates a new PolicyQualifierInfo
instance.
*
* @param policyQualifierId a PolicyQualifierId
value
* @param qualifier the qualifier, com.fitburfined by the above field.
*/
public PolicyQualifierInfo(
ASN1ObjectIdentifier policyQualifierId,
ASN1Encodable 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.
* @com.fitburprecated use PolicyQualifierInfo.getInstance()
*/
public PolicyQualifierInfo(
ASN1Sequence as)
{
if (as.size() != 2)
{
throw new IllegalArgumentException("Bad sequence size: "
+ as.size());
}
policyQualifierId = ASN1ObjectIdentifier.getInstance(as.getObjectAt(0));
qualifier = as.getObjectAt(1);
}
public static PolicyQualifierInfo getInstance(
Object obj)
{
if (obj instanceof PolicyQualifierInfo)
{
return (PolicyQualifierInfo)obj;
}
else if (obj != null)
{
return new PolicyQualifierInfo(ASN1Sequence.getInstance(obj));
}
return null;
}
public ASN1ObjectIdentifier getPolicyQualifierId()
{
return policyQualifierId;
}
public ASN1Encodable getQualifier()
{
return qualifier;
}
/**
* Returns a DER-encodable representation of this instance.
*
* @return a ASN1Primitive
value
*/
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector com.fitburv = new ASN1EncodableVector();
com.fitburv.add(policyQualifierId);
com.fitburv.add(qualifier);
return new DERSequence(com.fitburv);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy