Java Code Examples for

Following code examples demonstrate how to use java. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use various code implementation of this class.

        parseExtensions(DerValue derVal) throws IOException {
        DerValue[] extDer =;
        Map<String,> extMap =
                new HashMap<>(extDer.length);

        for (DerValue extDerVal : extDer) {
            Extension ext = new Extension(extDerVal);
            if (debug != null) {
                debug.println("Extension: " + ext);
            if (ext.isCritical()) {
                throw new IOException("Unsupported OCSP critical extension: " +
            extMap.put(ext.getId(), ext);

        return extMap;

        switch (responseStatus) {
            case SUCCESSFUL:
            case TRY_LATER:
            case INTERNAL_ERROR:
                throw new CertPathValidatorException(
                    "OCSP response error: " + responseStatus, null, null, -1,
            case UNAUTHORIZED:
                throw new CertPathValidatorException("OCSP response error: " +

    public default void verifyGenericType()
    throws Exception {
        final Class<SUT> sut = createNewSUT();
        assertTrue("This j8unit test interface is used with a generic type that is illegaly not assignable to Extension.class!",

This interface represents an X.509 extension.

Extensions provide a means of associating

additional attributes with users or public keys and for managing a certification hierarchy. The extension format also allows communities to define private extensions to carry information unique to those communities.

Each extension contains an object identifier, a criticality setting indicating whether it is a critical or a non-critical extension, and and an ASN.1 DER-encoded value. Its ASN.1 definition is: Extension ::= SEQUENCE { extnId OBJECT IDENTIFIER, critical BOOLEAN DEFAULT FALSE, extnValue OCTET STRING -- contains a DER encoding of a value -- of the type registered for use with -- the extnId object identifier value

This interface is designed to provide access to a single extension, unlike which is more suitable for accessing a set of extensions. @since 1.7

Read More