|
@@ -176,4 +176,36 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, Myuser> implements
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public JSONObject getbladeAuth(String username, String password) throws Exception {
|
|
|
+ MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
|
|
|
+ headers.add("Content-Type", "application/x-www-form-urlencoded");
|
|
|
+
|
|
|
+ //固定字符串
|
|
|
+ String auth ="c2FiZXI6NWMwMmMzZDViNzYxNTNkZGM5ZTczYzc5YzMzNzYzODAxNmE5ZDM2Ng==";
|
|
|
+ // 使用后端私钥解密数据
|
|
|
+ byte[] pwdData = RSAUtils.decrypt(Base64.getDecoder().decode(password.replaceAll(" ", "+")), RSAUtils.getKeyPair().getPrivate());
|
|
|
+
|
|
|
+ String pwdstr = MD5Utils.md5Encrypt(new String(pwdData));
|
|
|
+ // 数字签名
|
|
|
+ byte[] signature = RSAUtils.sign(password.getBytes(), RSAUtils.getKeyPair().getPrivate());
|
|
|
+
|
|
|
+ // 验证数字签名
|
|
|
+ boolean isValid = RSAUtils.verify(password.getBytes(), signature, RSAUtils.getKeyPair().getPublic());
|
|
|
+ if(!isValid){
|
|
|
+ throw new CustomException("登录密码验证错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ HttpEntity<LinkedMultiValueMap<String, Object>> param = new HttpEntity<>(null, headers);
|
|
|
+
|
|
|
+ ResponseEntity<String> responseEntity2 = restTemplate.postForEntity(imaConfig.getGatewayUrl() + "ims-idas/oauth/IToken?userInfo={1}&password={2}&auth={3}",
|
|
|
+ param, String.class, username, pwdstr,auth);
|
|
|
+ log.info("\n code:{}\n header:{}\n body:{}\n", responseEntity2.getStatusCodeValue(), responseEntity2.getHeaders(), responseEntity2.getBody());
|
|
|
+ if(200== responseEntity2.getStatusCodeValue()){
|
|
|
+ return JSON.parseObject(responseEntity2.getBody());
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|