提交 b02a60e5 编写于 作者: ibizdev's avatar ibizdev

ibizdev提交

上级 b44d409b
......@@ -18,4 +18,8 @@ public class IBZUAAFallback implements IBZUAAFeignClient {
return null;
}
@Override
public AuthenticationUser loginByUsername(String username) {
return null;
}
}
......@@ -26,4 +26,7 @@ public interface IBZUAAFeignClient
@PostMapping(value = "/uaa/login")
AuthenticationUser login(@RequestBody AuthorizationLogin authorizationLogin);
@PostMapping(value = "/uaa/loginbyusername")
AuthenticationUser loginByUsername(@RequestBody String username);
}
......@@ -34,7 +34,7 @@ public class AuthenticationController
@PostMapping(value = "${ibiz.auth.path:v7/login}")
public ResponseEntity<AuthenticationInfo> login(@Validated @RequestBody AuthorizationLogin authorizationLogin){
userDetailsService.resetByUsername(authorizationLogin.getUsername());
final AuthenticationUser authuserdetail = userDetailsService.loadUserByLogin(authorizationLogin.getDomain(),authorizationLogin.getLoginname(),authorizationLogin.getPassword());
final AuthenticationUser authuserdetail = userDetailsService.loadUserByLogin(authorizationLogin.getUsername(),authorizationLogin.getPassword());
// 生成令牌
final String token = jwtTokenUtil.generateToken(authuserdetail);
// 返回 token
......
......@@ -13,16 +13,14 @@ import org.springframework.stereotype.Service;
public interface AuthenticationUserService extends UserDetailsService {
@Override
@Cacheable( value="ibzdict_users",key = "'getByUsername:'+#p0")
@Cacheable( value="ibzuaa_users",key = "'getByUsername:'+#p0")
AuthenticationUser loadUserByUsername(String username);
@Cacheable( value="ibzdict_users",key = "'getByUsername:'+#p0")
@Cacheable( value="ibzuaa_users",key = "'getByUsername:'+#p0")
AuthenticationUser loadUserByLogin(String username,String password);
@Cacheable( value="ibzdict_users",key = "'getByUsername:'+#p1")
AuthenticationUser loadUserByLogin(String domain,String username,String password);
@CacheEvict( value="ibzdict_users",key = "'getByUsername:'+#p0")
@CacheEvict( value="ibzuaa_users",key = "'getByUsername:'+#p0")
void resetByUsername(String username);
}
......@@ -2,6 +2,7 @@ package cn.ibizlab.util.service;
import com.alibaba.fastjson.JSONObject;
import cn.ibizlab.util.client.IBZOUFeignClient;
import cn.ibizlab.util.errors.BadRequestAlertException;
import cn.ibizlab.util.client.IBZUAAFeignClient;
import cn.ibizlab.util.security.AuthenticationUser;
import cn.ibizlab.util.security.AuthorizationLogin;
......@@ -15,7 +16,6 @@ import org.springframework.util.StringUtils;
/**
* 实体[IBZUSER] 服务对象接口实现
*/
//@Primary
@Service("IBZUAAUserService")
public class IBZUAAUserService implements AuthenticationUserService{
......@@ -25,39 +25,32 @@ public class IBZUAAUserService implements AuthenticationUserService{
@Override
public AuthenticationUser loadUserByUsername(String username) {
AuthenticationUser user=uaaFeignClient.loginByUsername(username);
if(user==null)
throw new BadRequestAlertException("登录失败","IBZUAAUser",username);
return user;
}
@Override
public AuthenticationUser loadUserByLogin(String username, String password) {
String[] data=username.split("[|]");
String loginname=username;
String domains="";
String password="";
if(data.length==3) {
if(data.length==2) {
loginname=data[0].trim();
domains=data[1].trim();
password=data[2].trim();
}
else if(data.length==2) {
loginname=data[0].trim();
password=data[1].trim();
}
AuthorizationLogin user = new AuthorizationLogin();
user.setDomain(domains);
user.setLoginname(loginname);
user.setPassword(password);
return uaaFeignClient.login(user);
AuthorizationLogin logininfo = new AuthorizationLogin();
logininfo.setDomain(domains);
logininfo.setLoginname(loginname);
logininfo.setPassword(password);
AuthenticationUser user=uaaFeignClient.login(logininfo);
if(user==null)
throw new BadRequestAlertException("登录失败","IBZUAAUser",username);
return user;
}
@Override
public AuthenticationUser loadUserByLogin(String username, String password) {
AuthenticationUser authuserdetail = loadUserByUsername(username+"|"+password);
return authuserdetail;
}
@Override
public AuthenticationUser loadUserByLogin(String domain, String username, String password) {
if(!StringUtils.isEmpty(domain))
username = username+"|"+domain;
return loadUserByLogin(username,password);
}
@Override
public void resetByUsername(String username) {
......
......@@ -62,12 +62,6 @@ public class IBZUSERServiceImpl extends ServiceImpl<IBZUSERMapper, IBZUSER> impl
return authuserdetail;
}
@Override
public AuthenticationUser loadUserByLogin(String domain, String username, String password) {
if(!StringUtils.isEmpty(domain))
username = username+"|"+domain;
return loadUserByLogin(username,password);
}
public void resetByUsername(String username) {
......
......@@ -19,12 +19,6 @@ import org.springframework.beans.factory.annotation.Value;
@Service("SimpleUserService")
public class SimpleUserService implements AuthenticationUserService{
@Value("${ibiz.enablePermissionValid:false}")
boolean enablePermissionValid; //是否开启权限校验
@Value("${ibiz.systemid:2C40DFCD-0DF5-47BF-91A5-C45F810B0001}")
private String systemid;
@Override
public AuthenticationUser loadUserByUsername(String username) {
AuthenticationUser user = new AuthenticationUser();
......@@ -33,17 +27,12 @@ public class SimpleUserService implements AuthenticationUserService{
String domains="";
String password="";
if(data.length==3) {
if(data.length==2) {
loginname=data[0].trim();
domains=data[1].trim();
password=data[2].trim();
}
else if(data.length==2) {
loginname=data[0].trim();
password=data[1].trim();
}
user.setUserid(DigestUtils.md5DigestAsHex(username.getBytes()));
user.setUserid(username);
user.setUsercode(loginname);
user.setUsername(username);
user.setLoginname(loginname);
......@@ -59,17 +48,11 @@ public class SimpleUserService implements AuthenticationUserService{
@Override
public AuthenticationUser loadUserByLogin(String username, String password) {
password = DigestUtils.md5DigestAsHex(String.format("%1$s||%2$s", username, password).getBytes());
AuthenticationUser authuserdetail = loadUserByUsername(username+"|"+password);
AuthenticationUser authuserdetail = loadUserByUsername(username);
return authuserdetail;
}
@Override
public AuthenticationUser loadUserByLogin(String domain, String username, String password) {
if(!StringUtils.isEmpty(domain))
username = username+"|"+domain;
return loadUserByLogin(username,password);
}
@Override
public void resetByUsername(String username) {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册