/** * Create a sequence containing a vector of objects. * @param v the vector of objects to be put in the SEQUENCE */ protected ASN1Sequence( ASN1EncodableVector v) { for (int i = 0; i != v.size(); i++) { seq.addElement(v.get(i)); } }
/** * Create a SEQUENCE containing a vector of objects. * @param v the vector of objects to be put in the SEQUENCE. */ protected ASN1Sequence( ASN1EncodableVector v) { for (int i = 0; i != v.size(); i++) { seq.addElement(v.get(i)); } }
private ASN1Primitive getObjFromVector(ASN1EncodableVector v, int index) { if (v.size() <= index) { throw new IllegalArgumentException("too few objects in input vector"); } return v.get(index).toASN1Primitive(); }
private ASN1Primitive getObjFromVector(ASN1EncodableVector v, int index) { if (v.size() <= index) { throw new IllegalArgumentException("too few objects in input vector"); } return v.get(index).toASN1Primitive(); } /**
/** * Create a SET containing a vector of objects. * @param v a vector of objects to make up the SET. * @param doSort true if should be sorted DER style, false otherwise. */ protected ASN1Set( ASN1EncodableVector v, boolean doSort) { for (int i = 0; i != v.size(); i++) { set.addElement(v.get(i)); } if (doSort) { this.sort(); } }
/** * create a sequence containing a vector of objects. * @param v a vector of objects to make up the SET. * @param doSort true if should be sorted DER style, false otherwise. */ protected ASN1Set( ASN1EncodableVector v, boolean doSort) { for (int i = 0; i != v.size(); i++) { set.addElement(v.get(i)); } if (doSort) { this.sort(); } }
private static byte[] getEncodedVector(ASN1EncodableVector vec) { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); for (int i = 0; i != vec.size(); i++) { try { bOut.write(((ASN1Object)vec.get(i)).getEncoded(ASN1Encoding.DER)); } catch (IOException e) { throw new ASN1ParsingException("malformed object: " + e, e); } } return bOut.toByteArray(); }
private static byte[] getEncodedVector(ASN1EncodableVector vec) { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); for (int i = 0; i != vec.size(); i++) { try { bOut.write(((ASN1Object)vec.get(i)).getEncoded(ASN1Encoding.BER)); } catch (IOException e) { throw new ASN1ParsingException("malformed object: " + e, e); } } return bOut.toByteArray(); }
private static byte[] getEncodedVector(ASN1EncodableVector vec) { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); for (int i = 0; i != vec.size(); i++) { try { bOut.write(((ASN1Object)vec.get(i)).getEncoded(ASN1Encoding.DL)); } catch (IOException e) { throw new ASN1ParsingException("malformed object: " + e, e); } } return bOut.toByteArray(); }
public DERApplicationSpecific(int tagNo, ASN1EncodableVector vec) { this.tag = tagNo; this.isConstructed = true; ByteArrayOutputStream bOut = new ByteArrayOutputStream(); for (int i = 0; i != vec.size(); i++) { try { bOut.write(((ASN1Object)vec.get(i)).getEncoded(ASN1Encoding.DER)); } catch (IOException e) { throw new ASN1ParsingException("malformed object: " + e, e); } } this.octets = bOut.toByteArray(); }
public AttributeTable( ASN1EncodableVector v) { for (int i = 0; i != v.size(); i++) { Attribute a = Attribute.getInstance(v.get(i)); addAttribute(a.getAttrType(), a); } }
public AttributeTable( ASN1EncodableVector v) { for (int i = 0; i != v.size(); i++) { Attribute a = Attribute.getInstance(v.get(i)); addAttribute(a.getAttrType(), a); } }
final ASN1EncodableVector asn1EncodableVector = unsignedAttributes.toASN1EncodableVector(); for (int i = 0; i < asn1EncodableVector.size(); i++) { final Attribute attribute = (Attribute) asn1EncodableVector.get(i); final DEROctetString derOctetStringDigest = getAttributeDerOctetStringHash(attribute); final ASN1ObjectIdentifier attrType = attribute.getAttrType();
/** * The field unsignedAttrsHashIndex is a sequence of octet strings. Each one contains the hash value of one * instance of Attribute within unsignedAttrs field of the SignerInfo. A hash value for every instance of * Attribute, as present at the time when the corresponding archive time-stamp is requested, shall be included in * unsignedAttrsHashIndex. No other hash values shall be included in this field. * * @param signerInformation * @return */ @SuppressWarnings("unchecked") private ASN1Sequence getUnsignedAttributesHashIndex(SignerInformation signerInformation) throws DSSException { final ASN1EncodableVector unsignedAttributesHashIndex = new ASN1EncodableVector(); AttributeTable unsignedAttributes = signerInformation.getUnsignedAttributes(); final ASN1EncodableVector asn1EncodableVector = unsignedAttributes.toASN1EncodableVector(); for (int i = 0; i < asn1EncodableVector.size(); i++) { final Attribute attribute = (Attribute) asn1EncodableVector.get(i); if (!excludedAttributesFromAtsHashIndex.contains(attribute.getAttrType())) { final DEROctetString derOctetStringDigest = getAttributeDerOctetStringHash(attribute); unsignedAttributesHashIndex.add(derOctetStringDigest); } } return new DERSequence(unsignedAttributesHashIndex); }
ASN1Primitive readTaggedObject(boolean constructed, int tag) throws IOException { if (!constructed) { // Note: !CONSTRUCTED => IMPLICIT DefiniteLengthInputStream defIn = (DefiniteLengthInputStream)_in; return new DERTaggedObject(false, tag, new DEROctetString(defIn.toByteArray())); } ASN1EncodableVector v = readVector(); if (_in instanceof IndefiniteLengthInputStream) { return v.size() == 1 ? new BERTaggedObject(true, tag, v.get(0)) : new BERTaggedObject(false, tag, BERFactory.createSequence(v)); } return v.size() == 1 ? new DERTaggedObject(true, tag, v.get(0)) : new DERTaggedObject(false, tag, DERFactory.createSequence(v)); }
ASN1Primitive readTaggedObject(boolean constructed, int tag) throws IOException { if (!constructed) { // Note: !CONSTRUCTED => IMPLICIT DefiniteLengthInputStream defIn = (DefiniteLengthInputStream)_in; return new DERTaggedObject(false, tag, new DEROctetString(defIn.toByteArray())); } ASN1EncodableVector v = readVector(); if (_in instanceof IndefiniteLengthInputStream) { return v.size() == 1 ? new BERTaggedObject(true, tag, v.get(0)) : new BERTaggedObject(false, tag, BERFactory.createSequence(v)); } return v.size() == 1 ? new DERTaggedObject(true, tag, v.get(0)) : new DERTaggedObject(false, tag, DERFactory.createSequence(v)); }
private List<TimestampToken> createTimestamps(final ASN1ObjectIdentifier attrType, final TimestampType timestampType, final ArchiveTimestampType archiveTimestampType) { final List<TimestampToken> timestampTokenList = new ArrayList<TimestampToken>(); final AttributeTable attributes = attrType.equals(id_aa_ets_contentTimestamp) ? signerInformation.getSignedAttributes() : signerInformation.getUnsignedAttributes(); if (attributes != null) { final ASN1EncodableVector allAttributes = attributes.getAll(attrType); for (int ii = 0; ii < allAttributes.size(); ii++) { final Attribute attribute = (Attribute) allAttributes.get(ii); final ASN1Set attrValues = attribute.getAttrValues(); for (final ASN1Encodable value : attrValues.toArray()) { try { final byte[] encoded = value.toASN1Primitive().getEncoded(); // getEncoded(ASN1Encoding.DER) final CMSSignedData signedData = new CMSSignedData(encoded); final TimeStampToken token = new TimeStampToken(signedData); final TimestampToken timestampToken = new TimestampToken(token, timestampType, certPool); timestampToken.setArchiveTimestampType(archiveTimestampType); timestampTokenList.add(timestampToken); } catch (Exception e) { throw new DSSException(e); } } } } return timestampTokenList; }
strings[i] = (ASN1OctetString)v.get(i);
strings[i] = (ASN1OctetString)v.get(i);