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

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

Introduction

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

Prototype

public static ContentHints getInstance(Object o) 

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  ww w . j av  a2s. c  om
    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;
    }/*w  w w  . j  a  v a2 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;
}