From b541f4bbe8f95fcce635c8854405e8b926d5203d Mon Sep 17 00:00:00 2001 From: "SIMONVOLLENDORF\\Simon" <simon.vollendorf@smail.inf.h-brs.de> Date: Mon, 19 Jun 2017 15:10:32 +0200 Subject: [PATCH] -Bearbeitung der RegView, -DAO und -Control --- src/main/java/org/s4s/dao/RegistrationDAO.java | 4 ++-- src/main/java/org/s4s/dao/impl/RegistrationControl.java | 9 +++------ src/main/java/org/s4s/gui/views/RegistrierungView.java | 1 + 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/s4s/dao/RegistrationDAO.java b/src/main/java/org/s4s/dao/RegistrationDAO.java index cdc41f3..bcd68b2 100644 --- a/src/main/java/org/s4s/dao/RegistrationDAO.java +++ b/src/main/java/org/s4s/dao/RegistrationDAO.java @@ -16,7 +16,7 @@ import org.s4s.services.db.JDBCConnection; */ public class RegistrationDAO extends AbstractDatabaseClass { - Statement st = JDBCConnection.getInstance().getStatement(); + Statement st; String sql_update; public void addUser(String benutzer, String nachname, String vorname, java.util.Date gebDate, int fBereich, String email, String emailwdh, String passwort, String passwortWdh) { @@ -24,7 +24,7 @@ public class RegistrationDAO extends AbstractDatabaseClass { sql_update = "INSERT INTO \"ERR\".\"user\"(benutzername, nachname, vorname, geburtsdatum, fachbreichid, email, passwort)" + "VALUES(\'" + benutzer + "\', \'" + nachname + "\', \'" + vorname + "\', \'" + gebDate + "\', \'" + fBereich + "\', \'" + email + "\', \'" + passwort + "\')"; - int exe = st.executeUpdate(sql_update); + int exe = JDBCConnection.getInstance().getStatement().executeUpdate(sql_update); if(exe < 0) { throw new WrongInputException("Wrong Input!"); } diff --git a/src/main/java/org/s4s/dao/impl/RegistrationControl.java b/src/main/java/org/s4s/dao/impl/RegistrationControl.java index 7e1a192..5283da0 100644 --- a/src/main/java/org/s4s/dao/impl/RegistrationControl.java +++ b/src/main/java/org/s4s/dao/impl/RegistrationControl.java @@ -19,10 +19,7 @@ import org.s4s.exceptions.WrongInputException; */ public class RegistrationControl { //User-Block - private static String nachname; - private static String vorname; private static String email; - private static String passwort; private static RegistrationDAO regDAO = new RegistrationDAO(); @@ -59,14 +56,14 @@ public class RegistrationControl { throw new WrongInputException("Vorname enthält ungültige Zeichen!"); } - if (!passwordValidator()) { + if (!passwordValidator(passwort)) { throw new WrongInputException("Passwort ungültig!"); } } catch(WrongInputException w) { w.printStackTrace(); System.out.println("Exception occur: " + w.getMessage()); } - regDAO.addUser(benutzer, nachname, vorname, gebDate, fBereich, email, emailwdh, passwort, passwortWdh); + regDAO.addUser(benutzer, nachname, vorname, gebDate, fBereich, email, emailwdh, passwort, passwortWdh); } @@ -85,7 +82,7 @@ public class RegistrationControl { return EmailValidator.getInstance().isValid(email); } - public static boolean passwordValidator() { + public static boolean passwordValidator(String passwort) { return passwort.length() > 8; /* String regex = "^.*(?=.{8,})(?=..*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&+=]).*$"; diff --git a/src/main/java/org/s4s/gui/views/RegistrierungView.java b/src/main/java/org/s4s/gui/views/RegistrierungView.java index 47e424a..0b34178 100644 --- a/src/main/java/org/s4s/gui/views/RegistrierungView.java +++ b/src/main/java/org/s4s/gui/views/RegistrierungView.java @@ -51,6 +51,7 @@ public class RegistrierungView extends TemplateView implements View { content.addComponent(benutzername); DateField bday = new DateField("Geburtstag"); + bday.setDateFormat("YYYY-MM-DD"); content.addComponent(bday); TextField nachnameTxt = new TextField("Nachname:"); -- GitLab