From: Roland Haeder Date: Tue, 6 Oct 2015 10:11:50 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=0140a4ada4509c34e4309579cb74485263f91490;p=addressbook-war.git Continued: - added new beans (controller) for registration and login - added security constrain (maybe working?) for login area. Maybe this has to be done manually as the user table is very specific. - add dummy login error page - updated jars Signed-off-by:Roland Häder --- diff --git a/lib/jcontacts-business-core.jar b/lib/jcontacts-business-core.jar index 7e2bfd3a..a45d168c 100644 Binary files a/lib/jcontacts-business-core.jar and b/lib/jcontacts-business-core.jar differ diff --git a/lib/jcontacts-core.jar b/lib/jcontacts-core.jar index 60d3cc88..116c3511 100644 Binary files a/lib/jcontacts-core.jar and b/lib/jcontacts-core.jar differ diff --git a/lib/jcontacts-lib.jar b/lib/jcontacts-lib.jar index 7797a5a5..99666abd 100644 Binary files a/lib/jcontacts-lib.jar and b/lib/jcontacts-lib.jar differ diff --git a/lib/jcore.jar b/lib/jcore.jar index 2c6f30ef..b506a165 100644 Binary files a/lib/jcore.jar and b/lib/jcore.jar differ diff --git a/lib/jcoreee.jar b/lib/jcoreee.jar index 19ec1c4c..d87f56db 100644 Binary files a/lib/jcoreee.jar and b/lib/jcoreee.jar differ diff --git a/lib/juser-core.jar b/lib/juser-core.jar index 1651c24e..30c2eb82 100644 Binary files a/lib/juser-core.jar and b/lib/juser-core.jar differ diff --git a/lib/juser-lib.jar b/lib/juser-lib.jar index e6541325..60198aa1 100644 Binary files a/lib/juser-lib.jar and b/lib/juser-lib.jar differ diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml index f151f5a3..695ae363 100644 --- a/nbproject/build-impl.xml +++ b/nbproject/build-impl.xml @@ -881,11 +881,17 @@ exists or setup the property manually. For example like this: + + + + + + @@ -1041,6 +1047,7 @@ exists or setup the property manually. For example like this: + @@ -1056,6 +1063,7 @@ exists or setup the property manually. For example like this: + @@ -1470,6 +1478,7 @@ exists or setup the property manually. For example like this: --> + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties index 8245c238..87bf0946 100644 --- a/nbproject/genfiles.properties +++ b/nbproject/genfiles.properties @@ -1,8 +1,8 @@ -build.xml.data.CRC32=d8bc4ea8 +build.xml.data.CRC32=f85eb01a build.xml.script.CRC32=be5f34f7 build.xml.stylesheet.CRC32=651128d4@1.68.1.1 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=d8bc4ea8 -nbproject/build-impl.xml.script.CRC32=855e3438 +nbproject/build-impl.xml.data.CRC32=f85eb01a +nbproject/build-impl.xml.script.CRC32=045dff2a nbproject/build-impl.xml.stylesheet.CRC32=99ea4b56@1.68.1.1 diff --git a/nbproject/project.properties b/nbproject/project.properties index ced13a96..2f55c202 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -69,7 +69,8 @@ javac.classpath=\ ${file.reference.juser-lib.jar}:\ ${reference.addressbook-lib.jar}:\ ${file.reference.cdi-api.jar}:\ - ${file.reference.gf-client.jar} + ${file.reference.gf-client.jar}:\ + ${reference.juser-lib.jar} # Space-separated list of extra javac options javac.compilerargs=-Xlint:unchecked -Xlint:deprecation javac.debug=true @@ -99,8 +100,10 @@ lib.dir=${web.docbase.dir}/WEB-INF/lib persistence.xml.dir=${conf.dir} platform.active=default_platform project.addressbook-lib=../addressbook-lib +project.juser-lib=../juser-lib project.license=gpl30 reference.addressbook-lib.jar=${project.addressbook-lib}/dist/addressbook-lib.jar +reference.juser-lib.jar=${project.juser-lib}/dist/juser-lib.jar resource.dir=setup run.test.classpath=\ ${javac.test.classpath}:\ diff --git a/nbproject/project.xml b/nbproject/project.xml index 8a21668f..b80d7234 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -50,6 +50,10 @@ ${file.reference.gf-client.jar} WEB-INF/lib + + ${reference.juser-lib.jar} + WEB-INF/lib + @@ -71,6 +75,14 @@ clean jar + + juser-lib + jar + + jar + clean + jar + diff --git a/src/java/org/mxchange/addressbook/beans/login/UserLoginWebBean.java b/src/java/org/mxchange/addressbook/beans/login/UserLoginWebBean.java new file mode 100644 index 00000000..96270270 --- /dev/null +++ b/src/java/org/mxchange/addressbook/beans/login/UserLoginWebBean.java @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2015 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.addressbook.beans.login; + +import javax.enterprise.context.SessionScoped; +import javax.faces.view.facelets.FaceletException; +import javax.inject.Inject; +import javax.inject.Named; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import org.mxchange.addressbook.beans.user.UserWebController; +import org.mxchange.jusercore.exceptions.UserNotFoundException; +import org.mxchange.jusercore.exceptions.UserStatusLockedException; +import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException; +import org.mxchange.jusercore.model.login.UserLoginSessionBeanRemote; +import org.mxchange.jusercore.model.user.User; + +/** + * A web bean for user registration + *

+ * @author Roland Haeder + */ +@Named ("loginController") +@SessionScoped +public class UserLoginWebBean implements UserLoginWebController { + + /** + * Reemote register session bean + */ + private UserLoginSessionBeanRemote login; + + /** + * User controller + */ + @Inject + private UserWebController userController; + + /** + * Serial number + */ + private static final long serialVersionUID = 47_828_986_719_691_592L; + + /** + * Default constructor + */ + public UserLoginWebBean () { + try { + // Get initial context + Context context = new InitialContext(); + + // Try to lookup + this.login = (UserLoginSessionBeanRemote) context.lookup("ejb/stateless-login"); //NOI18N + } catch (final NamingException ex) { + // Continue to throw + throw new FaceletException(ex); + } + } + + @Override + public void doLogin () { + // Get user instance + User user = this.userController.createUserInstance(); + + try { + // Call bean + this.login.loginUser(user); + } catch (final UserNotFoundException | UserStatusLockedException | UserStatusUnconfirmedException ex) { + // Throw again + throw new FaceletException(ex); + } + } +} diff --git a/src/java/org/mxchange/addressbook/beans/login/UserLoginWebController.java b/src/java/org/mxchange/addressbook/beans/login/UserLoginWebController.java new file mode 100644 index 00000000..81d90ba8 --- /dev/null +++ b/src/java/org/mxchange/addressbook/beans/login/UserLoginWebController.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2015 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.addressbook.beans.login; + +import java.io.Serializable; + +/** + * An interface for registration web controllers + *

+ * @author Roland Haeder + */ +public interface UserLoginWebController extends Serializable { + + /** + * Logins the user, if the account is found, confirmed and unlocked. + */ + public void doLogin (); +} diff --git a/src/java/org/mxchange/addressbook/beans/register/UserRegisterWebBean.java b/src/java/org/mxchange/addressbook/beans/register/UserRegisterWebBean.java new file mode 100644 index 00000000..5c7b2667 --- /dev/null +++ b/src/java/org/mxchange/addressbook/beans/register/UserRegisterWebBean.java @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2015 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.addressbook.beans.register; + +import javax.enterprise.context.SessionScoped; +import javax.faces.view.facelets.FaceletException; +import javax.inject.Inject; +import javax.inject.Named; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import org.mxchange.addressbook.beans.user.UserWebController; +import org.mxchange.jusercore.exceptions.UserAlreadyRegisteredException; +import org.mxchange.jusercore.model.register.UserRegistrationSessionBeanRemote; +import org.mxchange.jusercore.model.user.User; + +/** + * A web bean for user registration + *

+ * @author Roland Haeder + */ +@Named ("registerController") +@SessionScoped +public class UserRegisterWebBean implements UserRegisterWebController { + + /** + * Reemote register session bean + */ + private UserRegistrationSessionBeanRemote register; + + /** + * User controller + */ + @Inject + private UserWebController userController; + + /** + * Serial number + */ + private static final long serialVersionUID = 47_828_986_719_691_592L; + + /** + * Default constructor + */ + public UserRegisterWebBean () { + try { + // Get initial context + Context context = new InitialContext(); + + // Try to lookup + this.register = (UserRegistrationSessionBeanRemote) context.lookup("ejb/stateless-register"); //NOI18N + } catch (final NamingException ex) { + // Continue to throw + throw new FaceletException(ex); + } + } + + @Override + public void doRegister () { + // Get user instance + User user = this.userController.createUserInstance(); + + try { + // Call bean + this.register.registerUser(user); + } catch (final UserAlreadyRegisteredException ex) { + // Continue to throw + throw new FaceletException(ex); + } + } +} diff --git a/src/java/org/mxchange/addressbook/beans/register/UserRegisterWebController.java b/src/java/org/mxchange/addressbook/beans/register/UserRegisterWebController.java new file mode 100644 index 00000000..bd27c9b3 --- /dev/null +++ b/src/java/org/mxchange/addressbook/beans/register/UserRegisterWebController.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2015 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.addressbook.beans.register; + +import java.io.Serializable; + +/** + * An interface for registration web controllers + *

+ * @author Roland Haeder + */ +public interface UserRegisterWebController extends Serializable { + + /** + * Registers the user, if not found. Otherwise this method should throw an + * exception. + */ + public void doRegister (); +} diff --git a/src/java/org/mxchange/addressbook/beans/user/UserWebBean.java b/src/java/org/mxchange/addressbook/beans/user/UserWebBean.java index 9ecf3bb7..6f72ab67 100644 --- a/src/java/org/mxchange/addressbook/beans/user/UserWebBean.java +++ b/src/java/org/mxchange/addressbook/beans/user/UserWebBean.java @@ -119,6 +119,11 @@ public class UserWebBean implements UserWebController { */ private String userName; + /** + * User password (unencrypted from web form) + */ + private String userPassword; + /** * ZIP code */ @@ -316,6 +321,16 @@ public class UserWebBean implements UserWebController { this.userName = userName; } + @Override + public String getUserPassword () { + return this.userPassword; + } + + @Override + public void setUserPassword (final String userPassword) { + this.userPassword = userPassword; + } + @Override public Integer getZipCode () { return this.zipCode; diff --git a/src/java/org/mxchange/addressbook/beans/user/UserWebController.java b/src/java/org/mxchange/addressbook/beans/user/UserWebController.java index 085c0e64..c161b61a 100644 --- a/src/java/org/mxchange/addressbook/beans/user/UserWebController.java +++ b/src/java/org/mxchange/addressbook/beans/user/UserWebController.java @@ -90,6 +90,20 @@ public interface UserWebController extends Serializable { */ public void setUserName (final String userName); + /** + * Getter for unencrypted user password + *

+ * @return Unencrypted user password + */ + public String getUserPassword (); + + /** + * Setter for unencrypted user password + *

+ * @param userPassword Unencrypted user password + */ + public void setUserPassword (final String userPassword); + /** * Company name *

diff --git a/web/WEB-INF/templates/guest/guest_login_form.tpl b/web/WEB-INF/templates/guest/guest_login_form.tpl index 0e810499..187e5e85 100644 --- a/web/WEB-INF/templates/guest/guest_login_form.tpl +++ b/web/WEB-INF/templates/guest/guest_login_form.tpl @@ -16,11 +16,11 @@

- +
- +
@@ -28,11 +28,11 @@
- +
- +
@@ -41,7 +41,7 @@ diff --git a/web/WEB-INF/web.xml b/web/WEB-INF/web.xml index d256d2a3..c270f524 100644 --- a/web/WEB-INF/web.xml +++ b/web/WEB-INF/web.xml @@ -21,4 +21,32 @@ faces/index.xhtml + + Constraint1 + + loginArea + Login area + /llogin/* + + + User Authentication + user + + + + FORM + Loginbereich / Login area + + /user/login.xhtml + /user/login_error.xhtml + + + + A logged-in user that has previously registered himself/herself. + user + + + tpl + text/plain + diff --git a/web/user/login.xhtml b/web/user/login.xhtml index fada53c0..77bf49b1 100644 --- a/web/user/login.xhtml +++ b/web/user/login.xhtml @@ -21,7 +21,7 @@
- Noch kein Kunde? Einfach beim Bestellen anmelden oder hier anmelden. + Noch kein Benutzerkonto? Einfach hier anmelden.
diff --git a/web/user/login_error.xhtml b/web/user/login_error.xhtml new file mode 100644 index 00000000..36b34d67 --- /dev/null +++ b/web/user/login_error.xhtml @@ -0,0 +1,29 @@ + + + + + + #{msg.PAGE_TITLE_USER_LOGIN_ERROR} + + + + + + + #{msg.SUB_TITLE_USER_LOGIN_ERROR} + + + + Hier kommt die Fehlermeldung hin. + + + + + + +