public AttributeTable remove(ASN1ObjectIdentifier attrType) { AttributeTable newTable = new AttributeTable(attributes); newTable.attributes.remove(attrType); return newTable; } }
Attribute signingTime = signerInformation.getSignedAttributes().get(CMSAttributes.signingTime); if (signingTime != null)
if (unsignedAttributes != null) vector = unsignedAttributes.toASN1EncodableVector(); return SignerInformation.replaceUnsignedAttributes(signer, new AttributeTable(signedAttributes));
AttributeTable getSignedAttributes(Map params, CAdESLevelBaselineB cadesProfile, SignatureParameters parameters, byte[] messageDigest) { AttributeTable signedAttributes = cadesProfile.getSignedAttributes(parameters); if (signedAttributes.get(CMSAttributes.contentType) == null) { ASN1ObjectIdentifier contentType = (ASN1ObjectIdentifier) params.get(CMSAttributeTableGenerator.CONTENT_TYPE); // contentType will be null if we're trying to generate a counter signature. if (contentType != null) { signedAttributes = signedAttributes.add(CMSAttributes.contentType, contentType); } } if (signedAttributes.get(CMSAttributes.messageDigest) == null) { // byte[] messageDigest = (byte[]) params.get(CMSAttributeTableGenerator.DIGEST); signedAttributes = signedAttributes.add(CMSAttributes.messageDigest, new DEROctetString(messageDigest)); } return signedAttributes; }
/** * Return a new table with the passed in attribute added. * * @param attrType * @param attrValue * @return */ public AttributeTable add(ASN1ObjectIdentifier attrType, ASN1Encodable attrValue) { AttributeTable newTable = new AttributeTable(attributes); newTable.addAttribute(attrType, new Attribute(attrType, new DERSet(attrValue))); return newTable; }
final DERTaggedObject taggedObject = (DERTaggedObject) signerInfo.getObjectAt(next); final ASN1Set unat = ASN1Set.getInstance(taggedObject, false); final AttributeTable attble = new AttributeTable(unat); final Attribute ts = attble.get(PKCSObjectIdentifiers.id_aa_signatureTimeStampToken); if (ts != null) { final ASN1Set attributeValues = ts.getAttrValues();
private CMSSignedData addNestedSignature(CMSSignedData primary, CMSSignedData secondary) throws CMSException { SignerInformation signerInformation = primary.getSignerInfos().getSigners().iterator().next(); AttributeTable unsignedAttributes = signerInformation.getUnsignedAttributes(); if (unsignedAttributes == null) { unsignedAttributes = new AttributeTable(new DERSet()); } Attribute nestedSignaturesAttribute = unsignedAttributes.get(AuthenticodeObjectIdentifiers.SPC_NESTED_SIGNATURE_OBJID); if (nestedSignaturesAttribute == null) { // first nested signature unsignedAttributes = unsignedAttributes.add(AuthenticodeObjectIdentifiers.SPC_NESTED_SIGNATURE_OBJID, secondary.toASN1Structure()); } else { // append the signature to the previous nested signatures ASN1EncodableVector nestedSignatures = new ASN1EncodableVector(); for (ASN1Encodable nestedSignature : nestedSignaturesAttribute.getAttrValues()) { nestedSignatures.add(nestedSignature); } nestedSignatures.add(secondary.toASN1Structure()); ASN1EncodableVector attributes = unsignedAttributes.remove(AuthenticodeObjectIdentifiers.SPC_NESTED_SIGNATURE_OBJID).toASN1EncodableVector(); attributes.add(new Attribute(AuthenticodeObjectIdentifiers.SPC_NESTED_SIGNATURE_OBJID, new DERSet(nestedSignatures))); unsignedAttributes = new AttributeTable(attributes); } signerInformation = SignerInformation.replaceUnsignedAttributes(signerInformation, unsignedAttributes); return CMSSignedData.replaceSigners(primary, new SignerInformationStore(signerInformation)); }
return new DERSet(); return new DERSet(authenticatedAttributes.toASN1EncodableVector()); } else { Hashtable<DERObjectIdentifier, Attribute> hashtable; hashtable = new Hashtable<DERObjectIdentifier, Attribute>(); } else { hashtable = authenticatedAttributes.toHashtable(); return new DERSet(new AttributeTable(hashtable).toASN1EncodableVector());
public Attributes toASN1Structure() { return new Attributes(this.toASN1EncodableVector()); }
Map<Object, Attribute> attrTbl = signer.getSignedAttributes().toHashtable(); StringBuilder strBuf = new StringBuilder(); for(Map.Entry<Object, Attribute> pair: attrTbl.entrySet()) { Attribute attribute = attributes.get(CMSAttributes.messageDigest); DEROctetString digest = (DEROctetString) attribute.getAttrValues().getObjectAt(0); logger.trace("\t**** Signed Attribute Message-Digest := " + Hex.toHexString(digest.getOctets()));
if ((signedAttributes==null)||(signedAttributes!= null && signedAttributes.size() == 0)) { throw new SignerException("O pacote PKCS7 não contém atributos assinados."); if ((unsignedAttributes==null)||(unsignedAttributes != null && unsignedAttributes.size() == 0)) { logger.info("O pacote PKCS7 não contem atributos nao assinados."); logger.info("UTCTime yyMMddHHmmssz : {}", (((ASN1UTCTime) signedAttributes.get(new ASN1ObjectIdentifier("1.2.840.113549.1.9.5")).getAttrValues().getObjectAt(0)).getTime())); Attribute attributeContentType = signedAttributes.get(CMSAttributes.contentType); if (attributeContentType == null) { throw new SignerException("O pacote PKCS7 não contém o atributo \"ContentType\""); Attribute attributeMessageDigest = signedAttributes.get(CMSAttributes.messageDigest); if (attributeMessageDigest == null) { throw new SignerException("O pacote PKCS7 não contém o atributo \"MessageDigest\"");
public Map getAtributosAssinados() { return timeStampToken.getSignedAttributes().toHashtable(); }
LOG.debug("Unprotected attributes size {}", unprotectedAttsTable.size()); @SuppressWarnings("unchecked") Hashtable<String, Attribute> unprotectedAtts = unprotectedAttsTable.toHashtable(); if (unprotectedAtts != null) { LOG.debug("Unprotected attributes: {}", attributesToString(unprotectedAtts));
public static boolean isEmpty(AttributeTable attributeTable) { return (attributeTable == null) || (attributeTable.size() == 0); }
DERTaggedObject taggedObject = (DERTaggedObject) signerInfo.getObjectAt(next); ASN1Set unat = ASN1Set.getInstance(taggedObject, false); AttributeTable attble = new AttributeTable(unat); Attribute ts = attble.get(PKCSObjectIdentifiers.id_aa_signatureTimeStampToken); if (ts != null && ts.getAttrValues().size() > 0) { ASN1Set attributeValues = ts.getAttrValues();
/** * Return a new table with the passed in attribute added. * * @param attrType the type of the attribute to add. * @param attrValue the value corresponding to the attribute (will be wrapped in a SET). * @return a new table with the extra attribute in it. */ public AttributeTable add(ASN1ObjectIdentifier attrType, ASN1Encodable attrValue) { AttributeTable newTable = new AttributeTable(attributes); newTable.addAttribute(attrType, new Attribute(attrType, new DERSet(attrValue))); return newTable; }
public Attributes toASN1Structure() { return new Attributes(this.toASN1EncodableVector()); }
public Map<?, ?> getSignedAttributes() { return timeStampToken.getSignedAttributes().toHashtable(); }
.getSignedAttributes().toHashtable(); .getSignedAttributes().size()); for (Entry<ASN1ObjectIdentifier, Attribute> entry : attrTable .entrySet()) {
/** * @param signedAttributes the signedAttributes * @param unsignedAttributes the unsignedAttributes * @return a SignerInfoGeneratorBuilder that generate the signed and unsigned attributes according to the parameters */ private SignerInfoGeneratorBuilder getSignerInfoGeneratorBuilder(AttributeTable signedAttributes, AttributeTable unsignedAttributes) { if (signedAttributes != null && signedAttributes.size() == 0) { signedAttributes = null; } final DefaultSignedAttributeTableGenerator signedAttributeGenerator = new DefaultSignedAttributeTableGenerator(signedAttributes); if (unsignedAttributes != null && unsignedAttributes.size() == 0) { unsignedAttributes = null; } final SimpleAttributeTableGenerator unsignedAttributeGenerator = new SimpleAttributeTableGenerator(unsignedAttributes); return getSignerInfoGeneratorBuilder(signedAttributeGenerator, unsignedAttributeGenerator); }