Example usage for java.security.cert X509CRLEntry getExtensionValue

List of usage examples for java.security.cert X509CRLEntry getExtensionValue

Introduction

In this page you can find the example usage for java.security.cert X509CRLEntry getExtensionValue.

Prototype

public byte[] getExtensionValue(String oid);

Source Link

Document

Gets the DER-encoded OCTET string for the extension value (extnValue) identified by the passed-in oid String.

Usage

From source file:eu.europa.esig.dss.DSSRevocationUtils.java

/**
 * This method returns the reason of the revocation of the certificate
 * extracted from the given CRL./*from   w  w w. java 2  s.c o m*/
 *
 * @param crlEntry
 *            An object for a revoked certificate in a CRL (Certificate
 *            Revocation List).
 * @return
 * @throws DSSException
 */
public static String getRevocationReason(final X509CRLEntry crlEntry) throws DSSException {
    final String reasonId = Extension.reasonCode.getId();
    final byte[] extensionBytes = crlEntry.getExtensionValue(reasonId);

    try {
        final ASN1Enumerated reasonCodeExtension = ASN1Enumerated
                .getInstance(X509ExtensionUtil.fromExtensionValue(extensionBytes));
        final CRLReason reason = CRLReason.getInstance(reasonCodeExtension);
        int intValue = reason.getValue().intValue();
        return CRLReasonEnum.fromInt(intValue).name();
    } catch (IOException e) {
        throw new DSSException(e);
    }
}