if (signerInformation.getSignedAttributes() != null) Attribute signingTime = signerInformation.getSignedAttributes().get(CMSAttributes.signingTime); if (signingTime != null)
/** * @param signerInformation * @return the existing signed attributes or an empty attributes {@code Hashtable} */ public static AttributeTable getSignedAttributes(final SignerInformation signerInformation) { final AttributeTable signedAttributes = signerInformation.getSignedAttributes(); if (signedAttributes == null) { return new AttributeTable(new Hashtable<ASN1ObjectIdentifier, Attribute>()); } else { return signedAttributes; } }
protected void logDigests(SignerInformation sigInfo) { // it is assumed that the verify function has already been called, other wise the getContentDigest function // will fail if (this.m_logDigest && sigInfo != null) { try { //get the digests final Attribute digAttr = sigInfo.getSignedAttributes().get(CMSAttributes.messageDigest); final ASN1Encodable hashObj = digAttr.getAttrValues().getObjectAt(0); final byte[] signedDigest = ((ASN1OctetString)hashObj).getOctets(); final String signedDigestHex = org.apache.commons.codec.binary.Hex.encodeHexString(signedDigest); LOGGER.info("Signed Message Digest: " + signedDigestHex); // should have the computed digest now final byte[] digest = sigInfo.getContentDigest(); final String digestHex = org.apache.commons.codec.binary.Hex.encodeHexString(digest); LOGGER.info("Computed Message Digest: " + digestHex); } catch (Throwable t) { /* no-op.... logging digests is a quiet operation */} } }
private void logDigests(SignerInformation sigInfo) { // it is assumed that the verify function has already been called, other wise the getContentDigest function // will fail if (this.m_logDigest && sigInfo != null) { try { //get the digests final Attribute digAttr = sigInfo.getSignedAttributes().get(CMSAttributes.messageDigest); final ASN1Encodable hashObj = digAttr.getAttrValues().getObjectAt(0); final byte[] signedDigest = ((ASN1OctetString)hashObj).getOctets(); final String signedDigestHex = org.apache.commons.codec.binary.Hex.encodeHexString(signedDigest); LOGGER.info("Signed Message Digest: " + signedDigestHex); // should have the computed digest now final byte[] digest = sigInfo.getContentDigest(); final String digestHex = org.apache.commons.codec.binary.Hex.encodeHexString(digest); LOGGER.info("Computed Message Digest: " + digestHex); } catch (Throwable t) { /* no-op.... logging digests is a quiet operation */} } }
@Override public Date getSigningTime() { final AttributeTable attributes = signerInformation.getSignedAttributes(); if (attributes == null) { return null;
@Override public String getContentType() { final AttributeTable signedAttributes = signerInformation.getSignedAttributes(); if (signedAttributes == null) { return null; } final Attribute contentTypeAttribute = signedAttributes.get(PKCSObjectIdentifiers.pkcs_9_at_contentType); if (contentTypeAttribute == null) { return null; } final ASN1ObjectIdentifier asn1Encodable = (ASN1ObjectIdentifier) contentTypeAttribute.getAttrValues().getObjectAt(0); final String contentType = asn1Encodable.getId(); return contentType; }
protected void debugLog(CMSSignedDataParser sp) throws CMSException { if (!LOG.isDebugEnabled()) { return; } SignerInformationStore signers = sp.getSignerInfos(); Set<AlgorithmIdentifier> messageDigestAlgorithms = sp.getDigestAlgorithmIDs(); for (AlgorithmIdentifier algorithm : messageDigestAlgorithms) { LOG.debug("Message digest algorithm: {}", algorithm.getAlgorithm().getId()); } LOG.debug("Included Signer Infos:"); int i = 0; for (SignerInformation signer : signers.getSigners()) { i++; LOG.debug(" Signer {}: {}", new Object[] {i, signerInformationToString(signer)}); if (signer.getSignedAttributes() != null) { @SuppressWarnings("unchecked") Hashtable<String, Attribute> authAttTable = signer.getSignedAttributes().toHashtable(); if (authAttTable != null) { LOG.debug(" Signed attributes of signer {}: {}", i, attributesToString(authAttTable)); } } if (signer.getUnsignedAttributes() != null) { @SuppressWarnings("unchecked") Hashtable<String, Attribute> unAuthAtts = signer.getUnsignedAttributes().toHashtable(); if (unAuthAtts != null) { LOG.debug(" Unsigned attributes of signer {}: {}", i, attributesToString(unAuthAtts)); } } } }
final Attribute digAttr = signer.getSignedAttributes().get(CMSAttributes.messageDigest); final ASN1Encodable hashObj = digAttr.getAttrValues().getObjectAt(0); final byte[] signedDigest = ((ASN1OctetString)hashObj).getOctets();
@Override public String[] getClaimedSignerRoles() { final AttributeTable attributes = signerInformation.getSignedAttributes(); if (attributes == null) { return null;
@Override public String getContentIdentifier() { final AttributeTable signedAttributes = signerInformation.getSignedAttributes(); if (signedAttributes == null) { return null; } final Attribute contentIdentifierAttribute = signedAttributes.get(PKCSObjectIdentifiers.id_aa_contentIdentifier); if (contentIdentifierAttribute == null) { return null; } final ASN1Encodable asn1Encodable = contentIdentifierAttribute.getAttrValues().getObjectAt(0); final ContentIdentifier contentIdentifier = ContentIdentifier.getInstance(asn1Encodable); final String contentIdentifierString = DSSASN1Utils.toString(contentIdentifier.getValue()); return contentIdentifierString; }
Map<Object, Attribute> attrTbl = signer.getSignedAttributes().toHashtable(); StringBuilder strBuf = new StringBuilder(); for(Map.Entry<Object, Attribute> pair: attrTbl.entrySet()) { AttributeTable attributes = signer.getSignedAttributes(); Attribute attribute = attributes.get(CMSAttributes.messageDigest); DEROctetString digest = (DEROctetString) attribute.getAttrValues().getObjectAt(0);
@Override public SignatureProductionPlace getSignatureProductionPlace() { final AttributeTable attributes = signerInformation.getSignedAttributes(); if (attributes == null) {
@Override public String getContentHints() { final AttributeTable signedAttributes = signerInformation.getSignedAttributes(); if (signedAttributes == null) { return null; } final Attribute contentHintAttribute = signedAttributes.get(PKCSObjectIdentifiers.id_aa_contentHint); if (contentHintAttribute == null) { return null; } final ASN1Encodable asn1Encodable = contentHintAttribute.getAttrValues().getObjectAt(0); final ContentHints contentHints = ContentHints.getInstance(asn1Encodable); final String contentHintsContentType = contentHints.getContentType().toString(); final String contentHintsContentDescription = contentHints.getContentDescription().getString(); final String contentHint = contentHintsContentType + " [" + contentHintsContentDescription + "]"; return contentHint; }
AttributeTable signedAttributes = signer.getSignedAttributes(); if ((signedAttributes==null)||(signedAttributes!= null && signedAttributes.size() == 0)) { throw new SignerException("O pacote PKCS7 não contém atributos assinados.");
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; }
AttributeTable signedAttributes = signerInformation.getSignedAttributes();
@Override public CommitmentType getCommitmentTypeIndication() { final AttributeTable attributes = signerInformation.getSignedAttributes(); if (attributes == null) { return null; } final Attribute commitmentTypeIndicationAttribute = attributes.get(PKCSObjectIdentifiers.id_aa_ets_commitmentType); if (commitmentTypeIndicationAttribute != null) { try { final ASN1Set attrValues = commitmentTypeIndicationAttribute.getAttrValues(); final int size = attrValues.size(); if (size > 0) { final CommitmentType commitmentType = new CommitmentType(); for (int ii = 0; ii < size; ii++) { final DERSequence derSequence = (DERSequence) attrValues.getObjectAt(ii); final CommitmentTypeIndication commitmentTypeIndication = CommitmentTypeIndication.getInstance(derSequence); final ASN1ObjectIdentifier commitmentTypeId = commitmentTypeIndication.getCommitmentTypeId(); commitmentType.addIdentifier(commitmentTypeId.getId()); } return commitmentType; } } catch (Exception e) { throw new DSSException("Error when dealing with CommitmentTypeIndication!", e); } } return null; }
AttributeTable signedAttributesTable = signerInformation.getSignedAttributes();
@Override public List<CertifiedRole> getCertifiedSignerRoles() { final AttributeTable signedAttributes = signerInformation.getSignedAttributes(); if (signedAttributes == null) { return null;
public SignaturePolicy getPolicyId() { final AttributeTable attributes = signerInformation.getSignedAttributes(); if (attributes == null) { return null;