private int id;
- Name name = new Name(null, null, null, null);
+ private Name name = new Name(null, null, null, null);
- Date dob;
+ private Date dob;
- String email;
+ private String email;
public User(int id) {
this.id = id;
return null;
}
+ public Certificate[] getCertificates() {
+ try {
+ PreparedStatement ps = DatabaseConnection.getInstance().prepare("SELECT serial FROM certs WHERE memid=? AND revoked=0");
+ ps.setInt(1, id);
+ ResultSet rs = ps.executeQuery();
+ rs.last();
+ int count = rs.getRow();
+ Certificate[] data = new Certificate[count];
+ rs.beforeFirst();
+ for (int i = 0; i < data.length; i++) {
+ if ( !rs.next()) {
+ throw new Error("Internal sql api violation.");
+ }
+ data[i] = Certificate.getBySerial(rs.getString(1));
+ }
+ rs.close();
+ return data;
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
+ public boolean isValidDomain(String domainname) {
+ for (Domain d : getDomains()) {
+ String sfx = d.getSuffix();
+ if (domainname.equals(sfx) || domainname.endsWith("." + sfx)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean isValidEmail(String email) {
+ for (EmailAddress em : getEmails()) {
+ if (em.getAddress().equals(email)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean isValidName(String name) {
+ return getName().matches(name);
+ }
+
public void updateDefaultEmail(EmailAddress newMail) throws GigiApiException {
try {
EmailAddress[] adrs = getEmails();