import org.cacert.gigi.util.PasswordHash;
import org.cacert.gigi.util.PasswordStrengthChecker;
+/**
+ * Represents an acting, assurable, user. Synchronizing on user means: no
+ * name-change and no assurance.
+ */
public class User extends CertificateOwner {
private Name name = new Name(null, null, null, null);
}
public int getAssurancePoints() {
- try (GigiPreparedStatement query = new GigiPreparedStatement("SELECT sum(points) FROM `notary` where `to`=? AND `deleted` is NULL")) {
+ try (GigiPreparedStatement query = new GigiPreparedStatement("SELECT sum(points) FROM `notary` where `to`=? AND `deleted` is NULL AND (`expire` IS NULL OR `expire` > CURRENT_TIMESTAMP)")) {
query.setInt(1, getId());
GigiResultSet rs = query.executeQuery();
List<Assurance> assurances = new LinkedList<Assurance>();
while (res.next()) {
- assurances.add(new Assurance(res));
+ assurances.add(assuranceByRes(res));
}
this.receivedAssurances = assurances.toArray(new Assurance[0]);
List<Assurance> assurances = new LinkedList<Assurance>();
while (res.next()) {
- assurances.add(new Assurance(res));
+ assurances.add(assuranceByRes(res));
}
this.madeAssurances = assurances.toArray(new Assurance[0]);
ps.executeUpdate();
}
}
+
+ private Assurance assuranceByRes(GigiResultSet res) {
+ return new Assurance(res.getInt("id"), User.getById(res.getInt("from")), User.getById(res.getInt("to")), res.getString("location"), res.getString("method"), res.getInt("points"), res.getString("date"));
+ }
}