class HealthChecks {

    public static HealthCheckProvider checkAuthKeyOcspStatus() {

        return () -> {

            // this fails if signer is down
            AuthKey authKey = KeyConf.getAuthKey();

            if (authKey == null) {
                return failure("No authentication key available. Signer might be down.");
            }

            CertChain certChain = authKey.getCertChain();

            if (certChain == null) {
                return failure("No certificate chain available in authentication key.");
            }
            X509Certificate certificate = certChain.getEndEntityCert();

            if (certificate == null) {
                return failure("No end entity certificate available for authentication key.");
            }

            int ocspStatus;

            try {
                ocspStatus = KeyConf.getOcspResponse(certificate).getStatus();
            } catch (Exception e) {
                log.error("Getting OCSP response for authentication key failed, got exception", e);
                return failure("Getting OCSP response for authentication key failed.");
            }

            return new HealthCheckResult(OCSPResp.SUCCESSFUL == ocspStatus,
                    "Authentication key OCSP response status " + ocspStatus);
        };
    }

    private  HealthChecks();

}