diff --git a/account/src/main/java/de/muehlencord/shared/account/presentation/LoginView.java b/account/src/main/java/de/muehlencord/shared/account/presentation/LoginView.java index e53c79f..7bc72d2 100644 --- a/account/src/main/java/de/muehlencord/shared/account/presentation/LoginView.java +++ b/account/src/main/java/de/muehlencord/shared/account/presentation/LoginView.java @@ -1,169 +1,169 @@ -package de.muehlencord.shared.account.presentation; - -import de.muehlencord.shared.account.business.account.boundary.AccountControl; -import de.muehlencord.shared.account.business.account.entity.AccountEntity; -import de.muehlencord.shared.jeeutil.FacesUtil; -import java.io.IOException; -import java.io.Serializable; -import javax.ejb.EJB; -import javax.faces.context.ExternalContext; -import javax.faces.context.FacesContext; -import javax.faces.view.ViewScoped; -import javax.inject.Named; - -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import org.apache.shiro.subject.Subject; -import org.apache.shiro.SecurityUtils; -import org.apache.shiro.authc.AuthenticationException; -import org.apache.shiro.authc.UsernamePasswordToken; -import org.apache.shiro.web.util.WebUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - * @author joern.muehlencord - */ -@Named(value = "loginView") -@ViewScoped -public class LoginView implements Serializable { - - private static final long serialVersionUID = -1164860380769648432L; - - @EJB - private AccountControl accountService; - - private String username = null; - private String password = null; - private boolean rememberMe = false; - - private String resetPasswordToken = null; - - private static final Logger LOGGER = LoggerFactory.getLogger(LoginView.class.getName()); - - public void authenticate() { - - // Example using most common scenario of username/password pair: - UsernamePasswordToken token = new UsernamePasswordToken(getUsername(), getPassword()); - - // "Remember Me" built-in: - token.setRememberMe(rememberMe); - Subject currentUser = SecurityUtils.getSubject(); - LOGGER.info("Submitting login with username of " + username); - - try { - currentUser.login(token); - // user logged in, update account entity - AccountEntity account = accountService.getAccountEntity(username, true); - accountService.updateLogin(account); - - // redirect to home - ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext(); - String fallbackUrl = "/web/index.xhtml"; // TODO make configurable - // ec.redirect(url); - WebUtils.redirectToSavedRequest((ServletRequest) ec.getRequest(), (ServletResponse) ec.getResponse(), fallbackUrl); - } catch (IOException | AuthenticationException ex) { - // Could catch a subclass of AuthenticationException if you like - String hint = "Error while authenticating user " + username; - if (LOGGER.isDebugEnabled()) { - LOGGER.debug(hint, ex); - } else { - LOGGER.error(hint + " Reason: " + ex.toString()); - } - FacesUtil.addErrorMessage("Login failed"); - - AccountEntity account = accountService.getAccountEntity(username, false); - if (account != null) { - accountService.addLoginError(account); - } - } finally { - token.clear(); - } - } - - public void logout() { - Subject currentUser = SecurityUtils.getSubject(); - try { - currentUser.logout(); - - ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext(); - - // check if redirect shall be executed - // default setting is yes to /login.xhtml - // can be overwritten using parameters - // de.muehlencord.shared.account.loginview.executeredirect boolean true/false - // de.muehlencord.shared.account.loginview.redirecttarget path to redirect to (without external context, will be added automatically) - String executeRedirectString = ec.getInitParameter("de.muehlencord.shared.account.loginview.executeredirect"); - boolean executeRedirect = true; - if (executeRedirectString != null) { - executeRedirect = Boolean.parseBoolean(executeRedirectString); - } - - String redirectTarget = ec.getInitParameter("de.muehlencord.shared.account.loginview.redirecttarget"); - if ((redirectTarget == null) || (redirectTarget.equals(""))) { - redirectTarget = "/login.xhtml"; - } - - if (executeRedirect) { - String url = ec.getRequestContextPath() + redirectTarget; - ec.redirect(url); - } - - } catch (Exception e) { - LOGGER.warn(e.toString()); - } - } - - public String executePasswordReset() { - boolean passwordResetted = accountService.resetPassword(username, password, resetPasswordToken); - if (passwordResetted) { - // TODO add email notification on updated user account - FacesUtil.addInfoMessage("Password resetted"); - return login(); - } else { - // TODO add email notificaton on failed password reset - FacesUtil.addErrorMessage("Password reset failed"); - return login(); - } - } - - /* **** naviation rules **** */ - public String login() { - return "/login.xhtml"; // TODO make configurable - } - - /* *** getter / setter */ - public String getUsername() { - return username; - } - - public void setUsername(String un) { - this.username = un; - } - - public String getPassword() { - return password; - } - - public void setPassword(String pw) { - this.password = pw; - } - - public boolean isRememberMe() { - return rememberMe; - } - - public void setRememberMe(boolean rememberMe) { - this.rememberMe = rememberMe; - } - - public String getResetPasswordToken() { - return resetPasswordToken; - } - - public void setResetPasswordToken(String resetPasswordToken) { - this.resetPasswordToken = resetPasswordToken; - } - -} +package de.muehlencord.shared.account.presentation; + +import de.muehlencord.shared.account.business.account.boundary.AccountControl; +import de.muehlencord.shared.account.business.account.entity.AccountEntity; +import de.muehlencord.shared.jeeutil.FacesUtil; +import java.io.IOException; +import java.io.Serializable; +import javax.ejb.EJB; +import javax.faces.context.ExternalContext; +import javax.faces.context.FacesContext; +import javax.faces.view.ViewScoped; +import javax.inject.Named; + +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import org.apache.shiro.subject.Subject; +import org.apache.shiro.SecurityUtils; +import org.apache.shiro.authc.AuthenticationException; +import org.apache.shiro.authc.UsernamePasswordToken; +import org.apache.shiro.web.util.WebUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author joern.muehlencord + */ +@Named(value = "loginView") +@ViewScoped +public class LoginView implements Serializable { + + private static final long serialVersionUID = -1164860380769648432L; + + @EJB + private AccountControl accountService; + + private String username = null; + private String password = null; + private boolean rememberMe = false; + + private String resetPasswordToken = null; + + private static final Logger LOGGER = LoggerFactory.getLogger(LoginView.class.getName()); + + public void authenticate() { + + // Example using most common scenario of username/password pair: + UsernamePasswordToken token = new UsernamePasswordToken(getUsername(), getPassword()); + + // "Remember Me" built-in: + token.setRememberMe(rememberMe); + Subject currentUser = SecurityUtils.getSubject(); + LOGGER.info("Submitting login with username of " + username); + + try { + currentUser.login(token); + // user logged in, update account entity + AccountEntity account = accountService.getAccountEntity(username, true); + accountService.updateLogin(account); + + // redirect to home + ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext(); + String fallbackUrl = "/web/index.xhtml"; // TODO make configurable + // ec.redirect(url); + WebUtils.redirectToSavedRequest((ServletRequest) ec.getRequest(), (ServletResponse) ec.getResponse(), fallbackUrl); + } catch (IOException | AuthenticationException ex) { + // Could catch a subclass of AuthenticationException if you like + String hint = "Error while authenticating user " + username; + if (LOGGER.isDebugEnabled()) { + LOGGER.debug(hint, ex); + } else { + LOGGER.error(hint + " Reason: " + ex.toString()); + } + FacesUtil.addGlobalErrorMessage("Login failed", hint); + + AccountEntity account = accountService.getAccountEntity(username, false); + if (account != null) { + accountService.addLoginError(account); + } + } finally { + token.clear(); + } + } + + public void logout() { + Subject currentUser = SecurityUtils.getSubject(); + try { + currentUser.logout(); + + ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext(); + + // check if redirect shall be executed + // default setting is yes to /login.xhtml + // can be overwritten using parameters + // de.muehlencord.shared.account.loginview.executeredirect boolean true/false + // de.muehlencord.shared.account.loginview.redirecttarget path to redirect to (without external context, will be added automatically) + String executeRedirectString = ec.getInitParameter("de.muehlencord.shared.account.loginview.executeredirect"); + boolean executeRedirect = true; + if (executeRedirectString != null) { + executeRedirect = Boolean.parseBoolean(executeRedirectString); + } + + String redirectTarget = ec.getInitParameter("de.muehlencord.shared.account.loginview.redirecttarget"); + if ((redirectTarget == null) || (redirectTarget.equals(""))) { + redirectTarget = "/login.xhtml"; + } + + if (executeRedirect) { + String url = ec.getRequestContextPath() + redirectTarget; + ec.redirect(url); + } + + } catch (Exception e) { + LOGGER.warn(e.toString()); + } + } + + public String executePasswordReset() { + boolean passwordResetted = accountService.resetPassword(username, password, resetPasswordToken); + if (passwordResetted) { + // TODO add email notification on updated user account + FacesUtil.addGlobalInfoMessage("Password resetted", null); + return login(); + } else { + // TODO add email notificaton on failed password reset + FacesUtil.addGlobalErrorMessage("Password reset failed", null); + return login(); + } + } + + /* **** naviation rules **** */ + public String login() { + return "/login.xhtml"; // TODO make configurable + } + + /* *** getter / setter */ + public String getUsername() { + return username; + } + + public void setUsername(String un) { + this.username = un; + } + + public String getPassword() { + return password; + } + + public void setPassword(String pw) { + this.password = pw; + } + + public boolean isRememberMe() { + return rememberMe; + } + + public void setRememberMe(boolean rememberMe) { + this.rememberMe = rememberMe; + } + + public String getResetPasswordToken() { + return resetPasswordToken; + } + + public void setResetPasswordToken(String resetPasswordToken) { + this.resetPasswordToken = resetPasswordToken; + } + +} diff --git a/account/src/main/java/de/muehlencord/shared/account/presentation/LostPasswordView.java b/account/src/main/java/de/muehlencord/shared/account/presentation/LostPasswordView.java index 84dcc00..439d2d6 100644 --- a/account/src/main/java/de/muehlencord/shared/account/presentation/LostPasswordView.java +++ b/account/src/main/java/de/muehlencord/shared/account/presentation/LostPasswordView.java @@ -1,48 +1,48 @@ -package de.muehlencord.shared.account.presentation; - -import de.muehlencord.shared.account.business.account.boundary.AccountControl; -import de.muehlencord.shared.jeeutil.FacesUtil; -import java.io.Serializable; -import javax.ejb.EJB; -import javax.faces.view.ViewScoped; -import javax.inject.Named; - -/** - * - * @author joern@muehlencord.de - */ -@Named (value = "lostPasswordView") -@ViewScoped -public class LostPasswordView implements Serializable { - - private static final long serialVersionUID = -1793445795465830069L; - - @EJB - private AccountControl accountService; - - private String userName; - private boolean passwordResetStarted = false; - - public String initPasswordReset() { - if (accountService.initPasswordReset(userName)) { - passwordResetStarted = true; - FacesUtil.addInfoMessage("Password reset started, please check your email account"); - } else { - FacesUtil.addErrorMessage("Error while resetting password. Please contact your administrator"); - } - return "/login.xhtml"; // TODO make configurable, get from LoginView? - } - - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName; - } - - public boolean getPasswordResetStarted() { - return passwordResetStarted; - } - -} +package de.muehlencord.shared.account.presentation; + +import de.muehlencord.shared.account.business.account.boundary.AccountControl; +import de.muehlencord.shared.jeeutil.FacesUtil; +import java.io.Serializable; +import javax.ejb.EJB; +import javax.faces.view.ViewScoped; +import javax.inject.Named; + +/** + * + * @author joern@muehlencord.de + */ +@Named (value = "lostPasswordView") +@ViewScoped +public class LostPasswordView implements Serializable { + + private static final long serialVersionUID = -1793445795465830069L; + + @EJB + private AccountControl accountService; + + private String userName; + private boolean passwordResetStarted = false; + + public String initPasswordReset() { + if (accountService.initPasswordReset(userName)) { + passwordResetStarted = true; + FacesUtil.addGlobalInfoMessage("Password reset started.", "Please check your email account."); + } else { + FacesUtil.addGlobalErrorMessage("Error while resetting password.", "Please contact your administrator."); + } + return "/login.xhtml"; // TODO make configurable, get from LoginView? + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public boolean getPasswordResetStarted() { + return passwordResetStarted; + } + +} diff --git a/poi-util/src/main/java/de/muehlencord/shared/poi/WorkbookApp.java b/poi-util/src/main/java/de/muehlencord/shared/poi/WorkbookApp.java index c97447c..0fde59b 100644 --- a/poi-util/src/main/java/de/muehlencord/shared/poi/WorkbookApp.java +++ b/poi-util/src/main/java/de/muehlencord/shared/poi/WorkbookApp.java @@ -161,7 +161,7 @@ public class WorkbookApp { newCell.setCellStyle(newCellStyle); } - switch (oldCell.getCellTypeEnum()) { + switch (oldCell.getCellType()) { case STRING: newCell.setCellValue(oldCell.getStringCellValue()); break; diff --git a/pom.xml b/pom.xml index 60d3460..e992b36 100644 --- a/pom.xml +++ b/pom.xml @@ -1,229 +1,229 @@ - - - 4.0.0 - de.muehlencord - shared - 1.1-SNAPSHOT - pom - shared - - configuration - network - security - - util - jeeutil - account - pdf - shiro-faces - poi-util - - - - scm:git:https://jomu.timelord.de/git/jomu/shared/ - HEAD - - - - - UTF-8 - 1.8 - 1.8 - - - - - - junit - junit - 4.12 - test - - - org.mockito - mockito-core - 2.21.0 - test - - - commons-codec - commons-codec - 1.11 - - - commons-net - commons-net - 3.6 - - - org.apache.commons - commons-lang3 - 3.7 - - - commons-io - commons-io - 2.6 - - - org.slf4j - slf4j-api - 1.7.25 - - - org.slf4j - slf4j-log4j12 - 1.7.25 - - - org.slf4j - jcl-over-slf4j - 1.7.25 - - - - com.sun.mail - javax.mail - 1.6.1 - - - com.microsoft.ews-java-api - ews-java-api - 2.0 - - - com.google.code.gson - gson - 2.8.5 - - - org.apache.shiro - shiro-core - 1.4.0 - - - org.apache.shiro - shiro-web - 1.4.0 - - - javax - javaee-api - 7.0 - - - - com.enterprisedt - edtFTPj - 1.5.3 - - - - com.lambdaworks - scrypt - 1.4.0 - - - org.bouncycastle - bcprov-jdk15on - 1.59 - - - - org.hibernate - hibernate-core - 5.0.10.Final - jar - - - - org.apache.pdfbox - pdfbox - 2.0.11 - - - org.freemarker - freemarker - 2.3.28 - - - org.primefaces - primefaces - 6.2 - - - com.sun.faces - jsf-api - 2.2.17 - provided - - - javax.el - javax.el-api - 3.0.0 - provided - - - org.apache.poi - poi-ooxml - 3.17 - - - com.inversoft - prime-jwt - 1.3.1 - - - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.0 - - ${maven.compiler.source} - ${maven.compiler.target} - true - - - - org.codehaus.mojo - jaxb2-maven-plugin - 2.4 - - - org.apache.maven.plugins - maven-ejb-plugin - 3.0.1 - - - org.codehaus.mojo - jaxws-maven-plugin - 2.5 - - - maven-release-plugin - 2.5.3 - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - maven-release-plugin - 2.5.3 - - v@{project.version} - - - - - + + + 4.0.0 + de.muehlencord + shared + 1.1-SNAPSHOT + pom + shared + + configuration + network + security + + util + jeeutil + account + pdf + shiro-faces + poi-util + + + + scm:git:https://jomu.timelord.de/git/jomu/shared/ + HEAD + + + + + UTF-8 + 1.8 + 1.8 + + + + + + junit + junit + 4.12 + test + + + org.mockito + mockito-core + 2.23.0 + test + + + commons-codec + commons-codec + 1.11 + + + commons-net + commons-net + 3.6 + + + org.apache.commons + commons-lang3 + 3.8.1 + + + commons-io + commons-io + 2.6 + + + org.slf4j + slf4j-api + 1.7.25 + + + org.slf4j + slf4j-log4j12 + 1.7.25 + + + org.slf4j + jcl-over-slf4j + 1.7.25 + + + + com.sun.mail + javax.mail + 1.6.2 + + + com.microsoft.ews-java-api + ews-java-api + 2.0 + + + com.google.code.gson + gson + 2.8.5 + + + org.apache.shiro + shiro-core + 1.4.0 + + + org.apache.shiro + shiro-web + 1.4.0 + + + javax + javaee-api + 7.0 + + + + com.enterprisedt + edtFTPj + 1.5.3 + + + + com.lambdaworks + scrypt + 1.4.0 + + + org.bouncycastle + bcprov-jdk15on + 1.59 + + + + org.hibernate + hibernate-core + 5.1.14.Final + jar + + + + org.apache.pdfbox + pdfbox + 2.0.12 + + + org.freemarker + freemarker + 2.3.28 + + + org.primefaces + primefaces + 6.2 + + + com.sun.faces + jsf-api + 2.2.18 + provided + + + javax.el + javax.el-api + 3.0.0 + provided + + + org.apache.poi + poi-ooxml + 4.0.0 + + + com.inversoft + prime-jwt + 1.3.1 + + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.0 + + ${maven.compiler.source} + ${maven.compiler.target} + true + + + + org.codehaus.mojo + jaxb2-maven-plugin + 2.4 + + + org.apache.maven.plugins + maven-ejb-plugin + 3.0.1 + + + org.codehaus.mojo + jaxws-maven-plugin + 2.5 + + + maven-release-plugin + 2.5.3 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + maven-release-plugin + 2.5.3 + + v@{project.version} + + + + + \ No newline at end of file