@Test public void toSignaturePolicyIdentifierUnexpectedAlgorithmTest() { junitExpectedException.expect(IllegalArgumentException.class); junitExpectedException.expectMessage("Invalid policy hash algorithm"); new SignaturePolicyInfo(POLICY_IDENTIFIER, POLICY_HASH, "SHA-12345", POLICY_URI).toSignaturePolicyIdentifier(); }
SignaturePolicyIdentifier toSignaturePolicyIdentifier() { String algId = DigestAlgorithms.getAllowedDigest(this.policyDigestAlgorithm); if (algId == null || algId.length() == 0) { throw new IllegalArgumentException("Invalid policy hash algorithm"); } 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(new ASN1ObjectIdentifier(algId)), new DEROctetString(this.policyHash)), SignUtils.createSigPolicyQualifiers(spqi))); return signaturePolicyIdentifier; }
SignaturePolicyInfo { SignaturePolicyIdentifier toSignaturePolicyIdentifier() { String algId = DigestAlgorithms.getAllowedDigest(this.policyDigestAlgorithm); if (algId == null || algId.length() == 0) { throw new IllegalArgumentException("Invalid policy hash algorithm"); } 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(new ASN1ObjectIdentifier(algId)), new DEROctetString(this.policyHash)), SignUtils.createSigPolicyQualifiers(spqi))); return signaturePolicyIdentifier; } }
SignaturePolicyInfo { SignaturePolicyIdentifier toSignaturePolicyIdentifier() { String algId = DigestAlgorithms.getAllowedDigest(this.policyDigestAlgorithm); if (algId == null || algId.length() == 0) { throw new IllegalArgumentException("Invalid policy hash algorithm"); } 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(new ASN1ObjectIdentifier(algId)), new DEROctetString(this.policyHash)), SignUtils.createSigPolicyQualifiers(spqi))); return signaturePolicyIdentifier; } SignaturePolicyInfo(String policyIdentifier, byte[] policyHash, String policyDigestAlgorithm, String policyUri);  SignaturePolicyInfo(String policyIdentifier, String policyHashBase64, String policyDigestAlgorithm, String policyUri); }
SignaturePolicyInfo { SignaturePolicyIdentifier toSignaturePolicyIdentifier() { String algId = DigestAlgorithms.getAllowedDigest(this.policyDigestAlgorithm); if (algId == null || algId.length() == 0) { throw new IllegalArgumentException("Invalid policy hash algorithm"); } 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(new ASN1ObjectIdentifier(algId)), new DEROctetString(this.policyHash)), SignUtils.createSigPolicyQualifiers(spqi))); return signaturePolicyIdentifier; } SignaturePolicyInfo(String policyIdentifier, byte[] policyHash, String policyDigestAlgorithm, String policyUri);  SignaturePolicyInfo(String policyIdentifier, String policyHashBase64, String policyDigestAlgorithm, String policyUri); String getPolicyIdentifier(); byte[] getPolicyHash(); String getPolicyDigestAlgorithm(); String getPolicyUri(); }
SignaturePolicyInfo { SignaturePolicyIdentifier toSignaturePolicyIdentifier() { String algId = DigestAlgorithms.getAllowedDigest(this.policyDigestAlgorithm); if (algId == null || algId.length() == 0) { throw new IllegalArgumentException("Invalid policy hash algorithm"); } 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(new ASN1ObjectIdentifier(algId)), new DEROctetString(this.policyHash)), SignUtils.createSigPolicyQualifiers(spqi))); return signaturePolicyIdentifier; } SignaturePolicyInfo(String policyIdentifier, byte[] policyHash, String policyDigestAlgorithm, String policyUri);  SignaturePolicyInfo(String policyIdentifier, String policyHashBase64, String policyDigestAlgorithm, String policyUri); String getPolicyIdentifier(); byte[] getPolicyHash(); String getPolicyDigestAlgorithm(); String getPolicyUri();  }