]> 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 46b4aca292f0455631a29bf0d4320efc212b7997..a16ff0760651223b32cc8e4f6549f0db169fdca5 100644 (file)
@@ -1,20 +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;
 
@@ -42,55 +38,26 @@ 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);
     }
+
+    @Override
+    public boolean isPermitted(User u) {
+        if (u == null) {
+            return false;
+        }
+        return u.isInGroup(Group.SUPPORTER);
+    }
 }