upgraded to shiro 1.4.0

enhanced error messages
This commit is contained in:
jomu
2017-06-15 15:20:09 +00:00
parent d90284d28c
commit 2590070958
2 changed files with 12 additions and 9 deletions

View File

@ -41,7 +41,7 @@ public class LoginView implements Serializable {
private String resetPasswordToken = null; private String resetPasswordToken = null;
private static final Logger LOGGER = LoggerFactory.getLogger(LoginView.class.getName()); private static final Logger LOGGER = LoggerFactory.getLogger(LoginView.class.getName());
public void authenticate() { public void authenticate() {
// Example using most common scenario of username/password pair: // Example using most common scenario of username/password pair:
@ -63,11 +63,15 @@ public class LoginView implements Serializable {
String fallbackUrl = "/web/index.xhtml"; // TODO make configurable String fallbackUrl = "/web/index.xhtml"; // TODO make configurable
// ec.redirect(url); // ec.redirect(url);
WebUtils.redirectToSavedRequest((ServletRequest) ec.getRequest(), (ServletResponse) ec.getResponse(), fallbackUrl); WebUtils.redirectToSavedRequest((ServletRequest) ec.getRequest(), (ServletResponse) ec.getResponse(), fallbackUrl);
} catch (IOException | AuthenticationException e) { } catch (IOException | AuthenticationException ex) {
// Could catch a subclass of AuthenticationException if you like // Could catch a subclass of AuthenticationException if you like
String hint = "Error while authenticating user " + username; String hint = "Error while authenticating user " + username;
LOGGER.error(hint + "Reason: " + e.toString()); if (LOGGER.isDebugEnabled()) {
FacesUtil.addErrorMessage("Login failed"); LOGGER.debug(hint, ex);
} else {
LOGGER.error(hint + " Reason: " + ex.toString());
}
FacesUtil.addErrorMessage("Login failed");
AccountEntity account = accountService.getAccountEntity(username, false); AccountEntity account = accountService.getAccountEntity(username, false);
if (account != null) { if (account != null) {
@ -96,11 +100,11 @@ public class LoginView implements Serializable {
boolean passwordResetted = accountService.resetPassword(username, password, resetPasswordToken); boolean passwordResetted = accountService.resetPassword(username, password, resetPasswordToken);
if (passwordResetted) { if (passwordResetted) {
// TODO add email notification on updated user account // TODO add email notification on updated user account
FacesUtil.addInfoMessage ("Password resetted"); FacesUtil.addInfoMessage("Password resetted");
return login(); return login();
} else { } else {
// TODO add email notificaton on failed password reset // TODO add email notificaton on failed password reset
FacesUtil.addErrorMessage("Password reset failed"); FacesUtil.addErrorMessage("Password reset failed");
return login(); return login();
} }
} }

View File

@ -44,7 +44,6 @@
<freemarker.version>2.3.24-incubating</freemarker.version> <freemarker.version>2.3.24-incubating</freemarker.version>
<pdfbox.version>2.0.2</pdfbox.version> <pdfbox.version>2.0.2</pdfbox.version>
<gson.version>2.7</gson.version> <gson.version>2.7</gson.version>
<shiro.version>1.3.2</shiro.version>
</properties> </properties>
<dependencyManagement> <dependencyManagement>
@ -110,12 +109,12 @@
<dependency> <dependency>
<groupId>org.apache.shiro</groupId> <groupId>org.apache.shiro</groupId>
<artifactId>shiro-core</artifactId> <artifactId>shiro-core</artifactId>
<version>${shiro.version}</version> <version>1.4.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.shiro</groupId> <groupId>org.apache.shiro</groupId>
<artifactId>shiro-web</artifactId> <artifactId>shiro-web</artifactId>
<version>${shiro.version}</version> <version>1.4.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax</groupId> <groupId>javax</groupId>