Search in sources :

Example 1 with OcspInfoType

use of ee.ria.xroad.common.conf.globalconf.sharedparameters.v2.OcspInfoType in project X-Road by nordic-institute.

the class SharedParametersV2 method cacheOcspData.

private void cacheOcspData(List<CaInfoType> typesUnderCA) throws CertificateException, IOException {
    for (CaInfoType caType : typesUnderCA) {
        X509Certificate cert = readCertificate(caType.getCert());
        List<OcspInfoType> caOcspTypes = caType.getOcsp();
        caCertsAndOcspData.put(cert, caOcspTypes);
    }
}
Also used : CaInfoType(ee.ria.xroad.common.conf.globalconf.sharedparameters.v2.CaInfoType) X509Certificate(java.security.cert.X509Certificate) OcspInfoType(ee.ria.xroad.common.conf.globalconf.sharedparameters.v2.OcspInfoType)

Example 2 with OcspInfoType

use of ee.ria.xroad.common.conf.globalconf.sharedparameters.v2.OcspInfoType in project X-Road by nordic-institute.

the class GlobalConfImpl method doGetOcspResponderAddressesForCertificate.

private List<String> doGetOcspResponderAddressesForCertificate(X509Certificate certificate, boolean certificateIsCA) throws Exception {
    List<String> responders = new ArrayList<>();
    for (SharedParametersV2 p : getSharedParameters()) {
        List<OcspInfoType> caOcspData = null;
        X509Certificate caCert;
        try {
            if (!certificateIsCA) {
                caCert = getCaCert(null, certificate);
            } else {
                caCert = certificate;
            }
            caOcspData = p.getCaCertsAndOcspData().get(caCert);
        } catch (CodedException e) {
            log.error("Unable to determine OCSP responders: {}", e);
        }
        if (caOcspData == null) {
            continue;
        }
        caOcspData.stream().map(OcspInfoType::getUrl).filter(StringUtils::isNotBlank).map(String::trim).forEach(responders::add);
    }
    String uri = CertUtils.getOcspResponderUriFromCert(certificate);
    if (uri != null) {
        responders.add(uri.trim());
    }
    return responders;
}
Also used : CodedException(ee.ria.xroad.common.CodedException) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) OcspInfoType(ee.ria.xroad.common.conf.globalconf.sharedparameters.v2.OcspInfoType) X509Certificate(java.security.cert.X509Certificate)

Aggregations

OcspInfoType (ee.ria.xroad.common.conf.globalconf.sharedparameters.v2.OcspInfoType)2 X509Certificate (java.security.cert.X509Certificate)2 CodedException (ee.ria.xroad.common.CodedException)1 CaInfoType (ee.ria.xroad.common.conf.globalconf.sharedparameters.v2.CaInfoType)1 ArrayList (java.util.ArrayList)1 StringUtils (org.apache.commons.lang3.StringUtils)1