v1.3 RC

上级 9cd40518
......@@ -20,14 +20,14 @@ import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
/**
* login Authentication abstract class
* login Authentication abstract class.
*
* @author Crystal.Sea
*
*/
public abstract class AbstractAuthenticationProvider {
private static final Logger _logger = LoggerFactory.getLogger(AbstractAuthenticationProvider.class);
private static final Logger _logger =
LoggerFactory.getLogger(AbstractAuthenticationProvider.class);
@Autowired
@Qualifier("applicationConfig")
......@@ -39,7 +39,7 @@ public abstract class AbstractAuthenticationProvider {
@Autowired
@Qualifier("tfaOTPAuthn")
protected AbstractOTPAuthn tfaOTPAuthn;
protected AbstractOTPAuthn tfaOptAuthn;
@Autowired
@Qualifier("remeberMeService")
......@@ -54,21 +54,22 @@ public abstract class AbstractAuthenticationProvider {
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 {
_logger.debug("Trying to authenticate user '{}' via {}", authentication.getPrincipal(), getProviderName());
public Authentication authenticate(Authentication authentication)
throws AuthenticationException {
_logger.debug("Trying to authenticate user '{}' via {}",
authentication.getPrincipal(), getProviderName());
try {
authentication = doInternalAuthenticate(authentication);
} catch (AuthenticationException e) {
e.printStackTrace();
_logger.error("Failed to authenticate user {} via {}: {}",
new Object[] { authentication.getPrincipal(), getProviderName(), e.getMessage() });
new Object[] {
authentication.getPrincipal(), getProviderName(), e.getMessage() });
throw e;
} catch (Exception e) {
e.printStackTrace();
......@@ -81,39 +82,45 @@ public abstract class AbstractAuthenticationProvider {
}
// user authenticated
_logger.debug("'{}' authenticated successfully by {}.", authentication.getPrincipal(), getProviderName());
_logger.debug("'{}' authenticated successfully by {}.",
authentication.getPrincipal(), getProviderName());
UserInfo userInfo = WebContext.getUserInfo();
Object password_set_type = WebContext.getSession()
final UserInfo userInfo = WebContext.getUserInfo();
final Object passwordSetType = WebContext.getSession()
.getAttribute(WebConstants.CURRENT_LOGIN_USER_PASSWORD_SET_TYPE);
// 登录完成后切换SESSION
_logger.debug("Login Session {}.", WebContext.getSession().getId());
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());
authenticationRealm.insertLoginHistory(userInfo, LOGINTYPE.LOCAL, "", "xe00000004", "success");
authenticationRealm.insertLoginHistory(
userInfo, LOGINTYPE.LOCAL, "", "xe00000004", "success");
// 认证设置
WebContext.setAuthentication(authentication);
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
UsernamePasswordAuthenticationToken simpleUserAuthentication = new UsernamePasswordAuthenticationToken(
userInfo.getUsername(), authentication.getCredentials(), authentication.getAuthorities());
UsernamePasswordAuthenticationToken simpleUserAuthentication =
new UsernamePasswordAuthenticationToken(
userInfo.getUsername(),
authentication.getCredentials(),
authentication.getAuthorities()
);
return simpleUserAuthentication;
}
/**
* session validate
* session validate.
*
* @param j_username
* @param j_cname
* @param sessionId
* @param sessionId String
*/
protected void sessionValid(String j_sessionId) {
if (j_sessionId == null || !j_sessionId.equals(WebContext.getSession().getId())) {
protected void sessionValid(String sessionId) {
if (sessionId == null || !sessionId.equals(WebContext.getSession().getId())) {
String message = WebContext.getI18nValue("login.error.session");
_logger.debug("login session valid error.");
throw new BadCredentialsException(message);
......@@ -121,15 +128,13 @@ public abstract class AbstractAuthenticationProvider {
}
/**
* session validate
* session validate.
*
* @param j_username
* @param j_cname
* @param sessionId
* @param jwtToken String
*/
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; } }
*/
String message = WebContext.getI18nValue("login.error.session");
......@@ -137,8 +142,8 @@ public abstract class AbstractAuthenticationProvider {
throw new BadCredentialsException(message);
}
protected void authTypeValid(String j_auth_type) {
if (j_auth_type == null) {
protected void authTypeValid(String authType) {
if (authType == null) {
String message = WebContext.getI18nValue("login.error.authtype");
_logger.debug("login AuthN type can not been null .");
throw new BadCredentialsException(message);
......@@ -146,19 +151,21 @@ public abstract class AbstractAuthenticationProvider {
}
/**
* captcha validate
* captcha validate .
*
* @param j_username
* @param j_cname
* @param captcha
* @param authType String
* @param captcha String
*/
protected void captchaValid(String j_captcha, String j_auth_type) {
if (applicationConfig.getLoginConfig().isCaptcha()) {// for basic
if (j_auth_type.equalsIgnoreCase("common")) {
protected void captchaValid(String captcha, String authType) {
if (applicationConfig.getLoginConfig().isCaptcha()) {
// for basic
if (authType.equalsIgnoreCase("common")) {
_logger.info("captcha : "
+ WebContext.getSession().getAttribute(WebConstants.KAPTCHA_SESSION_KEY).toString());
if (j_captcha == null || !j_captcha
.equals(WebContext.getSession().getAttribute(WebConstants.KAPTCHA_SESSION_KEY).toString())) {
+ 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");
_logger.debug("login captcha valid error.");
throw new BadCredentialsException(message);
......@@ -168,22 +175,24 @@ public abstract class AbstractAuthenticationProvider {
}
/**
* captcha validate
* captcha validate.
*
* @param j_username
* @param j_cname
* @param j_otp_captcha
* @param otpCaptcha String
* @param authType String
* @param userInfo UserInfo
*/
protected void tftcaptchaValid(String j_otp_captcha, String j_auth_type, UserInfo userInfo) {
if (applicationConfig.getLoginConfig().isOneTimePwd()) {// for one time password 2 factor
if (j_auth_type.equalsIgnoreCase("tfa")) {
protected void tftcaptchaValid(String otpCaptcha, String authType, UserInfo userInfo) {
// for one time password 2 factor
if (applicationConfig.getLoginConfig().isOneTimePwd()) {
if (authType.equalsIgnoreCase("tfa")) {
UserInfo validUserInfo = new UserInfo();
validUserInfo.setUsername(userInfo.getUsername());
String sharedSecret = PasswordReciprocal.getInstance().decoder(userInfo.getSharedSecret());
String sharedSecret =
PasswordReciprocal.getInstance().decoder(userInfo.getSharedSecret());
validUserInfo.setSharedSecret(sharedSecret);
validUserInfo.setSharedCounter(userInfo.getSharedCounter());
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");
_logger.debug("login captcha valid error.");
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
* step userinfo is null,query user from system
* step userinfo is null,query user from system.
*
* @param j_username
* @param j_cname
* @param username String
* @param password String
* @return
*/
protected UserInfo loadUserInfo(String j_username, String j_password) {
UserInfo userInfo = authenticationRealm.loadUserInfo(j_username, j_password);
protected UserInfo loadUserInfo(String username, String password) {
UserInfo userInfo = authenticationRealm.loadUserInfo(username, password);
if (userInfo != null) {
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
*/
protected boolean emptyPasswordValid(String j_password) {
if (null == j_password || "".equals(j_password)) {
protected boolean emptyPasswordValid(String password) {
if (null == password || "".equals(password)) {
throw new BadCredentialsException(WebContext.getI18nValue("login.error.password.null"));
}
return true;
}
/**
* check input username or password empty
* check input username or password empty.
*
* @param j_username
* @param password
* @param email String
* @return
*/
protected boolean emptyEmailValid(String j_email) {
if (null == j_email || "".equals(j_email)) {
protected boolean emptyEmailValid(String email) {
if (null == email || "".equals(email)) {
throw new BadCredentialsException("login.error.email.null");
}
return true;
}
/**
* check input username empty
* check input username empty.
*
* @param j_username
* @param username String
* @return
*/
protected boolean emptyUsernameValid(String j_username) {
if (null == j_username || "".equals(j_username)) {
protected boolean emptyUsernameValid(String username) {
if (null == username || "".equals(username)) {
throw new BadCredentialsException(WebContext.getI18nValue("login.error.username.null"));
}
return true;
}
protected boolean userinfoValid(UserInfo userInfo, String j_username) {
protected boolean userinfoValid(UserInfo userInfo, String username) {
if (null == userInfo) {
String message = WebContext.getI18nValue("login.error.username");
_logger.debug("login user " + j_username + " not in this System ." + message);
UserInfo loginUser = new UserInfo(j_username);
_logger.debug("login user " + username + " not in this System ." + message);
UserInfo loginUser = new UserInfo(username);
loginUser.setId(loginUser.generateId());
loginUser.setDisplayName("not exist");
loginUser.setLoginCount(0);
......
......@@ -6,22 +6,23 @@ import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
public class BasicAuthentication implements Authentication {
/**
*
*/
private static final long serialVersionUID = -110742975439268030L;
String j_username;
String j_password;
String j_sessionid;
String j_captcha;
String j_otp_captcha;
String j_remeberme;
String j_auth_type;
String j_jwt_token;
String username;
String password;
String sessionId;
String captcha;
String otpCaptcha;
String remeberMe;
String authType;
String jwtToken;
ArrayList<GrantedAuthority> grantedAuthority;
boolean authenticated;
/**
* BasicAuthentication.
*/
public BasicAuthentication() {
grantedAuthority = new ArrayList<GrantedAuthority>();
grantedAuthority.add(new SimpleGrantedAuthority("ROLE_USER"));
......@@ -40,7 +41,7 @@ public class BasicAuthentication implements Authentication {
@Override
public Object getCredentials() {
return this.getJ_password();
return this.getPassword();
}
@Override
......@@ -50,7 +51,7 @@ public class BasicAuthentication implements Authentication {
@Override
public Object getPrincipal() {
return this.getJ_username();
return this.getUsername();
}
@Override
......@@ -64,76 +65,69 @@ public class BasicAuthentication implements Authentication {
}
public String getJ_username() {
return j_username;
}
public String getUsername() {
return j_username;
}
public void setJ_username(String j_username) {
this.j_username = j_username;
return username;
}
public String getJ_password() {
return j_password;
public void setUsername(String username) {
this.username = username;
}
public void setJ_password(String j_password) {
this.j_password = j_password;
public String getPassword() {
return password;
}
public String getJ_sessionid() {
return j_sessionid;
public void setPassword(String password) {
this.password = password;
}
public String getSessionid() {
return j_sessionid;
public String getSessionId() {
return sessionId;
}
public void setJ_sessionid(String j_sessionid) {
this.j_sessionid = j_sessionid;
public void setSessionId(String sessionId) {
this.sessionId = sessionId;
}
public String getJ_captcha() {
return j_captcha;
public String getCaptcha() {
return captcha;
}
public void setJ_captcha(String j_captcha) {
this.j_captcha = j_captcha;
public void setCaptcha(String captcha) {
this.captcha = captcha;
}
public String getJ_otp_captcha() {
return j_otp_captcha;
public String getOtpCaptcha() {
return otpCaptcha;
}
public void setJ_otp_captcha(String j_otp_captcha) {
this.j_otp_captcha = j_otp_captcha;
public void setOtpCaptcha(String otpCaptcha) {
this.otpCaptcha = otpCaptcha;
}
public String getJ_remeberme() {
return j_remeberme;
public String getRemeberMe() {
return remeberMe;
}
public void setJ_remeberme(String j_remeberme) {
this.j_remeberme = j_remeberme;
public void setRemeberMe(String remeberMe) {
this.remeberMe = remeberMe;
}
public String getJ_auth_type() {
return j_auth_type;
public String getAuthType() {
return authType;
}
public void setJ_auth_type(String j_auth_type) {
this.j_auth_type = j_auth_type;
public void setAuthType(String authType) {
this.authType = authType;
}
public String getJ_jwt_token() {
return j_jwt_token;
public String getJwtToken() {
return jwtToken;
}
public void setJ_jwt_token(String j_jwt_token) {
this.j_jwt_token = j_jwt_token;
public void setJwtToken(String jwtToken) {
this.jwtToken = jwtToken;
}
public ArrayList<GrantedAuthority> getGrantedAuthority() {
......@@ -146,9 +140,18 @@ public class BasicAuthentication implements Authentication {
@Override
public String toString() {
return "BasicAuthentication [j_username=" + j_username + ", j_sessionId=" + j_sessionid + ", j_captcha="
+ j_captcha + ", j_otp_captcha=" + j_otp_captcha + ", j_remeberMe=" + j_remeberme + ", j_auth_type="
+ j_auth_type + ", j_jwtToken=" + j_jwt_token + ", authenticated=" + authenticated + "]";
StringBuilder builder = new StringBuilder();
builder.append("BasicAuthentication [username=").append(username)
.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();
}
}
......@@ -13,13 +13,13 @@ import org.springframework.web.context.request.ServletRequestAttributes;
/**
* database Authentication provider
* database Authentication provider.
* @author Crystal.Sea
*
*/
public class RealmAuthenticationProvider extends AbstractAuthenticationProvider {
private static final Logger _logger = LoggerFactory.getLogger(RealmAuthenticationProvider.class);
private static final Logger _logger =
LoggerFactory.getLogger(RealmAuthenticationProvider.class);
protected String getProviderName() {
return "RealmAuthenticationProvider";
......@@ -31,53 +31,58 @@ public class RealmAuthenticationProvider extends AbstractAuthenticationProvider
_logger.debug("authentication " + auth);
sessionValid(auth.getJ_sessionid());
sessionValid(auth.getSessionId());
//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;
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.passwordMatches(userInfo, auth.getJ_password());
authenticationRealm.passwordMatches(userInfo, auth.getPassword());
authenticationRealm.grantAuthority(userInfo);
/**
/*
* put userInfo to current session context
*/
WebContext.setUserInfo(userInfo);
auth.setAuthenticated(true);
if(auth.isAuthenticated()&&applicationConfig.getLoginConfig().isRemeberMe()){
if(auth.getJ_remeberme()!=null&&auth.getJ_remeberme().equals("remeberMe")){
WebContext.getSession().setAttribute(WebConstants.REMEBER_ME_SESSION,auth.getJ_username());
if (auth.isAuthenticated() && applicationConfig.getLoginConfig().isRemeberMe()) {
if (auth.getRemeberMe() != null && auth.getRemeberMe().equals("remeberMe")) {
WebContext.getSession().setAttribute(
WebConstants.REMEBER_ME_SESSION,auth.getUsername());
_logger.debug("do Remeber Me");
remeberMeService.createRemeberMe(
userInfo.getUsername(),
WebContext.getRequest(),
((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getResponse());
((ServletRequestAttributes)RequestContextHolder.getRequestAttributes())
.getResponse()
);
}
}
UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken =new UsernamePasswordAuthenticationToken(
UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken =
new UsernamePasswordAuthenticationToken(
auth,
"PASSWORD",
authenticationRealm.grantAuthority(userInfo));
usernamePasswordAuthenticationToken.setDetails(new WebAuthenticationDetails(WebContext.getRequest()));
usernamePasswordAuthenticationToken.setDetails(
new WebAuthenticationDetails(WebContext.getRequest()));
return usernamePasswordAuthenticationToken;
}
......
......@@ -11,38 +11,41 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.crypto.password.PasswordEncoder;
/**
* same as JdbcAuthenticationRealm
* same as JdbcAuthenticationRealm.
*
* @author Crystal.Sea
*
*/
public class DefaultJdbcAuthenticationRealm extends AbstractAuthenticationRealm{
private static Logger _logger = LoggerFactory.getLogger(DefaultJdbcAuthenticationRealm.class);
@Autowired
private PasswordEncoder passwordEncoder;
public class DefaultJdbcAuthenticationRealm extends AbstractAuthenticationRealm {
private static Logger _logger = LoggerFactory.getLogger(DefaultJdbcAuthenticationRealm.class);
@Autowired
private PasswordEncoder passwordEncoder;
public DefaultJdbcAuthenticationRealm() {
}
public DefaultJdbcAuthenticationRealm(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate=jdbcTemplate;
}
public DefaultJdbcAuthenticationRealm() {
}
public boolean passwordMatches(UserInfo userInfo, String j_password) {
boolean passwordMatches=false;
_logger.info("password : "+PasswordReciprocal.getInstance().rawPassword(userInfo.getUsername(), j_password));
passwordMatches= passwordEncoder.matches(PasswordReciprocal.getInstance().rawPassword(userInfo.getUsername(), j_password), userInfo.getPassword());
_logger.debug("passwordvalid : "+passwordMatches);
if(!passwordMatches){
setBadPasswordCount(userInfo);
throw new BadCredentialsException(WebContext.getI18nValue("login.error.password"));
}
return passwordMatches;
}
public DefaultJdbcAuthenticationRealm(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
/**
* passwordMatches.
*/
public boolean passwordMatches(UserInfo userInfo, String password) {
boolean passwordMatches = false;
_logger.info("password : "
+ PasswordReciprocal.getInstance().rawPassword(userInfo.getUsername(), password));
passwordMatches = passwordEncoder.matches(
PasswordReciprocal.getInstance().rawPassword(userInfo.getUsername(), password),
userInfo.getPassword());
_logger.debug("passwordvalid : " + passwordMatches);
if (!passwordMatches) {
setBadPasswordCount(userInfo);
throw new BadCredentialsException(WebContext.getI18nValue("login.error.password"));
}
return passwordMatches;
}
}
......@@ -4,21 +4,20 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.JdbcTemplate;
/**
* JdbcAuthenticationRealm.
* @author Crystal.Sea
*
*/
public class JdbcAuthenticationRealm extends DefaultJdbcAuthenticationRealm{
private static Logger _logger = LoggerFactory.getLogger(JdbcAuthenticationRealm.class);
public class JdbcAuthenticationRealm extends DefaultJdbcAuthenticationRealm {
private static Logger _logger = LoggerFactory.getLogger(JdbcAuthenticationRealm.class);
public JdbcAuthenticationRealm() {
_logger.debug("init . ");
}
public JdbcAuthenticationRealm() {
_logger.debug("init . ");
}
public JdbcAuthenticationRealm(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate=jdbcTemplate;
}
public JdbcAuthenticationRealm(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
}
......@@ -94,7 +94,13 @@ public abstract class AbstractRemeberMeService {
DateTime expiryDate = loginDate.plusSeconds(getRemeberMeValidity());
DateTime now = new DateTime();
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);
}
}
......
......@@ -90,7 +90,7 @@ renew [OPTIONAL] - if this parameter is set, ticket validation will only succeed
}
if(storedTicket!=null){
String principal=((BasicAuthentication)storedTicket.getAuthentication().getPrincipal()).getJ_username();
String principal=((BasicAuthentication)storedTicket.getAuthentication().getPrincipal()).getUsername();
_logger.debug("principal "+principal);
return new Service10ResponseBuilder().success()
.setUser(principal)
......
......@@ -190,7 +190,7 @@ For all error codes, it is RECOMMENDED that CAS provide a more detailed message
ServiceResponseBuilder serviceResponseBuilder=new ServiceResponseBuilder();
if(storedTicket!=null){
String principal=((BasicAuthentication)storedTicket.getAuthentication().getPrincipal()).getJ_username();
String principal=((BasicAuthentication)storedTicket.getAuthentication().getPrincipal()).getUsername();
_logger.debug("principal "+principal);
serviceResponseBuilder.success().setUser(principal);
......
......@@ -71,7 +71,7 @@ public class Cas30AuthorizeEndpoint extends AuthorizeBaseEndpoint{
ServiceResponseBuilder serviceResponseBuilder=new ServiceResponseBuilder();
if(storedTicket!=null){
String principal=((BasicAuthentication)storedTicket.getAuthentication().getPrincipal()).getJ_username();
String principal=((BasicAuthentication)storedTicket.getAuthentication().getPrincipal()).getUsername();
serviceResponseBuilder.success().setUser(principal);
if(BOOLEAN.isTrue(storedTicket.getCasDetails().getIsAdapter())){
......@@ -111,7 +111,7 @@ public class Cas30AuthorizeEndpoint extends AuthorizeBaseEndpoint{
ServiceResponseBuilder serviceResponseBuilder=new ServiceResponseBuilder();
if(storedTicket!=null){
String principal=((BasicAuthentication)storedTicket.getAuthentication().getPrincipal()).getJ_username();
String principal=((BasicAuthentication)storedTicket.getAuthentication().getPrincipal()).getUsername();
serviceResponseBuilder.success().setUser(principal);
if(BOOLEAN.isTrue(storedTicket.getCasDetails().getIsAdapter())){
......
......@@ -52,7 +52,7 @@ public class OAuth20AccessConfirmationController {
for(Object key:model.keySet()){
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
AuthorizationRequest clientAuth = (AuthorizationRequest) WebContext.getAttribute("authorizationRequest");
ClientDetails client = clientDetailsService.loadClientByClientId(clientAuth.getClientId());
......
......@@ -132,7 +132,7 @@ public class TokenEndpointAuthenticationFilter implements Filter {
}else {
Authentication authentication=ClientCredentials(request,response);
BasicAuthentication auth =new BasicAuthentication();
auth.setJ_username(((User)authentication.getPrincipal()).getUsername());
auth.setUsername(((User)authentication.getPrincipal()).getUsername());
auth.setAuthenticated(true);
UsernamePasswordAuthenticationToken simpleUserAuthentication = new UsernamePasswordAuthenticationToken(auth, authentication.getCredentials(), authentication.getAuthorities());
WebContext.setAuthentication(simpleUserAuthentication);
......
......@@ -29,19 +29,19 @@
<form class="form-horizontal m-t-20" id="loginForm" name="loginForm" action="<@base />/logon.do" method="post">
<div class="form-group">
<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 class="form-group">
<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 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" />
</div>
<div class="form-group text-center m-t-20">
<input type="hidden" name="j_auth_type" value="basic" />
<input type='hidden' id="sessionid" name="j_sessionid" value="${sessionid}" />
<input type="hidden" name="authType" value="basic" />
<input type='hidden' id="sessionid" name="sessionId" value="${sessionid}" />
<button id="loginSubmit" class="button btn-primary btn btn-common btn-block" type="submit">
<@locale code="login.button.login" />
</button>
......
......@@ -186,20 +186,20 @@ $(function(){
<td>
<div id="div_commonLogin" >
<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">
<tr>
<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>
<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>
<#if true==isCaptcha>
<tr>
<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>
</#if>
......@@ -210,7 +210,7 @@ $(function(){
<tr>
<td style="width:50%">
<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"/>
</span>
</td>
......@@ -222,7 +222,7 @@ $(function(){
</#if>
<tr style="display:none">
<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 >
......@@ -235,15 +235,15 @@ $(function(){
</div>
<div id="div_tfaLogin" >
<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">
<tr>
<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>
<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>
<#if true==isOneTimePwd>
<tr>
......@@ -255,7 +255,7 @@ $(function(){
<tr>
<td><@locale code="login.text.captcha"/></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="获取动态验证码"/>
</td>
......@@ -274,7 +274,7 @@ $(function(){
<tr>
<td style="width:50%">
<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"/>
</span>
</td>
......@@ -286,7 +286,7 @@ $(function(){
</#if>
<tr style="display:none">
<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 >
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册