1 package org.cacert.gigi.dbObjects;
5 import org.cacert.gigi.GigiApiException;
6 import org.cacert.gigi.database.DatabaseConnection;
7 import org.cacert.gigi.database.GigiPreparedStatement;
9 public class SupportedUser {
11 private User target, supporter;
13 private String ticket;
15 public SupportedUser(User target, User supporter, String ticket) {
16 this.supporter = supporter;
21 public boolean setName(Name newName) throws GigiApiException {
22 if (newName.equals(target.getName())) {
25 writeSELog("SE Name change");
26 target.setName(newName);
30 public boolean setDob(Date dob) throws GigiApiException {
31 if (dob.toString().equals(target.getDoB().toString())) {
34 writeSELog("SE dob change");
39 public void revokeAllCertificates() throws GigiApiException {
40 writeSELog("SE Revoke certificates");
41 Certificate[] certs = target.getCertificates(false);
42 for (int i = 0; i < certs.length; i++) {
47 private void writeSELog(String type) throws GigiApiException {
49 throw new GigiApiException("No ticket set!");
51 GigiPreparedStatement prep = DatabaseConnection.getInstance().prepare("INSERT INTO adminLog SET uid=?, admin=?, type=?, information=?");
52 prep.setInt(1, target.getId());
53 prep.setInt(2, supporter.getId());
54 prep.setString(3, type);
55 prep.setString(4, ticket);
60 return target.getId();
63 public Certificate[] getCertificates(boolean includeRevoked) {
64 return target.getCertificates(includeRevoked);
67 public String getTicket() {
71 public User getTargetUser() {
75 public void submitSupportAction() throws GigiApiException {
76 target.rawUpdateUserData();