- try {
- if (csr != null) {
- cr = new CertificateRequest(c, csr);
- cr.checkKeyStrength(out);
- } else if (spkac != null) {
- cr = new CertificateRequest(c, spkac, spkacChallenge);
- cr.checkKeyStrength(out);
- } else if (cr != null) {
- login = "1".equals(req.getParameter("login"));
- issueDate.update(req);
- GigiApiException error = new GigiApiException();
-
- try {
- cr.update(req.getParameter("CN"), req.getParameter("hash_alg"), req.getParameter("profile"), //
- req.getParameter("org"), req.getParameter("OU"), req.getParameter("SANs"), out, req);
- } catch (GigiApiException e) {
- error.mergeInto(e);
- }
- if (req.getParameter("CCA") == null) {
- error.mergeInto(new GigiApiException("You need to accept the CCA."));
- }
- Certificate result = null;
- try {
- result = cr.draft();
- } catch (GigiApiException e) {
- error.mergeInto(e);
- }
- if ( !error.isEmpty() || result == null) {
- error.format(out, Page.getLanguage(req));
- return false;
- }
- result.issue(issueDate.getFrom(), issueDate.getTo(), c.getActor()).waitFor(60000);
- this.result = result;
- return true;
- } else {
- throw new GigiApiException("Error no action.");
+ if (csr != null) {
+ cr = new CertificateRequest(c, csr);
+ // TODO cr.checkKeyStrength(out);
+ return new FormContinue();
+ } else if (spkac != null) {
+ cr = new CertificateRequest(c, spkac, spkacChallenge);
+ // TODO cr.checkKeyStrength(out);
+ return new FormContinue();
+ } else if (cr != null) {
+ login = "1".equals(req.getParameter("login"));
+ issueDate.update(req);
+ GigiApiException error = new GigiApiException();
+
+ try {
+ cr.update(req.getParameter("CN"), req.getParameter("hash_alg"), req.getParameter("profile"), //
+ req.getParameter("org"), req.getParameter("OU"), req.getParameter("SANs"));
+ } catch (GigiApiException e) {
+ error.mergeInto(e);
+ }
+
+ Certificate result = null;
+ try {
+ result = cr.draft();
+ } catch (GigiApiException e) {
+ error.mergeInto(e);
+ }
+ if ( !error.isEmpty() || result == null) {
+ throw error;
+ }
+ if (login) {
+ result.setLoginEnabled(true);
+ }
+ result.issue(issueDate.getFrom(), issueDate.getTo(), c.getActor()).waitFor(60000);
+ this.result = result;
+ Certificate c = result;
+ if (c.getStatus() != CertificateStatus.ISSUED) {
+ throw new PermamentFormException(new GigiApiException("Timeout while waiting for certificate."));
+ }
+ String ser = c.getSerial();
+ if (ser.isEmpty()) {
+ throw new PermamentFormException(new GigiApiException("Timeout while waiting for certificate."));