Java Code Examples for sun.security.provider.certpath.OCSP#getOCSPBytes()

The following examples show how to use sun.security.provider.certpath.OCSP#getOCSPBytes() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StatusResponseManager.java    From openjsse with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Get an OCSP response, either from the cache or from a responder.
 *
 * @return The StatusInfo object passed into the
 *         {@code OCSPFetchCall} constructor, with the
 *         {@code responseData} field filled in with the response
 *         or {@code null} if no response can be obtained.
 */
@Override
public StatusInfo call() {
    if (SSLLogger.isOn && SSLLogger.isOn("respmgr")) {
        SSLLogger.fine(
            "Starting fetch for SN " +
            statInfo.cid.getSerialNumber());
    }
    try {
        ResponseCacheEntry cacheEntry;
        List<Extension> extsToSend;

        if (statInfo.responder == null) {
            // If we have no URI then there's nothing to do
            // but return.
            if (SSLLogger.isOn && SSLLogger.isOn("respmgr")) {
                SSLLogger.fine(
                    "Null URI detected, OCSP fetch aborted");
            }
            return statInfo;
        } else {
            if (SSLLogger.isOn && SSLLogger.isOn("respmgr")) {
                SSLLogger.fine(
                    "Attempting fetch from " + statInfo.responder);
            }
        }

        // If the StatusResponseManager has been configured to not
        // forward extensions, then set extensions to an empty
        // list.
        //
        // We will forward the extensions unless one of two
        // conditions occur:
        // (1) The jdk.tls.stapling.ignoreExtensions property is
        //     true, or
        // (2) There is a non-empty ResponderId list.
        //
        // ResponderId selection is a feature that will be
        // supported in the future.
        extsToSend = (ignoreExtensions || !responderIds.isEmpty()) ?
                Collections.emptyList() : extensions;

        byte[] respBytes = OCSP.getOCSPBytes(
                Collections.singletonList(statInfo.cid),
                statInfo.responder, extsToSend);

        if (respBytes != null) {
            // Place the data into the response cache
            cacheEntry = new ResponseCacheEntry(respBytes,
                    statInfo.cid);

            // Get the response status and act on it appropriately
            if (SSLLogger.isOn && SSLLogger.isOn("respmgr")) {
                SSLLogger.fine("OCSP Status: " + cacheEntry.status +
                    " (" + respBytes.length + " bytes)");
            }
            if (cacheEntry.status ==
                    OCSPResponse.ResponseStatus.SUCCESSFUL) {
                // Set the response in the returned StatusInfo
                statInfo.responseData = cacheEntry;

                // Add the response to the cache (if applicable)
                addToCache(statInfo.cid, cacheEntry);
            }
        } else {
            if (SSLLogger.isOn && SSLLogger.isOn("respmgr")) {
                SSLLogger.fine(
                    "No data returned from OCSP Responder");
            }
        }
    } catch (IOException ioe) {
        if (SSLLogger.isOn && SSLLogger.isOn("respmgr")) {
            SSLLogger.fine("Caught exception: ", ioe);
        }
    }

    return statInfo;
}
 
Example 2
Source File: StatusResponseManager.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * Get an OCSP response, either from the cache or from a responder.
 *
 * @return The StatusInfo object passed into the
 *         {@code OCSPFetchCall} constructor, with the
 *         {@code responseData} field filled in with the response
 *         or {@code null} if no response can be obtained.
 */
@Override
public StatusInfo call() {
    if (SSLLogger.isOn && SSLLogger.isOn("respmgr")) {
        SSLLogger.fine(
            "Starting fetch for SN " +
            statInfo.cid.getSerialNumber());
    }
    try {
        ResponseCacheEntry cacheEntry;
        List<Extension> extsToSend;

        if (statInfo.responder == null) {
            // If we have no URI then there's nothing to do
            // but return.
            if (SSLLogger.isOn && SSLLogger.isOn("respmgr")) {
                SSLLogger.fine(
                    "Null URI detected, OCSP fetch aborted");
            }
            return statInfo;
        } else {
            if (SSLLogger.isOn && SSLLogger.isOn("respmgr")) {
                SSLLogger.fine(
                    "Attempting fetch from " + statInfo.responder);
            }
        }

        // If the StatusResponseManager has been configured to not
        // forward extensions, then set extensions to an empty
        // list.
        //
        // We will forward the extensions unless one of two
        // conditions occur:
        // (1) The jdk.tls.stapling.ignoreExtensions property is
        //     true, or
        // (2) There is a non-empty ResponderId list.
        //
        // ResponderId selection is a feature that will be
        // supported in the future.
        extsToSend = (ignoreExtensions || !responderIds.isEmpty()) ?
                Collections.emptyList() : extensions;

        byte[] respBytes = OCSP.getOCSPBytes(
                Collections.singletonList(statInfo.cid),
                statInfo.responder, extsToSend);

        if (respBytes != null) {
            // Place the data into the response cache
            cacheEntry = new ResponseCacheEntry(respBytes,
                    statInfo.cid);

            // Get the response status and act on it appropriately
            if (SSLLogger.isOn && SSLLogger.isOn("respmgr")) {
                SSLLogger.fine("OCSP Status: " + cacheEntry.status +
                    " (" + respBytes.length + " bytes)");
            }
            if (cacheEntry.status ==
                    OCSPResponse.ResponseStatus.SUCCESSFUL) {
                // Set the response in the returned StatusInfo
                statInfo.responseData = cacheEntry;

                // Add the response to the cache (if applicable)
                addToCache(statInfo.cid, cacheEntry);
            }
        } else {
            if (SSLLogger.isOn && SSLLogger.isOn("respmgr")) {
                SSLLogger.fine(
                    "No data returned from OCSP Responder");
            }
        }
    } catch (IOException ioe) {
        if (SSLLogger.isOn && SSLLogger.isOn("respmgr")) {
            SSLLogger.fine("Caught exception: ", ioe);
        }
    }

    return statInfo;
}
 
Example 3
Source File: StatusResponseManager.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Get an OCSP response, either from the cache or from a responder.
 *
 * @return The StatusInfo object passed into the {@code OCSPFetchCall}
 * constructor, with the {@code responseData} field filled in with the
 * response or {@code null} if no response can be obtained.
 */
@Override
public StatusInfo call() {
    debugLog("Starting fetch for SN " + statInfo.cid.getSerialNumber());
    try {
        ResponseCacheEntry cacheEntry;
        List<Extension> extsToSend;

        if (statInfo.responder == null) {
            // If we have no URI then there's nothing to do but return
            debugLog("Null URI detected, OCSP fetch aborted.");
            return statInfo;
        } else {
            debugLog("Attempting fetch from " + statInfo.responder);
        }

        // If the StatusResponseManager has been configured to not
        // forward extensions, then set extensions to an empty list.
        // We will forward the extensions unless one of two conditions
        // occur: (1) The jdk.tls.stapling.ignoreExtensions property is
        // true or (2) There is a non-empty ResponderId list.
        // ResponderId selection is a feature that will be
        // supported in the future.
        extsToSend = (ignoreExtensions || !responderIds.isEmpty()) ?
                Collections.emptyList() : extensions;

        byte[] respBytes = OCSP.getOCSPBytes(
                Collections.singletonList(statInfo.cid),
                statInfo.responder, extsToSend);

        if (respBytes != null) {
            // Place the data into the response cache
            cacheEntry = new ResponseCacheEntry(respBytes,
                    statInfo.cid);

            // Get the response status and act on it appropriately
            debugLog("OCSP Status: " + cacheEntry.status +
                    " (" + respBytes.length + " bytes)");
            if (cacheEntry.status ==
                    OCSPResponse.ResponseStatus.SUCCESSFUL) {
                // Set the response in the returned StatusInfo
                statInfo.responseData = cacheEntry;

                // Add the response to the cache (if applicable)
                addToCache(statInfo.cid, cacheEntry);
            }
        } else {
            debugLog("No data returned from OCSP Responder");
        }
    } catch (IOException ioe) {
        debugLog("Caught exception: " + ioe);
    }

    return statInfo;
}