package org.cacert.gigi.dbObjects;
import java.sql.Date;
+import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Locale;
import java.util.Set;
if ( !rs.next()) {
throw new GigiApiException("User not found... very bad.");
}
- if ( !PasswordHash.verifyHash(oldPass, rs.getString(1))) {
+ if (PasswordHash.verifyHash(oldPass, rs.getString(1)) == null) {
throw new GigiApiException("Old password does not match.");
}
rs.close();
}
}
+ public void setName(Name name) {
+ this.name = name;
+ }
+
public boolean canAssure() {
if ( !isOfAge(14)) { // PoJAM
return false;
ps.execute();
}
+ public List<Organisation> getOrganisations() {
+ List<Organisation> orgas = new ArrayList<>();
+ GigiPreparedStatement query = DatabaseConnection.getInstance().prepare("SELECT orgid FROM org_admin WHERE `memid`=? AND deleted is NULL");
+ query.setInt(1, getId());
+ GigiResultSet res = query.executeQuery();
+
+ while (res.next()) {
+ orgas.add(Organisation.getById(res.getInt(1)));
+ }
+ return orgas;
+ }
+
public static synchronized User getById(int id) {
CertificateOwner co = CertificateOwner.getById(id);
if (co instanceof User) {
return null;
}
+ public static User getByEmail(String mail) {
+ GigiPreparedStatement ps = DatabaseConnection.getInstance().prepare("SELECT users.id FROM users inner join certOwners on certOwners.id=users.id WHERE email=? AND deleted is null");
+ ps.setString(1, mail);
+ GigiResultSet rs = ps.executeQuery();
+ if ( !rs.next()) {
+ return null;
+ }
+ return User.getById(rs.getInt(1));
+ }
+
+ public static User[] findByEmail(String mail) {
+ LinkedList<User> results = new LinkedList<User>();
+ GigiPreparedStatement ps = DatabaseConnection.getInstance().prepare("SELECT users.id FROM users inner join certOwners on certOwners.id=users.id WHERE users.email LIKE ? AND deleted is null GROUP BY users.id ASC LIMIT 100");
+ ps.setString(1, mail);
+ GigiResultSet rs = ps.executeQuery();
+ while (rs.next()) {
+ results.add(User.getById(rs.getInt(1)));
+ }
+ return results.toArray(new User[results.size()]);
+ }
+
public boolean canIssue(CertificateProfile p) {
switch (p.getCAId()) {
case 0:
return false;
}
}
+
}