commit
0c0d2e1579
19 changed files with 408 additions and 211 deletions
|
|
@ -246,6 +246,25 @@ services:
|
||||||
command: mongod
|
command: mongod
|
||||||
restart: always
|
restart: always
|
||||||
|
|
||||||
|
kafka_manager:
|
||||||
|
image: hlebalbau/kafka-manager:stable
|
||||||
|
ports:
|
||||||
|
- "9000:9000"
|
||||||
|
hostname: kafka_manager.pymma
|
||||||
|
networks:
|
||||||
|
drools-network-dev:
|
||||||
|
ipv4_address: 172.27.1.89
|
||||||
|
links:
|
||||||
|
- zoo1:zoo1
|
||||||
|
- zoo2:zoo2
|
||||||
|
- zoo3:zoo3
|
||||||
|
environment:
|
||||||
|
ZK_HOSTS: "zoo1:2181, zoo2:2182, zoo3:2183"
|
||||||
|
KAFKA_MANAGER_AUTH_ENABLED: "true"
|
||||||
|
KAFKA_MANAGER_USERNAME: admin
|
||||||
|
KAFKA_MANAGER_PASSWORD: adminpymma
|
||||||
|
command: -Dpidfile.path=/dev/null
|
||||||
|
|
||||||
zoo1:
|
zoo1:
|
||||||
image: zookeeper:3.4.9
|
image: zookeeper:3.4.9
|
||||||
hostname: zoo1
|
hostname: zoo1
|
||||||
|
|
|
||||||
|
|
@ -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() {
|
||||||
|
|
|
||||||
|
|
@ -12,68 +12,80 @@
|
||||||
<artifactId>drools-framework-uberfire-security-service</artifactId>
|
<artifactId>drools-framework-uberfire-security-service</artifactId>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.uberfire</groupId>
|
<groupId>org.uberfire</groupId>
|
||||||
<artifactId>uberfire-api</artifactId>
|
<artifactId>uberfire-api</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.uberfire</groupId>
|
<groupId>org.uberfire</groupId>
|
||||||
<artifactId>uberfire-commons</artifactId>
|
<artifactId>uberfire-commons</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.kie.soup</groupId>
|
<groupId>org.kie.soup</groupId>
|
||||||
<artifactId>kie-soup-commons</artifactId>
|
<artifactId>kie-soup-commons</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.uberfire</groupId>
|
<groupId>org.uberfire</groupId>
|
||||||
<artifactId>uberfire-security-management-api</artifactId>
|
<artifactId>uberfire-security-management-api</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.uberfire</groupId>
|
<groupId>org.uberfire</groupId>
|
||||||
<artifactId>uberfire-security-management-backend</artifactId>
|
<artifactId>uberfire-security-management-backend</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.inject</groupId>
|
<groupId>javax.inject</groupId>
|
||||||
<artifactId>javax.inject</artifactId>
|
<artifactId>javax.inject</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jboss.errai</groupId>
|
<groupId>org.jboss.errai</groupId>
|
||||||
<artifactId>errai-javax-enterprise</artifactId>
|
<artifactId>errai-javax-enterprise</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jboss.errai</groupId>
|
<groupId>org.jboss.errai</groupId>
|
||||||
<artifactId>errai-security-server</artifactId>
|
<artifactId>errai-security-server</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jboss.errai</groupId>
|
<groupId>org.jboss.errai</groupId>
|
||||||
<artifactId>errai-bus</artifactId>
|
<artifactId>errai-bus</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.inject</groupId>
|
<groupId>javax.inject</groupId>
|
||||||
<artifactId>javax.inject</artifactId>
|
<artifactId>javax.inject</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
<version>1</version>
|
<version>1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--dependency>
|
<dependency>
|
||||||
<groupId>org.mongodb</groupId>
|
<groupId>org.mongodb</groupId>
|
||||||
<artifactId>mongodb-driver</artifactId>
|
<artifactId>mongodb-driver</artifactId>
|
||||||
<version>${version.mongodb.driver}</version>
|
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency-->
|
<version>${version.mongodb.driver}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,22 +16,26 @@
|
||||||
|
|
||||||
package org.chtijbug.guvnor.uberfire.security;
|
package org.chtijbug.guvnor.uberfire.security;
|
||||||
|
|
||||||
|
import com.mongodb.Block;
|
||||||
|
import com.mongodb.client.MongoClient;
|
||||||
|
import com.mongodb.client.MongoCollection;
|
||||||
|
import com.mongodb.client.MongoDatabase;
|
||||||
|
import org.bson.Document;
|
||||||
|
import org.bson.codecs.configuration.CodecRegistry;
|
||||||
import org.jboss.errai.security.shared.api.Group;
|
import org.jboss.errai.security.shared.api.Group;
|
||||||
|
import org.jboss.errai.security.shared.api.GroupImpl;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.uberfire.commons.config.ConfigProperties;
|
import org.uberfire.commons.config.ConfigProperties;
|
||||||
import org.uberfire.ext.security.management.api.*;
|
import org.uberfire.ext.security.management.api.*;
|
||||||
import org.uberfire.ext.security.management.api.exception.SecurityManagementException;
|
import org.uberfire.ext.security.management.api.exception.SecurityManagementException;
|
||||||
import org.uberfire.ext.security.management.api.exception.UnsupportedServiceCapabilityException;
|
|
||||||
import org.uberfire.ext.security.management.impl.GroupManagerSettingsImpl;
|
import org.uberfire.ext.security.management.impl.GroupManagerSettingsImpl;
|
||||||
|
import org.uberfire.ext.security.management.impl.SearchResponseImpl;
|
||||||
import org.uberfire.ext.security.management.search.GroupsIdentifierRuntimeSearchEngine;
|
import org.uberfire.ext.security.management.search.GroupsIdentifierRuntimeSearchEngine;
|
||||||
import org.uberfire.ext.security.management.search.IdentifierRuntimeSearchEngine;
|
import org.uberfire.ext.security.management.search.IdentifierRuntimeSearchEngine;
|
||||||
import org.uberfire.ext.security.management.util.SecurityManagementUtils;
|
import org.uberfire.ext.security.management.util.SecurityManagementUtils;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Groups manager service provider implementation for Apache tomcat, when using default realm based on properties files.</p>
|
* <p>Groups manager service provider implementation for Apache tomcat, when using default realm based on properties files.</p>
|
||||||
|
|
@ -45,6 +49,11 @@ public class KiePlatformGroupManager implements GroupManager, ContextualManager
|
||||||
|
|
||||||
IdentifierRuntimeSearchEngine<Group> groupsSearchEngine;
|
IdentifierRuntimeSearchEngine<Group> groupsSearchEngine;
|
||||||
|
|
||||||
|
private MongoClient mongoClient;
|
||||||
|
private CodecRegistry pojoCodecRegistry;
|
||||||
|
private MongoDatabase database;
|
||||||
|
|
||||||
|
|
||||||
public KiePlatformGroupManager() {
|
public KiePlatformGroupManager() {
|
||||||
this(new ConfigProperties(System.getProperties()));
|
this(new ConfigProperties(System.getProperties()));
|
||||||
}
|
}
|
||||||
|
|
@ -58,6 +67,12 @@ public class KiePlatformGroupManager implements GroupManager, ContextualManager
|
||||||
// loadConfig(gitPrefs);
|
// loadConfig(gitPrefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMongo (MongoClient mongoClient,CodecRegistry pojoCodecRegistry,MongoDatabase database){
|
||||||
|
this.mongoClient=mongoClient;
|
||||||
|
this.pojoCodecRegistry = pojoCodecRegistry;
|
||||||
|
this.database=database;
|
||||||
|
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void initialize(UserSystemManager userSystemManager) throws Exception {
|
public void initialize(UserSystemManager userSystemManager) throws Exception {
|
||||||
groupsSearchEngine = new GroupsIdentifierRuntimeSearchEngine();
|
groupsSearchEngine = new GroupsIdentifierRuntimeSearchEngine();
|
||||||
|
|
@ -70,37 +85,47 @@ public class KiePlatformGroupManager implements GroupManager, ContextualManager
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SearchResponse<Group> search(SearchRequest request) throws SecurityManagementException {
|
public SearchResponse<Group> search(SearchRequest request) throws SecurityManagementException {
|
||||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_SEARCH_GROUPS);
|
SearchResponse<Group> result = new SearchResponseImpl<>();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Group get(String identifier) throws SecurityManagementException {
|
public Group get(String identifier) throws SecurityManagementException {
|
||||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_READ_GROUP);
|
Group group = new GroupImpl(identifier);
|
||||||
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Group> getAll() throws SecurityManagementException {
|
public List<Group> getAll() throws SecurityManagementException {
|
||||||
return null;
|
List<Group> groups = new ArrayList<>();
|
||||||
|
MongoCollection<Document> userGroupsCollection = database.getCollection("userGroups");
|
||||||
|
userGroupsCollection.find().forEach((Block<? super Document>) document -> {
|
||||||
|
String groupName = document.getString("name");
|
||||||
|
Group group = new GroupImpl(groupName);
|
||||||
|
groups.add(group);
|
||||||
|
});
|
||||||
|
return groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Group create(Group entity) throws SecurityManagementException {
|
public Group create(Group entity) throws SecurityManagementException {
|
||||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_ADD_GROUP);
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Group update(Group entity) throws SecurityManagementException {
|
public Group update(Group entity) throws SecurityManagementException {
|
||||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_UPDATE_GROUP);
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(String... identifiers) throws SecurityManagementException {
|
public void delete(String... identifiers) throws SecurityManagementException {
|
||||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_DELETE_GROUP);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GroupManagerSettings getSettings() {
|
public GroupManagerSettings getSettings() {
|
||||||
final Map<Capability, CapabilityStatus> capabilityStatusMap = new HashMap<Capability, CapabilityStatus>(8);
|
final Map<Capability, CapabilityStatus> capabilityStatusMap = new HashMap<Capability, CapabilityStatus>(8);
|
||||||
for (final Capability capability : SecurityManagementUtils.GROUPS_CAPABILITIES) {
|
for (final Capability capability : SecurityManagementUtils.GROUPS_CAPABILITIES) {
|
||||||
capabilityStatusMap.put(capability,
|
capabilityStatusMap.put(capability,
|
||||||
getCapabilityStatus(capability));
|
getCapabilityStatus(capability));
|
||||||
|
|
@ -110,7 +135,7 @@ public class KiePlatformGroupManager implements GroupManager, ContextualManager
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CapabilityStatus getCapabilityStatus(Capability capability) {
|
protected CapabilityStatus getCapabilityStatus(Capability capability) {
|
||||||
/**
|
|
||||||
if (capability != null) {
|
if (capability != null) {
|
||||||
switch (capability) {
|
switch (capability) {
|
||||||
case CAN_SEARCH_GROUPS:
|
case CAN_SEARCH_GROUPS:
|
||||||
|
|
@ -121,13 +146,12 @@ public class KiePlatformGroupManager implements GroupManager, ContextualManager
|
||||||
return CapabilityStatus.ENABLED;
|
return CapabilityStatus.ENABLED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
**/
|
return CapabilityStatus.UNSUPPORTED;
|
||||||
return CapabilityStatus.UNSUPPORTED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void assignUsers(String name,
|
public void assignUsers(String name,
|
||||||
Collection<String> users) throws SecurityManagementException {
|
Collection<String> users) throws SecurityManagementException {
|
||||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_ASSIGN_GROUPS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2016 Red Hat, Inc. and/or its affiliates.
|
* Copyright 2016 Red Hat, Inc. and/or its affiliates.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
|
@ -16,52 +16,65 @@
|
||||||
|
|
||||||
package org.chtijbug.guvnor.uberfire.security;
|
package org.chtijbug.guvnor.uberfire.security;
|
||||||
|
|
||||||
import org.jboss.errai.security.shared.api.Group;
|
import com.mongodb.Block;
|
||||||
|
import com.mongodb.client.MongoClient;
|
||||||
|
import com.mongodb.client.MongoCollection;
|
||||||
|
import com.mongodb.client.MongoDatabase;
|
||||||
|
import org.bson.Document;
|
||||||
|
import org.bson.codecs.configuration.CodecRegistry;
|
||||||
import org.jboss.errai.security.shared.api.Role;
|
import org.jboss.errai.security.shared.api.Role;
|
||||||
|
import org.jboss.errai.security.shared.api.RoleImpl;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.uberfire.commons.config.ConfigProperties;
|
import org.uberfire.commons.config.ConfigProperties;
|
||||||
import org.uberfire.ext.security.management.api.*;
|
import org.uberfire.ext.security.management.api.*;
|
||||||
import org.uberfire.ext.security.management.api.exception.SecurityManagementException;
|
import org.uberfire.ext.security.management.api.exception.SecurityManagementException;
|
||||||
import org.uberfire.ext.security.management.api.exception.UnsupportedServiceCapabilityException;
|
|
||||||
import org.uberfire.ext.security.management.impl.RoleManagerSettingsImpl;
|
import org.uberfire.ext.security.management.impl.RoleManagerSettingsImpl;
|
||||||
import org.uberfire.ext.security.management.search.GroupsIdentifierRuntimeSearchEngine;
|
import org.uberfire.ext.security.management.impl.SearchResponseImpl;
|
||||||
import org.uberfire.ext.security.management.search.IdentifierRuntimeSearchEngine;
|
|
||||||
import org.uberfire.ext.security.management.util.SecurityManagementUtils;
|
import org.uberfire.ext.security.management.util.SecurityManagementUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Groups manager service provider implementation for Apache tomcat, when using default realm based on properties files.</p>
|
* <p>Groups manager service provider implementation for Apache tomcat, when using default realm based on properties files.</p>
|
||||||
|
*
|
||||||
* @since 0.8.0
|
* @since 0.8.0
|
||||||
*/
|
*/
|
||||||
public class KiePlatformRoleManager implements RoleManager,ContextualManager {
|
public class KiePlatformRoleManager implements RoleManager, ContextualManager {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(KiePlatformRoleManager.class);
|
private static final Logger LOG = LoggerFactory.getLogger(KiePlatformRoleManager.class);
|
||||||
|
|
||||||
|
|
||||||
|
private MongoClient mongoClient;
|
||||||
IdentifierRuntimeSearchEngine<Group> groupsSearchEngine;
|
private CodecRegistry pojoCodecRegistry;
|
||||||
|
private MongoDatabase database;
|
||||||
|
|
||||||
public KiePlatformRoleManager() {
|
public KiePlatformRoleManager() {
|
||||||
this(new ConfigProperties(System.getProperties()));
|
this(new ConfigProperties(System.getProperties()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public KiePlatformRoleManager(final Map<String, String> gitPrefs) {
|
public KiePlatformRoleManager(final Map<String, String> gitPrefs) {
|
||||||
this(new ConfigProperties(gitPrefs));
|
this(new ConfigProperties(gitPrefs));
|
||||||
}
|
}
|
||||||
|
|
||||||
public KiePlatformRoleManager(final ConfigProperties gitPrefs) {
|
public KiePlatformRoleManager(final ConfigProperties gitPrefs) {
|
||||||
// loadConfig(gitPrefs);
|
// loadConfig(gitPrefs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMongo(MongoClient mongoClient, CodecRegistry pojoCodecRegistry, MongoDatabase database) {
|
||||||
|
this.mongoClient = mongoClient;
|
||||||
|
this.pojoCodecRegistry = pojoCodecRegistry;
|
||||||
|
this.database = database;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(UserSystemManager userSystemManager) throws Exception {
|
public void initialize(UserSystemManager userSystemManager) throws Exception {
|
||||||
groupsSearchEngine = new GroupsIdentifierRuntimeSearchEngine();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -72,59 +85,70 @@ public class KiePlatformRoleManager implements RoleManager,ContextualManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SearchResponse<Role> search(SearchRequest request) throws SecurityManagementException {
|
public SearchResponse<Role> search(SearchRequest request) throws SecurityManagementException {
|
||||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_SEARCH_ROLES);
|
SearchResponse<Role> roleSearchResponse = new SearchResponseImpl<>();
|
||||||
|
return roleSearchResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Role get(String identifier) throws SecurityManagementException {
|
public Role get(String identifier) throws SecurityManagementException {
|
||||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_READ_ROLE);
|
RoleImpl role = new RoleImpl(identifier);
|
||||||
|
return role;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Role> getAll() throws SecurityManagementException {
|
public List<Role> getAll() throws SecurityManagementException {
|
||||||
return null;
|
|
||||||
|
MongoCollection<Document> userRolesCollection = database.getCollection("userRoles");
|
||||||
|
List<Role> roles = new ArrayList<>();
|
||||||
|
userRolesCollection.find().forEach((Block<? super Document>) document -> {
|
||||||
|
String roleName = document.getString("name");
|
||||||
|
RoleImpl role = new RoleImpl(roleName);
|
||||||
|
roles.add(role);
|
||||||
|
});
|
||||||
|
|
||||||
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Role create(Role entity) throws SecurityManagementException {
|
public Role create(Role entity) throws SecurityManagementException {
|
||||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_ADD_ROLE);
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Role update(Role entity) throws SecurityManagementException {
|
public Role update(Role entity) throws SecurityManagementException {
|
||||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_UPDATE_ROLE);
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(String... identifiers) throws SecurityManagementException {
|
public void delete(String... identifiers) throws SecurityManagementException {
|
||||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_DELETE_ROLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleManagerSettings getSettings() {
|
public RoleManagerSettings getSettings() {
|
||||||
final Map<Capability, CapabilityStatus> capabilityStatusMap = new HashMap<Capability, CapabilityStatus>(8);
|
final Map<Capability, CapabilityStatus> capabilityStatusMap = new HashMap<>(8);
|
||||||
for (final Capability capability : SecurityManagementUtils.ROLES_CAPABILITIES) {
|
for (final Capability capability : SecurityManagementUtils.ROLES_CAPABILITIES) {
|
||||||
capabilityStatusMap.put(capability,
|
capabilityStatusMap.put(capability,
|
||||||
getCapabilityStatus(capability));
|
getCapabilityStatus(capability));
|
||||||
}
|
}
|
||||||
return new RoleManagerSettingsImpl(capabilityStatusMap);
|
return new RoleManagerSettingsImpl(capabilityStatusMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CapabilityStatus getCapabilityStatus(Capability capability) {
|
protected CapabilityStatus getCapabilityStatus(Capability capability) {
|
||||||
/**
|
|
||||||
if (capability != null) {
|
if (capability != null) {
|
||||||
switch (capability) {
|
switch (capability) {
|
||||||
case CAN_SEARCH_ROLES:
|
case CAN_SEARCH_ROLES:
|
||||||
|
case CAN_READ_ROLE:
|
||||||
|
return CapabilityStatus.ENABLED;
|
||||||
case CAN_ADD_ROLE:
|
case CAN_ADD_ROLE:
|
||||||
case CAN_UPDATE_ROLE:
|
case CAN_UPDATE_ROLE:
|
||||||
case CAN_READ_ROLE:
|
|
||||||
case CAN_DELETE_ROLE:
|
case CAN_DELETE_ROLE:
|
||||||
return CapabilityStatus.ENABLED;
|
return CapabilityStatus.UNSUPPORTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
**/
|
|
||||||
return CapabilityStatus.UNSUPPORTED;
|
return CapabilityStatus.UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,12 @@
|
||||||
package org.chtijbug.guvnor.uberfire.security;
|
package org.chtijbug.guvnor.uberfire.security;
|
||||||
|
|
||||||
|
|
||||||
|
import com.mongodb.MongoClientSettings;
|
||||||
|
import com.mongodb.client.MongoClient;
|
||||||
|
import com.mongodb.client.MongoClients;
|
||||||
|
import com.mongodb.client.MongoDatabase;
|
||||||
|
import org.bson.codecs.configuration.CodecRegistry;
|
||||||
|
import org.bson.codecs.pojo.PojoCodecProvider;
|
||||||
import org.uberfire.ext.security.management.api.GroupManager;
|
import org.uberfire.ext.security.management.api.GroupManager;
|
||||||
import org.uberfire.ext.security.management.api.RoleManager;
|
import org.uberfire.ext.security.management.api.RoleManager;
|
||||||
import org.uberfire.ext.security.management.api.UserManagementService;
|
import org.uberfire.ext.security.management.api.UserManagementService;
|
||||||
|
|
@ -10,6 +16,9 @@ import javax.enterprise.context.Dependent;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import static org.bson.codecs.configuration.CodecRegistries.fromProviders;
|
||||||
|
import static org.bson.codecs.configuration.CodecRegistries.fromRegistries;
|
||||||
|
|
||||||
@Dependent
|
@Dependent
|
||||||
@Named(value = "PymmaKieSecurityService")
|
@Named(value = "PymmaKieSecurityService")
|
||||||
public class KiePlatformSecurityService implements UserManagementService {
|
public class KiePlatformSecurityService implements UserManagementService {
|
||||||
|
|
@ -20,46 +29,48 @@ public class KiePlatformSecurityService implements UserManagementService {
|
||||||
|
|
||||||
private String connectionString;
|
private String connectionString;
|
||||||
private String databaseName;
|
private String databaseName;
|
||||||
// private MongoClient mongoClient;
|
private MongoClient mongoClient;
|
||||||
// private CodecRegistry pojoCodecRegistry;
|
private CodecRegistry pojoCodecRegistry;
|
||||||
//private MongoDatabase database;
|
private MongoDatabase database;
|
||||||
|
|
||||||
|
|
||||||
public KiePlatformSecurityService() {
|
|
||||||
System.out.println("KiePlatformSecurityService initialized with databaseName = " + connectionString );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public KiePlatformSecurityService(KiePlatformUserManager userManager,
|
public KiePlatformSecurityService(KiePlatformUserManager userManager,
|
||||||
KiePlatformGroupManager groupManager,
|
KiePlatformGroupManager groupManager,
|
||||||
KiePlatformRoleManager roleManager) {
|
KiePlatformRoleManager roleManager) {
|
||||||
|
//-DconnectionString=localhost:28017 -Ddatabase=businessProxyDB
|
||||||
|
|
||||||
connectionString = System.getProperty("connectionString");
|
this.connectionString = System.getProperty("connectionString");
|
||||||
databaseName=System.getProperty("name");
|
this.databaseName=System.getProperty("database");
|
||||||
System.out.println("KiePlatformSecurityService initialized with databaseName = " + connectionString );
|
System.out.println("KiePlatformSecurityService initialized with databaseName = " + connectionString );
|
||||||
//mongoClient = MongoClients.create(connectionString);
|
this.mongoClient = MongoClients.create(connectionString);
|
||||||
//pojoCodecRegistry = fromRegistries(MongoClientSettings.getDefaultCodecRegistry(),
|
this.pojoCodecRegistry = fromRegistries(MongoClientSettings.getDefaultCodecRegistry(),
|
||||||
// fromProviders(PojoCodecProvider.builder().automatic(true).build()));
|
fromProviders(PojoCodecProvider.builder().automatic(true).build()));
|
||||||
// database = mongoClient.getDatabase(databaseName).withCodecRegistry(pojoCodecRegistry);
|
this.database = mongoClient.getDatabase(databaseName).withCodecRegistry(pojoCodecRegistry);
|
||||||
System.out.println("All setup");
|
System.out.println("All setup");
|
||||||
this.userManager = userManager;
|
this.userManager = userManager;
|
||||||
this.groupManager = groupManager;
|
this.groupManager = groupManager;
|
||||||
this.roleManager = roleManager;
|
this.roleManager = roleManager;
|
||||||
|
this.userManager.setMongo(mongoClient,pojoCodecRegistry,database);
|
||||||
|
this.groupManager.setMongo(mongoClient,pojoCodecRegistry,database);
|
||||||
|
this.roleManager.setMongo(mongoClient,pojoCodecRegistry,database);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserManager users() {
|
public UserManager users() {
|
||||||
return new KiePlatformUserManager();
|
return userManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GroupManager groups() {
|
public GroupManager groups() {
|
||||||
return new KiePlatformGroupManager();
|
return groupManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RoleManager roles() {
|
public RoleManager roles() {
|
||||||
return new KiePlatformRoleManager();
|
return roleManager;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2016 Red Hat, Inc. and/or its affiliates.
|
* Copyright 2016 Red Hat, Inc. and/or its affiliates.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
|
@ -16,33 +16,48 @@
|
||||||
|
|
||||||
package org.chtijbug.guvnor.uberfire.security;
|
package org.chtijbug.guvnor.uberfire.security;
|
||||||
|
|
||||||
|
import com.mongodb.BasicDBObject;
|
||||||
|
import com.mongodb.Block;
|
||||||
|
import com.mongodb.DBRef;
|
||||||
|
import com.mongodb.client.FindIterable;
|
||||||
|
import com.mongodb.client.MongoClient;
|
||||||
|
import com.mongodb.client.MongoCollection;
|
||||||
|
import com.mongodb.client.MongoDatabase;
|
||||||
|
import org.bson.Document;
|
||||||
|
import org.bson.codecs.configuration.CodecRegistry;
|
||||||
|
import org.jboss.errai.security.shared.api.Group;
|
||||||
|
import org.jboss.errai.security.shared.api.GroupImpl;
|
||||||
|
import org.jboss.errai.security.shared.api.Role;
|
||||||
|
import org.jboss.errai.security.shared.api.RoleImpl;
|
||||||
import org.jboss.errai.security.shared.api.identity.User;
|
import org.jboss.errai.security.shared.api.identity.User;
|
||||||
|
import org.jboss.errai.security.shared.api.identity.UserImpl;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.uberfire.commons.config.ConfigProperties;
|
import org.uberfire.commons.config.ConfigProperties;
|
||||||
import org.uberfire.ext.security.management.api.*;
|
import org.uberfire.ext.security.management.api.*;
|
||||||
import org.uberfire.ext.security.management.api.exception.SecurityManagementException;
|
import org.uberfire.ext.security.management.api.exception.SecurityManagementException;
|
||||||
import org.uberfire.ext.security.management.api.exception.UnsupportedServiceCapabilityException;
|
import org.uberfire.ext.security.management.impl.SearchResponseImpl;
|
||||||
import org.uberfire.ext.security.management.impl.UserManagerSettingsImpl;
|
import org.uberfire.ext.security.management.impl.UserManagerSettingsImpl;
|
||||||
import org.uberfire.ext.security.management.search.IdentifierRuntimeSearchEngine;
|
|
||||||
import org.uberfire.ext.security.management.search.UsersIdentifierRuntimeSearchEngine;
|
|
||||||
import org.uberfire.ext.security.management.util.SecurityManagementUtils;
|
import org.uberfire.ext.security.management.util.SecurityManagementUtils;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
|
import static com.mongodb.client.model.Filters.eq;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Users manager service provider implementation for Apache tomcat, when using default realm based on properties files.</p>
|
* <p>Users manager service provider implementation for Apache tomcat, when using default realm based on properties files.</p>
|
||||||
*
|
*
|
||||||
* @since 0.8.0
|
* @since 0.8.0
|
||||||
*/
|
*/
|
||||||
public class KiePlatformUserManager implements UserManager, ContextualManager {
|
public class KiePlatformUserManager implements UserManager, ContextualManager {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(KiePlatformUserManager.class);
|
private static final Logger LOG = LoggerFactory.getLogger(KiePlatformUserManager.class);
|
||||||
|
|
||||||
UserSystemManager userSystemManager;
|
|
||||||
IdentifierRuntimeSearchEngine<User> usersSearchEngine;
|
|
||||||
|
|
||||||
|
|
||||||
|
private MongoClient mongoClient;
|
||||||
|
private CodecRegistry pojoCodecRegistry;
|
||||||
|
private MongoDatabase database;
|
||||||
|
|
||||||
public KiePlatformUserManager() {
|
public KiePlatformUserManager() {
|
||||||
this(new ConfigProperties(System.getProperties()));
|
this(new ConfigProperties(System.getProperties()));
|
||||||
|
|
@ -56,12 +71,16 @@ public class KiePlatformUserManager implements UserManager, ContextualManager {
|
||||||
//loadConfig(gitPrefs);
|
//loadConfig(gitPrefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMongo(MongoClient mongoClient, CodecRegistry pojoCodecRegistry, MongoDatabase database) {
|
||||||
|
this.mongoClient = mongoClient;
|
||||||
|
this.pojoCodecRegistry = pojoCodecRegistry;
|
||||||
|
this.database = database;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(final UserSystemManager userSystemManager) throws Exception {
|
public void initialize(final UserSystemManager userSystemManager) throws Exception {
|
||||||
this.userSystemManager = userSystemManager;
|
System.out.println("All setup");
|
||||||
usersSearchEngine = new UsersIdentifierRuntimeSearchEngine();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -71,32 +90,89 @@ public class KiePlatformUserManager implements UserManager, ContextualManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SearchResponse<User> search(SearchRequest request) throws SecurityManagementException {
|
public SearchResponse<User> search(SearchRequest request) throws SecurityManagementException {
|
||||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_SEARCH_USERS);
|
|
||||||
|
MongoCollection<Document> userCollection = database.getCollection("user");
|
||||||
|
BasicDBObject regexQuery = new BasicDBObject();
|
||||||
|
regexQuery.put("login", new BasicDBObject("$regex", request.getSearchPattern() + ".*").append("$options", "i"));
|
||||||
|
List<User> users = new ArrayList<>();
|
||||||
|
long totalNumber = userCollection.countDocuments(regexQuery);
|
||||||
|
FindIterable<Document> documents = userCollection.find(regexQuery).skip(request.getPageSize() * (request.getPage() - 1)).limit(request.getPageSize());
|
||||||
|
documents.forEach((Block<? super Document>) document -> {
|
||||||
|
String userName = document.getString("login");
|
||||||
|
User user = fillUser(userName, document);
|
||||||
|
users.add(user);
|
||||||
|
});
|
||||||
|
boolean hasNextPage=true;
|
||||||
|
if ((request.getPageSize() * (request.getPage())>totalNumber)){
|
||||||
|
hasNextPage=false;
|
||||||
|
}
|
||||||
|
SearchResponse<User> response = new SearchResponseImpl(users, request.getPage(),request.getPageSize(),Long.valueOf(totalNumber).intValue(), hasNextPage);
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public User get(String identifier) throws SecurityManagementException {
|
public User get(String identifier) throws SecurityManagementException {
|
||||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_READ_USER);
|
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
|
||||||
public List<User> getAll() throws SecurityManagementException {
|
public List<User> getAll() throws SecurityManagementException {
|
||||||
return null;
|
List<User> users = new ArrayList<>();
|
||||||
|
MongoCollection<Document> userCollection = database.getCollection("user");
|
||||||
|
userCollection.find().forEach((Block<? super Document>) document -> {
|
||||||
|
String userName = document.getString("login");
|
||||||
|
User user = fillUser(userName, document);
|
||||||
|
users.add(user);
|
||||||
|
});
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
|
||||||
|
private User fillUser(String userName, Document document) {
|
||||||
|
|
||||||
|
AtomicReference<ArrayList<DBRef>> roles = new AtomicReference<ArrayList<DBRef>>(new ArrayList());
|
||||||
|
AtomicReference<ArrayList<DBRef>> groups = new AtomicReference<ArrayList<DBRef>>(new ArrayList());
|
||||||
|
roles.set((ArrayList) document.get("userRoles"));
|
||||||
|
groups.set((ArrayList) document.get("userGroups"));
|
||||||
|
List<Role> roleList = new ArrayList<>();
|
||||||
|
for (DBRef dbRef : roles.get()) {
|
||||||
|
Document roleDocument = Utils.getDocumentFromRef(dbRef,database);
|
||||||
|
Role role = new RoleImpl(roleDocument.getString("name"));
|
||||||
|
roleList.add(role);
|
||||||
|
}
|
||||||
|
List<Group> groupList = new ArrayList<>();
|
||||||
|
for (DBRef dbRef : groups.get()) {
|
||||||
|
Document groupDocument = Utils.getDocumentFromRef(dbRef,database);
|
||||||
|
Group group = new GroupImpl(groupDocument.getString("name"));
|
||||||
|
groupList.add(group);
|
||||||
|
}
|
||||||
|
User user = new UserImpl(userName,roleList,groupList);
|
||||||
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public User create(User entity) throws SecurityManagementException {
|
public User create(User entity) throws SecurityManagementException {
|
||||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_ADD_USER);
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public User update(User entity) throws SecurityManagementException {
|
public User update(User entity) throws SecurityManagementException {
|
||||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_UPDATE_USER);
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(String... identifiers) throws SecurityManagementException {
|
public void delete(String... identifiers) throws SecurityManagementException {
|
||||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_DELETE_USER);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -105,26 +181,23 @@ public class KiePlatformUserManager implements UserManager, ContextualManager {
|
||||||
final Map<Capability, CapabilityStatus> capabilityStatusMap = new HashMap<Capability, CapabilityStatus>(8);
|
final Map<Capability, CapabilityStatus> capabilityStatusMap = new HashMap<Capability, CapabilityStatus>(8);
|
||||||
for (final Capability capability : SecurityManagementUtils.USERS_CAPABILITIES) {
|
for (final Capability capability : SecurityManagementUtils.USERS_CAPABILITIES) {
|
||||||
capabilityStatusMap.put(capability,
|
capabilityStatusMap.put(capability,
|
||||||
getCapabilityStatus(capability));
|
getCapabilityStatus(capability));
|
||||||
}
|
}
|
||||||
return new UserManagerSettingsImpl(capabilityStatusMap,
|
return new UserManagerSettingsImpl(capabilityStatusMap,
|
||||||
null);
|
null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void assignGroups(String username,
|
public void assignGroups(String username,
|
||||||
Collection<String> groups) throws SecurityManagementException {
|
Collection<String> groups) throws SecurityManagementException {
|
||||||
Set<String> userRoles = SecurityManagementUtils.rolesToString(SecurityManagementUtils.getRoles(userSystemManager,
|
|
||||||
username));
|
|
||||||
userRoles.addAll(groups);
|
|
||||||
doAssignGroups(username,
|
|
||||||
userRoles);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void assignRoles(String username,
|
public void assignRoles(String username,
|
||||||
Collection<String> roles) throws SecurityManagementException {
|
Collection<String> roles) throws SecurityManagementException {
|
||||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_ASSIGN_ROLES);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doAssignGroups(String username,
|
private void doAssignGroups(String username,
|
||||||
|
|
@ -135,12 +208,12 @@ public class KiePlatformUserManager implements UserManager, ContextualManager {
|
||||||
@Override
|
@Override
|
||||||
public void changePassword(String username,
|
public void changePassword(String username,
|
||||||
String newPassword) throws SecurityManagementException {
|
String newPassword) throws SecurityManagementException {
|
||||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_CHANGE_PASSWORD);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CapabilityStatus getCapabilityStatus(Capability capability) {
|
protected CapabilityStatus getCapabilityStatus(Capability capability) {
|
||||||
/**
|
|
||||||
if (capability != null) {
|
if (capability != null) {
|
||||||
switch (capability) {
|
switch (capability) {
|
||||||
case CAN_SEARCH_USERS:
|
case CAN_SEARCH_USERS:
|
||||||
|
|
@ -156,7 +229,7 @@ public class KiePlatformUserManager implements UserManager, ContextualManager {
|
||||||
return CapabilityStatus.ENABLED;
|
return CapabilityStatus.ENABLED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
**/
|
|
||||||
return CapabilityStatus.UNSUPPORTED;
|
return CapabilityStatus.UNSUPPORTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -139,7 +139,7 @@
|
||||||
<goal>copy-resources</goal>
|
<goal>copy-resources</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<outputDirectory>${basedir}/target//unpack-tmp/WEB-INF/classes/META-INF</outputDirectory>
|
<outputDirectory>${basedir}/target/unpack-tmp/</outputDirectory>
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
<directory>src/main/resources</directory>
|
<directory>src/main/resources</directory>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ JBoss, Home of Professional Open Source
|
||||||
|
~ Copyright 2017 Red Hat Inc. and/or its affiliates and other contributors
|
||||||
|
~ as indicated by the @author tags. All rights reserved.
|
||||||
|
~ See the copyright.txt in the distribution for a
|
||||||
|
~ full listing of individual contributors.
|
||||||
|
~
|
||||||
|
~ This copyrighted material is made available to anyone wishing to use,
|
||||||
|
~ modify, copy, or redistribute it subject to the terms and conditions
|
||||||
|
~ of the GNU Lesser General Public License, v. 2.1.
|
||||||
|
~ This program is distributed in the hope that it will be useful, but WITHOUT A
|
||||||
|
~ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||||
|
~ PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||||
|
~ You should have received a copy of the GNU Lesser General Public License,
|
||||||
|
~ v.2.1 along with this distribution; if not, write to the Free Software
|
||||||
|
~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
~ MA 02110-1301, USA.
|
||||||
|
-->
|
||||||
|
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
|
||||||
|
<deployment>
|
||||||
|
<dependencies>
|
||||||
|
<!-- IMPORTANT: when adding dependency (module) here, make sure it is a public one.
|
||||||
|
Do not add private modules as there is no guarantee they won't be changed or
|
||||||
|
removed in future. WildFly also generates warning(s) during the deployment if
|
||||||
|
the WAR depends on private modules. -->
|
||||||
|
<!-- Keep the alphabetical order! -->
|
||||||
|
<!-- JMS API required by kie-server-client as there is an runtime API dependency
|
||||||
|
(even though the JMS is not being used for the communication itself). -->
|
||||||
|
<module name="javax.jms.api"/>
|
||||||
|
<module name="com.pymmasoftware.pymma-kie-loginmodule"/>
|
||||||
|
</dependencies>
|
||||||
|
</deployment>
|
||||||
|
</jboss-deployment-structure>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
org.jboss.weld.level=DEBUG
|
||||||
|
|
@ -77,13 +77,13 @@
|
||||||
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest:2.1" level="project" />
|
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest:2.1" level="project" />
|
||||||
<orderEntry type="library" name="Maven: com.google.guava:guava:13.0.1" level="project" />
|
<orderEntry type="library" name="Maven: com.google.guava:guava:13.0.1" level="project" />
|
||||||
<orderEntry type="library" name="Maven: commons-io:commons-io:2.1" level="project" />
|
<orderEntry type="library" name="Maven: commons-io:commons-io:2.1" level="project" />
|
||||||
<orderEntry type="library" name="Maven: io.github.kostaskougios:cloning:1.10.3" level="project" />
|
<orderEntry type="module" module-name="cloning" />
|
||||||
<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" />
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;
|
||||||
import org.springframework.kafka.core.*;
|
import org.springframework.kafka.core.*;
|
||||||
import org.springframework.kafka.support.serializer.JsonDeserializer;
|
import org.springframework.kafka.support.serializer.JsonDeserializer;
|
||||||
import org.springframework.kafka.support.serializer.JsonSerializer;
|
import org.springframework.kafka.support.serializer.JsonSerializer;
|
||||||
|
import org.springframework.kafka.transaction.KafkaTransactionManager;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
@ -104,13 +105,21 @@ public class DroolsBusinessProxyServer {
|
||||||
configProps.put(
|
configProps.put(
|
||||||
ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG,
|
ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG,
|
||||||
JsonSerializer.class);
|
JsonSerializer.class);
|
||||||
return new DefaultKafkaProducerFactory<>(configProps);
|
DefaultKafkaProducerFactory<String, KieContainerResponse> producer = new DefaultKafkaProducerFactory<>(configProps);
|
||||||
|
producer.transactionCapable();
|
||||||
|
producer.setTransactionIdPrefix("trans");
|
||||||
|
return producer;
|
||||||
|
}
|
||||||
|
@Bean
|
||||||
|
public KafkaTransactionManager transactionManager(ProducerFactory producerFactory) {
|
||||||
|
KafkaTransactionManager manager = new KafkaTransactionManager(producerKieContainerResponseactory());
|
||||||
|
return manager;
|
||||||
}
|
}
|
||||||
@Bean
|
@Bean
|
||||||
public KafkaTemplate<String, KieContainerResponse> kafkaKieContainerUpdateResponsableTemplate() {
|
public KafkaTemplate<String, KieContainerResponse> kafkaKieContainerUpdateResponsableTemplate() {
|
||||||
return new KafkaTemplate<>(producerKieContainerResponseactory());
|
return new KafkaTemplate<>(producerKieContainerResponseactory());
|
||||||
}
|
}
|
||||||
@Bean
|
@Bean(name="deployFinish")
|
||||||
public NewTopic actionDeployResponseTopic() {
|
public NewTopic actionDeployResponseTopic() {
|
||||||
return new NewTopic(KafkaTopicConstants.RESPONSE_DEPLOY_TOPIC, 1, (short) 1);
|
return new NewTopic(KafkaTopicConstants.RESPONSE_DEPLOY_TOPIC, 1, (short) 1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ package org.chtijbug.drools.proxy.service;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.apache.camel.CamelContext;
|
import org.apache.camel.CamelContext;
|
||||||
import org.apache.camel.Route;
|
import org.apache.camel.Route;
|
||||||
|
import org.apache.kafka.clients.admin.NewTopic;
|
||||||
import org.chtijbug.drools.KieContainerResponse;
|
import org.chtijbug.drools.KieContainerResponse;
|
||||||
import org.chtijbug.drools.KieContainerUpdate;
|
import org.chtijbug.drools.KieContainerUpdate;
|
||||||
import org.chtijbug.drools.common.KafkaTopicConstants;
|
import org.chtijbug.drools.common.KafkaTopicConstants;
|
||||||
|
|
@ -40,6 +41,7 @@ import org.kie.server.services.impl.marshal.MarshallerHelper;
|
||||||
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.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.kafka.annotation.KafkaListener;
|
import org.springframework.kafka.annotation.KafkaListener;
|
||||||
|
|
@ -91,6 +93,10 @@ public class KieServiceCommon {
|
||||||
@Autowired
|
@Autowired
|
||||||
KafkaTemplate<String, KieContainerResponse> kafkaKieContainerUpdateResponseTemplate;
|
KafkaTemplate<String, KieContainerResponse> kafkaKieContainerUpdateResponseTemplate;
|
||||||
|
|
||||||
|
@Qualifier("deployFinish")
|
||||||
|
@Autowired
|
||||||
|
NewTopic responseTopic;
|
||||||
|
|
||||||
public KieServiceCommon() {
|
public KieServiceCommon() {
|
||||||
// for now, if no server impl is passed as parameter, create one
|
// for now, if no server impl is passed as parameter, create one
|
||||||
// this.server = KieServerLocator.getInstance();
|
// this.server = KieServerLocator.getInstance();
|
||||||
|
|
@ -333,8 +339,8 @@ public class KieServiceCommon {
|
||||||
}
|
}
|
||||||
KieContainerResponse kieContainerResponse = new KieContainerResponse();
|
KieContainerResponse kieContainerResponse = new KieContainerResponse();
|
||||||
kieContainerResponse.setStatus(KieContainerResponse.STATUS.SUCCESS);
|
kieContainerResponse.setStatus(KieContainerResponse.STATUS.SUCCESS);
|
||||||
|
kafkaKieContainerUpdateResponseTemplate.executeInTransaction(kt ->
|
||||||
kafkaKieContainerUpdateResponseTemplate.send(KafkaTopicConstants.RESPONSE_DEPLOY_TOPIC,kieContainerResponse);
|
kt.send(KafkaTopicConstants.RESPONSE_DEPLOY_TOPIC,kieContainerResponse));
|
||||||
|
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
KieContainerResponse kieContainerResponse = new KieContainerResponse();
|
KieContainerResponse kieContainerResponse = new KieContainerResponse();
|
||||||
|
|
@ -344,7 +350,9 @@ public class KieServiceCommon {
|
||||||
for (StackTraceElement stackTraceElement : e.getStackTrace()){
|
for (StackTraceElement stackTraceElement : e.getStackTrace()){
|
||||||
kieContainerResponse.getErrorMessages().add(stackTraceElement.toString());
|
kieContainerResponse.getErrorMessages().add(stackTraceElement.toString());
|
||||||
}
|
}
|
||||||
kafkaKieContainerUpdateResponseTemplate.send(KafkaTopicConstants.RESPONSE_DEPLOY_TOPIC,kieContainerResponse);
|
kafkaKieContainerUpdateResponseTemplate.executeInTransaction(kt ->
|
||||||
|
kt.send(KafkaTopicConstants.RESPONSE_DEPLOY_TOPIC,kieContainerResponse));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,13 +39,13 @@
|
||||||
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:2.1" level="project" />
|
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:2.1" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest:2.1" level="project" />
|
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest:2.1" level="project" />
|
||||||
<orderEntry type="library" name="Maven: com.google.guava:guava:13.0.1" level="project" />
|
<orderEntry type="library" name="Maven: com.google.guava:guava:13.0.1" level="project" />
|
||||||
<orderEntry type="library" name="Maven: io.github.kostaskougios:cloning:1.10.3" level="project" />
|
<orderEntry type="module" module-name="cloning" />
|
||||||
<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