Java 类org.bouncycastle.asn1.ess.ContentHints 实例源码

项目:gwt-crypto    文件:ContentHintsUnitTest.java   
private void checkConstruction(
    ContentHints hints,
    ASN1ObjectIdentifier contentType,
    DERUTF8String description)
    throws IOException
{
    checkValues(hints, contentType, description);

    hints = ContentHints.getInstance(hints);

    checkValues(hints, contentType, description);

    ASN1InputStream aIn = new ASN1InputStream(hints.toASN1Primitive().getEncoded());

    ASN1Sequence seq = (ASN1Sequence)aIn.readObject();

    hints = ContentHints.getInstance(seq);

    checkValues(hints, contentType, description);
}
项目:dss    文件:CAdESSignature.java   
@Override
public String getContentHints() {
    final Attribute contentHintAttribute = getSignedAttribute(PKCSObjectIdentifiers.id_aa_contentHint);
    if (contentHintAttribute == null) {
        return null;
    }
    final ASN1Encodable asn1Encodable = contentHintAttribute.getAttrValues().getObjectAt(0);
    final ContentHints contentHints = ContentHints.getInstance(asn1Encodable);
    String contentHint = null;
    if (contentHints != null) {
        // content-type is mandatory
        contentHint = contentHints.getContentType().toString();
        // content-description is optional
        if (contentHints.getContentDescription() != null) {
            contentHint += " [" + contentHints.getContentDescription().toString() + "]";
        }
    }
    return contentHint;
}
项目:irma_future_id    文件:ContentHintsUnitTest.java   
private void checkConstruction(
    ContentHints hints,
    ASN1ObjectIdentifier contentType,
    DERUTF8String description)
    throws IOException
{
    checkValues(hints, contentType, description);

    hints = ContentHints.getInstance(hints);

    checkValues(hints, contentType, description);

    ASN1InputStream aIn = new ASN1InputStream(hints.toASN1Primitive().getEncoded());

    ASN1Sequence seq = (ASN1Sequence)aIn.readObject();

    hints = ContentHints.getInstance(seq);

    checkValues(hints, contentType, description);
}
项目:bc-java    文件:ContentHintsUnitTest.java   
private void checkConstruction(
    ContentHints hints,
    ASN1ObjectIdentifier contentType,
    DERUTF8String description)
    throws IOException
{
    checkValues(hints, contentType, description);

    hints = ContentHints.getInstance(hints);

    checkValues(hints, contentType, description);

    ASN1InputStream aIn = new ASN1InputStream(hints.toASN1Primitive().getEncoded());

    ASN1Sequence seq = (ASN1Sequence)aIn.readObject();

    hints = ContentHints.getInstance(seq);

    checkValues(hints, contentType, description);
}
项目:gwt-crypto    文件:ContentHintsUnitTest.java   
private void checkValues(
    ContentHints hints,
    ASN1ObjectIdentifier contentType,
    DERUTF8String description)
{
    checkMandatoryField("contentType", contentType, hints.getContentType());
    checkOptionalField("description", description, hints.getContentDescription());
}
项目:irma_future_id    文件:ContentHintsUnitTest.java   
private void checkValues(
    ContentHints hints,
    ASN1ObjectIdentifier contentType,
    DERUTF8String description)
{
    checkMandatoryField("contentType", contentType, hints.getContentType());
    checkOptionalField("description", description, hints.getContentDescription());
}
项目:bc-java    文件:ContentHintsUnitTest.java   
private void checkValues(
    ContentHints hints,
    ASN1ObjectIdentifier contentType,
    DERUTF8String description)
{
    checkMandatoryField("contentType", contentType, hints.getContentType());
    checkOptionalField("description", description, hints.getContentDescription());
}
项目:dss    文件:CAdESLevelBaselineB.java   
/**
 * ETSI TS 101 733 V2.2.1 (2013-04)
 *
 * 5.10.3 content-hints Attribute
 * The content-hints attribute provides information on the innermost signed content of a multi-layer message where
 * one content is encapsulated in another.
 * The syntax of the content-hints attribute type of the ES is as defined in ESS (RFC 2634 [5]).
 * When used to indicate the precise format of the data to be presented to the user, the following rules apply:
 * • the contentType indicates the type of the associated content. It is an object identifier (i.e. a unique string
 * of
 * integers) assigned by an authority that defines the content type; and
 * • when the contentType is id-data the contentDescription shall define the presentation format; the
 * format may be defined by MIME types.
 * When the format of the content is defined by MIME types, the following rules apply:
 * • the contentType shall be id-data as defined in CMS (RFC 3852 [4]);
 * • the contentDescription shall be used to indicate the encoding of the data, in accordance with the rules
 * defined RFC 2045 [6]; see annex F for an example of structured contents and MIME.
 * NOTE 1: id-data OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs7(7) 1 }.
 * NOTE 2: contentDescription is optional in ESS (RFC 2634 [5]). It may be used to complement
 * contentTypes defined elsewhere; such definitions are outside the scope of the present document.
 *
 * @param parameters
 * @param signedAttributes
 * @return
 */
private void addContentHints(final CAdESSignatureParameters parameters, final ASN1EncodableVector signedAttributes) {
    if (Utils.isStringNotBlank(parameters.getContentHintsType())) {

        final ASN1ObjectIdentifier contentHintsType = new ASN1ObjectIdentifier(parameters.getContentHintsType());
        final String contentHintsDescriptionString = parameters.getContentHintsDescription();
        final DERUTF8String contentHintsDescription = Utils.isStringBlank(contentHintsDescriptionString) ? null
                : new DERUTF8String(contentHintsDescriptionString);
        // "text/plain";
        // "1.2.840.113549.1.7.1";

        final ContentHints contentHints = new ContentHints(contentHintsType, contentHintsDescription);
        final DERSet attrValues = new DERSet(contentHints);
        final Attribute attribute = new Attribute(id_aa_contentHint, attrValues);
        signedAttributes.add(attribute);
    }
}