Commit 9eac2ec1 authored by tangwei's avatar tangwei

自动登录机器人

parent d452ff3d
...@@ -51,21 +51,21 @@ ...@@ -51,21 +51,21 @@
<artifactId>geodesy</artifactId> <artifactId>geodesy</artifactId>
<version>1.1.3</version> <version>1.1.3</version>
</dependency> </dependency>
<dependency> <!-- <dependency>-->
<groupId>com.yeejoin</groupId> <!-- <groupId>com.yeejoin</groupId>-->
<artifactId>amos-component-authtoken</artifactId> <!-- <artifactId>amos-component-authtoken</artifactId>-->
<version>1.7.13-SNAPSHOT</version> <!-- <version>1.7.13-SNAPSHOT</version>-->
<exclusions> <!-- <exclusions>-->
<exclusion> <!-- <exclusion>-->
<groupId>org.typroject</groupId> <!-- <groupId>org.typroject</groupId>-->
<artifactId>*</artifactId> <!-- <artifactId>*</artifactId>-->
</exclusion> <!-- </exclusion>-->
<exclusion> <!-- <exclusion>-->
<groupId>io.springfox</groupId> <!-- <groupId>io.springfox</groupId>-->
<artifactId>*</artifactId> <!-- <artifactId>*</artifactId>-->
</exclusion> <!-- </exclusion>-->
</exclusions> <!-- </exclusions>-->
</dependency> <!-- </dependency>-->
</dependencies> </dependencies>
</project> </project>
...@@ -47,17 +47,28 @@ import com.yeejoin.equipmanage.common.vo.Token; ...@@ -47,17 +47,28 @@ import com.yeejoin.equipmanage.common.vo.Token;
@Service("remoteSecurityService") @Service("remoteSecurityService")
public class RemoteSecurityService { public class RemoteSecurityService {
@Autowired // @Value("${security.password}")
AmosRequestContext amosRequestContext; // private String password;
@Value("${amos.system.user.password}") // @Value("${security.loginId}")
private String password; // private String loginId;
//
// @Value("${security.productWeb}")
// private String productWeb;
//
@Value("${security.productApp}") @Value("${security.productApp}")
private String productApp; private String productApp;
@Value("${amos.system.user.app-key}") @Value("${amos.system.user.app-key}")
private String appKeyApp; private String appKeyApp;
@Value("${amos.system.user.user-name}")
private String userName;
@Value("${amos.system.user.app-key}")
private String appKey;
@Value("${amos.system.user.product}")
private String product;
@Autowired @Autowired
private RedisTemplate<String, String> redisTemplate; private RedisTemplate<String, String> redisTemplate;
...@@ -67,6 +78,9 @@ public class RemoteSecurityService { ...@@ -67,6 +78,9 @@ public class RemoteSecurityService {
@Autowired @Autowired
private HttpServletRequest request; private HttpServletRequest request;
@Autowired
AmosRequestContext amosRequestContext ;
// * 根据公司id查询机构用户 // * 根据公司id查询机构用户
public List<AgencyUserModel> listUserByCompanyId(String companyId) { public List<AgencyUserModel> listUserByCompanyId(String companyId) {
...@@ -407,23 +421,28 @@ public class RemoteSecurityService { ...@@ -407,23 +421,28 @@ public class RemoteSecurityService {
// } // }
public Token getServerToken() { public Token getServerToken() {
IdPasswordAuthModel dPasswordAuthModel = new IdPasswordAuthModel(); // IdPasswordAuthModel dPasswordAuthModel = new IdPasswordAuthModel();
dPasswordAuthModel.setLoginId(amosRequestContext.getUserName()); // dPasswordAuthModel.setLoginId(loginId);
dPasswordAuthModel.setPassword(DesUtil.encode(password, "qaz")); // dPasswordAuthModel.setPassword(DesUtil.encode(password, "qaz"));
Token toke = null; // Token toke = null;
try { // try {
toke = JSON.parseObject(this.redisTemplate.opsForValue().get(buildKey(amosRequestContext.getUserName())), Token.class); // toke = JSON.parseObject(this.redisTemplate.opsForValue().get(buildKey(loginId)), Token.class);
if (ObjectUtils.isEmpty(toke)) { // if (ObjectUtils.isEmpty(toke)) {
toke = getLogin(dPasswordAuthModel); // toke = getLogin(dPasswordAuthModel);
} else { // } else {
RequestContext.setProduct(amosRequestContext.getProduct()); // RequestContext.setProduct(productWeb);
if (!redisUtils.refresh(toke.getToke())) { // if (!redisUtils.refresh(toke.getToke())) {
toke = getLogin(dPasswordAuthModel); // toke = getLogin(dPasswordAuthModel);
} // }
} // }
} catch (InnerInvokException e) { // } catch (InnerInvokException e) {
e.printStackTrace(); // e.printStackTrace();
} // }
Token toke=new Token();
toke.setAppKey(appKeyApp);
toke.setProduct(product);
toke.setToke(amosRequestContext.getToken());
redisTemplate.opsForValue().set(buildKey(userName), JSONObject.toJSONString(toke), 28, TimeUnit.DAYS);
return toke; return toke;
} }
...@@ -432,13 +451,17 @@ public class RemoteSecurityService { ...@@ -432,13 +451,17 @@ public class RemoteSecurityService {
return "system_" + username; return "system_" + username;
} }
private Token getLogin(IdPasswordAuthModel dPasswordAuthModel) { // private Token getLogin(IdPasswordAuthModel dPasswordAuthModel) {
Token toke = new Token(); // Token toke = new Token();
RequestContext.setProduct(amosRequestContext.getProduct()); // RequestContext.setProduct(productWeb);
toke.setToke(amosRequestContext.getToken()); // FeignClientResult feignClientResult = Privilege.authClient.idpassword(dPasswordAuthModel);
toke.setProduct(amosRequestContext.getProduct()); // Map map = (Map) feignClientResult.getResult();
toke.setAppKey(amosRequestContext.getAppKey()); // if (map != null) {
redisTemplate.opsForValue().set(buildKey(dPasswordAuthModel.getLoginId()), JSONObject.toJSONString(toke), 28, TimeUnit.DAYS); // toke.setToke(map.get("token").toString());
return toke; // toke.setProduct(productWeb);
} // toke.setAppKey(appKeyApp);
// redisTemplate.opsForValue().set(buildKey(dPasswordAuthModel.getLoginId()), JSONObject.toJSONString(toke), 28, TimeUnit.DAYS);
// }
// return toke;
// }
} }
...@@ -64,10 +64,10 @@ public class LoginController { ...@@ -64,10 +64,10 @@ public class LoginController {
@Value("${outSystem.user.password}") @Value("${outSystem.user.password}")
private String password; private String password;
@Value("${security.productWeb}") @Value("${amos.system.user.product}")
private String product; private String product;
@Value("${security.appKey}") @Value("${amos.system.user.app-key}")
private String appKey; private String appKey;
@ApiOperation(value = "通过userId登录", notes = "查询设备指标") @ApiOperation(value = "通过userId登录", notes = "查询设备指标")
......
...@@ -10,6 +10,7 @@ import java.util.Set; ...@@ -10,6 +10,7 @@ import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.yeejoin.amos.component.authtoken.robot.AmosRequestContext;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -44,17 +45,35 @@ import com.yeejoin.amos.latentdanger.common.remote.IAMOSSecurityServer; ...@@ -44,17 +45,35 @@ import com.yeejoin.amos.latentdanger.common.remote.IAMOSSecurityServer;
@Service("remoteSecurityService-danger") @Service("remoteSecurityService-danger")
public class RemoteSecurityService { public class RemoteSecurityService {
@Value("${security.password}") // @Value("${security.password}")
private String password; // private String password;
@Value("${security.loginId}") // @Value("${security.loginId}")
private String loginId; // private String loginId;
@Value("${security.productWeb}") // @Value("${security.productWeb}")
private String productWeb; // private String productWeb;
@Value("${security.appKey}") // @Value("${security.appKey}")
private String appKey; // private String appKey;
// @Value("${security.productApp}")
// private String productApp;
@Value("${security.productApp}") @Value("${security.productApp}")
private String productApp; private String productApp;
@Value("${amos.system.user.user-name}")
private String userName;
@Value("${amos.system.user.app-key}")
private String appKey;
@Value("${amos.system.user.product}")
private String product;
@Autowired
AmosRequestContext amosRequestContext ;
private static final Logger log = LoggerFactory.getLogger(RemoteSecurityService.class); private static final Logger log = LoggerFactory.getLogger(RemoteSecurityService.class);
@Autowired @Autowired
...@@ -101,34 +120,39 @@ public class RemoteSecurityService { ...@@ -101,34 +120,39 @@ public class RemoteSecurityService {
} }
public Toke getServerToken() { public Toke getServerToken() {
IdPasswordAuthModel dPasswordAuthModel = new IdPasswordAuthModel(); // IdPasswordAuthModel dPasswordAuthModel = new IdPasswordAuthModel();
dPasswordAuthModel.setLoginId(loginId); // dPasswordAuthModel.setLoginId(loginId);
dPasswordAuthModel.setPassword(DesUtil.encode(password, "qaz")); // dPasswordAuthModel.setPassword(DesUtil.encode(password, "qaz"));
Toke toke = null; // Toke toke = null;
try { // try {
toke = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(loginId)), Toke.class); // toke = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(loginId)), Toke.class);
if (ObjectUtils.isEmpty(toke)) { // if (ObjectUtils.isEmpty(toke)) {
toke = getLogin(dPasswordAuthModel); // toke = getLogin(dPasswordAuthModel);
} else { // } else {
RequestContext.setProduct(productWeb); // RequestContext.setProduct(productWeb);
if (!TokenOperation.refresh(toke.getToke())) { // if (!TokenOperation.refresh(toke.getToke())) {
toke = getLogin(dPasswordAuthModel); // toke = getLogin(dPasswordAuthModel);
} // }
} // }
} catch (InnerInvokException e) { // } catch (InnerInvokException e) {
e.printStackTrace(); // e.printStackTrace();
} // }
Toke toke=new Toke();
toke.setProduct(product);
toke.setAppKey(appKey);
toke.setToke(amosRequestContext.getToken());
redisTemplate.opsForValue().set(buildKey(userName), JSONObject.toJSONString(toke), 28, TimeUnit.DAYS);
return toke; return toke;
} }
private Toke getLogin(IdPasswordAuthModel dPasswordAuthModel) { private Toke getLogin(IdPasswordAuthModel dPasswordAuthModel) {
Toke toke = new Toke(); Toke toke = new Toke();
RequestContext.setProduct(productWeb); RequestContext.setProduct(product);
FeignClientResult feignClientResult = Privilege.authClient.idpassword(dPasswordAuthModel); FeignClientResult feignClientResult = Privilege.authClient.idpassword(dPasswordAuthModel);
Map map = (Map) feignClientResult.getResult(); Map map = (Map) feignClientResult.getResult();
if (map != null) { if (map != null) {
toke.setToke(map.get("token").toString()); toke.setToke(map.get("token").toString());
toke.setProduct(productWeb); toke.setProduct(product);
toke.setAppKey(appKey); toke.setAppKey(appKey);
redisTemplate.opsForValue().set(buildKey(dPasswordAuthModel.getLoginId()), JSONObject.toJSONString(toke), 28, TimeUnit.DAYS); redisTemplate.opsForValue().set(buildKey(dPasswordAuthModel.getLoginId()), JSONObject.toJSONString(toke), 28, TimeUnit.DAYS);
} }
...@@ -558,6 +582,7 @@ public class RemoteSecurityService { ...@@ -558,6 +582,7 @@ public class RemoteSecurityService {
return null; return null;
} }
public boolean loginOutFromApp(String toke, String product, String appKey) { public boolean loginOutFromApp(String toke, String product, String appKey) {
RequestContext.setToken(toke); RequestContext.setToken(toke);
RequestContext.setProduct(product); RequestContext.setProduct(product);
...@@ -628,7 +653,7 @@ public class RemoteSecurityService { ...@@ -628,7 +653,7 @@ public class RemoteSecurityService {
public AgencyUserModel getAgencyUserModel(String token) { public AgencyUserModel getAgencyUserModel(String token) {
RequestContext.setToken(token); RequestContext.setToken(token);
RequestContext.setAppKey(appKey); RequestContext.setAppKey(appKey);
RequestContext.setProduct(productWeb); RequestContext.setProduct(product);
try { try {
AgencyUserModel result = Privilege.agencyUserClient.getme().getResult(); AgencyUserModel result = Privilege.agencyUserClient.getme().getResult();
return result; return result;
......
...@@ -11,6 +11,7 @@ import java.util.Set; ...@@ -11,6 +11,7 @@ import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.yeejoin.amos.component.authtoken.robot.AmosRequestContext;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -45,17 +46,35 @@ import com.yeejoin.amos.maintenance.common.remote.IAMOSSecurityServer; ...@@ -45,17 +46,35 @@ import com.yeejoin.amos.maintenance.common.remote.IAMOSSecurityServer;
@Service("remoteSecurityService") @Service("remoteSecurityService")
public class RemoteSecurityService { public class RemoteSecurityService {
@Value("${security.password}") // @Value("${security.password}")
private String password; // private String password;
@Value("${security.loginId}") // @Value("${security.loginId}")
private String loginId; // private String loginId;
@Value("${security.productWeb}") // @Value("${security.productWeb}")
private String productWeb; // private String productWeb;
@Value("${security.appKey}") // @Value("${security.appKey}")
private String appKey; // private String appKey;
// @Value("${security.productApp}")
// private String productApp;
@Value("${security.productApp}") @Value("${security.productApp}")
private String productApp; private String productApp;
@Value("${amos.system.user.user-name}")
private String userName;
@Value("${amos.system.user.app-key}")
private String appKey;
@Value("${amos.system.user.product}")
private String product;
@Autowired
AmosRequestContext amosRequestContext ;
private static final Logger log = LoggerFactory.getLogger(RemoteSecurityService.class); private static final Logger log = LoggerFactory.getLogger(RemoteSecurityService.class);
@Autowired @Autowired
...@@ -102,34 +121,39 @@ public class RemoteSecurityService { ...@@ -102,34 +121,39 @@ public class RemoteSecurityService {
} }
public Toke getServerToken() { public Toke getServerToken() {
IdPasswordAuthModel dPasswordAuthModel = new IdPasswordAuthModel(); // IdPasswordAuthModel dPasswordAuthModel = new IdPasswordAuthModel();
dPasswordAuthModel.setLoginId(loginId); // dPasswordAuthModel.setLoginId(loginId);
dPasswordAuthModel.setPassword(DesUtil.encode(password, "qaz")); // dPasswordAuthModel.setPassword(DesUtil.encode(password, "qaz"));
Toke toke = null; // Toke toke = null;
try { // try {
toke = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(loginId)), Toke.class); // toke = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(loginId)), Toke.class);
if (ObjectUtils.isEmpty(toke)) { // if (ObjectUtils.isEmpty(toke)) {
toke = getLogin(dPasswordAuthModel); // toke = getLogin(dPasswordAuthModel);
} else { // } else {
RequestContext.setProduct(productWeb); // RequestContext.setProduct(product);
if (!TokenOperation.refresh(toke.getToke())) { // if (!TokenOperation.refresh(toke.getToke())) {
toke = getLogin(dPasswordAuthModel); // toke = getLogin(dPasswordAuthModel);
} // }
} // }
} catch (InnerInvokException e) { // } catch (InnerInvokException e) {
e.printStackTrace(); // e.printStackTrace();
} // }
Toke toke=new Toke();
toke.setProduct(product);
toke.setAppKey(appKey);
toke.setToke(amosRequestContext.getToken());
redisTemplate.opsForValue().set(buildKey(userName), JSONObject.toJSONString(toke), 28, TimeUnit.DAYS);
return toke; return toke;
} }
private Toke getLogin(IdPasswordAuthModel dPasswordAuthModel) { private Toke getLogin(IdPasswordAuthModel dPasswordAuthModel) {
Toke toke = new Toke(); Toke toke = new Toke();
RequestContext.setProduct(productWeb); RequestContext.setProduct(product);
FeignClientResult feignClientResult = Privilege.authClient.idpassword(dPasswordAuthModel); FeignClientResult feignClientResult = Privilege.authClient.idpassword(dPasswordAuthModel);
Map map = (Map) feignClientResult.getResult(); Map map = (Map) feignClientResult.getResult();
if (map != null) { if (map != null) {
toke.setToke(map.get("token").toString()); toke.setToke(map.get("token").toString());
toke.setProduct(productWeb); toke.setProduct(product);
toke.setAppKey(appKey); toke.setAppKey(appKey);
redisTemplate.opsForValue().set(buildKey(dPasswordAuthModel.getLoginId()), JSONObject.toJSONString(toke), 28, TimeUnit.DAYS); redisTemplate.opsForValue().set(buildKey(dPasswordAuthModel.getLoginId()), JSONObject.toJSONString(toke), 28, TimeUnit.DAYS);
} }
...@@ -637,7 +661,7 @@ public class RemoteSecurityService { ...@@ -637,7 +661,7 @@ public class RemoteSecurityService {
public AgencyUserModel getAgencyUserModel(String token) { public AgencyUserModel getAgencyUserModel(String token) {
RequestContext.setToken(token); RequestContext.setToken(token);
RequestContext.setAppKey(appKey); RequestContext.setAppKey(appKey);
RequestContext.setProduct(productWeb); RequestContext.setProduct(product);
try { try {
AgencyUserModel result = Privilege.agencyUserClient.getme().getResult(); AgencyUserModel result = Privilege.agencyUserClient.getme().getResult();
return result; return result;
......
...@@ -11,6 +11,7 @@ import java.util.Set; ...@@ -11,6 +11,7 @@ import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.yeejoin.amos.component.authtoken.robot.AmosRequestContext;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -45,17 +46,38 @@ import com.yeejoin.amos.patrol.common.remote.IAMOSSecurityServer; ...@@ -45,17 +46,38 @@ import com.yeejoin.amos.patrol.common.remote.IAMOSSecurityServer;
@Service("remoteSecurityService") @Service("remoteSecurityService")
public class RemoteSecurityService { public class RemoteSecurityService {
@Value("${security.password}") // @Value("${security.password}")
private String password; // private String password;
@Value("${security.loginId}") // @Value("${security.loginId}")
private String loginId; // private String loginId;
@Value("${security.productWeb}") // @Value("${security.productWeb}")
private String productWeb; // private String productWeb;
@Value("${security.appKey}") // @Value("${security.appKey}")
private String appKey; // private String appKey;
// @Value("${security.productApp}")
// private String productApp;
@Value("${security.productApp}") @Value("${security.productApp}")
private String productApp; private String productApp;
@Value("${amos.system.user.user-name}")
private String userName;
@Value("${amos.system.user.app-key}")
private String appKey;
@Value("${amos.system.user.product}")
private String product;
@Autowired
AmosRequestContext amosRequestContext ;
private static final Logger log = LoggerFactory.getLogger(RemoteSecurityService.class); private static final Logger log = LoggerFactory.getLogger(RemoteSecurityService.class);
@Autowired @Autowired
...@@ -102,36 +124,44 @@ public class RemoteSecurityService { ...@@ -102,36 +124,44 @@ public class RemoteSecurityService {
} }
public Toke getServerToken() { public Toke getServerToken() {
IdPasswordAuthModel dPasswordAuthModel = new IdPasswordAuthModel(); // IdPasswordAuthModel dPasswordAuthModel = new IdPasswordAuthModel();
dPasswordAuthModel.setLoginId(loginId); // dPasswordAuthModel.setLoginId(loginId);
dPasswordAuthModel.setPassword(DesUtil.encode(password, "qaz")); // dPasswordAuthModel.setPassword(DesUtil.encode(password, "qaz"));
Toke toke = null; // Toke toke = null;
try { // try {
toke = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(loginId)), Toke.class); // toke = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(loginId)), Toke.class);
if (ObjectUtils.isEmpty(toke)) { // if (ObjectUtils.isEmpty(toke)) {
toke = getLogin(dPasswordAuthModel); // toke = getLogin(dPasswordAuthModel);
} else { // } else {
RequestContext.setProduct(productWeb); // RequestContext.setProduct(productWeb);
if (!TokenOperation.refresh(toke.getToke())) { // if (!TokenOperation.refresh(toke.getToke())) {
toke = getLogin(dPasswordAuthModel); // toke = getLogin(dPasswordAuthModel);
} // }
} // }
RequestContext.setAppKey(toke.getAppKey()); // RequestContext.setAppKey(toke.getAppKey());
RequestContext.setToken(toke.getToke()); // RequestContext.setToken(toke.getToke());
} catch (InnerInvokException e) { // } catch (InnerInvokException e) {
e.printStackTrace(); // e.printStackTrace();
} // }
// return toke;
Toke toke=new Toke();
toke.setProduct(product);
toke.setAppKey(appKey);
toke.setToke(amosRequestContext.getToken());
redisTemplate.opsForValue().set(buildKey(userName), JSONObject.toJSONString(toke), 28, TimeUnit.DAYS);
return toke; return toke;
} }
private Toke getLogin(IdPasswordAuthModel dPasswordAuthModel) { private Toke getLogin(IdPasswordAuthModel dPasswordAuthModel) {
Toke toke = new Toke(); Toke toke = new Toke();
RequestContext.setProduct(productWeb); RequestContext.setProduct(product);
FeignClientResult feignClientResult = Privilege.authClient.idpassword(dPasswordAuthModel); FeignClientResult feignClientResult = Privilege.authClient.idpassword(dPasswordAuthModel);
Map map = (Map) feignClientResult.getResult(); Map map = (Map) feignClientResult.getResult();
if (map != null) { if (map != null) {
toke.setToke(map.get("token").toString()); toke.setToke(map.get("token").toString());
toke.setProduct(productWeb); toke.setProduct(product);
toke.setAppKey(appKey); toke.setAppKey(appKey);
redisTemplate.opsForValue().set(buildKey(dPasswordAuthModel.getLoginId()), JSONObject.toJSONString(toke), 28, TimeUnit.DAYS); redisTemplate.opsForValue().set(buildKey(dPasswordAuthModel.getLoginId()), JSONObject.toJSONString(toke), 28, TimeUnit.DAYS);
} }
...@@ -631,7 +661,7 @@ public class RemoteSecurityService { ...@@ -631,7 +661,7 @@ public class RemoteSecurityService {
public AgencyUserModel getAgencyUserModel(String token) { public AgencyUserModel getAgencyUserModel(String token) {
RequestContext.setToken(token); RequestContext.setToken(token);
RequestContext.setAppKey(appKey); RequestContext.setAppKey(appKey);
RequestContext.setProduct(productWeb); RequestContext.setProduct(product);
try { try {
AgencyUserModel result = Privilege.agencyUserClient.getme().getResult(); AgencyUserModel result = Privilege.agencyUserClient.getme().getResult();
return result; return result;
......
...@@ -87,7 +87,7 @@ public class UserController extends AbstractBaseController { ...@@ -87,7 +87,7 @@ public class UserController extends AbstractBaseController {
private String SecurityName; private String SecurityName;
@Value("${security.productApp}") @Value("${security.productApp}")
private String productApp; private String productApp;
@Value("${security.appKey}") @Value("${amos.system.user.app-key}")
private String appKey; private String appKey;
@Autowired @Autowired
private RestTemplate restTemplate; private RestTemplate restTemplate;
......
...@@ -11,6 +11,7 @@ import java.util.Set; ...@@ -11,6 +11,7 @@ import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.yeejoin.amos.component.authtoken.robot.AmosRequestContext;
import com.yeejoin.amos.feign.systemctl.model.MessageModel; import com.yeejoin.amos.feign.systemctl.model.MessageModel;
import com.yeejoin.amos.supervision.business.feign.JCSFeignClient; import com.yeejoin.amos.supervision.business.feign.JCSFeignClient;
import com.yeejoin.amos.supervision.common.remote.IAMOSSecurityServer; import com.yeejoin.amos.supervision.common.remote.IAMOSSecurityServer;
...@@ -48,17 +49,33 @@ import org.typroject.tyboot.core.foundation.context.RequestContextModel; ...@@ -48,17 +49,33 @@ import org.typroject.tyboot.core.foundation.context.RequestContextModel;
@Service("remoteSecurityService") @Service("remoteSecurityService")
public class RemoteSecurityService { public class RemoteSecurityService {
@Value("${security.password}") // @Value("${security.password}")
private String password; // private String password;
@Value("${security.loginId}") // @Value("${security.loginId}")
private String loginId; // private String loginId;
@Value("${security.productWeb}") // @Value("${security.productWeb}")
private String productWeb; // private String productWeb;
@Value("${security.appKey}") // @Value("${security.appKey}")
private String appKey; // private String appKey;
// @Value("${security.productApp}")
// private String productApp;
@Value("${security.productApp}") @Value("${security.productApp}")
private String productApp; private String productApp;
@Value("${amos.system.user.user-name}")
private String userName;
@Value("${amos.system.user.app-key}")
private String appKey;
@Value("${amos.system.user.product}")
private String product;
private static final Logger log = LoggerFactory.getLogger(RemoteSecurityService.class); private static final Logger log = LoggerFactory.getLogger(RemoteSecurityService.class);
@Autowired @Autowired
...@@ -70,6 +87,9 @@ public class RemoteSecurityService { ...@@ -70,6 +87,9 @@ public class RemoteSecurityService {
@Autowired @Autowired
private JCSFeignClient jcsFeignClient; private JCSFeignClient jcsFeignClient;
@Autowired
AmosRequestContext amosRequestContext ;
//根据公司名称获取公司人 //根据公司名称获取公司人
public List<CompanyModel> listCompanyTree(String toke, String product, String appKey, String companyName) { public List<CompanyModel> listCompanyTree(String toke, String product, String appKey, String companyName) {
RequestContext.setToken(toke); RequestContext.setToken(toke);
...@@ -107,34 +127,39 @@ public class RemoteSecurityService { ...@@ -107,34 +127,39 @@ public class RemoteSecurityService {
} }
public Toke getServerToken() { public Toke getServerToken() {
IdPasswordAuthModel dPasswordAuthModel = new IdPasswordAuthModel(); // IdPasswordAuthModel dPasswordAuthModel = new IdPasswordAuthModel();
dPasswordAuthModel.setLoginId(loginId); // dPasswordAuthModel.setLoginId(loginId);
dPasswordAuthModel.setPassword(DesUtil.encode(password, "qaz")); // dPasswordAuthModel.setPassword(DesUtil.encode(password, "qaz"));
Toke toke = null; // Toke toke = null;
try { // try {
toke = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(loginId)), Toke.class); // toke = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(loginId)), Toke.class);
if (ObjectUtils.isEmpty(toke)) { // if (ObjectUtils.isEmpty(toke)) {
toke = getLogin(dPasswordAuthModel); // toke = getLogin(dPasswordAuthModel);
} else { // } else {
RequestContext.setProduct(productWeb); // RequestContext.setProduct(productWeb);
if (!TokenOperation.refresh(toke.getToke())) { // if (!TokenOperation.refresh(toke.getToke())) {
toke = getLogin(dPasswordAuthModel); // toke = getLogin(dPasswordAuthModel);
} // }
} // }
} catch (InnerInvokException e) { // } catch (InnerInvokException e) {
e.printStackTrace(); // e.printStackTrace();
} // }
Toke toke=new Toke();
toke.setProduct(product);
toke.setAppKey(appKey);
toke.setToke(amosRequestContext.getToken());
redisTemplate.opsForValue().set(buildKey(userName), JSONObject.toJSONString(toke), 28, TimeUnit.DAYS);
return toke; return toke;
} }
private Toke getLogin(IdPasswordAuthModel dPasswordAuthModel) { private Toke getLogin(IdPasswordAuthModel dPasswordAuthModel) {
Toke toke = new Toke(); Toke toke = new Toke();
RequestContext.setProduct(productWeb); RequestContext.setProduct(product);
FeignClientResult feignClientResult = Privilege.authClient.idpassword(dPasswordAuthModel); FeignClientResult feignClientResult = Privilege.authClient.idpassword(dPasswordAuthModel);
Map map = (Map) feignClientResult.getResult(); Map map = (Map) feignClientResult.getResult();
if (map != null) { if (map != null) {
toke.setToke(map.get("token").toString()); toke.setToke(map.get("token").toString());
toke.setProduct(productWeb); toke.setProduct(product);
toke.setAppKey(appKey); toke.setAppKey(appKey);
redisTemplate.opsForValue().set(buildKey(dPasswordAuthModel.getLoginId()), JSONObject.toJSONString(toke), 28, TimeUnit.DAYS); redisTemplate.opsForValue().set(buildKey(dPasswordAuthModel.getLoginId()), JSONObject.toJSONString(toke), 28, TimeUnit.DAYS);
} }
...@@ -642,7 +667,7 @@ public class RemoteSecurityService { ...@@ -642,7 +667,7 @@ public class RemoteSecurityService {
public AgencyUserModel getAgencyUserModel(String token) { public AgencyUserModel getAgencyUserModel(String token) {
RequestContext.setToken(token); RequestContext.setToken(token);
RequestContext.setAppKey(appKey); RequestContext.setAppKey(appKey);
RequestContext.setProduct(productWeb); RequestContext.setProduct(product);
try { try {
AgencyUserModel result = Privilege.agencyUserClient.getme().getResult(); AgencyUserModel result = Privilege.agencyUserClient.getme().getResult();
return result; return result;
......
...@@ -33,6 +33,14 @@ ...@@ -33,6 +33,14 @@
<groupId>org.apache.logging.log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId> <artifactId>log4j-api</artifactId>
</dependency> </dependency>
<!--平台用户登录-->
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-component-authtoken</artifactId>
<version>1.7.13-SNAPSHOT</version>
</dependency>
</dependencies> </dependencies>
<modules> <modules>
......
...@@ -90,7 +90,13 @@ dcs.x.hw.appKey=s+YkvQhwilx91TRJHhNDmw== ...@@ -90,7 +90,13 @@ dcs.x.hw.appKey=s+YkvQhwilx91TRJHhNDmw==
equip.enabled =true equip.enabled =true
management.endpoints.enabled-by-default=false #management.endpoints.enabled-by-default=false
## 增加接口文档验证
knife4j.enable=true
knife4j.basic.enable=true
knife4j.basic.username= admin
knife4j.basic.password= yeejoin@2020
# 权限标识-物联区域 # 权限标识-物联区域
auth-key-area=area_info auth-key-area=area_info
......
...@@ -9,12 +9,37 @@ spring.datasource.testWhileIdle = true ...@@ -9,12 +9,37 @@ spring.datasource.testWhileIdle = true
spring.datasource.validationQuery = SELECT 1 spring.datasource.validationQuery = SELECT 1
#系统服务账号,用户后端服务调用 #系统服务账号,用户后端服务调用
security.password=a1234560 #security.password=a1234560
security.loginId=fas_autosys #security.loginId=fas_autosys
#
##应用product appkey
#security.productWeb=STUDIO_APP_WEB
#security.appKey =studio_normalapp_2681691
#security.password=a1234560
#security.loginId=fas_autosys
##应用product appkey
#security.productWeb=STUDIO_APP_WEB
#security.appKey =studio_normalapp_2681691
amos.system.user.user-name=fas_autosys
amos.system.user.password=a1234560
amos.system.user.app-key=studio_normalapp_2681691
amos.system.user.product=AMOS_STUDIO_WEB
#应用product appkey
security.productWeb=STUDIO_APP_WEB
security.appKey =studio_normalapp_2681691
eureka.client.serviceUrl.defaultZone=http://172.16.10.72:10001/eureka/ eureka.client.serviceUrl.defaultZone=http://172.16.10.72:10001/eureka/
eureka.client.registry-fetch-interval-seconds=5 eureka.client.registry-fetch-interval-seconds=5
......
...@@ -123,7 +123,16 @@ mybatis.interceptor.enabled = false ...@@ -123,7 +123,16 @@ mybatis.interceptor.enabled = false
## 消防救援保障部ID ## 消防救援保障部ID
fire-rescue=1432549862557130753 fire-rescue=1432549862557130753
management.endpoints.enabled-by-default=false #management.endpoints.enabled-by-default=false
## 增加接口文档验证
knife4j.enable=true
knife4j.basic.enable=true
knife4j.basic.username= admin
knife4j.basic.password= yeejoin@2020
#阿里云实时语音识别参数 #阿里云实时语音识别参数
speech-config.access-key-id=LTAI5t62oH95jgbjRiNXPsho speech-config.access-key-id=LTAI5t62oH95jgbjRiNXPsho
speech-config.access-key-secret=shy9SpogYgcdDoyTB3bvP21VSRmz8n speech-config.access-key-secret=shy9SpogYgcdDoyTB3bvP21VSRmz8n
......
...@@ -22,4 +22,9 @@ mybatis-plus.mapper-locations=classpath:mapper/* ...@@ -22,4 +22,9 @@ mybatis-plus.mapper-locations=classpath:mapper/*
## redis失效时间 ## redis失效时间
redis.cache.failure.time=10800 redis.cache.failure.time=10800
management.endpoints.enabled-by-default=false #management.endpoints.enabled-by-default=false
## 增加接口文档验证
knife4j.enable=true
knife4j.basic.enable=true
knife4j.basic.username= admin
knife4j.basic.password= yeejoin@2020
\ No newline at end of file
...@@ -4,6 +4,7 @@ import org.mybatis.spring.annotation.MapperScan; ...@@ -4,6 +4,7 @@ import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.elasticsearch.ElasticSearchRestHealthContributorAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.boot.web.servlet.ServletComponentScan;
...@@ -36,7 +37,8 @@ import java.net.UnknownHostException; ...@@ -36,7 +37,8 @@ import java.net.UnknownHostException;
* @author amos * @author amos
* @version $Id: LatentDangerApplication.java, v 0.1 2018年11月26日 下午4:56:29 amos Exp $ * @version $Id: LatentDangerApplication.java, v 0.1 2018年11月26日 下午4:56:29 amos Exp $
*/ */
@SpringBootApplication @SpringBootApplication(exclude = { ElasticSearchRestHealthContributorAutoConfiguration.class,//es健康检测
})
@EnableTransactionManagement @EnableTransactionManagement
@EnableConfigurationProperties @EnableConfigurationProperties
@ServletComponentScan @ServletComponentScan
......
...@@ -27,11 +27,19 @@ spring.datasource.hikari.maximum-pool-size = 10 ...@@ -27,11 +27,19 @@ spring.datasource.hikari.maximum-pool-size = 10
spring.datasource.testWhileIdle = true spring.datasource.testWhileIdle = true
spring.datasource.validationQuery = SELECT 1 spring.datasource.validationQuery = SELECT 1
security.password=a1234560 #security.password=a1234560
security.loginId=jc_wjk006 #security.loginId=jc_wjk006
security.productWeb=STUDIO_APP_WEB #security.productWeb=STUDIO_APP_WEB
#security.productApp=STUDIO_APP_MOBILE
#security.appKey=studio_normalapp_3168830
security.productApp=STUDIO_APP_MOBILE security.productApp=STUDIO_APP_MOBILE
security.appKey=studio_normalapp_3168830 amos.system.user.user-name=jc_wjk006
amos.system.user.password=a1234560
amos.system.user.app-key=studio_normalapp_3168830
amos.system.user.product=STUDIO_APP_WEB
#redis 配置 #redis 配置
spring.redis.database=1 spring.redis.database=1
......
...@@ -64,4 +64,9 @@ latentDanger.feign.name=AMOS-LATENT-DANGER ...@@ -64,4 +64,9 @@ latentDanger.feign.name=AMOS-LATENT-DANGER
Knowledgebase.fegin.name=AMOS-API-KNOWLEDGEBASE Knowledgebase.fegin.name=AMOS-API-KNOWLEDGEBASE
## 消防救援保障部ID ## 消防救援保障部ID
fire-rescue=1432549862557130753 fire-rescue=1432549862557130753
management.endpoints.enabled-by-default=false #management.endpoints.enabled-by-default=false
## 增加接口文档验证
knife4j.enable=true
knife4j.basic.enable=true
knife4j.basic.username= admin
knife4j.basic.password= yeejoin@2020
\ No newline at end of file
...@@ -9,11 +9,22 @@ eureka.client.serviceUrl.defaultZone=http://172.16.10.211:10001/eureka/ ...@@ -9,11 +9,22 @@ eureka.client.serviceUrl.defaultZone=http://172.16.10.211:10001/eureka/
jcs.fegin.name=JCS jcs.fegin.name=JCS
security.password=a1234560 #security.password=a1234560
security.loginId=jc_wjk006 #security.loginId=jc_wjk006
security.productWeb=STUDIO_APP_WEB #security.productWeb=STUDIO_APP_WEB
#security.productApp=STUDIO_APP_MOBILE
#security.appKey=studio_normalapp_3168830
security.productApp=STUDIO_APP_MOBILE security.productApp=STUDIO_APP_MOBILE
security.appKey=studio_normalapp_3168830 amos.system.user.user-name=jc_wjk006
amos.system.user.password=a1234560
amos.system.user.app-key=studio_normalapp_3168830
amos.system.user.product=STUDIO_APP_WEB
#redis 配置 #redis 配置
spring.redis.database=1 spring.redis.database=1
spring.redis.host=172.16.10.211 spring.redis.host=172.16.10.211
......
...@@ -67,4 +67,10 @@ eureka.instance.metadata-map.management.context-path=${server.servlet.context-pa ...@@ -67,4 +67,10 @@ eureka.instance.metadata-map.management.context-path=${server.servlet.context-pa
eureka.instance.status-page-url-path=/actuator/info eureka.instance.status-page-url-path=/actuator/info
eureka.instance.metadata-map.management.api-docs=http://localhost:${server.port}${server.servlet.context-path}/swagger-ui.html eureka.instance.metadata-map.management.api-docs=http://localhost:${server.port}${server.servlet.context-path}/swagger-ui.html
management.endpoints.enabled-by-default=false #management.endpoints.enabled-by-default=false
\ No newline at end of file
## 增加接口文档验证
knife4j.enable=true
knife4j.basic.enable=true
knife4j.basic.username= admin
knife4j.basic.password= yeejoin@2020
\ No newline at end of file
...@@ -27,11 +27,20 @@ spring.datasource.hikari.maximum-pool-size = 10 ...@@ -27,11 +27,20 @@ spring.datasource.hikari.maximum-pool-size = 10
spring.datasource.testWhileIdle = true spring.datasource.testWhileIdle = true
spring.datasource.validationQuery = SELECT 1 spring.datasource.validationQuery = SELECT 1
security.password=a1234560 #security.password=a1234560
security.loginId=jc_wjk006 #security.loginId=jc_wjk006
security.productWeb=STUDIO_APP_WEB #security.productWeb=STUDIO_APP_WEB
#security.productApp=STUDIO_APP_MOBILE
#security.appKey=studio_normalapp_3168830
security.productApp=STUDIO_APP_MOBILE security.productApp=STUDIO_APP_MOBILE
security.appKey=studio_normalapp_3168830 amos.system.user.user-name=jc_wjk006
amos.system.user.password=a1234560
amos.system.user.app-key=studio_normalapp_3168830
amos.system.user.product=STUDIO_APP_WEB
#redis 配置 #redis 配置
spring.redis.database=1 spring.redis.database=1
......
...@@ -58,6 +58,13 @@ rule.definition.default-agency=STATE_GRID ...@@ -58,6 +58,13 @@ rule.definition.default-agency=STATE_GRID
jcs.fegin.name=JCS jcs.fegin.name=JCS
emergency.command.section.id=1418223840361709569 emergency.command.section.id=1418223840361709569
management.endpoints.enabled-by-default=false #management.endpoints.enabled-by-default=false
## 增加接口文档验证
knife4j.enable=true
knife4j.basic.enable=true
knife4j.basic.username= admin
knife4j.basic.password= yeejoin@2020
equipment.hierarchy=1,2,4,6 equipment.hierarchy=1,2,4,6
\ No newline at end of file
...@@ -5,11 +5,19 @@ spring.datasource.password= Yeejoin@2020 ...@@ -5,11 +5,19 @@ spring.datasource.password= Yeejoin@2020
## eureka properties: ## eureka properties:
eureka.client.serviceUrl.defaultZone=http://172.16.10.211:10001/eureka/ eureka.client.serviceUrl.defaultZone=http://172.16.10.211:10001/eureka/
security.password=a1234560 #security.password=a1234560
security.loginId=jc_wjk006 #security.loginId=jc_wjk006
security.productWeb=STUDIO_APP_WEB #security.productWeb=STUDIO_APP_WEB
#security.productApp=STUDIO_APP_MOBILE
#security.appKey=studio_normalapp_3168830
security.productApp=STUDIO_APP_MOBILE security.productApp=STUDIO_APP_MOBILE
security.appKey=studio_normalapp_3168830 amos.system.user.user-name=jc_wjk006
amos.system.user.password=a1234560
amos.system.user.app-key=studio_normalapp_3056965
amos.system.user.product=STUDIO_APP_WEB
#redis 配置 #redis 配置
......
...@@ -73,4 +73,10 @@ eureka.instance.metadata-map.management.context-path=${server.servlet.context-pa ...@@ -73,4 +73,10 @@ eureka.instance.metadata-map.management.context-path=${server.servlet.context-pa
eureka.instance.status-page-url-path=/actuator/info eureka.instance.status-page-url-path=/actuator/info
eureka.instance.metadata-map.management.api-docs=http://localhost:${server.port}${server.servlet.context-path}/swagger-ui.html eureka.instance.metadata-map.management.api-docs=http://localhost:${server.port}${server.servlet.context-path}/swagger-ui.html
management.endpoints.enabled-by-default=false #management.endpoints.enabled-by-default=false
\ No newline at end of file
## 增加接口文档验证
knife4j.enable=true
knife4j.basic.enable=true
knife4j.basic.username= admin
knife4j.basic.password= yeejoin@2020
\ No newline at end of file
...@@ -5,3 +5,10 @@ spring.profiles.active=dev ...@@ -5,3 +5,10 @@ spring.profiles.active=dev
spring.jackson.time-zone=GMT+8 spring.jackson.time-zone=GMT+8
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.serialization.write-dates-as-timestamps=true spring.jackson.serialization.write-dates-as-timestamps=true
## ӽӿĵ֤
knife4j.enable=true
knife4j.basic.enable=true
knife4j.basic.username= admin
knife4j.basic.password= yeejoin@2020
\ No newline at end of file
...@@ -35,3 +35,11 @@ spring.redis.lettuce.pool.max-wait=-1 ...@@ -35,3 +35,11 @@ spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10 spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0 spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300 spring.redis.expire.time=300
## 增加接口文档验证
knife4j.enable=true
knife4j.basic.enable=true
knife4j.basic.username= admin
knife4j.basic.password= yeejoin@2020
\ No newline at end of file
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