Example usage for org.bouncycastle.asn1.pkcs PKCSObjectIdentifiers id_aa_ets_contentTimestamp

List of usage examples for org.bouncycastle.asn1.pkcs PKCSObjectIdentifiers id_aa_ets_contentTimestamp

Introduction

In this page you can find the example usage for org.bouncycastle.asn1.pkcs PKCSObjectIdentifiers id_aa_ets_contentTimestamp.

Prototype

ASN1ObjectIdentifier id_aa_ets_contentTimestamp

To view the source code for org.bouncycastle.asn1.pkcs PKCSObjectIdentifiers id_aa_ets_contentTimestamp.

Click Source Link

Document

PKCS#9: 1.2.840.113549.1.9.16.2.20 - <a href="http://tools.ietf.org/html/rfc3126">RFC 3126</a>

Usage

From source file:eu.europa.ec.markt.dss.signature.cades.CAdESLevelBaselineB.java

License:Open Source License

/**
 * A content time-stamp allows a time-stamp token of the data to be signed to be incorporated into the signed information.
 * It provides proof of the existence of the data before the signature was created.
 * <p/>/*from   w  w  w . j  a v a 2  s  .c  om*/
 * A content time-stamp attribute is the time-stamp token of the signed data content before it is signed.
 * This attribute is a signed attribute.
 * Its object identifier is :
 * id-aa-ets-contentTimestamp OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-9(9) smime(16) id-aa(2) 20}
 * <p/>
 * Content time-stamp attribute values have ASN.1 type ContentTimestamp:
 * ContentTimestamp ::= TimeStampToken
 * <p/>
 * The value of messageImprint of TimeStampToken (as described in RFC 3161) is the hash of the message digest as defined in
 * ETSI standard 101733 v.2.2.1, clause 5.6.1.
 * <p/>
 * NOTE: content-time-stamp indicates that the signed information was formed before the date included in the content-time-stamp.
 * NOTE (bis): There is a small difference in treatment between the content-time-stamp and the archive-timestamp (ATSv2) when the signature
 * is attached. In that case, the content-time-stamp is computed on the raw data (without ASN.1 tag and length) whereas the archive-timestamp
 * is computed on data as read.
 *
 * @param parameters
 * @param signedAttributes
 * @return
 */
private void addContentTimestamps(final SignatureParameters parameters,
        final ASN1EncodableVector signedAttributes) {

    if (parameters.getContentTimestamps() != null && !parameters.getContentTimestamps().isEmpty()) {

        final List<TimestampToken> contentTimestamps = parameters.getContentTimestamps();
        for (final TimestampToken contentTimestamp : contentTimestamps) {

            final ASN1Object asn1Object = DSSASN1Utils.toASN1Primitive(contentTimestamp.getEncoded());
            final DERSet attrValues = new DERSet(asn1Object);
            final Attribute attribute = new Attribute(PKCSObjectIdentifiers.id_aa_ets_contentTimestamp,
                    attrValues);
            signedAttributes.add(attribute);
        }
    }
}

From source file:eu.europa.ec.markt.dss.validation.cades.CAdESSignature.java

License:Open Source License

protected List<TimestampToken> getContentTimestamps() {
    return getTimestampList(PKCSObjectIdentifiers.id_aa_ets_contentTimestamp,
            TimestampToken.TimestampType.CONTENT_TIMESTAMP);
}

From source file:eu.europa.ec.markt.dss.validation102853.cades.CAdESSignature.java

License:Open Source License

private List<TimestampToken> getTimestampList(final ASN1ObjectIdentifier attrType,
        final TimestampType timestampType, final ArchiveTimestampType archiveTimestampType) {

    final List<TimestampToken> list = new ArrayList<TimestampToken>();

    final AttributeTable attributes;
    if (attrType.equals(PKCSObjectIdentifiers.id_aa_ets_contentTimestamp)) {

        attributes = signerInformation.getSignedAttributes();
    } else {/*from   w w w .  j  av a  2 s  .c o  m*/

        attributes = signerInformation.getUnsignedAttributes();
    }
    if (attributes == null) {
        return list;
    }
    final ASN1EncodableVector archiveList = attributes.getAll(attrType);
    for (int i = 0; i < archiveList.size(); i++) {
        final Attribute attribute = (Attribute) archiveList.get(i);

        final ASN1Set attrValues = attribute.getAttrValues();
        for (final ASN1Encodable value : attrValues.toArray()) {
            try {
                TimeStampToken token = new TimeStampToken(
                        new CMSSignedData(value.toASN1Primitive().getEncoded(ASN1Encoding.DER)));
                final TimestampToken timestampToken = new TimestampToken(token, timestampType, certPool);
                timestampToken.setArchiveTimestampType(archiveTimestampType);
                list.add(timestampToken);
            } catch (Exception e) {
                throw new RuntimeException("Parsing error", e);
            }
        }
    }
    return list;
}

From source file:eu.europa.ec.markt.dss.validation102853.cades.CAdESSignature.java

License:Open Source License

public List<TimestampToken> getContentTimestamps() {

    if (contentTimestamps == null) {
        contentTimestamps = getTimestampList(PKCSObjectIdentifiers.id_aa_ets_contentTimestamp,
                TimestampType.CONTENT_TIMESTAMP, null);
    }/*w ww.  j  a v  a  2s. c  om*/
    return contentTimestamps;
}