work on security uberfire security extension with mongodb
Refactor for Sonarlint
This commit is contained in:
parent
f3beaaabab
commit
7feaeee7d8
9 changed files with 110 additions and 119 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
package org.chtijbug.drools.console.service;
|
package org.chtijbug.drools.console.service;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.context.annotation.DependsOn;
|
import org.springframework.context.annotation.DependsOn;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
@ -13,16 +15,21 @@ import java.io.InputStreamReader;
|
||||||
@DependsOn("applicationContext")
|
@DependsOn("applicationContext")
|
||||||
public class GitRepositoryService {
|
public class GitRepositoryService {
|
||||||
|
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(GitRepositoryService.class);
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
GitRepositoryService service = new GitRepositoryService();
|
GitRepositoryService service = new GitRepositoryService();
|
||||||
service.executeCommand("cd /Users/nheron/kie-base-jbpm-6/niodir/.niogit/nico1.git && ./hooks/post-commit ");
|
service.executeCommand("cd /Users/nheron/kie-base-jbpm-6/niodir/.niogit/nico1.git && ./hooks/post-commit ");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addHookToRepo(String projectName, String gitBaseUrl) throws IOException {
|
public void addHookToRepo(String projectName, String gitRepoBase,String gitBaseUrl) throws IOException {
|
||||||
String fileBase = System.getProperty("org.uberfire.nio.git.dir");
|
String fileBase = System.getProperty("org.uberfire.nio.git.dir");
|
||||||
if (fileBase != null) {
|
if (fileBase != null) {
|
||||||
String gitdirectory = fileBase + "/.niogit/" + projectName + ".git";
|
if (gitRepoBase==null || gitBaseUrl.length()==0){
|
||||||
String gitFileName = fileBase + "/.niogit/" + projectName + ".git/hooks/post-commit";
|
gitRepoBase=".niogit";
|
||||||
|
}
|
||||||
|
String gitdirectory = fileBase + "/"+gitRepoBase+"/" + projectName + ".git";
|
||||||
|
String gitFileName = fileBase + "/"+gitRepoBase+"/" + projectName + ".git/hooks/post-commit";
|
||||||
/**
|
/**
|
||||||
* #!/bin/sh
|
* #!/bin/sh
|
||||||
* REPO=git@gitlab.pymma-software.com:nheron/jbpm-edop-base-example.git
|
* REPO=git@gitlab.pymma-software.com:nheron/jbpm-edop-base-example.git
|
||||||
|
|
@ -40,37 +47,40 @@ public class GitRepositoryService {
|
||||||
stringBuilder.append("cd $currentDir ").append("\n");
|
stringBuilder.append("cd $currentDir ").append("\n");
|
||||||
File file = new File(gitFileName);
|
File file = new File(gitFileName);
|
||||||
FileUtils.writeStringToFile(file, stringBuilder.toString());
|
FileUtils.writeStringToFile(file, stringBuilder.toString());
|
||||||
file.setExecutable(true, true);
|
boolean executable = file.setExecutable(true, true);
|
||||||
|
logger.info("executable {}",executable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void executeHookPush(String projectName, String gitBaseUrl) {
|
public void executeHookPush(String projectName, String gitRepoBase,String gitBaseUrl) {
|
||||||
String fileBase = System.getProperty("org.uberfire.nio.git.dir");
|
String fileBase = System.getProperty("org.uberfire.nio.git.dir");
|
||||||
if (fileBase != null) {
|
if (fileBase != null) {
|
||||||
|
if (gitRepoBase==null || gitBaseUrl.length()==0){
|
||||||
String gitFileName = fileBase + "/.niogit/" + projectName + ".git/hooks/post-commit";
|
gitRepoBase=".niogit";
|
||||||
|
}
|
||||||
|
String gitFileName = fileBase + "/"+gitRepoBase+"/" + projectName + ".git/hooks/post-commit";
|
||||||
this.executeCommand(gitFileName);
|
this.executeCommand(gitFileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String executeCommand(String command) {
|
private String executeCommand(String command) {
|
||||||
|
|
||||||
StringBuffer output = new StringBuffer();
|
StringBuilder output = new StringBuilder();
|
||||||
|
|
||||||
Process process;
|
Process process;
|
||||||
try {
|
try {
|
||||||
System.out.println(command);
|
logger.info(command);
|
||||||
System.out.println("============Command start======================");
|
logger.info("============Command start======================");
|
||||||
process = Runtime.getRuntime().exec(command);
|
process = Runtime.getRuntime().exec(command);
|
||||||
process.waitFor();
|
process.waitFor();
|
||||||
System.out.println("=============Command Stop=====================");
|
logger.info("=============Command Stop=====================");
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||||
String line = "";
|
String line = "";
|
||||||
try {
|
try {
|
||||||
while ((line = reader.readLine()) != null)
|
while ((line = reader.readLine()) != null)
|
||||||
System.out.println(line);
|
logger.info(line);
|
||||||
} finally {
|
} finally {
|
||||||
reader.close();
|
reader.close();
|
||||||
}
|
}
|
||||||
|
|
@ -86,7 +96,7 @@ public class GitRepositoryService {
|
||||||
String line = "";
|
String line = "";
|
||||||
try {
|
try {
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
System.out.println(line);
|
logger.info(line);
|
||||||
// Traitement du flux d'erreur de l'application si besoin est
|
// Traitement du flux d'erreur de l'application si besoin est
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
||||||
|
|
@ -11,19 +11,22 @@ import org.chtijbug.drools.proxy.persistence.repository.UserRepository;
|
||||||
import org.chtijbug.guvnor.server.jaxrs.api.UserLoginInformation;
|
import org.chtijbug.guvnor.server.jaxrs.api.UserLoginInformation;
|
||||||
import org.chtijbug.guvnor.server.jaxrs.jaxb.Asset;
|
import org.chtijbug.guvnor.server.jaxrs.jaxb.Asset;
|
||||||
import org.chtijbug.guvnor.server.jaxrs.model.PlatformProjectResponse;
|
import org.chtijbug.guvnor.server.jaxrs.model.PlatformProjectResponse;
|
||||||
import org.drools.workbench.models.guided.template.backend.RuleTemplateModelXMLPersistenceImpl;
|
|
||||||
import org.drools.workbench.models.guided.template.shared.TemplateModel;
|
|
||||||
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;
|
||||||
import org.springframework.context.annotation.DependsOn;
|
import org.springframework.context.annotation.DependsOn;
|
||||||
import org.springframework.http.*;
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.client.RequestCallback;
|
import org.springframework.web.client.RequestCallback;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.*;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@DependsOn("applicationContext")
|
@DependsOn("applicationContext")
|
||||||
|
|
@ -32,6 +35,8 @@ public class KieRepositoryService {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(KieRepositoryService.class);
|
private static Logger logger = LoggerFactory.getLogger(KieRepositoryService.class);
|
||||||
|
|
||||||
|
private static String chtijbugprefix="/chtijbug/";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserRepository userRepository;
|
private UserRepository userRepository;
|
||||||
|
|
||||||
|
|
@ -39,39 +44,13 @@ public class KieRepositoryService {
|
||||||
|
|
||||||
private ObjectMapper mapper = new ObjectMapper();
|
private ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
private String pojoToStringMethod(String assetContent, List<HashMap<String, Object>> objects) {
|
|
||||||
|
|
||||||
TemplateModel model = RuleTemplateModelXMLPersistenceImpl.getInstance().unmarshal(assetContent);
|
|
||||||
int i = 0;
|
|
||||||
model.clearRows();
|
|
||||||
for (HashMap<String, Object> t : objects) {
|
|
||||||
|
|
||||||
List<String> row = new ArrayList<>();
|
|
||||||
for (Map.Entry<String, Object> entry : t.entrySet()) {
|
|
||||||
row.add(String.valueOf(entry.getValue()));
|
|
||||||
}
|
|
||||||
model.addRow(i, row.toArray(new String[row.size()]));
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return RuleTemplateModelXMLPersistenceImpl.getInstance().marshal(model);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateAssetSource(String url, String username, String password, String spaceName, String projectName, String assetName, String assetSource) {
|
public void updateAssetSource(String url, String username, String password, String spaceName, String projectName, String assetName, String assetSource) {
|
||||||
|
|
||||||
String assetContent = getAssetSource(url,
|
String completeurl = url + chtijbugprefix + spaceName + "/" + projectName + "/asset/" + assetName + "/source";
|
||||||
username,
|
logger.info("url updateAssetSource : {}", completeurl);
|
||||||
password,
|
|
||||||
spaceName,
|
|
||||||
projectName,
|
|
||||||
assetName);
|
|
||||||
|
|
||||||
|
restTemplateKiewb
|
||||||
String completeurl = url + "/chtijbug/" + spaceName + "/" + projectName + "/asset/" + assetName + "/source";
|
|
||||||
logger.info("url moteur reco : " + completeurl);
|
|
||||||
|
|
||||||
ResponseEntity response = restTemplateKiewb
|
|
||||||
.execute(completeurl, HttpMethod.POST, requestCallback(assetSource, username, password), clientHttpResponse -> {
|
.execute(completeurl, HttpMethod.POST, requestCallback(assetSource, username, password), clientHttpResponse -> {
|
||||||
String extractedResponse = null;
|
String extractedResponse = null;
|
||||||
if (clientHttpResponse.getBody() != null) {
|
if (clientHttpResponse.getBody() != null) {
|
||||||
|
|
@ -79,27 +58,21 @@ public class KieRepositoryService {
|
||||||
String result = s.hasNext() ? s.next() : "";
|
String result = s.hasNext() ? s.next() : "";
|
||||||
extractedResponse = result;
|
extractedResponse = result;
|
||||||
}
|
}
|
||||||
ResponseEntity extractedValue = new ResponseEntity<>(extractedResponse, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
return new ResponseEntity<>(extractedResponse, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
||||||
return extractedValue;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// restTemplateKiewb.exchange(completeurl, HttpMethod.POST, requestCallBack(content, username, password), void.class);
|
|
||||||
System.out.println("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAssetSource(String url, String username, String password, String spaceName, String projectName, String assetName) {
|
public String getAssetSource(String url, String username, String password, String spaceName, String projectName, String assetName) {
|
||||||
String completeurl = url + "/chtijbug/" + spaceName + "/" + projectName + "/assets/" + assetName + "/source";
|
String completeurl = url + chtijbugprefix + spaceName + "/" + projectName + "/assets/" + assetName + "/source";
|
||||||
logger.info("url moteur reco : " + completeurl);
|
logger.info("url getAssetSource : {}", completeurl);
|
||||||
ResponseEntity<String> response = restTemplateKiewb
|
ResponseEntity<String> response = restTemplateKiewb
|
||||||
.execute(completeurl, HttpMethod.GET, requestCallback(null, username, password), clientHttpResponse -> {
|
.execute(completeurl, HttpMethod.GET, requestCallback(null, username, password), clientHttpResponse -> {
|
||||||
String extractedResponse = null;
|
String result=null;
|
||||||
if (clientHttpResponse.getBody() != null) {
|
if (clientHttpResponse.getBody() != null) {
|
||||||
Scanner s = new Scanner(clientHttpResponse.getBody()).useDelimiter("\\A");
|
Scanner s = new Scanner(clientHttpResponse.getBody()).useDelimiter("\\A");
|
||||||
String result = s.hasNext() ? s.next() : "";
|
result = s.hasNext() ? s.next() : "";
|
||||||
extractedResponse = result;
|
|
||||||
}
|
}
|
||||||
ResponseEntity<String> extractedValue = new ResponseEntity<>(extractedResponse, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
return new ResponseEntity<>(result, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
||||||
return extractedValue;
|
|
||||||
});
|
});
|
||||||
String reponseMoteur;
|
String reponseMoteur;
|
||||||
|
|
||||||
|
|
@ -108,8 +81,8 @@ public class KieRepositoryService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PlatformProjectResponse> getListSpaces2(String url, String username, String password) {
|
public List<PlatformProjectResponse> getListSpaces2(String url, String username, String password) {
|
||||||
String completeurl = url + "/chtijbug/detailedSpaces";
|
String completeurl = url + chtijbugprefix+"detailedSpaces";
|
||||||
logger.info("url moteur reco : " + completeurl);
|
logger.info("url getListSpaces2 :{} ", completeurl);
|
||||||
ResponseEntity<List<PlatformProjectResponse>> response = restTemplateKiewb
|
ResponseEntity<List<PlatformProjectResponse>> response = restTemplateKiewb
|
||||||
.execute(completeurl, HttpMethod.GET, requestCallback(null, username, password), clientHttpResponse -> {
|
.execute(completeurl, HttpMethod.GET, requestCallback(null, username, password), clientHttpResponse -> {
|
||||||
List<PlatformProjectResponse> extractedResponse = null;
|
List<PlatformProjectResponse> extractedResponse = null;
|
||||||
|
|
@ -119,8 +92,7 @@ public class KieRepositoryService {
|
||||||
PlatformProjectResponse[] values = mapper.readValue(result, PlatformProjectResponse[].class);
|
PlatformProjectResponse[] values = mapper.readValue(result, PlatformProjectResponse[].class);
|
||||||
extractedResponse = Arrays.asList(values);
|
extractedResponse = Arrays.asList(values);
|
||||||
}
|
}
|
||||||
ResponseEntity<List<PlatformProjectResponse>> extractedValue = new ResponseEntity<>(extractedResponse, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
return new ResponseEntity<>(extractedResponse, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
||||||
return extractedValue;
|
|
||||||
});
|
});
|
||||||
List<PlatformProjectResponse> reponseMoteur;
|
List<PlatformProjectResponse> reponseMoteur;
|
||||||
|
|
||||||
|
|
@ -131,7 +103,7 @@ public class KieRepositoryService {
|
||||||
public UserConnected login(String url, String username, String password,String workbenchName) {
|
public UserConnected login(String url, String username, String password,String workbenchName) {
|
||||||
|
|
||||||
User user = userRepository.findByLogin(username);
|
User user = userRepository.findByLogin(username);
|
||||||
String completeurl = url + "/chtijbug/login";
|
String completeurl = url + chtijbugprefix+"login";
|
||||||
if (user != null && user.getPassword().equals(password)) {
|
if (user != null && user.getPassword().equals(password)) {
|
||||||
if (user.getCustomer()!= null &&
|
if (user.getCustomer()!= null &&
|
||||||
user.getCustomer().getKieWorkbench()!= null
|
user.getCustomer().getKieWorkbench()!= null
|
||||||
|
|
@ -139,7 +111,7 @@ public class KieRepositoryService {
|
||||||
completeurl = user.getCustomer().getKieWorkbench().getInternalUrl()+"/rest/chtijbug/login";
|
completeurl = user.getCustomer().getKieWorkbench().getInternalUrl()+"/rest/chtijbug/login";
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("url moteur reco : " + completeurl);
|
logger.info("url moteur reco : {}" , completeurl);
|
||||||
ResponseEntity<UserLoginInformation> response = restTemplateKiewb
|
ResponseEntity<UserLoginInformation> response = restTemplateKiewb
|
||||||
.execute(completeurl, HttpMethod.GET, requestCallback(null, username, password), clientHttpResponse -> {
|
.execute(completeurl, HttpMethod.GET, requestCallback(null, username, password), clientHttpResponse -> {
|
||||||
UserLoginInformation extractedResponse = null;
|
UserLoginInformation extractedResponse = null;
|
||||||
|
|
@ -149,8 +121,7 @@ public class KieRepositoryService {
|
||||||
extractedResponse = mapper.readValue(result, UserLoginInformation.class);
|
extractedResponse = mapper.readValue(result, UserLoginInformation.class);
|
||||||
|
|
||||||
}
|
}
|
||||||
ResponseEntity<UserLoginInformation> extractedValue = new ResponseEntity<>(extractedResponse, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
return new ResponseEntity<>(extractedResponse, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
||||||
return extractedValue;
|
|
||||||
});
|
});
|
||||||
UserConnected userConnected = new UserConnected();
|
UserConnected userConnected = new UserConnected();
|
||||||
|
|
||||||
|
|
@ -169,8 +140,8 @@ public class KieRepositoryService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Asset> getListAssets(String url, String username, String password, String spaceName, String projectName) {
|
public List<Asset> getListAssets(String url, String username, String password, String spaceName, String projectName) {
|
||||||
String completeurl = url + "/chtijbug/" + spaceName + "/" + projectName + "/assets";
|
String completeurl = url + chtijbugprefix + spaceName + "/" + projectName + "/assets";
|
||||||
logger.info("url moteur reco : " + completeurl);
|
logger.info("url getListAssets : {}" , completeurl);
|
||||||
ResponseEntity<List<Asset>> response = restTemplateKiewb
|
ResponseEntity<List<Asset>> response = restTemplateKiewb
|
||||||
.execute(completeurl, HttpMethod.GET, requestCallback(null, username, password), clientHttpResponse -> {
|
.execute(completeurl, HttpMethod.GET, requestCallback(null, username, password), clientHttpResponse -> {
|
||||||
List<Asset> extractedResponse = null;
|
List<Asset> extractedResponse = null;
|
||||||
|
|
@ -180,8 +151,7 @@ public class KieRepositoryService {
|
||||||
Asset[] values = mapper.readValue(result, Asset[].class);
|
Asset[] values = mapper.readValue(result, Asset[].class);
|
||||||
extractedResponse = Arrays.asList(values);
|
extractedResponse = Arrays.asList(values);
|
||||||
}
|
}
|
||||||
ResponseEntity<List<Asset>> extractedValue = new ResponseEntity<>(extractedResponse, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
return new ResponseEntity<>(extractedResponse, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
||||||
return extractedValue;
|
|
||||||
});
|
});
|
||||||
List<Asset> reponseMoteur;
|
List<Asset> reponseMoteur;
|
||||||
|
|
||||||
|
|
@ -194,7 +164,7 @@ public class KieRepositoryService {
|
||||||
if (branchName!= null && branchName.length()>0){
|
if (branchName!= null && branchName.length()>0){
|
||||||
completeurl= url + "/spaces/" + space + "/projects/" + project +"/branches/"+branchName+ "/maven/" + command;
|
completeurl= url + "/spaces/" + space + "/projects/" + project +"/branches/"+branchName+ "/maven/" + command;
|
||||||
}
|
}
|
||||||
logger.info("url Maven install : " + completeurl);
|
logger.info("url buildProject Maven install : {}" , completeurl);
|
||||||
ResponseEntity<JobStatus> response = restTemplateKiewb
|
ResponseEntity<JobStatus> response = restTemplateKiewb
|
||||||
.execute(completeurl, HttpMethod.POST, requestCallback(null, username, password), clientHttpResponse -> {
|
.execute(completeurl, HttpMethod.POST, requestCallback(null, username, password), clientHttpResponse -> {
|
||||||
JobStatus extractedResponse = null;
|
JobStatus extractedResponse = null;
|
||||||
|
|
@ -204,8 +174,7 @@ public class KieRepositoryService {
|
||||||
JobStatus values = mapper.readValue(result, JobStatus.class);
|
JobStatus values = mapper.readValue(result, JobStatus.class);
|
||||||
extractedResponse = values;
|
extractedResponse = values;
|
||||||
}
|
}
|
||||||
ResponseEntity<JobStatus> extractedValue = new ResponseEntity<>(extractedResponse, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
return new ResponseEntity<>(extractedResponse, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
||||||
return extractedValue;
|
|
||||||
});
|
});
|
||||||
JobStatus reponseMoteur;
|
JobStatus reponseMoteur;
|
||||||
|
|
||||||
|
|
@ -217,7 +186,7 @@ public class KieRepositoryService {
|
||||||
public JobStatus getStatusJobID(String url, String username, String password, String jobID) {
|
public JobStatus getStatusJobID(String url, String username, String password, String jobID) {
|
||||||
|
|
||||||
String completeurl = url + "/jobs/" + jobID;
|
String completeurl = url + "/jobs/" + jobID;
|
||||||
logger.info("url moteur reco : " + completeurl);
|
logger.info("url getStatusJobID : {}" , completeurl);
|
||||||
ResponseEntity<JobStatus> response = restTemplateKiewb
|
ResponseEntity<JobStatus> response = restTemplateKiewb
|
||||||
.execute(completeurl, HttpMethod.GET, requestCallback(null, username, password), clientHttpResponse -> {
|
.execute(completeurl, HttpMethod.GET, requestCallback(null, username, password), clientHttpResponse -> {
|
||||||
JobStatus extractedResponse = null;
|
JobStatus extractedResponse = null;
|
||||||
|
|
@ -227,8 +196,7 @@ public class KieRepositoryService {
|
||||||
extractedResponse = mapper.readValue(result, JobStatus.class);
|
extractedResponse = mapper.readValue(result, JobStatus.class);
|
||||||
|
|
||||||
}
|
}
|
||||||
ResponseEntity<JobStatus> extractedValue = new ResponseEntity<>(extractedResponse, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
return new ResponseEntity<>(extractedResponse, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
||||||
return extractedValue;
|
|
||||||
});
|
});
|
||||||
JobStatus reponseMoteur;
|
JobStatus reponseMoteur;
|
||||||
|
|
||||||
|
|
@ -236,24 +204,8 @@ public class KieRepositoryService {
|
||||||
return reponseMoteur;
|
return reponseMoteur;
|
||||||
}
|
}
|
||||||
|
|
||||||
private HttpEntity requestCallBack(final Object content, String username, String password) {
|
|
||||||
HttpHeaders httpHeaders = new HttpHeaders();
|
|
||||||
httpHeaders.add(
|
|
||||||
HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
|
|
||||||
httpHeaders.add(
|
|
||||||
HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE);
|
|
||||||
String auth = username + ":" + password;
|
|
||||||
byte[] encodedAuth = Base64.encodeBase64(
|
|
||||||
auth.getBytes(Charset.forName("UTF-8")));
|
|
||||||
String authHeader = "Basic " + new String(encodedAuth);
|
|
||||||
httpHeaders.add(
|
|
||||||
HttpHeaders.AUTHORIZATION, authHeader);
|
|
||||||
HttpEntity httpEntity = new HttpEntity(content, httpHeaders);
|
|
||||||
|
|
||||||
|
|
||||||
return httpEntity;
|
|
||||||
}
|
|
||||||
|
|
||||||
private RequestCallback requestCallback(final Object content, String username, String password) {
|
private RequestCallback requestCallback(final Object content, String username, String password) {
|
||||||
return clientHttpRequest -> {
|
return clientHttpRequest -> {
|
||||||
if (content != null) {
|
if (content != null) {
|
||||||
|
|
@ -271,7 +223,7 @@ public class KieRepositoryService {
|
||||||
HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE);
|
HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE);
|
||||||
String auth = username + ":" + password;
|
String auth = username + ":" + password;
|
||||||
byte[] encodedAuth = Base64.encodeBase64(
|
byte[] encodedAuth = Base64.encodeBase64(
|
||||||
auth.getBytes(Charset.forName("UTF-8")));
|
auth.getBytes(StandardCharsets.UTF_8));
|
||||||
String authHeader = "Basic " + new String(encodedAuth);
|
String authHeader = "Basic " + new String(encodedAuth);
|
||||||
clientHttpRequest.getHeaders().add(
|
clientHttpRequest.getHeaders().add(
|
||||||
HttpHeaders.AUTHORIZATION, authHeader);
|
HttpHeaders.AUTHORIZATION, authHeader);
|
||||||
|
|
|
||||||
|
|
@ -28,28 +28,28 @@ public class RuntimeService {
|
||||||
|
|
||||||
private RestTemplate restTemplateKiewb = new RestTemplate();
|
private RestTemplate restTemplateKiewb = new RestTemplate();
|
||||||
|
|
||||||
public ReturnPerso verifyIfKieServerExist(String url) {
|
public ReturnPerso<KieServerInfo> verifyIfKieServerExist(String url) {
|
||||||
String completeurl = url + "/api/server/details";
|
String completeurl = url + "/api/server/details";
|
||||||
logger.info("url project content : " + completeurl);
|
logger.info("url pverifyIfKieServerExist :{} " , completeurl);
|
||||||
|
|
||||||
HttpHeaders httpHeaders=new HttpHeaders();
|
HttpHeaders httpHeaders=new HttpHeaders();
|
||||||
|
|
||||||
HttpEntity httpEntity=new HttpEntity(httpHeaders);
|
HttpEntity<Object> httpEntity=new HttpEntity<>(httpHeaders);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ResponseEntity<KieServerInfo> response = restTemplateKiewb.exchange(completeurl,
|
ResponseEntity<KieServerInfo> response = restTemplateKiewb.exchange(completeurl,
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
httpEntity,
|
httpEntity,
|
||||||
new ParameterizedTypeReference<KieServerInfo>() {
|
new ParameterizedTypeReference<>() {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.getBody() != null ) {
|
if (response.getBody() != null ) {
|
||||||
return new ReturnPerso(true,"the runtime has been successfully added",response.getBody());
|
return new ReturnPerso<>(true,"the runtime has been successfully added",response.getBody());
|
||||||
} else {
|
} else {
|
||||||
return new ReturnPerso(false,"server error ",null);
|
return new ReturnPerso<>(false,"server error ",null);
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
return new ReturnPerso(false,"The hostname is incorrect",null);
|
return new ReturnPerso<>(false,"The hostname is incorrect",null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,11 @@ import org.springframework.stereotype.Service;
|
||||||
@DependsOn("applicationContext")
|
@DependsOn("applicationContext")
|
||||||
public class UserConnectedService {
|
public class UserConnectedService {
|
||||||
|
|
||||||
public static String USER = "1";
|
public final static String USER = "1";
|
||||||
public static String ASSET = "2";
|
public final static String ASSET = "2";
|
||||||
public static String SPACE = "3";
|
public final static String SPACE = "3";
|
||||||
public static String PROJECT = "4";
|
public final static String PROJECT = "4";
|
||||||
public static String CURRENTPROJECT = "5";
|
public final static String CURRENTPROJECT = "5";
|
||||||
|
|
||||||
|
|
||||||
public UserConnected getUserConnected() {
|
public UserConnected getUserConnected() {
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,18 @@ public class KiePlatformUserManager implements UserManager, ContextualManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public User get(String identifier) throws SecurityManagementException {
|
public User get(String identifier) throws SecurityManagementException {
|
||||||
return new UserImpl(identifier);
|
MongoCollection<Document> userCollection = database.getCollection("user");
|
||||||
|
List<User> users = new ArrayList<>();
|
||||||
|
userCollection.find(eq("login", identifier)).forEach((Block<? super Document>) document -> {
|
||||||
|
String userName = document.getString("login");
|
||||||
|
User user = fillUser(userName, document);
|
||||||
|
users.add(user);
|
||||||
|
});
|
||||||
|
if (users.size()==1){
|
||||||
|
return users.get(0);
|
||||||
|
}else {
|
||||||
|
throw new SecurityManagementException("Unknown identifier "+identifier);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -133,17 +144,15 @@ public class KiePlatformUserManager implements UserManager, ContextualManager {
|
||||||
AtomicReference<ArrayList<DBRef>> groups = new AtomicReference<ArrayList<DBRef>>(new ArrayList());
|
AtomicReference<ArrayList<DBRef>> groups = new AtomicReference<ArrayList<DBRef>>(new ArrayList());
|
||||||
roles.set((ArrayList) document.get("userRoles"));
|
roles.set((ArrayList) document.get("userRoles"));
|
||||||
groups.set((ArrayList) document.get("userGroups"));
|
groups.set((ArrayList) document.get("userGroups"));
|
||||||
MongoCollection<Document> userRolesCollection = database.getCollection("userRoles");
|
|
||||||
List<Role> roleList = new ArrayList<>();
|
List<Role> roleList = new ArrayList<>();
|
||||||
for (DBRef dbRef : roles.get()) {
|
for (DBRef dbRef : roles.get()) {
|
||||||
Document roleDocument = userRolesCollection.find(eq("_id", dbRef.getId())).first();
|
Document roleDocument = Utils.getDocumentFromRef(dbRef,database);
|
||||||
Role role = new RoleImpl(roleDocument.getString("name"));
|
Role role = new RoleImpl(roleDocument.getString("name"));
|
||||||
roleList.add(role);
|
roleList.add(role);
|
||||||
}
|
}
|
||||||
MongoCollection<Document> userGroupsCollection = database.getCollection("userGroups");
|
|
||||||
List<Group> groupList = new ArrayList<>();
|
List<Group> groupList = new ArrayList<>();
|
||||||
for (DBRef dbRef : groups.get()) {
|
for (DBRef dbRef : groups.get()) {
|
||||||
Document groupDocument = userGroupsCollection.find(eq("_id", dbRef.getId())).first();
|
Document groupDocument = Utils.getDocumentFromRef(dbRef,database);
|
||||||
Group group = new GroupImpl(groupDocument.getString("name"));
|
Group group = new GroupImpl(groupDocument.getString("name"));
|
||||||
groupList.add(group);
|
groupList.add(group);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package org.chtijbug.guvnor.uberfire.security;
|
||||||
|
|
||||||
|
import com.mongodb.DBRef;
|
||||||
|
import com.mongodb.client.MongoCollection;
|
||||||
|
|
||||||
|
import com.mongodb.client.MongoDatabase;
|
||||||
|
import org.bson.Document;
|
||||||
|
|
||||||
|
import static com.mongodb.client.model.Filters.eq;
|
||||||
|
|
||||||
|
public class Utils {
|
||||||
|
public static Document getDocumentFromRef(DBRef dbRef, MongoDatabase database){
|
||||||
|
if (dbRef!=null) {
|
||||||
|
MongoCollection<Document> userRolesCollection = database.getCollection(dbRef.getCollectionName());
|
||||||
|
Document document = userRolesCollection.find(eq("_id", dbRef.getId())).first();
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -81,9 +81,9 @@
|
||||||
<orderEntry type="library" name="Maven: org.objenesis:objenesis:3.0.1" level="project" />
|
<orderEntry type="library" name="Maven: org.objenesis:objenesis:3.0.1" level="project" />
|
||||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.10.3" level="project" />
|
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.10.3" level="project" />
|
||||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.10.3" level="project" />
|
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.10.3" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.kie:kie-internal:7.40.0.20200703" level="project" />
|
<orderEntry type="library" name="Maven: org.kie:kie-internal:7.42.0.Final" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.kie:kie-api:7.40.0.20200703" level="project" />
|
<orderEntry type="library" name="Maven: org.kie:kie-api:7.42.0.Final" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.kie.soup:kie-soup-maven-support:7.40.0.20200703" level="project" />
|
<orderEntry type="library" name="Maven: org.kie.soup:kie-soup-maven-support:7.42.0.Final" level="project" />
|
||||||
<orderEntry type="library" name="Maven: com.sun.activation:javax.activation:1.2.0" level="project" />
|
<orderEntry type="library" name="Maven: com.sun.activation:javax.activation:1.2.0" level="project" />
|
||||||
<orderEntry type="library" name="Maven: javax.xml.bind:jaxb-api:2.3.1" level="project" />
|
<orderEntry type="library" name="Maven: javax.xml.bind:jaxb-api:2.3.1" level="project" />
|
||||||
<orderEntry type="library" name="Maven: javax.activation:javax.activation-api:1.2.0" level="project" />
|
<orderEntry type="library" name="Maven: javax.activation:javax.activation-api:1.2.0" level="project" />
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,9 @@
|
||||||
<orderEntry type="library" name="Maven: org.objenesis:objenesis:3.0.1" level="project" />
|
<orderEntry type="library" name="Maven: org.objenesis:objenesis:3.0.1" level="project" />
|
||||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.10.3" level="project" />
|
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.10.3" level="project" />
|
||||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.10.3" level="project" />
|
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.10.3" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.kie:kie-internal:7.40.0.20200703" level="project" />
|
<orderEntry type="library" name="Maven: org.kie:kie-internal:7.42.0.Final" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.kie:kie-api:7.40.0.20200703" level="project" />
|
<orderEntry type="library" name="Maven: org.kie:kie-api:7.42.0.Final" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.kie.soup:kie-soup-maven-support:7.40.0.20200703" level="project" />
|
<orderEntry type="library" name="Maven: org.kie.soup:kie-soup-maven-support:7.42.0.Final" level="project" />
|
||||||
<orderEntry type="library" name="Maven: com.sun.activation:javax.activation:1.2.0" level="project" />
|
<orderEntry type="library" name="Maven: com.sun.activation:javax.activation:1.2.0" level="project" />
|
||||||
<orderEntry type="library" name="Maven: javax.xml.bind:jaxb-api:2.3.1" level="project" />
|
<orderEntry type="library" name="Maven: javax.xml.bind:jaxb-api:2.3.1" level="project" />
|
||||||
<orderEntry type="library" name="Maven: javax.activation:javax.activation-api:1.2.0" level="project" />
|
<orderEntry type="library" name="Maven: javax.activation:javax.activation-api:1.2.0" level="project" />
|
||||||
|
|
|
||||||
2
pom.xml
2
pom.xml
|
|
@ -17,7 +17,7 @@
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<jbpm.version>7.40.0.20200703</jbpm.version>
|
<jbpm.version>7.42.0.Final</jbpm.version>
|
||||||
<node.version>v10.16.3</node.version>
|
<node.version>v10.16.3</node.version>
|
||||||
<npm.version>6.11.3</npm.version>
|
<npm.version>6.11.3</npm.version>
|
||||||
<frontend-maven-plugin.version>1.8.0</frontend-maven-plugin.version>
|
<frontend-maven-plugin.version>1.8.0</frontend-maven-plugin.version>
|
||||||
|
|
|
||||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue