private String createUnsubscribeUrl(String email, Notification notification) {
   StringBuilder sb = new StringBuilder();
   String baseUrl = systemConfig.getUrl();
   sb.append(baseUrl);
   if (!baseUrl.endsWith("/")) sb.append("/");
   sb.append("unsubscribe");
   sb.append("?email=").append(Str.encodeUrlParameter(email));
   if (notification.subject != null)
     sb.append("&subject=").append(Str.encodeUrlParameter(notification.subject.getId()));
   sb.append("&key=").append(Str.encodeUrlParameter(createKey(email)));
   return sb.toString();
 }
 private String createText(String email, Notification notification) {
   String text = notification.project.getSubscriberNotificationTemplate();
   if (notification.subject instanceof ReferenceSupport) {
     text =
         text.replace(
             "${entity.reference}", ((ReferenceSupport) notification.subject).getReference());
   }
   if (notification.subject instanceof LabelSupport) {
     text = text.replace("${entity.label}", ((LabelSupport) notification.subject).getLabel());
   }
   text = text.replace("${change.message}", notification.message);
   text = text.replace("${project.label}", notification.project.getLabel());
   text = text.replace("${project.id}", notification.project.getId());
   if (notification.project.isProductLabelSet())
     text = text.replace("${product.label}", notification.project.getProductLabel());
   if (notification.project.isHomepageUrlSet())
     text = text.replace("${homepage.url}", notification.project.getHomepageUrl());
   text = text.replace("${unsubscribe.url}", createUnsubscribeUrl(email, notification));
   text = text.replace("${unsubscribeall.url}", createUnsubscribeUrl(email, notification));
   text = text.replace("${kunagi.instance}", systemConfig.getInstanceNameWithApplicationLabel());
   text = text.replace("${kunagi.url}", systemConfig.getUrl());
   return text;
 }
示例#3
0
 @Override
 public void onTestLdap(GwtConversation conversation) {
   SystemConfig config = webApplication.getSystemConfig();
   try {
     Ldap.authenticateUserGetEmail(
         config.getLdapUrl(),
         config.getLdapUser(),
         config.getLdapPassword(),
         config.getLdapBaseDn(),
         config.getLdapUserFilterRegex(),
         "dummyUser",
         "dummyPassword");
   } catch (AuthenticationFailedException ex) {
   }
 }
示例#4
0
 private void onSystemConfigChanged(
     GwtConversation conversation, SystemConfig config, Map properties) {
   if (properties.containsKey("url")) {
     webApplication.getConfig().setUrl(config.getUrl());
   }
 }
 private String createKey(String email) {
   return PasswordHasher.hashPassword(email, systemConfig.getSubscriptionKeySeed());
 }