Search in sources :

Example 1 with HealthCheckResult

use of org.xipki.common.HealthCheckResult in project xipki by xipki.

the class OcspServerImpl method healthCheck.

@Override
public HealthCheckResult healthCheck(Responder responder2) {
    ResponderImpl responder = (ResponderImpl) responder2;
    HealthCheckResult result = new HealthCheckResult("OCSPResponder");
    boolean healthy = true;
    for (OcspStore store : responder.getStores()) {
        boolean storeHealthy = store.isHealthy();
        healthy &= storeHealthy;
        HealthCheckResult storeHealth = new HealthCheckResult("CertStatusStore." + store.getName());
        storeHealth.setHealthy(storeHealthy);
        result.addChildCheck(storeHealth);
    }
    boolean signerHealthy = responder.getSigner().isHealthy();
    healthy &= signerHealthy;
    HealthCheckResult signerHealth = new HealthCheckResult("Signer");
    signerHealth.setHealthy(signerHealthy);
    result.addChildCheck(signerHealth);
    result.setHealthy(healthy);
    return result;
}
Also used : OcspStore(org.xipki.ocsp.api.OcspStore) HealthCheckResult(org.xipki.common.HealthCheckResult)

Example 2 with HealthCheckResult

use of org.xipki.common.HealthCheckResult in project xipki by xipki.

the class HealthCheckResultTest method test1.

@Test
public void test1() {
    String encoded = "{\"healthy\":true}";
    HealthCheckResult result = HealthCheckResult.getInstanceFromJsonMessage("default", encoded);
    String noPrettyJson = "{\"healthy\":true}";
    String prettyJson = "{\n" + "    \"healthy\":true\n" + "}";
    check(result, noPrettyJson, prettyJson);
}
Also used : HealthCheckResult(org.xipki.common.HealthCheckResult) Test(org.junit.Test)

Example 3 with HealthCheckResult

use of org.xipki.common.HealthCheckResult in project xipki by xipki.

the class HealthCheckResultTest method test3.

@Test
public void test3() {
    HealthCheckResult result = new HealthCheckResult("mycheck-negative");
    result.setHealthy(false);
    String noPrettyJson = "{\"healthy\":false}";
    String prettyJson = "{\n" + "    \"healthy\":false\n" + "}";
    check(result, noPrettyJson, prettyJson);
}
Also used : HealthCheckResult(org.xipki.common.HealthCheckResult) Test(org.junit.Test)

Example 4 with HealthCheckResult

use of org.xipki.common.HealthCheckResult in project xipki by xipki.

the class HealthCheckResultTest method test4.

@Test
public void test4() {
    HealthCheckResult result = new HealthCheckResult("mycheck-positive");
    result.setHealthy(true);
    String noPrettyJson = "{\"healthy\":true}";
    String prettyJson = "{\n" + "    \"healthy\":true\n" + "}";
    check(result, noPrettyJson, prettyJson);
}
Also used : HealthCheckResult(org.xipki.common.HealthCheckResult) Test(org.junit.Test)

Example 5 with HealthCheckResult

use of org.xipki.common.HealthCheckResult in project xipki by xipki.

the class HealthCmd method execute0.

@Override
protected Object execute0() throws Exception {
    if (caName != null) {
        caName = caName.toLowerCase();
    }
    Set<String> caNames = caClient.getCaNames();
    if (isEmpty(caNames)) {
        throw new IllegalCmdParamException("no CA is configured");
    }
    if (caName != null && !caNames.contains(caName)) {
        throw new IllegalCmdParamException("CA " + caName + " is not within the configured CAs " + caNames);
    }
    if (caName == null) {
        if (caNames.size() == 1) {
            caName = caNames.iterator().next();
        } else {
            throw new IllegalCmdParamException("no CA is specified, one of " + caNames + " is required");
        }
    }
    HealthCheckResult healthResult = caClient.getHealthCheckResult(caName);
    String str = StringUtil.concat("healthy status for CA ", caName, ": ", (healthResult.isHealthy() ? "healthy" : "not healthy"));
    if (verbose) {
        str = StringUtil.concat(str, "\n", healthResult.toJsonMessage(true));
    }
    System.out.println(str);
    return null;
}
Also used : IllegalCmdParamException(org.xipki.console.karaf.IllegalCmdParamException) HealthCheckResult(org.xipki.common.HealthCheckResult)

Aggregations

HealthCheckResult (org.xipki.common.HealthCheckResult)14 Test (org.junit.Test)5 EOFException (java.io.EOFException)4 HttpMethod (io.netty.handler.codec.http.HttpMethod)2 HttpResponseStatus (io.netty.handler.codec.http.HttpResponseStatus)2 HttpVersion (io.netty.handler.codec.http.HttpVersion)2 X509CaCmpResponder (org.xipki.ca.server.api.X509CaCmpResponder)2 ResponderAndPath (org.xipki.ocsp.api.ResponderAndPath)2 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 HttpURLConnection (java.net.HttpURLConnection)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 CaClientException (org.xipki.ca.client.api.CaClientException)1 ResponderManager (org.xipki.ca.server.api.ResponderManager)1 IllegalCmdParamException (org.xipki.console.karaf.IllegalCmdParamException)1 OcspServer (org.xipki.ocsp.api.OcspServer)1 OcspStore (org.xipki.ocsp.api.OcspStore)1 ConcurrentContentSigner (org.xipki.security.ConcurrentContentSigner)1