diff --git a/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/AbstractAuthenticationProvider.java b/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/AbstractAuthenticationProvider.java index 53a06df1e..f96e5386c 100644 --- a/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/AbstractAuthenticationProvider.java +++ b/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/AbstractAuthenticationProvider.java @@ -116,8 +116,11 @@ public abstract class AbstractAuthenticationProvider { changeSession(authentication); - authenticationRealm.insertLoginHistory( - WebContext.getUserInfo(), ConstantsLoginType.LOCAL, "", "xe00000004", "success"); + authenticationRealm.insertLoginHistory( WebContext.getUserInfo(), + ConstantsLoginType.LOCAL, + "", + "xe00000004", + WebConstants.LOGIN_RESULT.SUCCESS); return authentication; } @@ -331,7 +334,7 @@ public abstract class AbstractAuthenticationProvider { loginUser.setDisplayName("not exist"); loginUser.setLoginCount(0); authenticationRealm.insertLoginHistory(loginUser, ConstantsLoginType.LOCAL, "", - WebContext.getI18nValue("login.error.username"), "user not exist"); + WebContext.getI18nValue("login.error.username"),WebConstants.LOGIN_RESULT.USER_NOT_EXIST); throw new BadCredentialsException(WebContext.getI18nValue("login.error.username")); } return true; diff --git a/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/LoginCredential.java b/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/LoginCredential.java index 0e5d75eda..d4c2e777b 100644 --- a/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/LoginCredential.java +++ b/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/LoginCredential.java @@ -20,6 +20,7 @@ package org.maxkey.authn; import java.util.ArrayList; import java.util.Collection; +import org.maxkey.web.WebConstants; import org.springframework.security.core.Authentication; import org.springframework.security.core.GrantedAuthority; @@ -40,7 +41,7 @@ public class LoginCredential implements Authentication { String onlineTicket; String provider; String code; - String message="SUCCESS"; + String message = WebConstants.LOGIN_RESULT.SUCCESS; ArrayList grantedAuthority; boolean authenticated; diff --git a/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/support/httpheader/HttpHeaderEntryPoint.java b/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/support/httpheader/HttpHeaderEntryPoint.java index b373d38b1..bb3de7152 100644 --- a/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/support/httpheader/HttpHeaderEntryPoint.java +++ b/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/support/httpheader/HttpHeaderEntryPoint.java @@ -97,7 +97,8 @@ public class HttpHeaderEntryPoint implements AsyncHandlerInterceptor { isAuthenticated=false; }else { _logger.info("Security Authentication not null . "); - UsernamePasswordAuthenticationToken authenticationToken = (UsernamePasswordAuthenticationToken) SecurityContextHolder.getContext().getAuthentication(); + UsernamePasswordAuthenticationToken authenticationToken = + (UsernamePasswordAuthenticationToken) SecurityContextHolder.getContext().getAuthentication(); String lastSessionUserName = authenticationToken.getPrincipal().toString(); _logger.info("Authentication Principal : " + lastSessionUserName); if (lastSessionUserName != null && !lastSessionUserName.equals(httpHeaderUsername)) { diff --git a/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/support/rememberme/HttpRemeberMeEntryPoint.java b/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/support/rememberme/HttpRemeberMeEntryPoint.java index db950760b..ec82743de 100644 --- a/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/support/rememberme/HttpRemeberMeEntryPoint.java +++ b/maxkey-authentications/maxkey-authentication-core/src/main/java/org/maxkey/authn/support/rememberme/HttpRemeberMeEntryPoint.java @@ -95,7 +95,8 @@ public class HttpRemeberMeEntryPoint implements AsyncHandlerInterceptor { DateTime expiryDate = loginDate.plusSeconds(remeberMeService.getRemeberMeValidity()); DateTime now = new DateTime(); if (now.isBefore(expiryDate)) { - LoginCredential loginCredential =new LoginCredential(storeRemeberMe.getUsername(),"",ConstantsLoginType.REMEBER_ME); + LoginCredential loginCredential = + new LoginCredential(storeRemeberMe.getUsername(),"",ConstantsLoginType.REMEBER_ME); authenticationProvider.authentication(loginCredential,true); remeberMeService.updateRemeberMe(remeberMeCookie, response); _logger.debug("RemeberMe Logined in , username " + storeRemeberMe.getUsername()); diff --git a/maxkey-core/src/main/java/org/maxkey/web/WebConstants.java b/maxkey-core/src/main/java/org/maxkey/web/WebConstants.java index 39e3c0378..42cea714a 100644 --- a/maxkey-core/src/main/java/org/maxkey/web/WebConstants.java +++ b/maxkey-core/src/main/java/org/maxkey/web/WebConstants.java @@ -85,5 +85,14 @@ public class WebConstants { public static final String ONLINE_TICKET_NAME = "online_ticket"; public static final String ONLINE_TICKET_PREFIX = "OT"; + + public static final class LOGIN_RESULT{ + public static final String SUCCESS = "success"; + public static final String FAIL = "fail"; + public static final String PASSWORD_ERROE = "password error"; + public static final String USER_NOT_EXIST = "user not exist"; + + + } }