X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;ds=sidebyside;f=src%2Forg%2Fcacert%2Fgigi%2FdbObjects%2FSupportedUser.java;h=a663215a8c658913c0d4991b552de9cc68941c6d;hb=1d08cc98005de07c416207536bcae3592fbc7b73;hp=7affe34caa18c35625e8a0cff56ab02d10248469;hpb=8862fb3f5a428afff2a0321ee83e880e14b1a252;p=gigi.git diff --git a/src/org/cacert/gigi/dbObjects/SupportedUser.java b/src/org/cacert/gigi/dbObjects/SupportedUser.java index 7affe34c..a663215a 100644 --- a/src/org/cacert/gigi/dbObjects/SupportedUser.java +++ b/src/org/cacert/gigi/dbObjects/SupportedUser.java @@ -1,18 +1,15 @@ package org.cacert.gigi.dbObjects; import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringWriter; import java.util.HashMap; import java.util.Locale; import org.cacert.gigi.GigiApiException; import org.cacert.gigi.database.GigiPreparedStatement; import org.cacert.gigi.dbObjects.Certificate.CertificateStatus; -import org.cacert.gigi.email.SendMail; import org.cacert.gigi.localisation.Language; +import org.cacert.gigi.output.template.MailTemplate; import org.cacert.gigi.output.template.Outputable; -import org.cacert.gigi.output.template.SprintfCommand; import org.cacert.gigi.util.DayDate; import org.cacert.gigi.util.ServerConstants; @@ -30,21 +27,12 @@ public class SupportedUser { this.ticket = ticket; } - public boolean setName(Name newName) throws GigiApiException { - if (newName.equals(target.getName())) { - return false; - } - writeSELog("SE Name change"); - target.setName(newName); - return true; - } - public boolean setDob(DayDate dob) throws GigiApiException { if (dob.equals(target.getDoB())) { return false; } writeSELog("SE dob change"); - target.setDoB(dob); + target.setDoBAsSupport(dob); return true; } @@ -59,6 +47,15 @@ public class SupportedUser { } } + public void revokeCertificate(Certificate cert) throws GigiApiException { + + // TODO Check for open jobs! + if (cert.getStatus() == CertificateStatus.ISSUED) { + writeSELog("SE Revoke certificate"); + cert.revoke().waitFor(60000); + } + } + private void writeSELog(String type) throws GigiApiException { if (ticket == null) { throw new GigiApiException("No ticket set!"); @@ -88,10 +85,6 @@ public class SupportedUser { return target; } - public void submitSupportAction() throws GigiApiException { - target.rawUpdateUserData(); - } - public void grant(Group toMod) { target.grantGroup(supporter, toMod); } @@ -100,19 +93,18 @@ public class SupportedUser { target.revokeGroup(supporter, toMod); } + private static final MailTemplate supportNotification = new MailTemplate(SupportedUser.class.getResource("SupportNotificationMail.templ")); + public void sendSupportNotification(String subject, Outputable message) { try { - StringWriter sw = new StringWriter(); - PrintWriter outMail = new PrintWriter(sw); - outMail.print("Hi," + "\n\n"); - SprintfCommand.createSimple("supporter {0} triggered:", supporter.getName().toString()).output(outMail, Language.getInstance(Locale.ENGLISH), new HashMap()); - outMail.print("\n\n"); - message.output(outMail, Language.getInstance(Locale.ENGLISH), new HashMap()); - outMail.print("\n\n"); - outMail.print("RA DB"); - outMail.close(); - String supportemailaddress = "support@" + ServerConstants.getWwwHostName().replaceFirst("^www\\.", ""); - SendMail.getInstance().sendMail(supportemailaddress, "[" + this.getTicket() + "] RA DB " + subject, sw.toString(), supportemailaddress, null, null, null, null, false); + HashMap vars = new HashMap<>(); + vars.put("supporter", supporter.getPreferredName().toString()); + vars.put("action", message); + vars.put("ticket", this.getTicket()); + vars.put("subject", subject); + + String supportemailaddress = ServerConstants.getSupportMailAddress(); + supportNotification.sendMail(Language.getInstance(Locale.ENGLISH), vars, supportemailaddress); } catch (IOException e) { e.printStackTrace(); }