Example usage for org.bouncycastle.asn1.ess ContentHints getContentDescription

List of usage examples for org.bouncycastle.asn1.ess ContentHints getContentDescription

Introduction

In this page you can find the example usage for org.bouncycastle.asn1.ess ContentHints getContentDescription.

Prototype

public DERUTF8String getContentDescription() 

Source Link

Usage

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

License:Open Source License

@Override
public String getContentHints() {

    final AttributeTable signedAttributes = signerInformation.getSignedAttributes();
    if (signedAttributes == null) {
        return null;
    }//from www . j  ava  2s .co m
    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;
}

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

License:Open Source License

@Override
public String getContentHints() {
    final AttributeTable signedAttributes = signerInformation.getSignedAttributes();
    if (signedAttributes == null) {
        return null;
    }/*from  w  w  w  .ja v a  2  s .co  m*/
    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);
    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;
}