diff --git a/pom.xml b/pom.xml index 94f60403d758399ce1c3f90a846335c6280ea815..50a896db84d4ff46d7b197824ade182793aa4afc 100644 --- a/pom.xml +++ b/pom.xml @@ -1,101 +1,106 @@ <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> - <groupId>org.s4s</groupId> - <artifactId>shopInShop</artifactId> - <packaging>war</packaging> - <version>1.0-SNAPSHOT</version> - <name>shopInShop</name> + <groupId>org.s4s</groupId> + <artifactId>shopInShop</artifactId> + <packaging>war</packaging> + <version>1.0-SNAPSHOT</version> + <name>shopInShop</name> - <prerequisites> - <maven>3</maven> - </prerequisites> + <prerequisites> + <maven>3</maven> + </prerequisites> - <properties> - <vaadin.version>7.7.8</vaadin.version> - <vaadin.plugin.version>7.7.8</vaadin.plugin.version> - <jetty.plugin.version>9.3.9.v20160517</jetty.plugin.version> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <maven.compiler.source>1.8</maven.compiler.source> - <maven.compiler.target>1.8</maven.compiler.target> - <!-- If there are no local customisations, this can also be "fetch" or "cdn" --> - <vaadin.widgetset.mode>local</vaadin.widgetset.mode> - </properties> + <properties> + <vaadin.version>7.7.8</vaadin.version> + <vaadin.plugin.version>7.7.8</vaadin.plugin.version> + <jetty.plugin.version>9.3.9.v20160517</jetty.plugin.version> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <maven.compiler.source>1.8</maven.compiler.source> + <maven.compiler.target>1.8</maven.compiler.target> + <!-- If there are no local customisations, this can also be "fetch" or "cdn" --> + <vaadin.widgetset.mode>local</vaadin.widgetset.mode> + </properties> - <repositories> - <repository> - <id>vaadin-addons</id> - <url>http://maven.vaadin.com/vaadin-addons</url> - </repository> - </repositories> + <repositories> + <repository> + <id>vaadin-addons</id> + <url>http://maven.vaadin.com/vaadin-addons</url> + </repository> + </repositories> - <dependencyManagement> - <dependencies> - <dependency> - <groupId>postgresql</groupId> - <artifactId>postgresql</artifactId> - <version>9.1-901-1.jdbc4</version> - </dependency> - <dependency> - <groupId>com.vaadin</groupId> - <artifactId>vaadin-bom</artifactId> - <version>${vaadin.version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> - </dependencies> - </dependencyManagement> + <dependencyManagement> + <dependencies> + <dependency> + <groupId>postgresql</groupId> + <artifactId>postgresql</artifactId> + <version>9.1-901-1.jdbc4</version> + </dependency> + <dependency> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-bom</artifactId> + <version>${vaadin.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> - <dependencies> - <dependency> - <groupId>org.postgresql</groupId> - <artifactId>postgresql</artifactId> - <version>LATEST</version> - </dependency> - <dependency> - <groupId>javax.servlet</groupId> - <artifactId>javax.servlet-api</artifactId> - <version>3.0.1</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.vaadin</groupId> - <artifactId>vaadin-server</artifactId> - </dependency> - <dependency> - <groupId>com.vaadin</groupId> - <artifactId>vaadin-push</artifactId> - </dependency> - <dependency> - <groupId>com.vaadin</groupId> - <artifactId>vaadin-client-compiled</artifactId> - </dependency> - <dependency> - <groupId>com.vaadin</groupId> - <artifactId>vaadin-themes</artifactId> - </dependency> - <dependency> - <groupId>org.projectlombok</groupId> - <artifactId>lombok</artifactId> - <version>1.16.16</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-lang3</artifactId> - <version>3.4</version> - <type>jar</type> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.11</version> - <scope>test</scope> - <type>jar</type> - </dependency> - <dependency> + <dependencies> + <dependency> + <groupId>org.postgresql</groupId> + <artifactId>postgresql</artifactId> + <version>LATEST</version> + </dependency> + <dependency> + <groupId>commons-validator</groupId> + <artifactId>commons-validator</artifactId> + <version>1.4.1</version> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <version>3.0.1</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-server</artifactId> + </dependency> + <dependency> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-push</artifactId> + </dependency> + <dependency> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-client-compiled</artifactId> + </dependency> + <dependency> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-themes</artifactId> + </dependency> + <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + <version>1.16.16</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + <version>3.4</version> + <type>jar</type> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.11</version> + <scope>test</scope> + <type>jar</type> + </dependency> + <dependency> <groupId>org.hamcrest</groupId> <artifactId>hamcrest-core</artifactId> <version>1.3</version> @@ -108,137 +113,137 @@ <version>1.3</version> <scope>test</scope> </dependency> - <dependency> + <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>LATEST</version> -</dependency> + </dependency> - </dependencies> + </dependencies> - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-war-plugin</artifactId> - <version>2.6</version> - <configuration> - <failOnMissingWebXml>false</failOnMissingWebXml> - <!-- Exclude an unnecessary file generated by the GWT compiler. --> - <packagingExcludes>WEB-INF/classes/VAADIN/widgetsets/WEB-INF/**</packagingExcludes> - </configuration> - </plugin> - <plugin> - <groupId>com.vaadin</groupId> - <artifactId>vaadin-maven-plugin</artifactId> - <version>${vaadin.plugin.version}</version> - <executions> - <execution> - <goals> - <goal>update-theme</goal> - <goal>update-widgetset</goal> - <goal>compile</goal> - <!-- Comment out compile-theme goal to use on-the-fly theme compilation --> - <goal>compile-theme</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-clean-plugin</artifactId> - <version>3.0.0</version> - <!-- Clean up also any pre-compiled themes --> - <configuration> - <filesets> - <fileset> - <directory>src/main/webapp/VAADIN/themes</directory> - <includes> - <include>**/styles.css</include> - <include>**/styles.scss.cache</include> - </includes> - </fileset> - </filesets> - </configuration> - </plugin> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-war-plugin</artifactId> + <version>2.6</version> + <configuration> + <failOnMissingWebXml>false</failOnMissingWebXml> + <!-- Exclude an unnecessary file generated by the GWT compiler. --> + <packagingExcludes>WEB-INF/classes/VAADIN/widgetsets/WEB-INF/**</packagingExcludes> + </configuration> + </plugin> + <plugin> + <groupId>com.vaadin</groupId> + <artifactId>vaadin-maven-plugin</artifactId> + <version>${vaadin.plugin.version}</version> + <executions> + <execution> + <goals> + <goal>update-theme</goal> + <goal>update-widgetset</goal> + <goal>compile</goal> + <!-- Comment out compile-theme goal to use on-the-fly theme compilation --> + <goal>compile-theme</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-clean-plugin</artifactId> + <version>3.0.0</version> + <!-- Clean up also any pre-compiled themes --> + <configuration> + <filesets> + <fileset> + <directory>src/main/webapp/VAADIN/themes</directory> + <includes> + <include>**/styles.css</include> + <include>**/styles.scss.cache</include> + </includes> + </fileset> + </filesets> + </configuration> + </plugin> - <!-- The Jetty plugin allows us to easily test the development build by - running jetty:run on the command line. --> - <plugin> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-maven-plugin</artifactId> - <version>${jetty.plugin.version}</version> - <configuration> - <scanIntervalSeconds>2</scanIntervalSeconds> - </configuration> - </plugin> - <plugin> - <groupId>org.jacoco</groupId> - <artifactId>jacoco-maven-plugin</artifactId> - <version>0.7.1.201405082137</version> - <executions> - <execution> - <goals> - <goal>prepare-agent</goal> - </goals> - </execution> - <execution> - <id>report</id> - <phase>prepare-package</phase> - <goals> - <goal>report</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> + <!-- The Jetty plugin allows us to easily test the development build by + running jetty:run on the command line. --> + <plugin> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-maven-plugin</artifactId> + <version>${jetty.plugin.version}</version> + <configuration> + <scanIntervalSeconds>2</scanIntervalSeconds> + </configuration> + </plugin> + <plugin> + <groupId>org.jacoco</groupId> + <artifactId>jacoco-maven-plugin</artifactId> + <version>0.7.1.201405082137</version> + <executions> + <execution> + <goals> + <goal>prepare-agent</goal> + </goals> + </execution> + <execution> + <id>report</id> + <phase>prepare-package</phase> + <goals> + <goal>report</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> - <profiles> - <profile> - <!-- Vaadin pre-release repositories --> - <id>vaadin-prerelease</id> - <activation> - <activeByDefault>false</activeByDefault> - </activation> + <profiles> + <profile> + <!-- Vaadin pre-release repositories --> + <id>vaadin-prerelease</id> + <activation> + <activeByDefault>false</activeByDefault> + </activation> - <repositories> - <repository> - <id>vaadin-prereleases</id> - <url>http://maven.vaadin.com/vaadin-prereleases</url> - </repository> - <repository> - <id>vaadin-snapshots</id> - <url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url> - <releases> - <enabled>false</enabled> - </releases> - <snapshots> - <enabled>true</enabled> - </snapshots> - </repository> - </repositories> - <pluginRepositories> - <pluginRepository> - <id>vaadin-prereleases</id> - <url>http://maven.vaadin.com/vaadin-prereleases</url> - </pluginRepository> - <pluginRepository> - <id>vaadin-snapshots</id> - <url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url> - <releases> - <enabled>false</enabled> - </releases> - <snapshots> - <enabled>true</enabled> - </snapshots> - </pluginRepository> - </pluginRepositories> - </profile> - </profiles> + <repositories> + <repository> + <id>vaadin-prereleases</id> + <url>http://maven.vaadin.com/vaadin-prereleases</url> + </repository> + <repository> + <id>vaadin-snapshots</id> + <url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url> + <releases> + <enabled>false</enabled> + </releases> + <snapshots> + <enabled>true</enabled> + </snapshots> + </repository> + </repositories> + <pluginRepositories> + <pluginRepository> + <id>vaadin-prereleases</id> + <url>http://maven.vaadin.com/vaadin-prereleases</url> + </pluginRepository> + <pluginRepository> + <id>vaadin-snapshots</id> + <url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url> + <releases> + <enabled>false</enabled> + </releases> + <snapshots> + <enabled>true</enabled> + </snapshots> + </pluginRepository> + </pluginRepositories> + </profile> + </profiles> </project> diff --git a/src/main/java/org/s4s/dao/impl/RegistrationControl.java b/src/main/java/org/s4s/dao/impl/RegistrationControl.java index e62c9278742e1273d8f1fd53ca1ca72ccb94c321..7219721becfff8144021d7888836fdb1b53c9a87 100644 --- a/src/main/java/org/s4s/dao/impl/RegistrationControl.java +++ b/src/main/java/org/s4s/dao/impl/RegistrationControl.java @@ -5,14 +5,87 @@ */ package org.s4s.dao.impl; +import java.sql.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.apache.commons.validator.routines.EmailValidator; + + /** * * @author Simon */ public class RegistrationControl { - //Link von RegistrierungButton <- Registrierung View - //Dialogfeld mit den einzugebenden Daten - //daraufhin SQL-Injection + //User-Block + private static String surname; + private static String firstname; + private static String email; + private static String password; + + //DB-Block + Connection con; + Statement st; + ResultSet rs; + String sql_update; + String url; + + + public static boolean init(String[] data) { + surname = data[0]; + firstname = data[1]; + email = data[2]; + password = data[4]; + + if (!nameValidator(surname)) { + return false; + } + if (!nameValidator(firstname)) { + return false; + } + if (!emailValidator()) { + return false; + } if (!passwordValidator()) { + return false; + } + return true; + + } + + + public void addUser() { + try { + con = DriverManager.getConnection(url); + st = con.createStatement(); + sql_update = "INSERT INTO "; //erweitern + st.executeUpdate(sql_update); + + } catch (Exception ex) { + ex.printStackTrace(); + System.out.println("Exception occur: " + ex); + } + + } + + public static boolean nameValidator(String toValidate) { + //wenn Eingabe falsch -> Notification + + for (int i = 0; i < toValidate.length(); ++i) { + if (!Character.isLetter(toValidate.charAt(i))) { + return false; + } + } + return true; + } + + public static boolean emailValidator() { + return EmailValidator.getInstance().isValid(email); + } + public static boolean passwordValidator() { + String regex = "^.*(?=.{8,})(?=..*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&+=]).*$"; + Pattern p = Pattern.compile(regex); + Matcher m = p.matcher(password); + return m.matches(); + } } diff --git a/src/main/java/org/s4s/gui/views/LoginView.java b/src/main/java/org/s4s/gui/views/LoginView.java index 2f6c5bd091d8905862dd62ed3bc001d9d5a354cb..55f3b11c9afbc1e4136ca26364704763a9875731 100644 --- a/src/main/java/org/s4s/gui/views/LoginView.java +++ b/src/main/java/org/s4s/gui/views/LoginView.java @@ -47,9 +47,17 @@ public class LoginView extends TemplateView { Label label = new Label(" ", ContentMode.HTML); layout.addComponent(label); - + + HorizontalLayout hLay = new HorizontalLayout(); + Button button = new Button("Login", FontAwesome.BEER); - layout.addComponent(button); + Button buttonReg = new Button("Registrieren", FontAwesome.BEER); + hLay.addComponent(button); + Label lbl = new Label(" ", ContentMode.HTML); + hLay.addComponent(lbl); + hLay.addComponent(buttonReg); + layout.addComponent(label); + layout.addComponent(hLay); this.addComponent(layout); @@ -75,6 +83,16 @@ public class LoginView extends TemplateView { } }); + + +// layout.addComponent(buttonReg); + + buttonReg.addClickListener(new Button.ClickListener() { + @Override + public void buttonClick(Button.ClickEvent event) { + UI.getCurrent().getNavigator().navigateTo(Views.REGISTRIERUNG); + } + }); } } diff --git a/src/main/java/org/s4s/gui/views/RegistrierungView.java b/src/main/java/org/s4s/gui/views/RegistrierungView.java index dd5cf883e4085dcf67d8c116d0d378af3e41cc56..9fb1d5ab26e088496125ae2d2c4abfade44dba6d 100644 --- a/src/main/java/org/s4s/gui/views/RegistrierungView.java +++ b/src/main/java/org/s4s/gui/views/RegistrierungView.java @@ -18,6 +18,7 @@ import com.vaadin.ui.Panel; import com.vaadin.ui.PasswordField; import com.vaadin.ui.TextField; import com.vaadin.ui.UI; +import org.s4s.dao.impl.RegistrationControl; import org.s4s.services.util.Views; @@ -96,6 +97,11 @@ public class RegistrierungView extends TemplateView implements View { String passwort = passwortTxt.getValue(); String passwortWdh = passwortTxtWdh.getValue(); // RegistrierungControl.Methode(Parameter); + //Anbindungstestblock. svolle2s + + RegistrationControl.init(new String[]{nachname, vorname, email, emailwdh, passwort, passwortWdh}); + + System.out.println(nachname); System.out.println(vorname); System.out.println(email); diff --git a/src/main/java/org/s4s/gui/views/TemplateView.java b/src/main/java/org/s4s/gui/views/TemplateView.java index 33e2122aa08d1206401e0ab3229482142bec6aad..6e24f53df23b584204acc77789d26cd686df5ee0 100644 --- a/src/main/java/org/s4s/gui/views/TemplateView.java +++ b/src/main/java/org/s4s/gui/views/TemplateView.java @@ -93,7 +93,7 @@ public class TemplateView extends VerticalLayout implements View { MenuBar.MenuItem categoryItem = barmenu.addItem("Kategorien", null, null); categoryItem.addItem("Literatur", null, mycommand); categoryItem.addItem("Mitschriften", null, mycommand); - categoryItem.addItem("Currywurst", null, mycommand); + categoryItem.addItem("Nachhilfe", null, mycommand); // Yet another top-level item MenuBar.MenuItem shoppingCardItem = barmenu.addItem("Warenkorb", null, mycommand);