org.bouncycastle.asn1.ASN1Set Java Examples
The following examples show how to use
org.bouncycastle.asn1.ASN1Set.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CadesLevelBaselineLTATimestampExtractor.java From dss with GNU Lesser General Public License v2.1 | 7 votes |
/** * The field crlsHashIndex is a sequence of octet strings. Each one contains the * hash value of one instance of RevocationInfoChoice within crls field of the * root SignedData. A hash value for every instance of RevocationInfoChoice, as * present at the time when the corresponding archive time-stamp is requested, * shall be included in crlsHashIndex. No other hash values shall be included in * this field. * * @return * @throws eu.europa.esig.dss.model.DSSException */ @SuppressWarnings("unchecked") private ASN1Sequence getCRLsHashIndex() { final ASN1EncodableVector crlsHashIndex = new ASN1EncodableVector(); final SignedData signedData = SignedData.getInstance(cmsSignedData.toASN1Structure().getContent()); final ASN1Set signedDataCRLs = signedData.getCRLs(); if (signedDataCRLs != null) { final Enumeration<ASN1Encodable> crLs = signedDataCRLs.getObjects(); if (crLs != null) { while (crLs.hasMoreElements()) { final ASN1Encodable asn1Encodable = crLs.nextElement(); digestAndAddToList(crlsHashIndex, DSSASN1Utils.getDEREncoded(asn1Encodable)); } } } return new DERSequence(crlsHashIndex); }
Example #2
Source File: CAdESSignature.java From dss with GNU Lesser General Public License v2.1 | 7 votes |
private SignerAttribute getSignerAttributeV1() { final Attribute id_aa_ets_signerAttr = getSignedAttribute(PKCSObjectIdentifiers.id_aa_ets_signerAttr); if (id_aa_ets_signerAttr != null) { final ASN1Set attrValues = id_aa_ets_signerAttr.getAttrValues(); final ASN1Encodable attrValue = attrValues.getObjectAt(0); try { return SignerAttribute.getInstance(attrValue); } catch (Exception e) { String warningMessage = "Unable to parse signerAttr - [{}]. Reason : {}"; if (LOG.isDebugEnabled()) { LOG.warn(warningMessage, Utils.toBase64(DSSASN1Utils.getDEREncoded(attrValue)), e.getMessage(), e); } else { LOG.warn(warningMessage, Utils.toBase64(DSSASN1Utils.getDEREncoded(attrValue)), e.getMessage()); } } } return null; }
Example #3
Source File: CertificateUtils.java From nifi with Apache License 2.0 | 6 votes |
/** * Extract extensions from CSR object */ public static Extensions getExtensionsFromCSR(JcaPKCS10CertificationRequest csr) { Attribute[] attributess = csr.getAttributes(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest); for (Attribute attribute : attributess) { ASN1Set attValue = attribute.getAttrValues(); if (attValue != null) { ASN1Encodable extension = attValue.getObjectAt(0); if (extension instanceof Extensions) { return (Extensions) extension; } else if (extension instanceof DERSequence) { return Extensions.getInstance(extension); } } } return null; }
Example #4
Source File: CMSOCSPSource.java From dss with GNU Lesser General Public License v2.1 | 6 votes |
private void collectRevocationRefs(AttributeTable unsignedAttributes, ASN1ObjectIdentifier revocationReferencesAttribute, RevocationRefOrigin origin) { final Attribute attribute = unsignedAttributes.get(revocationReferencesAttribute); if (attribute == null) { return; } final ASN1Set attrValues = attribute.getAttrValues(); if (attrValues.size() <= 0) { return; } final ASN1Encodable attrValue = attrValues.getObjectAt(0); final ASN1Sequence completeRevocationRefs = (ASN1Sequence) attrValue; for (int i = 0; i < completeRevocationRefs.size(); i++) { final CrlOcspRef otherCertId = CrlOcspRef.getInstance(completeRevocationRefs.getObjectAt(i)); final OcspListID ocspListID = otherCertId.getOcspids(); if (ocspListID != null) { for (final OcspResponsesID ocspResponsesID : ocspListID.getOcspResponses()) { final OCSPRef ocspRef = new OCSPRef(ocspResponsesID); addRevocationReference(ocspRef, origin); } } } }
Example #5
Source File: AbstractRequirementChecks.java From dss with GNU Lesser General Public License v2.1 | 6 votes |
@BeforeEach public void init() throws Exception { DSSDocument signedDocument = getSignedDocument(); ASN1InputStream asn1sInput = new ASN1InputStream(signedDocument.openStream()); ASN1Sequence asn1Seq = (ASN1Sequence) asn1sInput.readObject(); assertEquals(2, asn1Seq.size()); ASN1ObjectIdentifier oid = ASN1ObjectIdentifier.getInstance(asn1Seq.getObjectAt(0)); assertEquals(PKCSObjectIdentifiers.signedData, oid); ASN1TaggedObject taggedObj = ASN1TaggedObject.getInstance(asn1Seq.getObjectAt(1)); signedData = SignedData.getInstance(taggedObj.getObject()); ASN1Set signerInfosAsn1 = signedData.getSignerInfos(); assertEquals(1, signerInfosAsn1.size()); signerInfo = SignerInfo.getInstance(ASN1Sequence.getInstance(signerInfosAsn1.getObjectAt(0))); Utils.closeQuietly(asn1sInput); }
Example #6
Source File: CMSCertificateSource.java From dss with GNU Lesser General Public License v2.1 | 6 votes |
private void extractSigningCertificateV1(Attribute attribute) { final ASN1Set attrValues = attribute.getAttrValues(); for (int ii = 0; ii < attrValues.size(); ii++) { final ASN1Encodable asn1Encodable = attrValues.getObjectAt(ii); try { final SigningCertificate signingCertificate = SigningCertificate.getInstance(asn1Encodable); if (signingCertificate != null) { extractESSCertIDs(signingCertificate.getCerts(), CertificateRefOrigin.SIGNING_CERTIFICATE); } else { LOG.warn("SigningCertificate attribute is null"); } } catch (Exception e) { LOG.warn("SigningCertificate attribute '{}' is not well defined!", Utils.toBase64(DSSASN1Utils.getDEREncoded(asn1Encodable))); } } }
Example #7
Source File: CMSCertificateSource.java From dss with GNU Lesser General Public License v2.1 | 6 votes |
private void extractSigningCertificateV2(Attribute attribute) { final ASN1Set attrValues = attribute.getAttrValues(); for (int ii = 0; ii < attrValues.size(); ii++) { final ASN1Encodable asn1Encodable = attrValues.getObjectAt(ii); try { final SigningCertificateV2 signingCertificate = SigningCertificateV2.getInstance(asn1Encodable); if (signingCertificate != null) { extractESSCertIDv2s(signingCertificate.getCerts(), CertificateRefOrigin.SIGNING_CERTIFICATE); } else { LOG.warn("SigningCertificateV2 attribute is null"); } } catch (Exception e) { LOG.warn("SigningCertificateV2 attribute '{}' is not well defined!", Utils.toBase64(DSSASN1Utils.getDEREncoded(asn1Encodable))); } } }
Example #8
Source File: CAdESTimestampDataBuilder.java From dss with GNU Lesser General Public License v2.1 | 6 votes |
/** * Remove any archive-timestamp-v2/3 attribute added after the * timestampToken */ private ASN1Sequence filterUnauthenticatedAttributes(ASN1Set unauthenticatedAttributes, TimestampToken timestampToken) { ASN1EncodableVector result = new ASN1EncodableVector(); for (int ii = 0; ii < unauthenticatedAttributes.size(); ii++) { final Attribute attribute = Attribute.getInstance(unauthenticatedAttributes.getObjectAt(ii)); final ASN1ObjectIdentifier attrType = attribute.getAttrType(); if (id_aa_ets_archiveTimestampV2.equals(attrType) || id_aa_ets_archiveTimestampV3.equals(attrType)) { try { TimeStampToken token = DSSASN1Utils.getTimeStampToken(attribute); if (!token.getTimeStampInfo().getGenTime().before(timestampToken.getGenerationTime())) { continue; } } catch (Exception e) { throw new DSSException(e); } } result.add(unauthenticatedAttributes.getObjectAt(ii)); } return new DERSequence(result); }
Example #9
Source File: CAdESTimestampDataBuilder.java From dss with GNU Lesser General Public License v2.1 | 6 votes |
private byte[] getCRLDataBytes(final SignedData signedData) throws IOException { byte[] crlBytes = null; final ASN1Set crLs = signedData.getCRLs(); if (crLs != null) { if (signedData.getCRLs() instanceof BERSet) { crlBytes = new BERTaggedObject(false, 1, new BERSequence(crLs.toArray())).getEncoded(); } else { crlBytes = new DERTaggedObject(false, 1, new DERSequence(crLs.toArray())).getEncoded(); } if (LOG.isTraceEnabled()) { LOG.trace("CRLs: {}", DSSUtils.toHex(crlBytes)); } } if (LOG.isDebugEnabled()) { LOG.debug("CRLs are not present in the SignedData."); } return crlBytes; }
Example #10
Source File: CAdESTimestampDataBuilder.java From dss with GNU Lesser General Public License v2.1 | 6 votes |
private byte[] getCertificateDataBytes(final SignedData signedData) throws IOException { byte[] certificatesBytes = null; final ASN1Set certificates = signedData.getCertificates(); if (certificates != null) { /* * In order to calculate correct message imprint it is important * to use the correct encoding. */ if (certificates instanceof BERSet) { certificatesBytes = new BERTaggedObject(false, 0, new BERSequence(certificates.toArray())).getEncoded(); } else { certificatesBytes = new DERTaggedObject(false, 0, new DERSequence(certificates.toArray())).getEncoded(); } if (LOG.isTraceEnabled()) { LOG.trace("Certificates: {}", DSSUtils.toHex(certificatesBytes)); } } if (LOG.isDebugEnabled()) { LOG.debug("Certificates are not present in the SignedData."); } return certificatesBytes; }
Example #11
Source File: Asn1Utils.java From android-testdpc with Apache License 2.0 | 6 votes |
public static Set<Integer> getIntegersFromAsn1Set(ASN1Encodable set) throws CertificateParsingException { if (!(set instanceof ASN1Set)) { throw new CertificateParsingException( "Expected set, found " + set.getClass().getName()); } /* ImmutableSet.Builder<Integer> builder = ImmutableSet.builder(); for (Enumeration<?> e = ((ASN1Set) set).getObjects(); e.hasMoreElements();) { builder.add(getIntegerFromAsn1((ASN1Integer) e.nextElement())); } return builder.build(); */ HashSet<Integer> ret = new HashSet<>(); for (Enumeration<?> e = ((ASN1Set) set).getObjects(); e.hasMoreElements();) { ret.add(getIntegerFromAsn1((ASN1Integer) e.nextElement())); } return ret; }
Example #12
Source File: ExtensionSyntaxChecker.java From xipki with Apache License 2.0 | 6 votes |
private static void checkSetSyntax(String name, ASN1Set set, List<SubFieldSyntax> subFields) throws BadCertTemplateException { List<SubFieldSyntax> subFields0 = new ArrayList<SubFieldSyntax>(subFields); final int size = set.size(); for (int i = 0; i < size; i++) { ASN1ObjectHolder objHolder = new ASN1ObjectHolder(); objHolder.object = set.getObjectAt(i); // find the matched SubField SubFieldSyntax syntax = getSyntax(name, objHolder, subFields0); if (syntax == null) { throw new BadCertTemplateException("invalid " + name); } subFields0.remove(syntax); checkContentTextOrSubFields(name, syntax, objHolder.object); } for (SubFieldSyntax m : subFields0) { if (m.isRequired()) { throw new BadCertTemplateException("invalid " + name); } } }
Example #13
Source File: ExtensionSyntaxChecker.java From xipki with Apache License 2.0 | 6 votes |
private static void checkContentTextOrSubFields(String name, ExtnSyntax subField, ASN1Encodable obj) throws BadCertTemplateException { if (obj instanceof ASN1String) { if (subField.getStringRegex() != null) { assertMatch(name, subField.getStringRegex(), ((ASN1String) obj).getString()); } return; } FieldType syntaxType = subField.type(); if (syntaxType == FieldType.SEQUENCE) { checkSequenceSyntax(name, (ASN1Sequence) obj, subField.getSubFields()); } else if (syntaxType == FieldType.SET) { checkSetSyntax(name, (ASN1Set) obj, subField.getSubFields()); } else if (syntaxType == FieldType.SEQUENCE_OF) { checkSequenceOfOrSetOfSyntax(name, (ASN1Sequence) obj, null, subField.getSubFields()); } else if (syntaxType == FieldType.SET_OF) { checkSequenceOfOrSetOfSyntax(name, null, (ASN1Set) obj, subField.getSubFields()); } }
Example #14
Source File: AttestationApplicationId.java From android-key-attestation with Apache License 2.0 | 6 votes |
private AttestationApplicationId(DEROctetString attestationApplicationId) throws IOException { ASN1Sequence attestationApplicationIdSequence = (ASN1Sequence) ASN1Sequence.fromByteArray(attestationApplicationId.getOctets()); ASN1Set attestationPackageInfos = (ASN1Set) attestationApplicationIdSequence.getObjectAt( ATTESTATION_APPLICATION_ID_PACKAGE_INFOS_INDEX); this.packageInfos = new ArrayList<>(); for (ASN1Encodable packageInfo : attestationPackageInfos) { this.packageInfos.add(new AttestationPackageInfo((ASN1Sequence) packageInfo)); } ASN1Set digests = (ASN1Set) attestationApplicationIdSequence.getObjectAt( ATTESTATION_APPLICATION_ID_SIGNATURE_DIGESTS_INDEX); this.signatureDigests = new ArrayList<>(); for (ASN1Encodable digest : digests) { this.signatureDigests.add(((ASN1OctetString) digest).getOctets()); } }
Example #15
Source File: CAdESTimeStampSigner.java From signer with GNU Lesser General Public License v3.0 | 6 votes |
private Timestamp checkTimeStamp(byte[] timeStamp, byte[] content, byte[] hash){ try { Security.addProvider(new BouncyCastleProvider()); ais = new ASN1InputStream(new ByteArrayInputStream(timeStamp)); ASN1Sequence seq=(ASN1Sequence)ais.readObject(); Attribute attributeTimeStamp = new Attribute((ASN1ObjectIdentifier)seq.getObjectAt(0), (ASN1Set)seq.getObjectAt(1)); byte[] varTimeStamp = attributeTimeStamp.getAttrValues().getObjectAt(0).toASN1Primitive().getEncoded(); TimeStampOperator timeStampOperator = new TimeStampOperator(); if (content != null){ timeStampOperator.validate(content, varTimeStamp,null); }else{ timeStampOperator.validate(null, varTimeStamp,hash); } TimeStampToken timeStampToken = new TimeStampToken(new CMSSignedData(varTimeStamp)); Timestamp timeStampSigner = new Timestamp(timeStampToken); return timeStampSigner; } catch (CertificateCoreException | IOException | TSPException | CMSException e) { throw new SignerException(e); } }
Example #16
Source File: CertificateUtils.java From nifi-registry with Apache License 2.0 | 6 votes |
/** * Extract extensions from CSR object */ public static Extensions getExtensionsFromCSR(JcaPKCS10CertificationRequest csr) { Attribute[] attributess = csr.getAttributes(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest); for (Attribute attribute : attributess) { ASN1Set attValue = attribute.getAttrValues(); if (attValue != null) { ASN1Encodable extension = attValue.getObjectAt(0); if (extension instanceof Extensions) { return (Extensions) extension; } else if (extension instanceof DERSequence) { return Extensions.getInstance(extension); } } } return null; }
Example #17
Source File: CMSSignedDataWrapper.java From Websocket-Smart-Card-Signer with GNU Affero General Public License v3.0 | 6 votes |
private static ASN1Set buildSignedAttributes(byte[] hash, Date dateTime, X509Certificate cert) throws Exception { ASN1EncodableVector v = new ASN1EncodableVector(); v.add(new Attribute(CMSAttributes.contentType, new DERSet(PKCSObjectIdentifiers.data))); if (dateTime != null) v.add(new Attribute(CMSAttributes.signingTime, new DERSet(new Time(dateTime)))); v.add(new Attribute(CMSAttributes.messageDigest, new DERSet(new DEROctetString(hash)))); // CADES support section ASN1EncodableVector aaV2 = new ASN1EncodableVector(); AlgorithmIdentifier algoId = new AlgorithmIdentifier(new ASN1ObjectIdentifier(CMSSignedDataGenerator.DIGEST_SHA256), null); aaV2.add(algoId); byte[] dig = SignUtils.calculateHASH(CMSSignedDataGenerator.DIGEST_SHA256, cert.getEncoded()); aaV2.add(new DEROctetString(dig)); Attribute cades = new Attribute(PKCSObjectIdentifiers.id_aa_signingCertificateV2, new DERSet(new DERSequence(new DERSequence(new DERSequence(aaV2))))); v.add(cades); ASN1Set signedAttributes = new DERSet(v); return signedAttributes; }
Example #18
Source File: CertificateUtils.java From localization_nifi with Apache License 2.0 | 6 votes |
/** * Extract extensions from CSR object */ public static Extensions getExtensionsFromCSR(JcaPKCS10CertificationRequest csr) { Attribute[] attributess = csr.getAttributes(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest); for (Attribute attribute : attributess) { ASN1Set attValue = attribute.getAttrValues(); if (attValue != null) { ASN1Encodable extension = attValue.getObjectAt(0); if (extension instanceof Extensions) { return (Extensions) extension; } else if (extension instanceof DERSequence) { return Extensions.getInstance(extension); } } } return null; }
Example #19
Source File: AbstractRequirementChecks.java From dss with GNU Lesser General Public License v2.1 | 5 votes |
private int countInSet(ASN1ObjectIdentifier oid, ASN1Set set) { int counter = 0; if (set != null) { for (int i = 0; i < set.size(); i++) { ASN1Sequence attrSeq = ASN1Sequence.getInstance(set.getObjectAt(i)); ASN1ObjectIdentifier attrOid = ASN1ObjectIdentifier.getInstance(attrSeq.getObjectAt(0)); if (oid.equals(attrOid)) { counter++; } } } return counter; }
Example #20
Source File: EnrolmentResponse.java From xipki with Apache License 2.0 | 5 votes |
public EnrolmentResponse(PkiMessage pkcsRep) throws ScepClientException { Args.notNull(pkcsRep, "pkcsRep"); MessageType messageType = pkcsRep.getMessageType(); if (MessageType.CertRep != messageType) { throw new ScepClientException("messageType must not be other than CertRep: " + messageType); } this.pkcsRep = pkcsRep; if (PkiStatus.SUCCESS != pkcsRep.getPkiStatus()) { return; } ASN1Encodable messageData = pkcsRep.getMessageData(); if (!(messageData instanceof ContentInfo)) { throw new ScepClientException("pkcsRep is not a ContentInfo"); } ContentInfo ci = (ContentInfo) messageData; SignedData sd = SignedData.getInstance(ci.getContent()); ASN1Set asn1Certs = sd.getCertificates(); if (asn1Certs == null || asn1Certs.size() == 0) { throw new ScepClientException("no certificate is embedded in pkcsRep"); } try { this.certificates = Collections.unmodifiableList(ScepUtil.getCertsFromSignedData(sd)); } catch (CertificateException ex) { throw new ScepClientException(ex.getMessage(), ex); } }
Example #21
Source File: InfiniteLoopDSS621Test.java From dss with GNU Lesser General Public License v2.1 | 5 votes |
private List<X509Certificate> extractCertificates(SignedData signedData) throws Exception { ASN1Set certificates = signedData.getCertificates(); logger.debug("CERTIFICATES (" + certificates.size() + ") : " + certificates); List<X509Certificate> foundCertificates = new ArrayList<>(); for (int i = 0; i < certificates.size(); i++) { ASN1Sequence seqCertif = ASN1Sequence.getInstance(certificates.getObjectAt(i)); X509CertificateHolder certificateHolder = new X509CertificateHolder(seqCertif.getEncoded()); CertificateToken certificate = DSSASN1Utils.getCertificate(certificateHolder); foundCertificates.add(certificate.getCertificate()); } return foundCertificates; }
Example #22
Source File: CAdESWithContentTimestampTest.java From dss with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected DSSDocument getSignedDocument() { FileDocument fileDocument = new FileDocument("src/test/resources/validation/Signature-C-BES-4.p7m"); try (InputStream is = fileDocument.openStream(); ASN1InputStream asn1sInput = new ASN1InputStream(is)) { ASN1Sequence asn1Seq = (ASN1Sequence) asn1sInput.readObject(); ASN1TaggedObject taggedObj = ASN1TaggedObject.getInstance(asn1Seq.getObjectAt(1)); ASN1Primitive object = taggedObj.getObject(); SignedData signedData = SignedData.getInstance(object); ASN1Set signerInfosAsn1 = signedData.getSignerInfos(); ASN1Sequence seqSignedInfo = ASN1Sequence.getInstance(signerInfosAsn1.getObjectAt(0)); SignerInfo signedInfo = SignerInfo.getInstance(seqSignedInfo); ASN1Set authenticatedAttributes = signedInfo.getAuthenticatedAttributes(); boolean found = false; for (int i = 0; i < authenticatedAttributes.size(); i++) { ASN1Sequence authAttrSeq = ASN1Sequence.getInstance(authenticatedAttributes.getObjectAt(i)); ASN1ObjectIdentifier attrOid = ASN1ObjectIdentifier.getInstance(authAttrSeq.getObjectAt(0)); if (PKCSObjectIdentifiers.id_aa_ets_contentTimestamp.equals(attrOid)) { found = true; } } assertTrue(found); } catch (Exception e) { fail(e); } return fileDocument; }
Example #23
Source File: CaUtil.java From xipki with Apache License 2.0 | 5 votes |
public static String getChallengePassword(CertificationRequestInfo csr) { Args.notNull(csr, "csr"); ASN1Set attrs = csr.getAttributes(); for (int i = 0; i < attrs.size(); i++) { Attribute attr = Attribute.getInstance(attrs.getObjectAt(i)); if (PKCSObjectIdentifiers.pkcs_9_at_challengePassword.equals(attr.getAttrType())) { ASN1String str = (ASN1String) attr.getAttributeValues()[0]; return str.getString(); } } return null; }
Example #24
Source File: CaUtil.java From xipki with Apache License 2.0 | 5 votes |
public static Extensions getExtensions(CertificationRequestInfo csr) { Args.notNull(csr, "csr"); ASN1Set attrs = csr.getAttributes(); for (int i = 0; i < attrs.size(); i++) { Attribute attr = Attribute.getInstance(attrs.getObjectAt(i)); if (PKCSObjectIdentifiers.pkcs_9_at_extensionRequest.equals(attr.getAttrType())) { return Extensions.getInstance(attr.getAttributeValues()[0]); } } return null; }
Example #25
Source File: ScepResponder.java From xipki with Apache License 2.0 | 5 votes |
private static String getChallengePassword(CertificationRequestInfo csr) { ASN1Set attrs = csr.getAttributes(); for (int i = 0; i < attrs.size(); i++) { Attribute attr = Attribute.getInstance(attrs.getObjectAt(i)); if (PKCSObjectIdentifiers.pkcs_9_at_challengePassword.equals(attr.getAttrType())) { ASN1String str = (ASN1String) attr.getAttributeValues()[0]; return str.getString(); } } return null; }
Example #26
Source File: ScepUtil.java From xipki with Apache License 2.0 | 5 votes |
public static ASN1Encodable getFirstAttrValue(AttributeTable attrs, ASN1ObjectIdentifier type) { Args.notNull(attrs, "attrs"); Args.notNull(type, "type"); Attribute attr = attrs.get(type); if (attr == null) { return null; } ASN1Set set = attr.getAttrValues(); return (set.size() == 0) ? null : set.getObjectAt(0); }
Example #27
Source File: DSSASN1Utils.java From dss with GNU Lesser General Public License v2.1 | 5 votes |
/** * Returns ats-hash-index table, with a specified version present in from timestamp's unsigned properties * * @param timestampUnsignedAttributes {@link AttributeTable} unsigned properties of the timestamp * @param atsHashIndexVersionIdentifier {@link ASN1ObjectIdentifier} identifier of ats-hash-index table to get * @return the content of SignedAttribute: ATS-hash-index unsigned attribute with a requested version if present */ public static ASN1Sequence getAtsHashIndexByVersion(AttributeTable timestampUnsignedAttributes, ASN1ObjectIdentifier atsHashIndexVersionIdentifier) { if (timestampUnsignedAttributes != null && atsHashIndexVersionIdentifier != null) { final Attribute atsHashIndexAttribute = timestampUnsignedAttributes.get(atsHashIndexVersionIdentifier); if (atsHashIndexAttribute != null) { final ASN1Set attrValues = atsHashIndexAttribute.getAttrValues(); if (attrValues != null && attrValues.size() == 1) { return (ASN1Sequence) attrValues.getObjectAt(0).toASN1Primitive(); } } } return null; }
Example #28
Source File: DSSASN1Utils.java From dss with GNU Lesser General Public License v2.1 | 5 votes |
/** * Returns {@link ASN1Encodable} for a given {@code oid} found in the {@code unsignedAttributes} * @param unsignedAttributes {@link AttributeTable} of a signature * @param oid target {@link ASN1ObjectIdentifier} * @return {@link ASN1Encodable} */ public static ASN1Encodable getAsn1Encodable(AttributeTable unsignedAttributes, ASN1ObjectIdentifier oid) { final ASN1Set attrValues = getAsn1AttributeSet(unsignedAttributes, oid); if (attrValues == null || attrValues.size() <= 0) { return null; } return attrValues.getObjectAt(0); }
Example #29
Source File: DSSASN1Utils.java From dss with GNU Lesser General Public License v2.1 | 5 votes |
/** * Returns an Attribute values for a given {@code oid} found in the {@code unsignedAttributes} * @param unsignedAttributes {@link AttributeTable} of a signature * @param oid target {@link ASN1ObjectIdentifier} * @return {@link ASN1Set} */ public static ASN1Set getAsn1AttributeSet(AttributeTable unsignedAttributes, ASN1ObjectIdentifier oid) { final Attribute attribute = unsignedAttributes.get(oid); if (attribute == null) { return null; } return attribute.getAttrValues(); }
Example #30
Source File: ScepUtil.java From xipki with Apache License 2.0 | 5 votes |
public static X509CRLHolder getCrlFromPkiMessage(SignedData signedData) throws CRLException { Args.notNull(signedData, "signedData"); ASN1Set set = signedData.getCRLs(); if (set == null || set.size() == 0) { return null; } try { CertificateList cl = CertificateList.getInstance(set.getObjectAt(0)); return new X509CRLHolder(cl); } catch (IllegalArgumentException ex) { throw new CRLException(ex); } }