This commit is contained in:
shimingxy 2020-04-01 21:34:46 +08:00
parent 9cd40518ab
commit b7db556e23
15 changed files with 887 additions and 840 deletions

View File

@ -20,14 +20,14 @@ import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException; import org.springframework.security.core.AuthenticationException;
/** /**
* login Authentication abstract class * login Authentication abstract class.
* *
* @author Crystal.Sea * @author Crystal.Sea
* *
*/ */
public abstract class AbstractAuthenticationProvider { public abstract class AbstractAuthenticationProvider {
private static final Logger _logger =
private static final Logger _logger = LoggerFactory.getLogger(AbstractAuthenticationProvider.class); LoggerFactory.getLogger(AbstractAuthenticationProvider.class);
@Autowired @Autowired
@Qualifier("applicationConfig") @Qualifier("applicationConfig")
@ -39,7 +39,7 @@ public abstract class AbstractAuthenticationProvider {
@Autowired @Autowired
@Qualifier("tfaOTPAuthn") @Qualifier("tfaOTPAuthn")
protected AbstractOTPAuthn tfaOTPAuthn; protected AbstractOTPAuthn tfaOptAuthn;
@Autowired @Autowired
@Qualifier("remeberMeService") @Qualifier("remeberMeService")
@ -54,21 +54,22 @@ public abstract class AbstractAuthenticationProvider {
return (UsernamePasswordAuthenticationToken.class.isAssignableFrom(authentication)); return (UsernamePasswordAuthenticationToken.class.isAssignableFrom(authentication));
} }
/* /**
* authenticate (non-Javadoc) * authenticate .
* *
* @see org.springframework.security.authentication.AuthenticationProvider#
* authenticate(org.springframework.security.core.Authentication)
*/ */
public Authentication authenticate(Authentication authentication) throws AuthenticationException { public Authentication authenticate(Authentication authentication)
_logger.debug("Trying to authenticate user '{}' via {}", authentication.getPrincipal(), getProviderName()); throws AuthenticationException {
_logger.debug("Trying to authenticate user '{}' via {}",
authentication.getPrincipal(), getProviderName());
try { try {
authentication = doInternalAuthenticate(authentication); authentication = doInternalAuthenticate(authentication);
} catch (AuthenticationException e) { } catch (AuthenticationException e) {
e.printStackTrace(); e.printStackTrace();
_logger.error("Failed to authenticate user {} via {}: {}", _logger.error("Failed to authenticate user {} via {}: {}",
new Object[] { authentication.getPrincipal(), getProviderName(), e.getMessage() }); new Object[] {
authentication.getPrincipal(), getProviderName(), e.getMessage() });
throw e; throw e;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -81,39 +82,45 @@ public abstract class AbstractAuthenticationProvider {
} }
// user authenticated // user authenticated
_logger.debug("'{}' authenticated successfully by {}.", authentication.getPrincipal(), getProviderName()); _logger.debug("'{}' authenticated successfully by {}.",
authentication.getPrincipal(), getProviderName());
UserInfo userInfo = WebContext.getUserInfo(); final UserInfo userInfo = WebContext.getUserInfo();
Object password_set_type = WebContext.getSession() final Object passwordSetType = WebContext.getSession()
.getAttribute(WebConstants.CURRENT_LOGIN_USER_PASSWORD_SET_TYPE); .getAttribute(WebConstants.CURRENT_LOGIN_USER_PASSWORD_SET_TYPE);
// 登录完成后切换SESSION // 登录完成后切换SESSION
_logger.debug("Login Session {}.", WebContext.getSession().getId()); _logger.debug("Login Session {}.", WebContext.getSession().getId());
WebContext.getSession().invalidate(); WebContext.getSession().invalidate();
WebContext.setAttribute(WebConstants.CURRENT_USER_SESSION_ID, WebContext.getSession().getId()); WebContext.setAttribute(
WebConstants.CURRENT_USER_SESSION_ID, WebContext.getSession().getId());
_logger.debug("Login Success Session {}.", WebContext.getSession().getId()); _logger.debug("Login Success Session {}.", WebContext.getSession().getId());
authenticationRealm.insertLoginHistory(userInfo, LOGINTYPE.LOCAL, "", "xe00000004", "success"); authenticationRealm.insertLoginHistory(
userInfo, LOGINTYPE.LOCAL, "", "xe00000004", "success");
// 认证设置 // 认证设置
WebContext.setAuthentication(authentication); WebContext.setAuthentication(authentication);
WebContext.setUserInfo(userInfo); WebContext.setUserInfo(userInfo);
WebContext.getSession().setAttribute(WebConstants.CURRENT_LOGIN_USER_PASSWORD_SET_TYPE, password_set_type); WebContext.getSession().setAttribute(
WebConstants.CURRENT_LOGIN_USER_PASSWORD_SET_TYPE, passwordSetType);
// create new authentication response containing the user and it's authorities // create new authentication response containing the user and it's authorities
UsernamePasswordAuthenticationToken simpleUserAuthentication = new UsernamePasswordAuthenticationToken( UsernamePasswordAuthenticationToken simpleUserAuthentication =
userInfo.getUsername(), authentication.getCredentials(), authentication.getAuthorities()); new UsernamePasswordAuthenticationToken(
userInfo.getUsername(),
authentication.getCredentials(),
authentication.getAuthorities()
);
return simpleUserAuthentication; return simpleUserAuthentication;
} }
/** /**
* session validate * session validate.
* *
* @param j_username * @param sessionId String
* @param j_cname
* @param sessionId
*/ */
protected void sessionValid(String j_sessionId) { protected void sessionValid(String sessionId) {
if (j_sessionId == null || !j_sessionId.equals(WebContext.getSession().getId())) { if (sessionId == null || !sessionId.equals(WebContext.getSession().getId())) {
String message = WebContext.getI18nValue("login.error.session"); String message = WebContext.getI18nValue("login.error.session");
_logger.debug("login session valid error."); _logger.debug("login session valid error.");
throw new BadCredentialsException(message); throw new BadCredentialsException(message);
@ -121,15 +128,13 @@ public abstract class AbstractAuthenticationProvider {
} }
/** /**
* session validate * session validate.
* *
* @param j_username * @param jwtToken String
* @param j_cname
* @param sessionId
*/ */
protected void jwtTokenValid(String j_jwtToken) { protected void jwtTokenValid(String jwtToken) {
/* /*
* if(j_jwtToken!=null && ! j_jwtToken.equals("")){ * if(jwtToken!=null && ! jwtToken.equals("")){
* if(jwtLoginService.jwtTokenValidation(j_jwtToken)){ return; } } * if(jwtLoginService.jwtTokenValidation(j_jwtToken)){ return; } }
*/ */
String message = WebContext.getI18nValue("login.error.session"); String message = WebContext.getI18nValue("login.error.session");
@ -137,8 +142,8 @@ public abstract class AbstractAuthenticationProvider {
throw new BadCredentialsException(message); throw new BadCredentialsException(message);
} }
protected void authTypeValid(String j_auth_type) { protected void authTypeValid(String authType) {
if (j_auth_type == null) { if (authType == null) {
String message = WebContext.getI18nValue("login.error.authtype"); String message = WebContext.getI18nValue("login.error.authtype");
_logger.debug("login AuthN type can not been null ."); _logger.debug("login AuthN type can not been null .");
throw new BadCredentialsException(message); throw new BadCredentialsException(message);
@ -146,19 +151,21 @@ public abstract class AbstractAuthenticationProvider {
} }
/** /**
* captcha validate * captcha validate .
* *
* @param j_username * @param authType String
* @param j_cname * @param captcha String
* @param captcha
*/ */
protected void captchaValid(String j_captcha, String j_auth_type) { protected void captchaValid(String captcha, String authType) {
if (applicationConfig.getLoginConfig().isCaptcha()) {// for basic if (applicationConfig.getLoginConfig().isCaptcha()) {
if (j_auth_type.equalsIgnoreCase("common")) { // for basic
if (authType.equalsIgnoreCase("common")) {
_logger.info("captcha : " _logger.info("captcha : "
+ WebContext.getSession().getAttribute(WebConstants.KAPTCHA_SESSION_KEY).toString()); + WebContext.getSession().getAttribute(
if (j_captcha == null || !j_captcha WebConstants.KAPTCHA_SESSION_KEY).toString());
.equals(WebContext.getSession().getAttribute(WebConstants.KAPTCHA_SESSION_KEY).toString())) { if (captcha == null || !captcha
.equals(WebContext.getSession().getAttribute(
WebConstants.KAPTCHA_SESSION_KEY).toString())) {
String message = WebContext.getI18nValue("login.error.captcha"); String message = WebContext.getI18nValue("login.error.captcha");
_logger.debug("login captcha valid error."); _logger.debug("login captcha valid error.");
throw new BadCredentialsException(message); throw new BadCredentialsException(message);
@ -168,22 +175,24 @@ public abstract class AbstractAuthenticationProvider {
} }
/** /**
* captcha validate * captcha validate.
* *
* @param j_username * @param otpCaptcha String
* @param j_cname * @param authType String
* @param j_otp_captcha * @param userInfo UserInfo
*/ */
protected void tftcaptchaValid(String j_otp_captcha, String j_auth_type, UserInfo userInfo) { protected void tftcaptchaValid(String otpCaptcha, String authType, UserInfo userInfo) {
if (applicationConfig.getLoginConfig().isOneTimePwd()) {// for one time password 2 factor // for one time password 2 factor
if (j_auth_type.equalsIgnoreCase("tfa")) { if (applicationConfig.getLoginConfig().isOneTimePwd()) {
if (authType.equalsIgnoreCase("tfa")) {
UserInfo validUserInfo = new UserInfo(); UserInfo validUserInfo = new UserInfo();
validUserInfo.setUsername(userInfo.getUsername()); validUserInfo.setUsername(userInfo.getUsername());
String sharedSecret = PasswordReciprocal.getInstance().decoder(userInfo.getSharedSecret()); String sharedSecret =
PasswordReciprocal.getInstance().decoder(userInfo.getSharedSecret());
validUserInfo.setSharedSecret(sharedSecret); validUserInfo.setSharedSecret(sharedSecret);
validUserInfo.setSharedCounter(userInfo.getSharedCounter()); validUserInfo.setSharedCounter(userInfo.getSharedCounter());
validUserInfo.setId(userInfo.getId()); validUserInfo.setId(userInfo.getId());
if (j_otp_captcha == null || !tfaOTPAuthn.validate(validUserInfo, j_otp_captcha)) { if (otpCaptcha == null || !tfaOptAuthn.validate(validUserInfo, otpCaptcha)) {
String message = WebContext.getI18nValue("login.error.captcha"); String message = WebContext.getI18nValue("login.error.captcha");
_logger.debug("login captcha valid error."); _logger.debug("login captcha valid error.");
throw new BadCredentialsException(message); throw new BadCredentialsException(message);
@ -195,14 +204,14 @@ public abstract class AbstractAuthenticationProvider {
/** /**
* login user by j_username and j_cname first query user by j_cname if first * login user by j_username and j_cname first query user by j_cname if first
* step userinfo is null,query user from system * step userinfo is null,query user from system.
* *
* @param j_username * @param username String
* @param j_cname * @param password String
* @return * @return
*/ */
protected UserInfo loadUserInfo(String j_username, String j_password) { protected UserInfo loadUserInfo(String username, String password) {
UserInfo userInfo = authenticationRealm.loadUserInfo(j_username, j_password); UserInfo userInfo = authenticationRealm.loadUserInfo(username, password);
if (userInfo != null) { if (userInfo != null) {
if (userInfo.getUserType() == "SYSTEM") { if (userInfo.getUserType() == "SYSTEM") {
@ -216,50 +225,49 @@ public abstract class AbstractAuthenticationProvider {
} }
/** /**
* check input password empty * check input password empty.
* *
* @param password * @param password String
* @return * @return
*/ */
protected boolean emptyPasswordValid(String j_password) { protected boolean emptyPasswordValid(String password) {
if (null == j_password || "".equals(j_password)) { if (null == password || "".equals(password)) {
throw new BadCredentialsException(WebContext.getI18nValue("login.error.password.null")); throw new BadCredentialsException(WebContext.getI18nValue("login.error.password.null"));
} }
return true; return true;
} }
/** /**
* check input username or password empty * check input username or password empty.
* *
* @param j_username * @param email String
* @param password
* @return * @return
*/ */
protected boolean emptyEmailValid(String j_email) { protected boolean emptyEmailValid(String email) {
if (null == j_email || "".equals(j_email)) { if (null == email || "".equals(email)) {
throw new BadCredentialsException("login.error.email.null"); throw new BadCredentialsException("login.error.email.null");
} }
return true; return true;
} }
/** /**
* check input username empty * check input username empty.
* *
* @param j_username * @param username String
* @return * @return
*/ */
protected boolean emptyUsernameValid(String j_username) { protected boolean emptyUsernameValid(String username) {
if (null == j_username || "".equals(j_username)) { if (null == username || "".equals(username)) {
throw new BadCredentialsException(WebContext.getI18nValue("login.error.username.null")); throw new BadCredentialsException(WebContext.getI18nValue("login.error.username.null"));
} }
return true; return true;
} }
protected boolean userinfoValid(UserInfo userInfo, String j_username) { protected boolean userinfoValid(UserInfo userInfo, String username) {
if (null == userInfo) { if (null == userInfo) {
String message = WebContext.getI18nValue("login.error.username"); String message = WebContext.getI18nValue("login.error.username");
_logger.debug("login user " + j_username + " not in this System ." + message); _logger.debug("login user " + username + " not in this System ." + message);
UserInfo loginUser = new UserInfo(j_username); UserInfo loginUser = new UserInfo(username);
loginUser.setId(loginUser.generateId()); loginUser.setId(loginUser.generateId());
loginUser.setDisplayName("not exist"); loginUser.setDisplayName("not exist");
loginUser.setLoginCount(0); loginUser.setLoginCount(0);

View File

@ -6,22 +6,23 @@ import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority;
public class BasicAuthentication implements Authentication { public class BasicAuthentication implements Authentication {
/**
*
*/
private static final long serialVersionUID = -110742975439268030L; private static final long serialVersionUID = -110742975439268030L;
String j_username; String username;
String j_password; String password;
String j_sessionid; String sessionId;
String j_captcha; String captcha;
String j_otp_captcha; String otpCaptcha;
String j_remeberme; String remeberMe;
String j_auth_type; String authType;
String j_jwt_token; String jwtToken;
ArrayList<GrantedAuthority> grantedAuthority; ArrayList<GrantedAuthority> grantedAuthority;
boolean authenticated; boolean authenticated;
/**
* BasicAuthentication.
*/
public BasicAuthentication() { public BasicAuthentication() {
grantedAuthority = new ArrayList<GrantedAuthority>(); grantedAuthority = new ArrayList<GrantedAuthority>();
grantedAuthority.add(new SimpleGrantedAuthority("ROLE_USER")); grantedAuthority.add(new SimpleGrantedAuthority("ROLE_USER"));
@ -40,7 +41,7 @@ public class BasicAuthentication implements Authentication {
@Override @Override
public Object getCredentials() { public Object getCredentials() {
return this.getJ_password(); return this.getPassword();
} }
@Override @Override
@ -50,7 +51,7 @@ public class BasicAuthentication implements Authentication {
@Override @Override
public Object getPrincipal() { public Object getPrincipal() {
return this.getJ_username(); return this.getUsername();
} }
@Override @Override
@ -64,76 +65,69 @@ public class BasicAuthentication implements Authentication {
} }
public String getJ_username() {
return j_username;
}
public String getUsername() { public String getUsername() {
return j_username; return username;
} }
public void setJ_username(String j_username) { public void setUsername(String username) {
this.j_username = j_username; this.username = username;
} }
public String getJ_password() { public String getPassword() {
return j_password; return password;
} }
public void setJ_password(String j_password) { public void setPassword(String password) {
this.j_password = j_password; this.password = password;
} }
public String getJ_sessionid() { public String getSessionId() {
return j_sessionid; return sessionId;
} }
public String getSessionid() { public void setSessionId(String sessionId) {
return j_sessionid; this.sessionId = sessionId;
} }
public void setJ_sessionid(String j_sessionid) { public String getCaptcha() {
this.j_sessionid = j_sessionid; return captcha;
} }
public String getJ_captcha() { public void setCaptcha(String captcha) {
return j_captcha; this.captcha = captcha;
} }
public void setJ_captcha(String j_captcha) { public String getOtpCaptcha() {
this.j_captcha = j_captcha; return otpCaptcha;
} }
public String getJ_otp_captcha() { public void setOtpCaptcha(String otpCaptcha) {
return j_otp_captcha; this.otpCaptcha = otpCaptcha;
} }
public void setJ_otp_captcha(String j_otp_captcha) { public String getRemeberMe() {
this.j_otp_captcha = j_otp_captcha; return remeberMe;
} }
public String getJ_remeberme() { public void setRemeberMe(String remeberMe) {
return j_remeberme; this.remeberMe = remeberMe;
} }
public void setJ_remeberme(String j_remeberme) { public String getAuthType() {
this.j_remeberme = j_remeberme; return authType;
} }
public String getJ_auth_type() { public void setAuthType(String authType) {
return j_auth_type; this.authType = authType;
} }
public void setJ_auth_type(String j_auth_type) { public String getJwtToken() {
this.j_auth_type = j_auth_type; return jwtToken;
} }
public String getJ_jwt_token() { public void setJwtToken(String jwtToken) {
return j_jwt_token; this.jwtToken = jwtToken;
}
public void setJ_jwt_token(String j_jwt_token) {
this.j_jwt_token = j_jwt_token;
} }
public ArrayList<GrantedAuthority> getGrantedAuthority() { public ArrayList<GrantedAuthority> getGrantedAuthority() {
@ -146,9 +140,18 @@ public class BasicAuthentication implements Authentication {
@Override @Override
public String toString() { public String toString() {
return "BasicAuthentication [j_username=" + j_username + ", j_sessionId=" + j_sessionid + ", j_captcha=" StringBuilder builder = new StringBuilder();
+ j_captcha + ", j_otp_captcha=" + j_otp_captcha + ", j_remeberMe=" + j_remeberme + ", j_auth_type=" builder.append("BasicAuthentication [username=").append(username)
+ j_auth_type + ", j_jwtToken=" + j_jwt_token + ", authenticated=" + authenticated + "]"; .append(", password=").append(password)
.append(", sessionId=").append(sessionId)
.append(", captcha=").append(captcha)
.append(", otpCaptcha=").append(otpCaptcha)
.append(", remeberMe=").append(remeberMe)
.append(", authType=").append(authType)
.append(", jwtToken=").append(jwtToken)
.append(", grantedAuthority=").append(grantedAuthority)
.append(", authenticated=").append(authenticated)
.append("]");
return builder.toString();
} }
} }

View File

@ -13,13 +13,13 @@ import org.springframework.web.context.request.ServletRequestAttributes;
/** /**
* database Authentication provider * database Authentication provider.
* @author Crystal.Sea * @author Crystal.Sea
* *
*/ */
public class RealmAuthenticationProvider extends AbstractAuthenticationProvider { public class RealmAuthenticationProvider extends AbstractAuthenticationProvider {
private static final Logger _logger =
private static final Logger _logger = LoggerFactory.getLogger(RealmAuthenticationProvider.class); LoggerFactory.getLogger(RealmAuthenticationProvider.class);
protected String getProviderName() { protected String getProviderName() {
return "RealmAuthenticationProvider"; return "RealmAuthenticationProvider";
@ -31,31 +31,31 @@ public class RealmAuthenticationProvider extends AbstractAuthenticationProvider
_logger.debug("authentication " + auth); _logger.debug("authentication " + auth);
sessionValid(auth.getJ_sessionid()); sessionValid(auth.getSessionId());
//jwtTokenValid(j_jwtToken); //jwtTokenValid(j_jwtToken);
authTypeValid(auth.getJ_auth_type()); authTypeValid(auth.getAuthType());
captchaValid(auth.getJ_captcha(),auth.getJ_auth_type()); captchaValid(auth.getCaptcha(),auth.getAuthType());
emptyPasswordValid(auth.getJ_password()); emptyPasswordValid(auth.getPassword());
UserInfo userInfo = null; UserInfo userInfo = null;
emptyUsernameValid(auth.getJ_username()); emptyUsernameValid(auth.getUsername());
userInfo= loadUserInfo(auth.getJ_username(),auth.getJ_password()); userInfo = loadUserInfo(auth.getUsername(),auth.getPassword());
userinfoValid(userInfo, auth.getJ_password()); userinfoValid(userInfo, auth.getPassword());
tftcaptchaValid(auth.getJ_otp_captcha(),auth.getJ_auth_type(),userInfo); tftcaptchaValid(auth.getOtpCaptcha(),auth.getAuthType(),userInfo);
authenticationRealm.passwordPolicyValid(userInfo); authenticationRealm.passwordPolicyValid(userInfo);
authenticationRealm.passwordMatches(userInfo, auth.getJ_password()); authenticationRealm.passwordMatches(userInfo, auth.getPassword());
authenticationRealm.grantAuthority(userInfo); authenticationRealm.grantAuthority(userInfo);
/** /*
* put userInfo to current session context * put userInfo to current session context
*/ */
WebContext.setUserInfo(userInfo); WebContext.setUserInfo(userInfo);
@ -63,21 +63,26 @@ public class RealmAuthenticationProvider extends AbstractAuthenticationProvider
auth.setAuthenticated(true); auth.setAuthenticated(true);
if (auth.isAuthenticated() && applicationConfig.getLoginConfig().isRemeberMe()) { if (auth.isAuthenticated() && applicationConfig.getLoginConfig().isRemeberMe()) {
if(auth.getJ_remeberme()!=null&&auth.getJ_remeberme().equals("remeberMe")){ if (auth.getRemeberMe() != null && auth.getRemeberMe().equals("remeberMe")) {
WebContext.getSession().setAttribute(WebConstants.REMEBER_ME_SESSION,auth.getJ_username()); WebContext.getSession().setAttribute(
WebConstants.REMEBER_ME_SESSION,auth.getUsername());
_logger.debug("do Remeber Me"); _logger.debug("do Remeber Me");
remeberMeService.createRemeberMe( remeberMeService.createRemeberMe(
userInfo.getUsername(), userInfo.getUsername(),
WebContext.getRequest(), WebContext.getRequest(),
((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getResponse()); ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes())
.getResponse()
);
} }
} }
UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken =new UsernamePasswordAuthenticationToken( UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken =
new UsernamePasswordAuthenticationToken(
auth, auth,
"PASSWORD", "PASSWORD",
authenticationRealm.grantAuthority(userInfo)); authenticationRealm.grantAuthority(userInfo));
usernamePasswordAuthenticationToken.setDetails(new WebAuthenticationDetails(WebContext.getRequest())); usernamePasswordAuthenticationToken.setDetails(
new WebAuthenticationDetails(WebContext.getRequest()));
return usernamePasswordAuthenticationToken; return usernamePasswordAuthenticationToken;
} }

View File

@ -35,8 +35,8 @@ import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority;
/** /**
* AbstractAuthenticationRealm.
* @author Crystal.Sea * @author Crystal.Sea
* *
*/ */
@ -53,9 +53,11 @@ public abstract class AbstractAuthenticationRealm{
private static final String HISTORY_LOGIN_INSERT_STATEMENT = "INSERT INTO HISTORY_LOGIN (ID , SESSIONID , UID , USERNAME , DISPLAYNAME , LOGINTYPE , MESSAGE , CODE , PROVIDER , SOURCEIP , BROWSER , PLATFORM , APPLICATION , LOGINURL )VALUES( ? , ? , ? , ? , ?, ? , ? , ?, ? , ? , ?, ? , ? , ?)"; private static final String HISTORY_LOGIN_INSERT_STATEMENT = "INSERT INTO HISTORY_LOGIN (ID , SESSIONID , UID , USERNAME , DISPLAYNAME , LOGINTYPE , MESSAGE , CODE , PROVIDER , SOURCEIP , BROWSER , PLATFORM , APPLICATION , LOGINURL )VALUES( ? , ? , ? , ? , ?, ? , ? , ?, ? , ? , ?, ? , ? , ?)";
private static final String LOGIN_USERINFO_UPDATE_STATEMENT = "UPDATE USERINFO SET LASTLOGINTIME = ? , LASTLOGINIP = ? , LOGINCOUNT = ?, ONLINE = "+UserInfo.ONLINE.ONLINE+" WHERE ID = ?"; private static final String LOGIN_USERINFO_UPDATE_STATEMENT = "UPDATE USERINFO SET LASTLOGINTIME = ? , LASTLOGINIP = ? , LOGINCOUNT = ?, ONLINE = "
+ UserInfo.ONLINE.ONLINE + " WHERE ID = ?";
private static final String LOGOUT_USERINFO_UPDATE_STATEMENT = "UPDATE USERINFO SET LASTLOGOFFTIME = ? , ONLINE = "+UserInfo.ONLINE.OFFLINE+" WHERE ID = ?"; private static final String LOGOUT_USERINFO_UPDATE_STATEMENT = "UPDATE USERINFO SET LASTLOGOFFTIME = ? , ONLINE = "
+ UserInfo.ONLINE.OFFLINE + " WHERE ID = ?";
private static final String HISTORY_LOGOUT_UPDATE_STATEMENT = "UPDATE HISTORY_LOGIN SET LOGOUTTIME = ? WHERE SESSIONID = ?"; private static final String HISTORY_LOGOUT_UPDATE_STATEMENT = "UPDATE HISTORY_LOGIN SET LOGOUTTIME = ? WHERE SESSIONID = ?";
@ -71,12 +73,10 @@ public abstract class AbstractAuthenticationRealm{
protected boolean provisioning; protected boolean provisioning;
@Autowired @Autowired
@Qualifier("remeberMeService") @Qualifier("remeberMeService")
protected AbstractRemeberMeService remeberMeService; protected AbstractRemeberMeService remeberMeService;
/** /**
* *
*/ */
@ -84,15 +84,13 @@ public abstract class AbstractAuthenticationRealm{
} }
public AbstractAuthenticationRealm(JdbcTemplate jdbcTemplate) { public AbstractAuthenticationRealm(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate; this.jdbcTemplate = jdbcTemplate;
} }
public PasswordPolicy getPasswordPolicy() { public PasswordPolicy getPasswordPolicy() {
if (passwordPolicy == null) { if (passwordPolicy == null) {
passwordPolicy=jdbcTemplate.queryForObject( passwordPolicy = jdbcTemplate.queryForObject(PASSWORD_POLICY_SELECT_STATEMENT,
PASSWORD_POLICY_SELECT_STATEMENT,
new PasswordPolicyRowMapper()); new PasswordPolicyRowMapper());
_logger.debug("query PasswordPolicy : " + passwordPolicy); _logger.debug("query PasswordPolicy : " + passwordPolicy);
} }
@ -108,14 +106,17 @@ public abstract class AbstractAuthenticationRealm{
_logger.debug("login Attempts is " + userInfo.getBadPasswordCount()); _logger.debug("login Attempts is " + userInfo.getBadPasswordCount());
lockUser(userInfo); lockUser(userInfo);
throw new BadCredentialsException(WebContext.getI18nValue("login.error.attempts") +" "+userInfo.getBadPasswordCount()); throw new BadCredentialsException(
WebContext.getI18nValue("login.error.attempts") + " " + userInfo.getBadPasswordCount());
} }
if (userInfo.getPasswordSetType() != PASSWORDSETTYPE.PASSWORD_NORMAL) { if (userInfo.getPasswordSetType() != PASSWORDSETTYPE.PASSWORD_NORMAL) {
WebContext.getSession().setAttribute(WebConstants.CURRENT_LOGIN_USER_PASSWORD_SET_TYPE, userInfo.getPasswordSetType()); WebContext.getSession().setAttribute(WebConstants.CURRENT_LOGIN_USER_PASSWORD_SET_TYPE,
userInfo.getPasswordSetType());
return true; return true;
} else { } else {
WebContext.getSession().setAttribute(WebConstants.CURRENT_LOGIN_USER_PASSWORD_SET_TYPE, PASSWORDSETTYPE.PASSWORD_NORMAL); WebContext.getSession().setAttribute(WebConstants.CURRENT_LOGIN_USER_PASSWORD_SET_TYPE,
PASSWORDSETTYPE.PASSWORD_NORMAL);
} }
/* /*
@ -127,13 +128,15 @@ public abstract class AbstractAuthenticationRealm{
_logger.info("last password set date 锛<>" + passwordLastSetTimeString); _logger.info("last password set date 锛<>" + passwordLastSetTimeString);
DateTime currentdateTime = new DateTime(); DateTime currentdateTime = new DateTime();
DateTime changePwdDateTime=DateTime.parse(passwordLastSetTimeString, DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss")); DateTime changePwdDateTime = DateTime.parse(passwordLastSetTimeString,
DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"));
Duration duration = new Duration(changePwdDateTime, currentdateTime); Duration duration = new Duration(changePwdDateTime, currentdateTime);
int intDuration = Integer.parseInt(duration.getStandardDays() + ""); int intDuration = Integer.parseInt(duration.getStandardDays() + "");
_logger.debug("validate duration " + intDuration); _logger.debug("validate duration " + intDuration);
_logger.debug("validate result " + (intDuration <= getPasswordPolicy().getExpiration())); _logger.debug("validate result " + (intDuration <= getPasswordPolicy().getExpiration()));
if (intDuration > getPasswordPolicy().getExpiration()) { if (intDuration > getPasswordPolicy().getExpiration()) {
WebContext.getSession().setAttribute(WebConstants.CURRENT_LOGIN_USER_PASSWORD_SET_TYPE, PASSWORDSETTYPE.PASSWORD_EXPIRED); WebContext.getSession().setAttribute(WebConstants.CURRENT_LOGIN_USER_PASSWORD_SET_TYPE,
PASSWORDSETTYPE.PASSWORD_EXPIRED);
} }
} }
@ -141,9 +144,7 @@ public abstract class AbstractAuthenticationRealm{
} }
public UserInfo loadUserInfo(String username, String password) { public UserInfo loadUserInfo(String username, String password) {
List<UserInfo> listUserInfo=jdbcTemplate.query( List<UserInfo> listUserInfo = jdbcTemplate.query(DEFAULT_USERINFO_SELECT_STATEMENT, new UserInfoRowMapper(),
DEFAULT_USERINFO_SELECT_STATEMENT,
new UserInfoRowMapper(),
username); username);
UserInfo userInfo = null; UserInfo userInfo = null;
if (listUserInfo != null && listUserInfo.size() > 0) { if (listUserInfo != null && listUserInfo.size() > 0) {
@ -155,7 +156,6 @@ public abstract class AbstractAuthenticationRealm{
public abstract boolean passwordMatches(UserInfo userInfo, String password); public abstract boolean passwordMatches(UserInfo userInfo, String password);
public static boolean isAuthenticated() { public static boolean isAuthenticated() {
if (WebContext.getUserInfo() != null) { if (WebContext.getUserInfo() != null) {
return true; return true;
@ -166,16 +166,14 @@ public abstract class AbstractAuthenticationRealm{
/** /**
* 閿佸畾鐢ㄦ埛锛歩slock锛<EFBFBD>1 鐢ㄦ埛瑙i攣 2 鐢ㄦ埛閿佸畾 * 閿佸畾鐢ㄦ埛锛歩slock锛<EFBFBD>1 鐢ㄦ埛瑙i攣 2 鐢ㄦ埛閿佸畾
*
* @param userInfo * @param userInfo
*/ */
public void lockUser(UserInfo userInfo) { public void lockUser(UserInfo userInfo) {
try { try {
if (userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) { if (userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
jdbcTemplate.update(LOCK_USER_UPDATE_STATEMENT, jdbcTemplate.update(LOCK_USER_UPDATE_STATEMENT,
new Object[] { new Object[] { STATUS.LOCK, new Date(), userInfo.getId() },
STATUS.LOCK,
new Date(),
userInfo.getId()},
new int[] { Types.VARCHAR, Types.TIMESTAMP, Types.VARCHAR }); new int[] { Types.VARCHAR, Types.TIMESTAMP, Types.VARCHAR });
} }
} catch (Exception e) { } catch (Exception e) {
@ -185,16 +183,14 @@ public abstract class AbstractAuthenticationRealm{
/** /**
* 閿佸畾鐢ㄦ埛锛歩slock锛<EFBFBD>1 鐢ㄦ埛瑙i攣 2 鐢ㄦ埛閿佸畾 * 閿佸畾鐢ㄦ埛锛歩slock锛<EFBFBD>1 鐢ㄦ埛瑙i攣 2 鐢ㄦ埛閿佸畾
*
* @param userInfo * @param userInfo
*/ */
public void unlockUser(UserInfo userInfo) { public void unlockUser(UserInfo userInfo) {
try { try {
if (userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) { if (userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
jdbcTemplate.update(UNLOCK_USER_UPDATE_STATEMENT, jdbcTemplate.update(UNLOCK_USER_UPDATE_STATEMENT,
new Object[] { new Object[] { STATUS.ACTIVE, new Date(), userInfo.getId() },
STATUS.ACTIVE,
new Date(),
userInfo.getId()},
new int[] { Types.VARCHAR, Types.TIMESTAMP, Types.VARCHAR }); new int[] { Types.VARCHAR, Types.TIMESTAMP, Types.VARCHAR });
} }
} catch (Exception e) { } catch (Exception e) {
@ -204,17 +200,14 @@ public abstract class AbstractAuthenticationRealm{
/** /**
* 閲嶇疆閿欒瀵嗙爜娆暟鍜岃В閿佺敤鎴<EFBFBD> * 閲嶇疆閿欒瀵嗙爜娆暟鍜岃В閿佺敤鎴<EFBFBD>
*
* @param userInfo * @param userInfo
*/ */
public void resetBadPasswordCountAndLockout(UserInfo userInfo) { public void resetBadPasswordCountAndLockout(UserInfo userInfo) {
try { try {
if (userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) { if (userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
jdbcTemplate.update(BADPASSWORDCOUNT_RESET_UPDATE_STATEMENT, jdbcTemplate.update(BADPASSWORDCOUNT_RESET_UPDATE_STATEMENT,
new Object[] { new Object[] { 0, STATUS.ACTIVE, new Date(), userInfo.getId() },
0,
STATUS.ACTIVE,
new Date(),
userInfo.getId()},
new int[] { Types.INTEGER, Types.INTEGER, Types.TIMESTAMP, Types.VARCHAR }); new int[] { Types.INTEGER, Types.INTEGER, Types.TIMESTAMP, Types.VARCHAR });
} }
} catch (Exception e) { } catch (Exception e) {
@ -225,6 +218,7 @@ public abstract class AbstractAuthenticationRealm{
/** /**
* 鏇存柊閿欒瀵嗙爜娆 * 鏇存柊閿欒瀵嗙爜娆
*
* @param userInfo * @param userInfo
*/ */
public void setBadPasswordCount(UserInfo userInfo) { public void setBadPasswordCount(UserInfo userInfo) {
@ -233,10 +227,7 @@ public abstract class AbstractAuthenticationRealm{
int badPasswordCount = userInfo.getBadPasswordCount() + 1; int badPasswordCount = userInfo.getBadPasswordCount() + 1;
userInfo.setBadPasswordCount(badPasswordCount); userInfo.setBadPasswordCount(badPasswordCount);
jdbcTemplate.update(BADPASSWORDCOUNT_UPDATE_STATEMENT, jdbcTemplate.update(BADPASSWORDCOUNT_UPDATE_STATEMENT,
new Object[] { new Object[] { badPasswordCount, new Date(), userInfo.getId() },
badPasswordCount,
new Date(),
userInfo.getId()},
new int[] { Types.INTEGER, Types.TIMESTAMP, Types.VARCHAR }); new int[] { Types.INTEGER, Types.TIMESTAMP, Types.VARCHAR });
insertLoginHistory(userInfo, LOGINTYPE.LOCAL, "", "xe00000004", "password error"); insertLoginHistory(userInfo, LOGINTYPE.LOCAL, "", "xe00000004", "password error");
} }
@ -261,6 +252,7 @@ public abstract class AbstractAuthenticationRealm{
/** /**
* grant Authority by userinfo * grant Authority by userinfo
*
* @param userInfo * @param userInfo
* @return ArrayList<GrantedAuthority> * @return ArrayList<GrantedAuthority>
*/ */
@ -281,6 +273,7 @@ public abstract class AbstractAuthenticationRealm{
/** /**
* login log write to log db * login log write to log db
*
* @param uid * @param uid
* @param j_username * @param j_username
* @param type * @param type
@ -302,7 +295,8 @@ public abstract class AbstractAuthenticationRealm{
platform = arrayUserAgent[2].trim(); platform = arrayUserAgent[2].trim();
} else if (userAgent.indexOf("Trident") > 0) { } else if (userAgent.indexOf("Trident") > 0) {
arrayUserAgent = userAgent.split(";"); arrayUserAgent = userAgent.split(";");
browser="MSIE/"+arrayUserAgent[3].split("\\)")[0];; browser = "MSIE/" + arrayUserAgent[3].split("\\)")[0];
;
platform = arrayUserAgent[0].split("\\(")[1]; platform = arrayUserAgent[0].split("\\(")[1];
} else if (userAgent.indexOf("Chrome") > 0) { } else if (userAgent.indexOf("Chrome") > 0) {
arrayUserAgent = userAgent.split(" "); arrayUserAgent = userAgent.split(" ");
@ -313,7 +307,8 @@ public abstract class AbstractAuthenticationRealm{
browser = browser.substring(0, browser.indexOf('.')); browser = browser.substring(0, browser.indexOf('.'));
} }
} }
platform=(arrayUserAgent[1].substring(1)+" "+arrayUserAgent[2]+" "+arrayUserAgent[3].substring(0, arrayUserAgent[3].length()-1)).trim(); platform = (arrayUserAgent[1].substring(1) + " " + arrayUserAgent[2] + " "
+ arrayUserAgent[3].substring(0, arrayUserAgent[3].length() - 1)).trim();
} else if (userAgent.indexOf("Firefox") > 0) { } else if (userAgent.indexOf("Firefox") > 0) {
arrayUserAgent = userAgent.split(" "); arrayUserAgent = userAgent.split(" ");
for (int i = 0; i < arrayUserAgent.length; i++) { for (int i = 0; i < arrayUserAgent.length; i++) {
@ -322,36 +317,23 @@ public abstract class AbstractAuthenticationRealm{
browser = browser.substring(0, browser.indexOf('.')); browser = browser.substring(0, browser.indexOf('.'));
} }
} }
platform=(arrayUserAgent[1].substring(1)+" "+arrayUserAgent[2]+" "+arrayUserAgent[3].substring(0, arrayUserAgent[3].length()-1)).trim(); platform = (arrayUserAgent[1].substring(1) + " " + arrayUserAgent[2] + " "
+ arrayUserAgent[3].substring(0, arrayUserAgent[3].length() - 1)).trim();
} }
jdbcTemplate.update(HISTORY_LOGIN_INSERT_STATEMENT, jdbcTemplate.update(HISTORY_LOGIN_INSERT_STATEMENT,
new Object[] { new Object[] { WebContext.genId(), sessionId, userInfo.getId(), userInfo.getUsername(),
WebContext.genId(), userInfo.getDisplayName(), type, message, code, provider, ipAddress, browser, platform,
sessionId, "Browser", loginDate },
userInfo.getId(), new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
userInfo.getUsername(), Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
userInfo.getDisplayName(), Types.VARCHAR, Types.TIMESTAMP });
type,
message,
code,
provider,
ipAddress,
browser,
platform,
"Browser",
loginDate},
new int[] {Types.VARCHAR, Types.VARCHAR,Types.VARCHAR,Types.VARCHAR, Types.VARCHAR,Types.VARCHAR, Types.VARCHAR,Types.VARCHAR, Types.VARCHAR,Types.VARCHAR, Types.VARCHAR,Types.VARCHAR, Types.VARCHAR,Types.TIMESTAMP });
userInfo.setLastLoginTime(DateUtils.formatDateTime(loginDate)); userInfo.setLastLoginTime(DateUtils.formatDateTime(loginDate));
jdbcTemplate.update(LOGIN_USERINFO_UPDATE_STATEMENT, jdbcTemplate.update(LOGIN_USERINFO_UPDATE_STATEMENT,
new Object[] { new Object[] { loginDate, ipAddress, userInfo.getLoginCount() + 1, userInfo.getId() },
loginDate,
ipAddress,
userInfo.getLoginCount()+1,
userInfo.getId()},
new int[] { Types.TIMESTAMP, Types.VARCHAR, Types.INTEGER, Types.VARCHAR }); new int[] { Types.TIMESTAMP, Types.VARCHAR, Types.INTEGER, Types.VARCHAR });
return true; return true;
@ -366,19 +348,15 @@ public abstract class AbstractAuthenticationRealm{
remeberMeService.removeRemeberMe(response); remeberMeService.removeRemeberMe(response);
jdbcTemplate.update(HISTORY_LOGOUT_UPDATE_STATEMENT, jdbcTemplate.update(HISTORY_LOGOUT_UPDATE_STATEMENT,
new Object[] { new Object[] { logoutDateTime, sessionIdAttribute.toString() },
logoutDateTime,
sessionIdAttribute.toString()},
new int[] { Types.TIMESTAMP, Types.VARCHAR }); new int[] { Types.TIMESTAMP, Types.VARCHAR });
} }
jdbcTemplate.update(LOGOUT_USERINFO_UPDATE_STATEMENT, jdbcTemplate.update(LOGOUT_USERINFO_UPDATE_STATEMENT, new Object[] { logoutDateTime, userInfo.getId() },
new Object[] {
logoutDateTime,
userInfo.getId()},
new int[] { Types.TIMESTAMP, Types.VARCHAR }); new int[] { Types.TIMESTAMP, Types.VARCHAR });
_logger.debug("Session " +WebContext.getAttribute(WebConstants.CURRENT_USER_SESSION_ID)+ ", user "+userInfo.getUsername()+" Logout, datetime "+DateUtils.toUtc(logoutDateTime)+" ."); _logger.debug("Session " + WebContext.getAttribute(WebConstants.CURRENT_USER_SESSION_ID) + ", user "
+ userInfo.getUsername() + " Logout, datetime " + DateUtils.toUtc(logoutDateTime) + " .");
} }
return true; return true;

View File

@ -11,9 +11,9 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder;
/** /**
* same as JdbcAuthenticationRealm * same as JdbcAuthenticationRealm.
*
* @author Crystal.Sea * @author Crystal.Sea
* *
*/ */
@ -23,7 +23,6 @@ public class DefaultJdbcAuthenticationRealm extends AbstractAuthenticationRealm{
@Autowired @Autowired
private PasswordEncoder passwordEncoder; private PasswordEncoder passwordEncoder;
public DefaultJdbcAuthenticationRealm() { public DefaultJdbcAuthenticationRealm() {
} }
@ -32,12 +31,16 @@ public class DefaultJdbcAuthenticationRealm extends AbstractAuthenticationRealm{
this.jdbcTemplate = jdbcTemplate; this.jdbcTemplate = jdbcTemplate;
} }
/**
public boolean passwordMatches(UserInfo userInfo, String j_password) { * passwordMatches.
*/
public boolean passwordMatches(UserInfo userInfo, String password) {
boolean passwordMatches = false; boolean passwordMatches = false;
_logger.info("password : "
_logger.info("password : "+PasswordReciprocal.getInstance().rawPassword(userInfo.getUsername(), j_password)); + PasswordReciprocal.getInstance().rawPassword(userInfo.getUsername(), password));
passwordMatches= passwordEncoder.matches(PasswordReciprocal.getInstance().rawPassword(userInfo.getUsername(), j_password), userInfo.getPassword()); passwordMatches = passwordEncoder.matches(
PasswordReciprocal.getInstance().rawPassword(userInfo.getUsername(), password),
userInfo.getPassword());
_logger.debug("passwordvalid : " + passwordMatches); _logger.debug("passwordvalid : " + passwordMatches);
if (!passwordMatches) { if (!passwordMatches) {
setBadPasswordCount(userInfo); setBadPasswordCount(userInfo);

View File

@ -4,15 +4,14 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
/** /**
* JdbcAuthenticationRealm.
* @author Crystal.Sea * @author Crystal.Sea
* *
*/ */
public class JdbcAuthenticationRealm extends DefaultJdbcAuthenticationRealm { public class JdbcAuthenticationRealm extends DefaultJdbcAuthenticationRealm {
private static Logger _logger = LoggerFactory.getLogger(JdbcAuthenticationRealm.class); private static Logger _logger = LoggerFactory.getLogger(JdbcAuthenticationRealm.class);
public JdbcAuthenticationRealm() { public JdbcAuthenticationRealm() {
_logger.debug("init . "); _logger.debug("init . ");
} }

View File

@ -94,7 +94,13 @@ public abstract class AbstractRemeberMeService {
DateTime expiryDate = loginDate.plusSeconds(getRemeberMeValidity()); DateTime expiryDate = loginDate.plusSeconds(getRemeberMeValidity());
DateTime now = new DateTime(); DateTime now = new DateTime();
if (now.isBefore(expiryDate)) { if (now.isBefore(expiryDate)) {
if (WebContext.setAuthentication(storeRemeberMe.getUsername(), LOGINTYPE.REMEBER_ME, "", "", "success")) { if (WebContext.setAuthentication(
storeRemeberMe.getUsername(),
LOGINTYPE.REMEBER_ME,
"",
"",
"success")
) {
return updateRemeberMe(remeberMeCookie, response); return updateRemeberMe(remeberMeCookie, response);
} }
} }

View File

@ -1,10 +1,8 @@
package org.maxkey.web; package org.maxkey.web;
import java.util.Locale; import java.util.Locale;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.maxkey.authn.BasicAuthentication; import org.maxkey.authn.BasicAuthentication;
import org.maxkey.authn.realm.AbstractAuthenticationRealm; import org.maxkey.authn.realm.AbstractAuthenticationRealm;
@ -24,16 +22,16 @@ import org.springframework.web.servlet.i18n.CookieLocaleResolver;
import org.springframework.web.servlet.support.RequestContextUtils; import org.springframework.web.servlet.support.RequestContextUtils;
/** /**
* Application is common class for Web Application Context * Application is common class for Web Application Context.
* *
* @author Crystal.Sea * @author Crystal.Sea
* @since 1.5 * @since 1.5
*/ */
public final class WebContext { public final class WebContext {
/** /**
* set Current login user to session * set Current login user to session.
*
* @see WebConstants.CURRENT_USER * @see WebConstants.CURRENT_USER
*/ */
public static void setUserInfo(UserInfo userInfo) { public static void setUserInfo(UserInfo userInfo) {
@ -41,7 +39,8 @@ public final class WebContext {
} }
/** /**
* get Current login user from session * get Current login user from session.
*
* @see WebConstants.CURRENT_USER * @see WebConstants.CURRENT_USER
* @return UserInfo * @return UserInfo
*/ */
@ -49,11 +48,11 @@ public final class WebContext {
return ((UserInfo) getAttribute(WebConstants.CURRENT_USER)); return ((UserInfo) getAttribute(WebConstants.CURRENT_USER));
} }
/** /**
* set Message to session,session id is Constants.MESSAGE * set Message to session,session id is Constants.MESSAGE
*
* @see WebConstants.MESSAGE * @see WebConstants.MESSAGE
* @param message * @param message Message
*/ */
public static void setMessage(Message message) { public static void setMessage(Message message) {
setAttribute(WebConstants.CURRENT_MESSAGE, message); setAttribute(WebConstants.CURRENT_MESSAGE, message);
@ -61,6 +60,7 @@ public final class WebContext {
/** /**
* get message from session,session id is Constants.MESSAGE * get message from session,session id is Constants.MESSAGE
*
* @see WebConstants.MESSAGE * @see WebConstants.MESSAGE
* @return Message * @return Message
*/ */
@ -70,24 +70,40 @@ public final class WebContext {
/** /**
* clear session Message ,session id is Constants.MESSAGE * clear session Message ,session id is Constants.MESSAGE
*
* @see WebConstants.MESSAGE * @see WebConstants.MESSAGE
*/ */
public static void clearMessage() { public static void clearMessage() {
removeAttribute(WebConstants.CURRENT_MESSAGE); removeAttribute(WebConstants.CURRENT_MESSAGE);
} }
public static boolean setAuthentication(String username, String type, String provider, String code, String message){ /**
AbstractAuthenticationRealm authenticationRealm = (AbstractAuthenticationRealm)getBean("authenticationRealm"); * setAuthentication.
* @param username String
* @param type String
* @param provider String
* @param code String
* @param message String
* @return boolean
*/
public static boolean setAuthentication(String username,
String type,
String provider,
String code,
String message) {
AbstractAuthenticationRealm authenticationRealm =
(AbstractAuthenticationRealm) getBean("authenticationRealm");
UserInfo loadeduserInfo = authenticationRealm.loadUserInfo(username, ""); UserInfo loadeduserInfo = authenticationRealm.loadUserInfo(username, "");
if (loadeduserInfo != null) if (loadeduserInfo != null) {
{
setUserInfo(loadeduserInfo); setUserInfo(loadeduserInfo);
BasicAuthentication authentication = new BasicAuthentication(); BasicAuthentication authentication = new BasicAuthentication();
authentication.setJ_username(loadeduserInfo.getUsername()); authentication.setUsername(loadeduserInfo.getUsername());
UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken =new UsernamePasswordAuthenticationToken( UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken =
new UsernamePasswordAuthenticationToken(
authentication, authentication,
"PASSWORD", "PASSWORD",
authenticationRealm.grantAuthority(loadeduserInfo)); authenticationRealm.grantAuthority(loadeduserInfo)
);
authentication.setAuthenticated(true); authentication.setAuthenticated(true);
WebContext.setAuthentication(usernamePasswordAuthenticationToken); WebContext.setAuthentication(usernamePasswordAuthenticationToken);
@ -107,6 +123,10 @@ public final class WebContext {
return authentication; return authentication;
} }
/**
* isAuthenticated.
* @return isAuthenticated
*/
public static boolean isAuthenticated() { public static boolean isAuthenticated() {
if (getUserInfo() != null) { if (getUserInfo() != null) {
return true; return true;
@ -114,52 +134,59 @@ public final class WebContext {
return false; return false;
} }
/** /**
* get ApplicationContext from web ServletContext configuration * get ApplicationContext from web ServletContext configuration.
*
* @return ApplicationContext * @return ApplicationContext
*/ */
public static ApplicationContext getApplicationContext() { public static ApplicationContext getApplicationContext() {
return WebApplicationContextUtils.getWebApplicationContext(getSession().getServletContext()); return WebApplicationContextUtils.getWebApplicationContext(
getSession().getServletContext());
} }
/** /**
* get bean from spring configuration by bean id * get bean from spring configuration by bean id.
* @param id *
* @param id String
* @return Object * @return Object
*/ */
public static Object getBean(String id) { public static Object getBean(String id) {
return getApplicationContext().getBean(id); return getApplicationContext().getBean(id);
} }
// below method is common HttpServlet method // below method is common HttpServlet method
/** /**
* get Spring HttpServletRequest * get Spring HttpServletRequest.
*
* @return HttpServletRequest * @return HttpServletRequest
*/ */
public static HttpServletRequest getRequest() { public static HttpServletRequest getRequest() {
return ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest(); return ((ServletRequestAttributes)
RequestContextHolder.getRequestAttributes()).getRequest();
} }
/** /**
* get Http Context full Path,if port equals 80 is omitted * get Http Context full Path,if port equals 80 is omitted.
* @return String *
* eg:http://192.168.1.20:9080/webcontext or http://www.website.com/webcontext * @return String eg:http://192.168.1.20:9080/webcontext or
* http://www.website.com/webcontext
*/ */
public static String getHttpContextPath() { public static String getHttpContextPath() {
HttpServletRequest httpServletRequest = WebContext.getRequest(); HttpServletRequest httpServletRequest = WebContext.getRequest();
ApplicationConfig applicationConfig=(ApplicationConfig)WebContext.getBean("applicationConfig"); ApplicationConfig applicationConfig = (
ApplicationConfig) WebContext.getBean("applicationConfig");
if(applicationConfig.getServerPrefix()!=null&&!applicationConfig.getServerPrefix().equals("")){ if (applicationConfig.getServerPrefix() != null
&& !applicationConfig.getServerPrefix().equals("")) {
return applicationConfig.getServerPrefix(); return applicationConfig.getServerPrefix();
} else { } else {
String httpContextPath=httpServletRequest.getScheme()+"://"+applicationConfig.getDomainName(); String httpContextPath =
httpServletRequest.getScheme() + "://" + applicationConfig.getDomainName();
int port = httpServletRequest.getServerPort(); int port = httpServletRequest.getServerPort();
if (port == 443 && httpServletRequest.getScheme().equalsIgnoreCase("https")) { if (port == 443 && httpServletRequest.getScheme().equalsIgnoreCase("https")) {
//
} else if (port == 80 && httpServletRequest.getScheme().equalsIgnoreCase("http")) { } else if (port == 80 && httpServletRequest.getScheme().equalsIgnoreCase("http")) {
//
} else { } else {
httpContextPath += ":" + port; httpContextPath += ":" + port;
} }
@ -170,7 +197,8 @@ public final class WebContext {
} }
/** /**
* get current Session * get current Session.
*
* @return HttpSession * @return HttpSession
*/ */
public static HttpSession getSession() { public static HttpSession getSession() {
@ -178,7 +206,8 @@ public final class WebContext {
} }
/** /**
* get current Session,if no session ,new Session created * get current Session,if no session ,new Session created.
*
* @return HttpSession * @return HttpSession
*/ */
public static HttpSession getSession(boolean create) { public static HttpSession getSession(boolean create) {
@ -186,17 +215,19 @@ public final class WebContext {
} }
/** /**
* set Attribute to session ,Attribute name is name,value is value * set Attribute to session ,Attribute name is name,value is value.
* @param name *
* @param value * @param name String
* @param value String
*/ */
public static void setAttribute(String name, Object value) { public static void setAttribute(String name, Object value) {
getSession().setAttribute(name, value); getSession().setAttribute(name, value);
} }
/** /**
* get Attribute from session by name * get Attribute from session by name.
* @param name *
* @param name String
* @return * @return
*/ */
public static Object getAttribute(String name) { public static Object getAttribute(String name) {
@ -204,17 +235,18 @@ public final class WebContext {
} }
/** /**
* remove Attribute from session by name * remove Attribute from session by name.
* @param name *
* @param name String
*/ */
public static void removeAttribute(String name) { public static void removeAttribute(String name) {
getSession().removeAttribute(name); getSession().removeAttribute(name);
} }
/** /**
* get Request Parameter by name * get Request Parameter by name.
* @param name *
* @param name String
* @return String * @return String
*/ */
public static String getParameter(String name) { public static String getParameter(String name) {
@ -222,8 +254,9 @@ public final class WebContext {
} }
/** /**
* encoding encodingString by ApplicationConfig * encoding encodingString by ApplicationConfig.
* @param encodingString *
* @param encodingString String
* @return encoded String * @return encoded String
*/ */
public static String encoding(String encodingString) { public static String encoding(String encodingString) {
@ -231,16 +264,17 @@ public final class WebContext {
return applicationConfig.getCharacterEncodingConfig().encoding(encodingString); return applicationConfig.getCharacterEncodingConfig().encoding(encodingString);
} }
/** /**
* get locale from Spring Resolver,if locale is null,get locale from Spring SessionLocaleResolver * get locale from Spring Resolver,if locale is null,get locale from Spring.
* this is from internationalization * SessionLocaleResolver this is from internationalization
*
* @return Locale * @return Locale
*/ */
public static Locale getLocale() { public static Locale getLocale() {
Locale locale = null; Locale locale = null;
try { try {
CookieLocaleResolver cookieLocaleResolver=(CookieLocaleResolver) getBean("localeResolver"); CookieLocaleResolver cookieLocaleResolver =
(CookieLocaleResolver) getBean("localeResolver");
locale = cookieLocaleResolver.resolveLocale(getRequest()); locale = cookieLocaleResolver.resolveLocale(getRequest());
} catch (Exception e) { } catch (Exception e) {
@ -252,11 +286,9 @@ public final class WebContext {
return locale; return locale;
} }
/** /**
* get Current Date,eg 2012-07-10 * get Current Date,eg 2012-07-10.
*
* @return String * @return String
*/ */
public static String getCurrentDate() { public static String getCurrentDate() {
@ -264,7 +296,8 @@ public final class WebContext {
} }
/** /**
* get System Menu RootId,root id is constant * get System Menu RootId,root id is constant.
*
* @return String * @return String
*/ */
public static String getSystemNavRootId() { public static String getSystemNavRootId() {
@ -272,7 +305,8 @@ public final class WebContext {
} }
/** /**
* get Request IpAddress,for current Request * get Request IpAddress,for current Request.
*
* @return String,100.167.216.100 * @return String,100.167.216.100
*/ */
public static final String getRequestIpAddress() { public static final String getRequestIpAddress() {
@ -280,8 +314,9 @@ public final class WebContext {
} }
/** /**
* get Request IpAddress by request * get Request IpAddress by request.
* @param request *
* @param request HttpServletRequest
* @return String * @return String
*/ */
public static final String getRequestIpAddress(HttpServletRequest request) { public static final String getRequestIpAddress(HttpServletRequest request) {
@ -295,22 +330,29 @@ public final class WebContext {
if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
ipAddress = request.getRemoteAddr(); ipAddress = request.getRemoteAddr();
} }
LogFactory.getLog(WebContext.class).debug("getRequestIpAddress() RequestIpAddress:"+ipAddress); LogFactory.getLog(WebContext.class).debug(
"getRequestIpAddress() RequestIpAddress:" + ipAddress);
return ipAddress; return ipAddress;
} }
/**
public static boolean captchaValid(String j_captcha){ * captchaValid.
if(j_captcha==null * @param captcha String
|| !j_captcha.equals(WebContext.getSession().getAttribute(WebConstants.KAPTCHA_SESSION_KEY).toString())){ * @return
*/
public static boolean captchaValid(String captcha) {
if (captcha == null || !captcha
.equals(WebContext.getSession().getAttribute(
WebConstants.KAPTCHA_SESSION_KEY).toString())) {
return false; return false;
} }
return true; return true;
} }
//TODO:
/** /**
* TODO: * getI18nValue.
* @param code * @param code String
* @return * @return
*/ */
public static String getI18nValue(String code) { public static String getI18nValue(String code) {
@ -321,15 +363,18 @@ public final class WebContext {
return code; return code;
} }
//TODO:
/** /**
* TODO: * getRequestLocale.
* @return * @return
*/ */
public static String getRequestLocale() { public static String getRequestLocale() {
return ""; return "";
} }
/** /**
* generate random Universally Unique Identifier,delete - * generate random Universally Unique Identifier,delete -.
*
* @return String * @return String
*/ */
public static String genId() { public static String genId() {

View File

@ -90,7 +90,7 @@ renew [OPTIONAL] - if this parameter is set, ticket validation will only succeed
} }
if(storedTicket!=null){ if(storedTicket!=null){
String principal=((BasicAuthentication)storedTicket.getAuthentication().getPrincipal()).getJ_username(); String principal=((BasicAuthentication)storedTicket.getAuthentication().getPrincipal()).getUsername();
_logger.debug("principal "+principal); _logger.debug("principal "+principal);
return new Service10ResponseBuilder().success() return new Service10ResponseBuilder().success()
.setUser(principal) .setUser(principal)

View File

@ -190,7 +190,7 @@ For all error codes, it is RECOMMENDED that CAS provide a more detailed message
ServiceResponseBuilder serviceResponseBuilder=new ServiceResponseBuilder(); ServiceResponseBuilder serviceResponseBuilder=new ServiceResponseBuilder();
if(storedTicket!=null){ if(storedTicket!=null){
String principal=((BasicAuthentication)storedTicket.getAuthentication().getPrincipal()).getJ_username(); String principal=((BasicAuthentication)storedTicket.getAuthentication().getPrincipal()).getUsername();
_logger.debug("principal "+principal); _logger.debug("principal "+principal);
serviceResponseBuilder.success().setUser(principal); serviceResponseBuilder.success().setUser(principal);

View File

@ -71,7 +71,7 @@ public class Cas30AuthorizeEndpoint extends AuthorizeBaseEndpoint{
ServiceResponseBuilder serviceResponseBuilder=new ServiceResponseBuilder(); ServiceResponseBuilder serviceResponseBuilder=new ServiceResponseBuilder();
if(storedTicket!=null){ if(storedTicket!=null){
String principal=((BasicAuthentication)storedTicket.getAuthentication().getPrincipal()).getJ_username(); String principal=((BasicAuthentication)storedTicket.getAuthentication().getPrincipal()).getUsername();
serviceResponseBuilder.success().setUser(principal); serviceResponseBuilder.success().setUser(principal);
if(BOOLEAN.isTrue(storedTicket.getCasDetails().getIsAdapter())){ if(BOOLEAN.isTrue(storedTicket.getCasDetails().getIsAdapter())){
@ -111,7 +111,7 @@ public class Cas30AuthorizeEndpoint extends AuthorizeBaseEndpoint{
ServiceResponseBuilder serviceResponseBuilder=new ServiceResponseBuilder(); ServiceResponseBuilder serviceResponseBuilder=new ServiceResponseBuilder();
if(storedTicket!=null){ if(storedTicket!=null){
String principal=((BasicAuthentication)storedTicket.getAuthentication().getPrincipal()).getJ_username(); String principal=((BasicAuthentication)storedTicket.getAuthentication().getPrincipal()).getUsername();
serviceResponseBuilder.success().setUser(principal); serviceResponseBuilder.success().setUser(principal);
if(BOOLEAN.isTrue(storedTicket.getCasDetails().getIsAdapter())){ if(BOOLEAN.isTrue(storedTicket.getCasDetails().getIsAdapter())){

View File

@ -52,7 +52,7 @@ public class OAuth20AccessConfirmationController {
for(Object key:model.keySet()){ for(Object key:model.keySet()){
modelRequest.put(key.toString(), model.get(key).toString()); modelRequest.put(key.toString(), model.get(key).toString());
} }
String principal=((BasicAuthentication)WebContext.getAuthentication().getPrincipal()).getJ_username(); String principal=((BasicAuthentication)WebContext.getAuthentication().getPrincipal()).getUsername();
//Map<String, Object> model //Map<String, Object> model
AuthorizationRequest clientAuth = (AuthorizationRequest) WebContext.getAttribute("authorizationRequest"); AuthorizationRequest clientAuth = (AuthorizationRequest) WebContext.getAttribute("authorizationRequest");
ClientDetails client = clientDetailsService.loadClientByClientId(clientAuth.getClientId()); ClientDetails client = clientDetailsService.loadClientByClientId(clientAuth.getClientId());

View File

@ -132,7 +132,7 @@ public class TokenEndpointAuthenticationFilter implements Filter {
}else { }else {
Authentication authentication=ClientCredentials(request,response); Authentication authentication=ClientCredentials(request,response);
BasicAuthentication auth =new BasicAuthentication(); BasicAuthentication auth =new BasicAuthentication();
auth.setJ_username(((User)authentication.getPrincipal()).getUsername()); auth.setUsername(((User)authentication.getPrincipal()).getUsername());
auth.setAuthenticated(true); auth.setAuthenticated(true);
UsernamePasswordAuthenticationToken simpleUserAuthentication = new UsernamePasswordAuthenticationToken(auth, authentication.getCredentials(), authentication.getAuthorities()); UsernamePasswordAuthenticationToken simpleUserAuthentication = new UsernamePasswordAuthenticationToken(auth, authentication.getCredentials(), authentication.getAuthorities());
WebContext.setAuthentication(simpleUserAuthentication); WebContext.setAuthentication(simpleUserAuthentication);

View File

@ -29,19 +29,19 @@
<form class="form-horizontal m-t-20" id="loginForm" name="loginForm" action="<@base />/logon.do" method="post"> <form class="form-horizontal m-t-20" id="loginForm" name="loginForm" action="<@base />/logon.do" method="post">
<div class="form-group"> <div class="form-group">
<span class="input-group-addon"><i class="fa fa-user"></i></span> <span class="input-group-addon"><i class="fa fa-user"></i></span>
<input id='j_username' name='j_username' value="admin" class="form-control" type="text" required="" placeholder="<@locale code="login.text.username"/>"> <input id='j_username' name='username' value="admin" class="form-control" type="text" required="" placeholder="<@locale code="login.text.username"/>">
</div> </div>
<div class="form-group"> <div class="form-group">
<span class="input-group-addon"><i class="fa fa-key"></i></span> <span class="input-group-addon"><i class="fa fa-key"></i></span>
<input id='j_password' name='j_password' class="form-control" type="password" required="" placeholder="<@locale code="login.text.password"/>"> <input id='j_password' name='password' class="form-control" type="password" required="" placeholder="<@locale code="login.text.password"/>">
</div> </div>
<div class="form-group"> <div class="form-group">
<input id="j_captcha" name="j_captcha" class="form-control" value="" type="text" required="" placeholder="<@locale code="login.text.captcha"/>"> <input id="j_captcha" name="captcha" class="form-control" value="" type="text" required="" placeholder="<@locale code="login.text.captcha"/>">
<img id="j_captchaimg" src="<@base/>/captcha" /> <img id="j_captchaimg" src="<@base/>/captcha" />
</div> </div>
<div class="form-group text-center m-t-20"> <div class="form-group text-center m-t-20">
<input type="hidden" name="j_auth_type" value="basic" /> <input type="hidden" name="authType" value="basic" />
<input type='hidden' id="sessionid" name="j_sessionid" value="${sessionid}" /> <input type='hidden' id="sessionid" name="sessionId" value="${sessionid}" />
<button id="loginSubmit" class="button btn-primary btn btn-common btn-block" type="submit"> <button id="loginSubmit" class="button btn-primary btn btn-common btn-block" type="submit">
<@locale code="login.button.login" /> <@locale code="login.button.login" />
</button> </button>

View File

@ -186,20 +186,20 @@ $(function(){
<td> <td>
<div id="div_commonLogin" > <div id="div_commonLogin" >
<form id="loginForm" name="loginForm" action="<@base />/logon.do" method="post"> <form id="loginForm" name="loginForm" action="<@base />/logon.do" method="post">
<input type="hidden" name="j_auth_type" value="basic"/> <input type="hidden" name="authType" value="basic"/>
<table class="table login_form_table"> <table class="table login_form_table">
<tr> <tr>
<td><@locale code="login.text.username"/></td> <td><@locale code="login.text.username"/></td>
<td><input class="form-control" type='text' id='j_username' name='j_username' value="admin" tabindex="1"/></td> <td><input class="form-control" type='text' id='j_username' name='username' value="admin" tabindex="1"/></td>
</tr> </tr>
<tr> <tr>
<td><@locale code="login.text.password"/></td> <td><@locale code="login.text.password"/></td>
<td><input class="form-control" type='password' id='j_password' name='j_password' value="admin" tabindex="2"/></td> <td><input class="form-control" type='password' id='j_password' name='password' value="admin" tabindex="2"/></td>
</tr> </tr>
<#if true==isCaptcha> <#if true==isCaptcha>
<tr> <tr>
<td><@locale code="login.text.captcha"/></td> <td><@locale code="login.text.captcha"/></td>
<td><input class="form-control" type='text' id="j_captcha" name="j_captcha" tabindex="3" value="" style="float: left;"/><img id="j_captchaimg" src="<@base/>/captcha"/></td> <td><input class="form-control" type='text' id="j_captcha" name="captcha" tabindex="3" value="" style="float: left;"/><img id="j_captchaimg" src="<@base/>/captcha"/></td>
</tr> </tr>
</#if> </#if>
@ -210,7 +210,7 @@ $(function(){
<tr> <tr>
<td style="width:50%"> <td style="width:50%">
<span class="form_checkbox_label"> <span class="form_checkbox_label">
<input type='checkbox' id="remeberMe" name="j_remeberme" class="checkbox" tabindex="4" value="remeberMe" /> <input type='checkbox' id="remeberMe" name="remeberMe" class="checkbox" tabindex="4" value="remeberMe" />
<@locale code="login.text.remeberme"/> <@locale code="login.text.remeberme"/>
</span> </span>
</td> </td>
@ -222,7 +222,7 @@ $(function(){
</#if> </#if>
<tr style="display:none"> <tr style="display:none">
<td>sessionid</td> <td>sessionid</td>
<td><input class="form-control" type='text' id="sessionid" name="j_sessionid" value="${sessionid}" /></td> <td><input class="form-control" type='text' id="j_sessionid" name="sessionId" value="${sessionid}" /></td>
</tr> </tr>
<tr > <tr >
@ -235,15 +235,15 @@ $(function(){
</div> </div>
<div id="div_tfaLogin" > <div id="div_tfaLogin" >
<form id="tfaLoginForm" name="tfaLoginForm" action="<@base />/logon.do" method="post"> <form id="tfaLoginForm" name="tfaLoginForm" action="<@base />/logon.do" method="post">
<input type="hidden" name="j_auth_type" value="tfa"/> <input type="hidden" name="authType" value="tfa"/>
<table class="login_form_table"> <table class="login_form_table">
<tr> <tr>
<td><@locale code="login.text.username"/></td> <td><@locale code="login.text.username"/></td>
<td><input class="form-control" type='text' id='tfa_j_username' name='j_username' value="" tabindex="1"/></td> <td><input class="form-control" type='text' id='tfa_j_username' name='username' value="" tabindex="1"/></td>
</tr> </tr>
<tr> <tr>
<td><@locale code="login.text.password"/></td> <td><@locale code="login.text.password"/></td>
<td><input class="form-control" type='password' id='tfa_j_password' name='j_password' value="" tabindex="2" /></td> <td><input class="form-control" type='password' id='tfa_j_password' name='password' value="" tabindex="2" /></td>
</tr> </tr>
<#if true==isOneTimePwd> <#if true==isOneTimePwd>
<tr> <tr>
@ -255,7 +255,7 @@ $(function(){
<tr> <tr>
<td><@locale code="login.text.captcha"/></td> <td><@locale code="login.text.captcha"/></td>
<td> <td>
<input class="form-control" type='text' id="tfa_j_otp_captcha" name="j_otp_captcha" tabindex="3" value="" style="float: left;"/> <input class="form-control" type='text' id="tfa_j_otp_captcha" name="otpCaptcha" tabindex="3" value="" style="float: left;"/>
<input class="form-control" id="tfa_j_otp_captcha_button" type="button" tabindex="5" class="button" value="获取动态验证码"/> <input class="form-control" id="tfa_j_otp_captcha_button" type="button" tabindex="5" class="button" value="获取动态验证码"/>
</td> </td>
@ -274,7 +274,7 @@ $(function(){
<tr> <tr>
<td style="width:50%"> <td style="width:50%">
<span class="form_checkbox_label"> <span class="form_checkbox_label">
<input type='checkbox' id="tfa_remeberMe" name="j_remeberme" class="checkbox" tabindex="4" value="remeberMe" /> <input type='checkbox' id="tfa_remeberMe" name="remeberMe" class="checkbox" tabindex="4" value="remeberMe" />
<@locale code="login.text.remeberme"/> <@locale code="login.text.remeberme"/>
</span> </span>
</td> </td>
@ -286,7 +286,7 @@ $(function(){
</#if> </#if>
<tr style="display:none"> <tr style="display:none">
<td>sessionid</td> <td>sessionid</td>
<td><input class="form-control" type='text' id="tfa_sessionid" name="j_sessionid" value="${sessionid}" /></td> <td><input class="form-control" type='text' id="tfa_sessionid" name="sessionId" value="${sessionid}" /></td>
</tr> </tr>
<tr > <tr >