X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;ds=sidebyside;f=src%2Forg%2Fcacert%2Fgigi%2FdbObjects%2FSupportedUser.java;h=e600b85bf2d2fca302375d18e06693e19108c056;hb=2b238f215190e6d24fa928a657fa0fb30059abb7;hp=e5daeb31bc0be4923418d595b006147068385f6b;hpb=9efe305311c7e9f78a41093d2e2e9c57bfd10c7b;p=gigi.git diff --git a/src/org/cacert/gigi/dbObjects/SupportedUser.java b/src/org/cacert/gigi/dbObjects/SupportedUser.java index e5daeb31..e600b85b 100644 --- a/src/org/cacert/gigi/dbObjects/SupportedUser.java +++ b/src/org/cacert/gigi/dbObjects/SupportedUser.java @@ -4,6 +4,8 @@ import java.io.IOException; import java.util.HashMap; import java.util.Locale; +import javax.servlet.http.HttpServletRequest; + import org.cacert.gigi.GigiApiException; import org.cacert.gigi.database.GigiPreparedStatement; import org.cacert.gigi.dbObjects.Certificate.CertificateStatus; @@ -11,6 +13,8 @@ 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.output.template.TranslateCommand; +import org.cacert.gigi.pages.PasswordResetPage; import org.cacert.gigi.util.DayDate; import org.cacert.gigi.util.ServerConstants; @@ -34,6 +38,13 @@ public class SupportedUser { } writeSELog("SE dob change"); target.setDoBAsSupport(dob); + String subject = "Change DoB Data"; + // send notification to support + Outputable message = new TranslateCommand("The DoB was changed."); + sendSupportNotification(subject, message); + // send notification to user + message = SprintfCommand.createSimple("The DoB in your account was changed to {0}.", dob); + sendSupportUserNotification(subject, message); return true; } @@ -46,6 +57,11 @@ public class SupportedUser { certs[i].revoke(); } } + // send notification to support + Outputable message = SprintfCommand.createSimple("All certificates in the account {0} <{1}> have been revoked.", target.getPreferredName().toString(), target.getEmail()); + sendSupportNotification("Revoke certificates", message); + // send notification to user + sendSupportUserNotification("Revoke certificate", new TranslateCommand("All certificates in your account have been revoked.")); } public void revokeCertificate(Certificate cert) throws GigiApiException { @@ -56,7 +72,7 @@ public class SupportedUser { cert.revoke().waitFor(60000); // send notification to support String subject = "Revoke certificate"; - Outputable message = SprintfCommand.createSimple("Certificate with serial number {0} for {1} <{2}>, has been revoked.", cert.getSerial(), target.getPreferredName().toString(), target.getEmail()); + Outputable message = SprintfCommand.createSimple("Certificate with serial number {0} for {1} <{2}> has been revoked.", cert.getSerial(), target.getPreferredName().toString(), target.getEmail()); sendSupportNotification(subject, message); // send notification to user subject = "Revoke certificate"; @@ -96,15 +112,39 @@ public class SupportedUser { public void grant(Group toMod) throws GigiApiException { target.grantGroup(supporter, toMod); + String subject = "Change Group Permissions"; + // send notification to support + Outputable message = SprintfCommand.createSimple("The group permission '{0}' was granted.", toMod.getName()); + sendSupportNotification(subject, message); + // send notification to user + message = SprintfCommand.createSimple("The group permission '{0}' was granted to your account.", toMod.getName()); + sendSupportUserNotification(subject, message); + if (toMod == Group.SUPPORTER) { + subject = "Support role granted"; + message = SprintfCommand.createSimple("The group permission '{0}' was granted for '{1}'.", toMod.getName(), target.getPreferredName().toString()); + sendBoardNotification(subject, message); + } } - public void revoke(Group toMod) { + public void revoke(Group toMod) throws GigiApiException { target.revokeGroup(supporter, toMod); + String subject = "Change Group Permissions"; + // send notification to support + Outputable message = SprintfCommand.createSimple("The group permission '{0}' was revoked.", toMod.getName()); + sendSupportNotification(subject, message); + // send notification to user + message = SprintfCommand.createSimple("The group permission '{0}' was revoked from your account.", toMod.getName()); + sendSupportUserNotification(subject, message); + if (toMod == Group.SUPPORTER) { + subject = "Support role revoked"; + message = SprintfCommand.createSimple("The group permission '{0}' was revoked for '{1}'.", toMod.getName(), target.getPreferredName().toString()); + sendBoardNotification(subject, message); + } } private static final MailTemplate supportNotification = new MailTemplate(SupportedUser.class.getResource("SupportNotificationMail.templ")); - public void sendSupportNotification(String subject, Outputable message) { + private void sendSupportNotification(String subject, Outputable message) { try { HashMap vars = new HashMap<>(); vars.put("supporter", supporter.getPreferredName().toString()); @@ -121,7 +161,7 @@ public class SupportedUser { private static final MailTemplate supportUserNotification = new MailTemplate(SupportedUser.class.getResource("SupportUserNotificationMail.templ")); - public void sendSupportUserNotification(String subject, Outputable message) { + private void sendSupportUserNotification(String subject, Outputable message) { try { HashMap vars = new HashMap<>(); vars.put("action", message); @@ -133,4 +173,28 @@ public class SupportedUser { e.printStackTrace(); } } + + public void triggerPasswordReset(String aword, HttpServletRequest req) { + Language l = Language.getInstance(target.getPreferredLocale()); + String method = l.getTranslation("A password reset was triggered. Please enter the required text sent to you by support on this page:"); + String subject = l.getTranslation("Password reset by support."); + PasswordResetPage.initPasswordResetProcess(target, req, aword, l, method, subject); + Outputable message = new TranslateCommand("A password reset was triggered and an email was sent to user."); + sendSupportNotification(subject, message); + } + + private void sendBoardNotification(String subject, Outputable message) { + try { + HashMap vars = new HashMap<>(); + vars.put("supporter", supporter.getPreferredName().toString()); + vars.put("action", message); + vars.put("ticket", this.getTicket()); + vars.put("subject", subject); + + String boardemailaddress = ServerConstants.getBoardMailAddress(); + supportNotification.sendMail(Language.getInstance(Locale.ENGLISH), vars, boardemailaddress); + } catch (IOException e) { + e.printStackTrace(); + } + } }