use of org.spongycastle.asn1.DEROctetString in project signer by demoiselle.
the class BasicCertificate method getExtensionValue.
/**
* Gets the contents of a given OID
*
* @param oid Object Identifier (OID)
*
* @return org.bouncycastle.asn1.ASN1Primitive Content related to the reported OID
*/
public ASN1Primitive getExtensionValue(String oid) {
byte[] extensionValue = certificate.getExtensionValue(oid);
if (extensionValue == null) {
return null;
}
try {
varASN1InputStream = new ASN1InputStream(extensionValue);
DEROctetString oct = (DEROctetString) varASN1InputStream.readObject();
varASN1InputStream = new ASN1InputStream(oct.getOctets());
return varASN1InputStream.readObject();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
use of org.spongycastle.asn1.DEROctetString in project signer by demoiselle.
the class PolicyIssuerName method parse.
@Override
public void parse(ASN1Primitive primitive) {
if (primitive instanceof DLSequence) {
DLSequence sequence = (DLSequence) primitive;
ASN1Encodable asn1Encodable = sequence.getObjectAt(0);
if (asn1Encodable instanceof DERTaggedObject) {
DERTaggedObject derTaggedObject = (DERTaggedObject) asn1Encodable;
ASN1Primitive object = derTaggedObject.getObject();
if (object instanceof DEROctetString) {
OctetString octetString = new OctetString();
octetString.parse(object);
this.issuerName = octetString.getValueUTF8();
} else if (object instanceof DERSequence) {
DERSequence sequence2 = (DERSequence) object;
for (int i = 0; i < sequence2.size(); i++) {
ASN1Encodable obj = sequence2.getObjectAt(i);
if (obj instanceof DERSet) {
DERSet set = (DERSet) obj;
ASN1Encodable object2 = set.getObjectAt(0);
if (object2 instanceof DERSequence) {
DERSequence sequence3 = (DERSequence) object2;
ObjectIdentifier objectIdendifier = new ObjectIdentifier();
objectIdendifier.parse(sequence3.getObjectAt(0).toASN1Primitive());
String name = null;
ASN1Encodable object3 = sequence3.getObjectAt(1);
if (object3 instanceof DERPrintableString) {
name = ((DERPrintableString) object3).getString();
} else if (object3 instanceof DERUTF8String) {
name = ((DERUTF8String) object3).getString();
} else {
System.out.println(policyMessagesBundle.getString("error.not.recognized.object", object3.getClass(), object3.toString()));
}
if (this.issuerNames == null) {
this.issuerNames = new HashMap<ObjectIdentifier, String>();
}
this.issuerNames.put(objectIdendifier, name);
}
}
}
}
}
}
}
use of org.spongycastle.asn1.DEROctetString in project signer by demoiselle.
the class SignaturePolicy method parse.
public void parse(ASN1Primitive derObject) {
ASN1Sequence derSequence = ASN1Object.getDERSequence(derObject);
this.signPolicyHashAlg = new AlgorithmIdentifier();
this.signPolicyHashAlg.parse(derSequence.getObjectAt(0).toASN1Primitive());
this.signPolicyInfo = new SignPolicyInfo();
this.signPolicyInfo.parse(derSequence.getObjectAt(1).toASN1Primitive());
if (derSequence.size() == 3) {
this.signPolicyHash = new SignPolicyHash((DEROctetString) derSequence.getObjectAt(2));
}
}
use of org.spongycastle.asn1.DEROctetString in project signer by demoiselle.
the class OctetString method parse.
@Override
public void parse(ASN1Primitive derObject) {
if (derObject instanceof DEROctetString) {
this.derOctetString = (DEROctetString) derObject;
String octetString = derOctetString.toString();
octetString = octetString.substring(1);
this.setValue(octetString);
}
}
use of org.spongycastle.asn1.DEROctetString in project signer by demoiselle.
the class PolicyInfo method parse.
@Override
public void parse(ASN1Primitive primitive) {
ASN1Sequence sequence1 = ASN1Object.getDERSequence(primitive);
this.signingPeriod = new SigningPeriod();
this.signingPeriod.parse(sequence1.getObjectAt(0).toASN1Primitive());
int indice = 2;
ASN1Primitive secondObject = sequence1.getObjectAt(1).toASN1Primitive();
if (secondObject instanceof ASN1ObjectIdentifier) {
indice = 1;
}
if (indice == 2) {
this.revocationDate = new GeneralizedTime();
this.revocationDate.parse(secondObject);
}
this.policyOID = new ObjectIdentifier();
this.policyOID.parse(sequence1.getObjectAt(indice).toASN1Primitive());
DERIA5String policyURI = (DERIA5String) sequence1.getObjectAt(indice + 1);
this.policyURI = policyURI.getString();
ASN1Primitive policyDigest = sequence1.getObjectAt(indice + 2).toASN1Primitive();
ASN1Sequence sequence2 = ASN1Sequence.getInstance(policyDigest);
DEROctetString derOctetString = (DEROctetString) sequence2.getObjectAt(1).toASN1Primitive();
ASN1Sequence sequence3 = ASN1Object.getDERSequence(sequence2.getObjectAt(0).toASN1Primitive());
ASN1ObjectIdentifier objectIdentifier = (ASN1ObjectIdentifier) sequence3.getObjectAt(0).toASN1Primitive();
AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(objectIdentifier);
this.policyDigest = new OtherHashAlgAndValue(algorithmIdentifier, derOctetString);
}
Aggregations