List of usage examples for org.bouncycastle.asn1.esf SignaturePolicyIdentifier SignaturePolicyIdentifier
public SignaturePolicyIdentifier(SignaturePolicyId signaturePolicyId)
From source file:com.itextpdf.signatures.SignaturePolicyInfo.java
License:Open Source License
SignaturePolicyIdentifier toSignaturePolicyIdentifier() {
String algId = DigestAlgorithms.getAllowedDigest(this.policyDigestAlgorithm);
if (algId == null || algId.length() == 0) {
throw new IllegalArgumentException("Invalid policy hash algorithm");
}/* w w w .j av a 2 s. co m*/
SignaturePolicyIdentifier signaturePolicyIdentifier = null;
SigPolicyQualifierInfo spqi = null;
if (this.policyUri != null && this.policyUri.length() > 0) {
spqi = new SigPolicyQualifierInfo(PKCSObjectIdentifiers.id_spq_ets_uri,
new DERIA5String(this.policyUri));
}
signaturePolicyIdentifier = new SignaturePolicyIdentifier(new SignaturePolicyId(
DERObjectIdentifier
.getInstance(new DERObjectIdentifier(this.policyIdentifier.replace("urn:oid:", ""))),
new OtherHashAlgAndValue(new AlgorithmIdentifier(algId), new DEROctetString(this.policyHash)),
SignUtils.createSigPolicyQualifiers(spqi)));
return signaturePolicyIdentifier;
}
From source file:eu.europa.ec.markt.dss.signature.cades.CAdESLevelBaselineB.java
License:Open Source License
private void addSignaturePolicyId(final SignatureParameters parameters, final ASN1EncodableVector signedAttributes) { Policy policy = parameters.bLevel().getSignaturePolicy(); if (policy != null && policy.getId() != null) { final String policyId = policy.getId(); SignaturePolicyIdentifier sigPolicy = null; if (!"".equals(policyId)) { // explicit final ASN1ObjectIdentifier derOIPolicyId = new ASN1ObjectIdentifier(policyId); final ASN1ObjectIdentifier oid = policy.getDigestAlgorithm().getOid(); final AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(oid); OtherHashAlgAndValue otherHashAlgAndValue = new OtherHashAlgAndValue(algorithmIdentifier, new DEROctetString(policy.getDigestValue())); sigPolicy = new SignaturePolicyIdentifier( new SignaturePolicyId(derOIPolicyId, otherHashAlgAndValue)); } else {// implicit sigPolicy = new SignaturePolicyIdentifier(); }//from www. ja v a 2 s . c o m final DERSet attrValues = new DERSet(sigPolicy); final Attribute attribute = new Attribute(PKCSObjectIdentifiers.id_aa_ets_sigPolicyId, attrValues); signedAttributes.add(attribute); } }
From source file:eu.europa.ec.markt.dss.signature.cades.CAdESProfileEPES.java
License:Open Source License
@Override public Hashtable<ASN1ObjectIdentifier, ASN1Encodable> getSignedAttributes(SignatureParameters parameters) { try {// w w w . j a v a2s .c o m Hashtable<ASN1ObjectIdentifier, ASN1Encodable> signedAttrs = super.getSignedAttributes(parameters); Attribute policy = null; SignaturePolicyIdentifier sigPolicy = null; switch (parameters.getSignaturePolicy()) { case EXPLICIT: sigPolicy = new SignaturePolicyIdentifier( new SignaturePolicyId(new DERObjectIdentifier(parameters.getSignaturePolicyId()), new OtherHashAlgAndValue( new AlgorithmIdentifier(DigestAlgorithm .getByName(parameters.getSignaturePolicyHashAlgo()).getOid()), new DEROctetString(parameters.getSignaturePolicyHashValue())))); policy = new Attribute(PKCSObjectIdentifiers.id_aa_ets_sigPolicyId, new DERSet(sigPolicy)); signedAttrs.put(PKCSObjectIdentifiers.id_aa_ets_sigPolicyId, policy); break; case IMPLICIT: sigPolicy = new SignaturePolicyIdentifier(); sigPolicy.isSignaturePolicyImplied(); policy = new Attribute(PKCSObjectIdentifiers.id_aa_ets_sigPolicyId, new DERSet(sigPolicy)); signedAttrs.put(PKCSObjectIdentifiers.id_aa_ets_sigPolicyId, policy); break; case NO_POLICY: break; } return signedAttrs; } catch (NoSuchAlgorithmException ex) { throw new ProfileException(ex.getMessage()); } }