Commit ce900365 authored by tianyiming's avatar tianyiming

机器人账号自动登陆调整为平台功能

parent fe87cfca
......@@ -136,7 +136,21 @@
<version>6.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-component-authtoken</artifactId>
<version>1.7.13-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.typroject</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>io.springfox</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
......
......@@ -64,10 +64,10 @@ public class LoginController {
@Value("${outSystem.user.password}")
private String password;
@Value("${security.productWeb}")
@Value("${amos.system.user.product}")
private String product;
@Value("${security.appKey}")
@Value("${amos.system.user.app-key}")
private String appKey;
@ApiOperation(value = "通过userId登录", notes = "查询设备指标")
......
......@@ -9,6 +9,7 @@ import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import com.yeejoin.amos.component.authtoken.robot.AmosRequestContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
......@@ -38,20 +39,12 @@ import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
@Service("remoteSecurityService")
public class RemoteSecurityService {
@Autowired
AmosRequestContext amosRequestContext;
@Value("${security.password}")
@Value("${amos.system.user.password}")
private String password;
@Value("${security.loginId}")
private String loginId;
@Value("${security.productWeb}")
private String productWeb;
@Value("${security.appKey}")
private String appKey;
@Autowired
private RedisTemplate<String, String> redisTemplate;
......@@ -157,15 +150,15 @@ public class RemoteSecurityService {
public Toke getServerToken() {
IdPasswordAuthModel dPasswordAuthModel=new IdPasswordAuthModel();
dPasswordAuthModel.setLoginId(loginId);
dPasswordAuthModel.setLoginId(amosRequestContext.getUserName());
dPasswordAuthModel.setPassword(DesUtil.encode(password, "qaz"));
Toke toke = null;
try {
toke = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(loginId)), Toke.class);
toke = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(amosRequestContext.getUserName())), Toke.class);
if(ObjectUtils.isEmpty(toke)){
toke = getLogin(dPasswordAuthModel);
}else{
RequestContext.setProduct(productWeb);
RequestContext.setProduct(amosRequestContext.getProduct());
if (!TokenOperation.refresh(toke.getToke())) {
toke = getLogin(dPasswordAuthModel);
}
......@@ -178,15 +171,11 @@ public class RemoteSecurityService {
private Toke getLogin(IdPasswordAuthModel dPasswordAuthModel){
Toke toke = new Toke();
RequestContext.setProduct(productWeb);
FeignClientResult feignClientResult = Privilege.authClient.idpassword(dPasswordAuthModel);
Map map = (Map) feignClientResult.getResult();
if(map!=null){
toke.setToke(map.get("token").toString());
toke.setProduct(productWeb);
toke.setAppKey(appKey);
redisTemplate.opsForValue().set(buildKey(dPasswordAuthModel.getLoginId()), JSONObject.toJSONString(toke),28,TimeUnit.DAYS);
}
RequestContext.setProduct(amosRequestContext.getProduct());
toke.setToke(amosRequestContext.getToken());
toke.setProduct(amosRequestContext.getProduct());
toke.setAppKey(amosRequestContext.getAppKey());
redisTemplate.opsForValue().set(buildKey(dPasswordAuthModel.getLoginId()), JSONObject.toJSONString(toke), 28, TimeUnit.DAYS);
return toke;
}
......
......@@ -130,7 +130,7 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
@Value("${autoSys.alarm.nameKeys}")
private String nameKeys;
@Value("${security.loginId}")
@Value("${amos.system.user.user-name}")
private String loginId;
@Value("${autoSys.fire.pool.index_key}")
......
......@@ -9,12 +9,16 @@ spring.datasource.testWhileIdle = true
spring.datasource.validationQuery = SELECT 1
#系统服务账号,用户后端服务调用
security.password=a1234560
security.loginId=fas_autosys
#security.password=a1234560
#security.loginId=fas_autosys
amos.system.user.user-name=fas_autosys
amos.system.user.password=a1234560
#应用product appkey
security.productWeb=STUDIO_APP_WEB
security.appKey =studio_normalapp_3056965
#security.productWeb=STUDIO_APP_WEB
#security.appKey =studio_normalapp_3056965
amos.system.user.app-key=studio_normalapp_3056965
amos.system.user.product=STUDIO_APP_WEB
eureka.client.serviceUrl.defaultZone=http://172.16.11.201:10001/eureka/
eureka.client.register-with-eureka = true
......
......@@ -9,12 +9,16 @@ spring.datasource.testWhileIdle = true
spring.datasource.validationQuery = SELECT 1
#系统服务账号,用户后端服务调用
security.password=a1234560
security.loginId=fas_autosys
#security.password=a1234560
#security.loginId=fas_autosys
amos.system.user.user-name=fas_autosys
amos.system.user.password=a1234560
#应用product appkey
security.productWeb=STUDIO_APP_WEB
security.appKey =studio_normalapp_2681691
#security.productWeb=STUDIO_APP_WEB
#security.appKey =studio_normalapp_3056965
amos.system.user.app-key=studio_normalapp_3056965
amos.system.user.product=STUDIO_APP_WEB
eureka.client.serviceUrl.defaultZone=http://172.16.11.20:10001/eureka/
eureka.client.register-with-eureka = true
......
......@@ -9,12 +9,16 @@ spring.datasource.testWhileIdle = true
spring.datasource.validationQuery = SELECT 1
#系统服务账号,用户后端服务调用
security.password=a1234560
security.loginId=fas_autosys
#security.password=a1234560
#security.loginId=fas_autosys
amos.system.user.user-name=fas_autosys
amos.system.user.password=a1234560
#应用product appkey
security.productWeb=STUDIO_APP_WEB
security.appKey =studio_normalapp_2681691
#security.productWeb=STUDIO_APP_WEB
#security.appKey =studio_normalapp_3056965
amos.system.user.app-key=studio_normalapp_3056965
amos.system.user.product=STUDIO_APP_WEB
eureka.client.serviceUrl.defaultZone=http://172.16.11.20:10001/eureka/
eureka.client.register-with-eureka = true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment