|
@@ -372,8 +372,14 @@ public class RestClientService {
|
|
|
String ssoToken = getSSOToken();
|
|
|
String url = configService.getConfigValue(ConfigInfo.SSO_CREATECLIENT);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
- jsonObject.put("appName",System.getenv("appName"));
|
|
|
+ //if (ObjectUtil.isNotNull(System.getenv("appName"))){
|
|
|
+ // jsonObject.put("appName",System.getenv("appName"));
|
|
|
+ //}else {
|
|
|
+ // jsonObject.put("appName","InterlockServer");
|
|
|
+ //}
|
|
|
+ jsonObject.put("appName","InterlockServer");
|
|
|
jsonObject.put("appId",System.getenv("appId"));
|
|
|
+ jsonObject.put("serviceName","InterlockServer");
|
|
|
jsonObject.put("cluster",System.getenv("cluster"));
|
|
|
jsonObject.put("workspace",System.getenv("workspace"));
|
|
|
jsonObject.put("namespace",System.getenv("namespace"));
|
|
@@ -462,6 +468,51 @@ public class RestClientService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public JSONObject addSSOUserTest(String userName,String password){
|
|
|
+ ArrayList<String> scopList = new ArrayList<>();
|
|
|
+ scopList.add("Admin");
|
|
|
+
|
|
|
+ String clientToken = configService.getConfigValue(ConfigInfo.POST_CLIENT_TOKEN);
|
|
|
+ String clientId = configService.getConfigValue(ConfigInfo.CLIENT_ID);
|
|
|
+ String clientSecret = configService.getConfigValue(ConfigInfo.CLIENT_SECRET);
|
|
|
+
|
|
|
+ if (ObjectUtil.isNull(clientToken) || "".equals(clientToken) || ObjectUtil.isNull(clientId) || "".equals(clientId) || ObjectUtil.isNull(clientSecret) || "".equals(clientSecret)){
|
|
|
+ getClientToken2();
|
|
|
+ clientToken = configService.getConfigValue(ConfigInfo.POST_CLIENT_TOKEN);
|
|
|
+ clientId = configService.getConfigValue(ConfigInfo.CLIENT_ID);
|
|
|
+ clientSecret = configService.getConfigValue(ConfigInfo.CLIENT_SECRET);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ String url = configService.getConfigValue(ConfigInfo.SSO_ADDUSER)+"/"+userName+"/scopes";
|
|
|
+
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("clientId",clientId);
|
|
|
+ jsonObject.put("clientSecret",clientSecret);
|
|
|
+ jsonObject.put("action","append");
|
|
|
+ jsonObject.put("scopes",scopList);
|
|
|
+ if (ObjectUtil.isNotNull(password) || !"".equals(password)) {
|
|
|
+ jsonObject.put("password",password);
|
|
|
+ }
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
|
|
|
+ headers.setContentType(type);
|
|
|
+ headers.add("Authorization", "Bearer " + clientToken);
|
|
|
+ HttpEntity<String> httpEntity = new HttpEntity<String>(jsonObject.toString(), headers);
|
|
|
+
|
|
|
+ HttpClient httpClient = HttpClients.custom().build();
|
|
|
+ HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(httpClient);
|
|
|
+
|
|
|
+ //RestTemplate restTemplate1 = new RestTemplate(factory);
|
|
|
+ //restTemplate1.setErrorHandler(new MyResponseErrorHandler());
|
|
|
+ ResponseEntity<JSONObject> response = restTemplate.exchange(url,HttpMethod.PATCH,httpEntity, JSONObject.class);
|
|
|
+ return response.getBody();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* author: dzc
|
|
|
* version: 1.0
|