use of org.xipki.console.karaf.CmdFailure in project xipki by xipki.
the class GetCaCertCmd method execute0.
@Override
protected Object execute0() throws Exception {
CaIdentifier tmpCaId = new CaIdentifier(url, caId);
CaCertValidator caCertValidator = new CaCertValidator() {
@Override
public boolean isTrusted(X509Certificate cert) {
return true;
}
};
ScepClient client = new ScepClient(tmpCaId, caCertValidator);
client.init();
X509Certificate caCert = client.getCaCert();
if (caCert == null) {
throw new CmdFailure("received no CA certficate from server");
}
saveVerbose("saved certificate to file", new File(outFile), caCert.getEncoded());
return null;
}
use of org.xipki.console.karaf.CmdFailure in project xipki by xipki.
the class GetCrlCmd method execute0.
@Override
protected Object execute0() throws Exception {
Certificate cert = Certificate.getInstance(IoUtil.read(certFile));
ScepClient client = getScepClient();
X509CRL crl = client.scepGetCrl(getIdentityKey(), getIdentityCert(), cert.getIssuer(), cert.getSerialNumber().getPositiveValue());
if (crl == null) {
throw new CmdFailure("received no CRL from server");
}
saveVerbose("saved CRL to file", new File(outputFile), crl.getEncoded());
return null;
}
use of org.xipki.console.karaf.CmdFailure in project xipki by xipki.
the class CaRequestorCheckCmd method execute0.
@Override
protected Object execute0() throws Exception {
println("checking CA requestor CA='" + caName + "', requestor='" + requestorName + "'");
if (caManager.getCa(caName) == null) {
throw new UnexpectedException("could not find CA '" + caName + "'");
}
Set<CaHasRequestorEntry> entries = caManager.getRequestorsForCa(caName);
CaHasRequestorEntry entry = null;
String upRequestorName = requestorName.toLowerCase();
for (CaHasRequestorEntry m : entries) {
if (m.getRequestorIdent().getName().equals(upRequestorName)) {
entry = m;
break;
}
}
if (entry == null) {
throw new CmdFailure("CA is not associated with requestor '" + requestorName + "'");
}
boolean ra = isEnabled(raS, false, "ra");
boolean bo = entry.isRa();
if (ra != bo) {
throw new CmdFailure("ra: is '" + bo + "', expected '" + ra + "'");
}
if (permissions != null) {
int intPermission = ShellUtil.getPermission(permissions);
if (intPermission != entry.getPermission()) {
throw new CmdFailure("permissions: is '" + entry.getPermission() + "', but expected '" + intPermission + "'");
}
}
if (profiles != null) {
if (profiles.size() == 1) {
if (CaManager.NULL.equalsIgnoreCase(profiles.iterator().next())) {
profiles = Collections.emptySet();
}
}
if (!profiles.equals(entry.getProfiles())) {
throw new CmdFailure("profiles: is '" + entry.getProfiles() + "', but expected '" + profiles + "'");
}
}
println(" checked CA requestor CA='" + caName + "', requestor='" + requestorName + "'");
return null;
}
use of org.xipki.console.karaf.CmdFailure in project xipki by xipki.
the class CertPollCmd method execute0.
@Override
protected Object execute0() throws Exception {
CertificationRequest csr = CertificationRequest.getInstance(IoUtil.read(csrFile));
ScepClient client = getScepClient();
X509Certificate caCert = client.getAuthorityCertStore().getCaCert();
X500Name caSubject = X500Name.getInstance(caCert.getSubjectX500Principal().getEncoded());
EnrolmentResponse resp = client.scepCertPoll(getIdentityKey(), getIdentityCert(), csr, caSubject);
if (resp.isFailure()) {
throw new CmdFailure("server returned 'failure'");
}
if (resp.isPending()) {
throw new CmdFailure("server returned 'pending'");
}
List<X509Certificate> certs = resp.getCertificates();
if (certs == null || certs.isEmpty()) {
throw new CmdFailure("received no certficate from server");
}
saveVerbose("saved certificate to file", new File(outputFile), certs.get(0).getEncoded());
return null;
}
use of org.xipki.console.karaf.CmdFailure in project xipki by xipki.
the class GetCertCmd method execute0.
@Override
protected Object execute0() throws Exception {
ScepClient client = getScepClient();
BigInteger serial = toBigInt(serialNumber);
X509Certificate caCert = client.getAuthorityCertStore().getCaCert();
X500Name caSubject = X500Name.getInstance(caCert.getSubjectX500Principal().getEncoded());
List<X509Certificate> certs = client.scepGetCert(getIdentityKey(), getIdentityCert(), caSubject, serial);
if (certs == null || certs.isEmpty()) {
throw new CmdFailure("received no certficate from server");
}
saveVerbose("saved certificate to file", new File(outputFile), certs.get(0).getEncoded());
return null;
}
Aggregations