use of org.bouncycastle.asn1.esf.OtherHashAlgAndValue in project signer by demoiselle.
the class RevocationRefs method makeCrlValidatedID.
/**
* @param extract
* CrlValidatedID from X509CRL
* @return a CrlValidatedID
* @throws NoSuchAlgorithmException
* @throws CRLException
*/
private CrlValidatedID makeCrlValidatedID(X509CRL crl) throws NoSuchAlgorithmException, CRLException {
Digest digest = DigestFactory.getInstance().factoryDefault();
digest.setAlgorithm(DigestAlgorithmEnum.SHA_256);
OtherHashAlgAndValue otherHashAlgAndValue = new OtherHashAlgAndValue(new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha256), new DEROctetString(digest.digest(crl.getEncoded())));
OtherHash hash = new OtherHash(otherHashAlgAndValue);
BigInteger crlnumber;
CrlIdentifier crlid;
if (crl.getExtensionValue("2.5.29.20") != null) {
ASN1Integer varASN1Integer = new ASN1Integer(crl.getExtensionValue("2.5.29.20"));
crlnumber = varASN1Integer.getPositiveValue();
crlid = new CrlIdentifier(new X500Name(crl.getIssuerX500Principal().getName()), new DERUTCTime(crl.getThisUpdate()), crlnumber);
} else {
crlid = new CrlIdentifier(new X500Name(crl.getIssuerX500Principal().getName()), new DERUTCTime(crl.getThisUpdate()));
}
CrlValidatedID crlvid = new CrlValidatedID(hash, crlid);
return crlvid;
}
use of org.bouncycastle.asn1.esf.OtherHashAlgAndValue 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);
}
use of org.bouncycastle.asn1.esf.OtherHashAlgAndValue in project signer by demoiselle.
the class IdSigningPolicy method getValue.
/**
* org.bouncycastle.asn1.ASN1ObjectIdentifier sigPolicyId
* org.bouncycastle.asn1.esf.OtherHashAlgAndValue sigPolicyHash
* List<org.bouncycastle.asn1.esf.SigPolicyQualifierInfo> sigPolicyQualifierInfos
*/
@Override
public Attribute getValue() {
// Atributo 1
ASN1ObjectIdentifier sigPolicyId = new ASN1ObjectIdentifier(signaturePolicy.getSignPolicyInfo().getSignPolicyIdentifier().getValue());
// Atributo 2
OtherHashAlgAndValue sigPolicyHash = new OtherHashAlgAndValue(new AlgorithmIdentifier(new ASN1ObjectIdentifier(signaturePolicy.getSignPolicyHashAlg().getAlgorithm().getValue())), signaturePolicy.getSignPolicyHash().getDerOctetString());
// Atributo 3
List<SigPolicyQualifierInfo> sigPolicyQualifierInfos = new ArrayList<SigPolicyQualifierInfo>();
ASN1ObjectIdentifier sigPolicyQualifierId = new ASN1ObjectIdentifier("1.2.840.113549.1.9.16.5.1");
DERIA5String sigQualifier = new DERIA5String(signaturePolicy.getSignPolicyURI());
SigPolicyQualifierInfo bcSigPolicyQualifierInfo = new SigPolicyQualifierInfo(sigPolicyQualifierId, sigQualifier);
sigPolicyQualifierInfos.add(bcSigPolicyQualifierInfo);
SigPolicyQualifiers sigPolicyQualifiers = new SigPolicyQualifiers(sigPolicyQualifierInfos.toArray(new SigPolicyQualifierInfo[] {}));
SignaturePolicyId signaturePolicyId = new SignaturePolicyId(sigPolicyId, sigPolicyHash, sigPolicyQualifiers);
return new Attribute(new ASN1ObjectIdentifier(oid), new DERSet(signaturePolicyId));
}
Aggregations