+ String message = req.getParameter("message");
+ if (message != null && message.isEmpty()) {
+ message = null;
+ }
+ if (message != null) {
+ if (message.startsWith(CONFIDENTIAL_MARKER)) {
+ message = " " + message;
+ }
+ String confidential = req.getParameter("confidential");
+ if (confidential != null && !confidential.isEmpty()) {
+ message = CONFIDENTIAL_MARKER + "\n" + message;
+ }
+ if (message.contains("---")) {
+ throw new GigiApiException("Your message may not contain '---'.");
+ }
+ if ( !message.matches("[ -~\r\n\t]*")) {
+ throw new GigiApiException("Your message may only contain printable ASCII characters, tab, newline and space.");
+ }
+ }
+ CertificateOwner co = c.getOwner();
+ String primaryEmail;
+ Language l = Language.getInstance(Locale.ENGLISH);
+ if (co instanceof User) {
+ primaryEmail = ((User) co).getEmail();
+ l = Language.getInstance(((User) co).getPreferredLocale());
+ } else if (co instanceof Organisation) {
+ primaryEmail = ((Organisation) co).getContactEmail();
+ } else {
+ throw new IllegalArgumentException("certificate owner of unknown type");
+ }
+ HashMap<String, Object> vars = new HashMap<>();
+ vars.put("appName", ServerConstants.getAppName());
+ if (message != null && !message.startsWith(CONFIDENTIAL_MARKER)) {
+ vars.put("message", message);
+ } else {
+ vars.put("message", null);
+ }
+ vars.put("serial", c.getSerial());
+ try {
+ revocationNotice.sendMail(l, vars, primaryEmail);
+ } catch (IOException e) {
+ throw new GigiApiException("Sending the notification mail failed.");
+ }
+ Job j = c.revoke(challenge, Base64.getEncoder().encodeToString(signature), message);