提交 262b3545 编写于 作者: sq3536's avatar sq3536

uaa整改

上级 1d572280
...@@ -9,6 +9,7 @@ import cn.ibizlab.util.service.AuthenticationUserService; ...@@ -9,6 +9,7 @@ import cn.ibizlab.util.service.AuthenticationUserService;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
...@@ -37,6 +38,7 @@ public class ClientAuthenticationResource ...@@ -37,6 +38,7 @@ public class ClientAuthenticationResource
private String OPPriTag="OPPRIV"; private String OPPriTag="OPPRIV";
@Autowired @Autowired
@Qualifier("IBZUSERService")
private AuthenticationUserService userDetailsService; private AuthenticationUserService userDetailsService;
@Autowired @Autowired
...@@ -49,10 +51,26 @@ public class ClientAuthenticationResource ...@@ -49,10 +51,26 @@ public class ClientAuthenticationResource
@PostMapping(value = "uaa/login") @PostMapping(value = "uaa/login")
public ResponseEntity<AuthenticationUser> login(@Validated @RequestBody AuthorizationLogin authorizationLogin){ public ResponseEntity<AuthenticationUser> login(@Validated @RequestBody AuthorizationLogin authorizationLogin){
userDetailsService.resetByUsername(authorizationLogin.getUsername()); userDetailsService.resetByUsername(authorizationLogin.getUsername());
AuthenticationUser user = userDetailsService.loadUserByLogin(authorizationLogin.getDomain(),authorizationLogin.getLoginname(),authorizationLogin.getPassword()); AuthenticationUser user = userDetailsService.loadUserByLogin(authorizationLogin.getUsername(),authorizationLogin.getPassword());
setUserName(user,authorizationLogin); if(user.getPermisionList()==null)
{
setUserPermission(user); setUserPermission(user);
setUserOrgInfo(user); setUserOrgInfo(user);
}
return ResponseEntity.ok().body(user);
}
@PostMapping(value = "uaa/loginbyusername")
public ResponseEntity<AuthenticationUser> loginByUsername(@Validated @RequestBody String username){
//userDetailsService.resetByUsername(authorizationLogin.getUsername());
AuthenticationUser user = userDetailsService.loadUserByUsername(username);
if(user.getPermisionList()==null)
{
setUserPermission(user);
setUserOrgInfo(user);
}
return ResponseEntity.ok().body(user); return ResponseEntity.ok().body(user);
} }
...@@ -141,19 +159,5 @@ public class ClientAuthenticationResource ...@@ -141,19 +159,5 @@ public class ClientAuthenticationResource
user.setOrgInfo(orgInfo); user.setOrgInfo(orgInfo);
} }
/**
* 设置用户信息
* @param user
* @param authorizationLogin
*/
private void setUserName(AuthenticationUser user, AuthorizationLogin authorizationLogin) {
String domain=authorizationLogin.getDomain();
String username=authorizationLogin.getUsername();
String password=authorizationLogin.getPassword();
if(!StringUtils.isEmpty(domain))
username = username+"|"+domain;
username=username+"|"+password;
user.setUsername(username);
}
} }
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册