]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/pages/admin/support/SupportUserDetailsPage.java
UPD: Use the ENUM
[gigi.git] / src / org / cacert / gigi / pages / admin / support / SupportUserDetailsPage.java
index b9368e42edbb44872729afdb2b002ffe465a4a1b..a16ff0760651223b32cc8e4f6549f0db169fdca5 100644 (file)
@@ -1,21 +1,16 @@
 package org.cacert.gigi.pages.admin.support;
 
 import java.io.IOException;
-import java.security.GeneralSecurityException;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.cacert.gigi.dbObjects.Certificate;
-import org.cacert.gigi.dbObjects.CertificateProfile;
 import org.cacert.gigi.dbObjects.EmailAddress;
 import org.cacert.gigi.dbObjects.Group;
 import org.cacert.gigi.dbObjects.User;
 import org.cacert.gigi.localisation.Language;
-import org.cacert.gigi.output.DateSelector;
 import org.cacert.gigi.output.template.IterableDataset;
 import org.cacert.gigi.pages.Page;
 
@@ -43,55 +38,18 @@ public class SupportUserDetailsPage extends Page {
 
             @Override
             public boolean next(Language l, Map<String, Object> vars) {
+                if (i == addrs.length) {
+                    return false;
+                }
                 String address = addrs[i].getAddress();
+                i++;
                 if ( !address.equals(user.getEmail())) {
                     vars.put("secmail", address);
                 }
-                i++;
-                return i != addrs.length - 1;
-            }
-        });
-        final Certificate[] certs = user.getCertificates(true);
-        final CertificateProfile[] profiles = CertificateProfile.getAll();
-        vars.put("types", new IterableDataset() {
-
-            int typeIndex = 0;
-
-            @Override
-            public boolean next(Language l, Map<String, Object> vars) {
-                if (typeIndex > profiles.length - 1) {
-                    return false;
-                }
-                int valid = 0;
-                int total = 0;
-                long lastExpire = Long.MIN_VALUE;
-                for (int i = 0; i < certs.length; i++) {
-                    try {
-                        if (certs[i].getProfile().getId() != profiles[typeIndex].getId()) {
-                            continue;
-                        }
-                        total++;
-                        certs[i].cert().checkValidity();
-                        lastExpire = Math.max(lastExpire, certs[i].cert().getNotAfter().getTime());
-                        valid++;
-                    } catch (GeneralSecurityException | IOException e) {
-                        continue;
-                    }
-                }
-                vars.put("total", total);
-                vars.put("profile", profiles[typeIndex].getVisibleName());
-                vars.put("valid", valid);
-                vars.put("exp", total - valid);
-                vars.put("rev", "TODO");
-                if (lastExpire == Long.MIN_VALUE) {
-                    vars.put("lastdate", "-");
-                } else {
-                    vars.put("lastdate", DateSelector.getDateFormat().format(new Date(lastExpire)));
-                }
-                typeIndex++;
                 return true;
             }
         });
+        vars.put("certifrevoke", new SupportRevokeCertificatesForm(req, user));
         getDefaultTemplate().output(resp.getWriter(), getLanguage(req), vars);
     }
 
@@ -100,6 +58,6 @@ public class SupportUserDetailsPage extends Page {
         if (u == null) {
             return false;
         }
-        return u.isInGroup(Group.getByString("supporter"));
+        return u.isInGroup(Group.SUPPORTER);
     }
 }