]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/dbObjects/SupportedUser.java
add: nucleus assurance
[gigi.git] / src / org / cacert / gigi / dbObjects / SupportedUser.java
index 447825ba8eeb3c81b161d3aaa71bd31152a02d88..044f712b45f0a0ea8988a7f019d24097688824fb 100644 (file)
@@ -3,13 +3,14 @@ package org.cacert.gigi.dbObjects;
 import java.sql.Date;
 
 import org.cacert.gigi.GigiApiException;
-import org.cacert.gigi.database.DatabaseConnection;
 import org.cacert.gigi.database.GigiPreparedStatement;
 import org.cacert.gigi.dbObjects.Certificate.CertificateStatus;
 
 public class SupportedUser {
 
-    private User target, supporter;
+    private User target;
+
+    private User supporter;
 
     private String ticket;
 
@@ -52,12 +53,13 @@ public class SupportedUser {
         if (ticket == null) {
             throw new GigiApiException("No ticket set!");
         }
-        GigiPreparedStatement prep = DatabaseConnection.getInstance().prepare("INSERT INTO adminLog SET uid=?, admin=?, type=?, information=?");
-        prep.setInt(1, target.getId());
-        prep.setInt(2, supporter.getId());
-        prep.setString(3, type);
-        prep.setString(4, ticket);
-        prep.executeUpdate();
+        try (GigiPreparedStatement prep = new GigiPreparedStatement("INSERT INTO `adminLog` SET uid=?, admin=?, type=?, information=?")) {
+            prep.setInt(1, target.getId());
+            prep.setInt(2, supporter.getId());
+            prep.setString(3, type);
+            prep.setString(4, ticket);
+            prep.executeUpdate();
+        }
     }
 
     public int getId() {
@@ -80,4 +82,12 @@ public class SupportedUser {
         target.rawUpdateUserData();
     }
 
+    public void grant(Group toMod) {
+        target.grantGroup(supporter, toMod);
+    }
+
+    public void revoke(Group toMod) {
+        target.revokeGroup(supporter, toMod);
+    }
+
 }