commit
0c0d2e1579
19 changed files with 408 additions and 211 deletions
|
|
@ -246,6 +246,25 @@ services:
|
|||
command: mongod
|
||||
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:
|
||||
image: zookeeper:3.4.9
|
||||
hostname: zoo1
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package org.chtijbug.drools.console.service;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.DependsOn;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
@ -13,16 +15,21 @@ import java.io.InputStreamReader;
|
|||
@DependsOn("applicationContext")
|
||||
public class GitRepositoryService {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(GitRepositoryService.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
GitRepositoryService service = new GitRepositoryService();
|
||||
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");
|
||||
if (fileBase != null) {
|
||||
String gitdirectory = fileBase + "/.niogit/" + projectName + ".git";
|
||||
String gitFileName = fileBase + "/.niogit/" + projectName + ".git/hooks/post-commit";
|
||||
if (gitRepoBase==null || gitBaseUrl.length()==0){
|
||||
gitRepoBase=".niogit";
|
||||
}
|
||||
String gitdirectory = fileBase + "/"+gitRepoBase+"/" + projectName + ".git";
|
||||
String gitFileName = fileBase + "/"+gitRepoBase+"/" + projectName + ".git/hooks/post-commit";
|
||||
/**
|
||||
* #!/bin/sh
|
||||
* 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");
|
||||
File file = new File(gitFileName);
|
||||
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");
|
||||
if (fileBase != null) {
|
||||
|
||||
String gitFileName = fileBase + "/.niogit/" + projectName + ".git/hooks/post-commit";
|
||||
if (gitRepoBase==null || gitBaseUrl.length()==0){
|
||||
gitRepoBase=".niogit";
|
||||
}
|
||||
String gitFileName = fileBase + "/"+gitRepoBase+"/" + projectName + ".git/hooks/post-commit";
|
||||
this.executeCommand(gitFileName);
|
||||
}
|
||||
}
|
||||
|
||||
private String executeCommand(String command) {
|
||||
|
||||
StringBuffer output = new StringBuffer();
|
||||
StringBuilder output = new StringBuilder();
|
||||
|
||||
Process process;
|
||||
try {
|
||||
System.out.println(command);
|
||||
System.out.println("============Command start======================");
|
||||
logger.info(command);
|
||||
logger.info("============Command start======================");
|
||||
process = Runtime.getRuntime().exec(command);
|
||||
process.waitFor();
|
||||
System.out.println("=============Command Stop=====================");
|
||||
logger.info("=============Command Stop=====================");
|
||||
new Thread(() -> {
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
String line = "";
|
||||
try {
|
||||
while ((line = reader.readLine()) != null)
|
||||
System.out.println(line);
|
||||
logger.info(line);
|
||||
} finally {
|
||||
reader.close();
|
||||
}
|
||||
|
|
@ -86,7 +96,7 @@ public class GitRepositoryService {
|
|||
String line = "";
|
||||
try {
|
||||
while ((line = reader.readLine()) != null) {
|
||||
System.out.println(line);
|
||||
logger.info(line);
|
||||
// Traitement du flux d'erreur de l'application si besoin est
|
||||
}
|
||||
} 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.jaxb.Asset;
|
||||
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.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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.web.client.RequestCallback;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
|
||||
@Service
|
||||
@DependsOn("applicationContext")
|
||||
|
|
@ -32,6 +35,8 @@ public class KieRepositoryService {
|
|||
|
||||
private static Logger logger = LoggerFactory.getLogger(KieRepositoryService.class);
|
||||
|
||||
private static String chtijbugprefix="/chtijbug/";
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
|
|
@ -39,39 +44,13 @@ public class KieRepositoryService {
|
|||
|
||||
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) {
|
||||
|
||||
String assetContent = getAssetSource(url,
|
||||
username,
|
||||
password,
|
||||
spaceName,
|
||||
projectName,
|
||||
assetName);
|
||||
String completeurl = url + chtijbugprefix + spaceName + "/" + projectName + "/asset/" + assetName + "/source";
|
||||
logger.info("url updateAssetSource : {}", completeurl);
|
||||
|
||||
|
||||
String completeurl = url + "/chtijbug/" + spaceName + "/" + projectName + "/asset/" + assetName + "/source";
|
||||
logger.info("url moteur reco : " + completeurl);
|
||||
|
||||
ResponseEntity response = restTemplateKiewb
|
||||
restTemplateKiewb
|
||||
.execute(completeurl, HttpMethod.POST, requestCallback(assetSource, username, password), clientHttpResponse -> {
|
||||
String extractedResponse = null;
|
||||
if (clientHttpResponse.getBody() != null) {
|
||||
|
|
@ -79,27 +58,21 @@ public class KieRepositoryService {
|
|||
String result = s.hasNext() ? s.next() : "";
|
||||
extractedResponse = result;
|
||||
}
|
||||
ResponseEntity extractedValue = new ResponseEntity<>(extractedResponse, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
||||
return extractedValue;
|
||||
return new ResponseEntity<>(extractedResponse, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
||||
});
|
||||
|
||||
// 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) {
|
||||
String completeurl = url + "/chtijbug/" + spaceName + "/" + projectName + "/assets/" + assetName + "/source";
|
||||
logger.info("url moteur reco : " + completeurl);
|
||||
String completeurl = url + chtijbugprefix + spaceName + "/" + projectName + "/assets/" + assetName + "/source";
|
||||
logger.info("url getAssetSource : {}", completeurl);
|
||||
ResponseEntity<String> response = restTemplateKiewb
|
||||
.execute(completeurl, HttpMethod.GET, requestCallback(null, username, password), clientHttpResponse -> {
|
||||
String extractedResponse = null;
|
||||
String result=null;
|
||||
if (clientHttpResponse.getBody() != null) {
|
||||
Scanner s = new Scanner(clientHttpResponse.getBody()).useDelimiter("\\A");
|
||||
String result = s.hasNext() ? s.next() : "";
|
||||
extractedResponse = result;
|
||||
result = s.hasNext() ? s.next() : "";
|
||||
}
|
||||
ResponseEntity<String> extractedValue = new ResponseEntity<>(extractedResponse, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
||||
return extractedValue;
|
||||
return new ResponseEntity<>(result, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
||||
});
|
||||
String reponseMoteur;
|
||||
|
||||
|
|
@ -108,8 +81,8 @@ public class KieRepositoryService {
|
|||
}
|
||||
|
||||
public List<PlatformProjectResponse> getListSpaces2(String url, String username, String password) {
|
||||
String completeurl = url + "/chtijbug/detailedSpaces";
|
||||
logger.info("url moteur reco : " + completeurl);
|
||||
String completeurl = url + chtijbugprefix+"detailedSpaces";
|
||||
logger.info("url getListSpaces2 :{} ", completeurl);
|
||||
ResponseEntity<List<PlatformProjectResponse>> response = restTemplateKiewb
|
||||
.execute(completeurl, HttpMethod.GET, requestCallback(null, username, password), clientHttpResponse -> {
|
||||
List<PlatformProjectResponse> extractedResponse = null;
|
||||
|
|
@ -119,8 +92,7 @@ public class KieRepositoryService {
|
|||
PlatformProjectResponse[] values = mapper.readValue(result, PlatformProjectResponse[].class);
|
||||
extractedResponse = Arrays.asList(values);
|
||||
}
|
||||
ResponseEntity<List<PlatformProjectResponse>> extractedValue = new ResponseEntity<>(extractedResponse, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
||||
return extractedValue;
|
||||
return new ResponseEntity<>(extractedResponse, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
||||
});
|
||||
List<PlatformProjectResponse> reponseMoteur;
|
||||
|
||||
|
|
@ -131,7 +103,7 @@ public class KieRepositoryService {
|
|||
public UserConnected login(String url, String username, String password,String workbenchName) {
|
||||
|
||||
User user = userRepository.findByLogin(username);
|
||||
String completeurl = url + "/chtijbug/login";
|
||||
String completeurl = url + chtijbugprefix+"login";
|
||||
if (user != null && user.getPassword().equals(password)) {
|
||||
if (user.getCustomer()!= null &&
|
||||
user.getCustomer().getKieWorkbench()!= null
|
||||
|
|
@ -139,7 +111,7 @@ public class KieRepositoryService {
|
|||
completeurl = user.getCustomer().getKieWorkbench().getInternalUrl()+"/rest/chtijbug/login";
|
||||
}
|
||||
|
||||
logger.info("url moteur reco : " + completeurl);
|
||||
logger.info("url moteur reco : {}" , completeurl);
|
||||
ResponseEntity<UserLoginInformation> response = restTemplateKiewb
|
||||
.execute(completeurl, HttpMethod.GET, requestCallback(null, username, password), clientHttpResponse -> {
|
||||
UserLoginInformation extractedResponse = null;
|
||||
|
|
@ -149,8 +121,7 @@ public class KieRepositoryService {
|
|||
extractedResponse = mapper.readValue(result, UserLoginInformation.class);
|
||||
|
||||
}
|
||||
ResponseEntity<UserLoginInformation> extractedValue = new ResponseEntity<>(extractedResponse, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
||||
return extractedValue;
|
||||
return new ResponseEntity<>(extractedResponse, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
||||
});
|
||||
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) {
|
||||
String completeurl = url + "/chtijbug/" + spaceName + "/" + projectName + "/assets";
|
||||
logger.info("url moteur reco : " + completeurl);
|
||||
String completeurl = url + chtijbugprefix + spaceName + "/" + projectName + "/assets";
|
||||
logger.info("url getListAssets : {}" , completeurl);
|
||||
ResponseEntity<List<Asset>> response = restTemplateKiewb
|
||||
.execute(completeurl, HttpMethod.GET, requestCallback(null, username, password), clientHttpResponse -> {
|
||||
List<Asset> extractedResponse = null;
|
||||
|
|
@ -180,8 +151,7 @@ public class KieRepositoryService {
|
|||
Asset[] values = mapper.readValue(result, Asset[].class);
|
||||
extractedResponse = Arrays.asList(values);
|
||||
}
|
||||
ResponseEntity<List<Asset>> extractedValue = new ResponseEntity<>(extractedResponse, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
||||
return extractedValue;
|
||||
return new ResponseEntity<>(extractedResponse, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
||||
});
|
||||
List<Asset> reponseMoteur;
|
||||
|
||||
|
|
@ -194,7 +164,7 @@ public class KieRepositoryService {
|
|||
if (branchName!= null && branchName.length()>0){
|
||||
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
|
||||
.execute(completeurl, HttpMethod.POST, requestCallback(null, username, password), clientHttpResponse -> {
|
||||
JobStatus extractedResponse = null;
|
||||
|
|
@ -204,8 +174,7 @@ public class KieRepositoryService {
|
|||
JobStatus values = mapper.readValue(result, JobStatus.class);
|
||||
extractedResponse = values;
|
||||
}
|
||||
ResponseEntity<JobStatus> extractedValue = new ResponseEntity<>(extractedResponse, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
||||
return extractedValue;
|
||||
return new ResponseEntity<>(extractedResponse, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
||||
});
|
||||
JobStatus reponseMoteur;
|
||||
|
||||
|
|
@ -217,7 +186,7 @@ public class KieRepositoryService {
|
|||
public JobStatus getStatusJobID(String url, String username, String password, String jobID) {
|
||||
|
||||
String completeurl = url + "/jobs/" + jobID;
|
||||
logger.info("url moteur reco : " + completeurl);
|
||||
logger.info("url getStatusJobID : {}" , completeurl);
|
||||
ResponseEntity<JobStatus> response = restTemplateKiewb
|
||||
.execute(completeurl, HttpMethod.GET, requestCallback(null, username, password), clientHttpResponse -> {
|
||||
JobStatus extractedResponse = null;
|
||||
|
|
@ -227,8 +196,7 @@ public class KieRepositoryService {
|
|||
extractedResponse = mapper.readValue(result, JobStatus.class);
|
||||
|
||||
}
|
||||
ResponseEntity<JobStatus> extractedValue = new ResponseEntity<>(extractedResponse, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
||||
return extractedValue;
|
||||
return new ResponseEntity<>(extractedResponse, clientHttpResponse.getHeaders(), clientHttpResponse.getStatusCode());
|
||||
});
|
||||
JobStatus reponseMoteur;
|
||||
|
||||
|
|
@ -236,24 +204,8 @@ public class KieRepositoryService {
|
|||
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) {
|
||||
return clientHttpRequest -> {
|
||||
if (content != null) {
|
||||
|
|
@ -271,7 +223,7 @@ public class KieRepositoryService {
|
|||
HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE);
|
||||
String auth = username + ":" + password;
|
||||
byte[] encodedAuth = Base64.encodeBase64(
|
||||
auth.getBytes(Charset.forName("UTF-8")));
|
||||
auth.getBytes(StandardCharsets.UTF_8));
|
||||
String authHeader = "Basic " + new String(encodedAuth);
|
||||
clientHttpRequest.getHeaders().add(
|
||||
HttpHeaders.AUTHORIZATION, authHeader);
|
||||
|
|
|
|||
|
|
@ -28,28 +28,28 @@ public class RuntimeService {
|
|||
|
||||
private RestTemplate restTemplateKiewb = new RestTemplate();
|
||||
|
||||
public ReturnPerso verifyIfKieServerExist(String url) {
|
||||
public ReturnPerso<KieServerInfo> verifyIfKieServerExist(String url) {
|
||||
String completeurl = url + "/api/server/details";
|
||||
logger.info("url project content : " + completeurl);
|
||||
logger.info("url pverifyIfKieServerExist :{} " , completeurl);
|
||||
|
||||
HttpHeaders httpHeaders=new HttpHeaders();
|
||||
|
||||
HttpEntity httpEntity=new HttpEntity(httpHeaders);
|
||||
HttpEntity<Object> httpEntity=new HttpEntity<>(httpHeaders);
|
||||
|
||||
try {
|
||||
ResponseEntity<KieServerInfo> response = restTemplateKiewb.exchange(completeurl,
|
||||
HttpMethod.GET,
|
||||
httpEntity,
|
||||
new ParameterizedTypeReference<KieServerInfo>() {
|
||||
new ParameterizedTypeReference<>() {
|
||||
});
|
||||
|
||||
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 {
|
||||
return new ReturnPerso(false,"server error ",null);
|
||||
return new ReturnPerso<>(false,"server error ",null);
|
||||
}
|
||||
}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")
|
||||
public class UserConnectedService {
|
||||
|
||||
public static String USER = "1";
|
||||
public static String ASSET = "2";
|
||||
public static String SPACE = "3";
|
||||
public static String PROJECT = "4";
|
||||
public static String CURRENTPROJECT = "5";
|
||||
public final static String USER = "1";
|
||||
public final static String ASSET = "2";
|
||||
public final static String SPACE = "3";
|
||||
public final static String PROJECT = "4";
|
||||
public final static String CURRENTPROJECT = "5";
|
||||
|
||||
|
||||
public UserConnected getUserConnected() {
|
||||
|
|
|
|||
|
|
@ -12,68 +12,80 @@
|
|||
<artifactId>drools-framework-uberfire-security-service</artifactId>
|
||||
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.uberfire</groupId>
|
||||
<artifactId>uberfire-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.uberfire</groupId>
|
||||
<artifactId>uberfire-commons</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.kie.soup</groupId>
|
||||
<artifactId>kie-soup-commons</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.uberfire</groupId>
|
||||
<artifactId>uberfire-security-management-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.uberfire</groupId>
|
||||
<artifactId>uberfire-security-management-backend</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.inject</groupId>
|
||||
<artifactId>javax.inject</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jboss.errai</groupId>
|
||||
<artifactId>errai-javax-enterprise</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jboss.errai</groupId>
|
||||
<artifactId>errai-security-server</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jboss.errai</groupId>
|
||||
<artifactId>errai-bus</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.inject</groupId>
|
||||
<artifactId>javax.inject</artifactId>
|
||||
<scope>provided</scope>
|
||||
<version>1</version>
|
||||
</dependency>
|
||||
|
||||
<!--dependency>
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongodb-driver</artifactId>
|
||||
<version>${version.mongodb.driver}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency-->
|
||||
<version>${version.mongodb.driver}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
|||
|
|
@ -16,22 +16,26 @@
|
|||
|
||||
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.GroupImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.uberfire.commons.config.ConfigProperties;
|
||||
import org.uberfire.ext.security.management.api.*;
|
||||
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.SearchResponseImpl;
|
||||
import org.uberfire.ext.security.management.search.GroupsIdentifierRuntimeSearchEngine;
|
||||
import org.uberfire.ext.security.management.search.IdentifierRuntimeSearchEngine;
|
||||
import org.uberfire.ext.security.management.util.SecurityManagementUtils;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <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;
|
||||
|
||||
private MongoClient mongoClient;
|
||||
private CodecRegistry pojoCodecRegistry;
|
||||
private MongoDatabase database;
|
||||
|
||||
|
||||
public KiePlatformGroupManager() {
|
||||
this(new ConfigProperties(System.getProperties()));
|
||||
}
|
||||
|
|
@ -58,6 +67,12 @@ public class KiePlatformGroupManager implements GroupManager, ContextualManager
|
|||
// loadConfig(gitPrefs);
|
||||
}
|
||||
|
||||
public void setMongo (MongoClient mongoClient,CodecRegistry pojoCodecRegistry,MongoDatabase database){
|
||||
this.mongoClient=mongoClient;
|
||||
this.pojoCodecRegistry = pojoCodecRegistry;
|
||||
this.database=database;
|
||||
|
||||
}
|
||||
@Override
|
||||
public void initialize(UserSystemManager userSystemManager) throws Exception {
|
||||
groupsSearchEngine = new GroupsIdentifierRuntimeSearchEngine();
|
||||
|
|
@ -70,32 +85,42 @@ public class KiePlatformGroupManager implements GroupManager, ContextualManager
|
|||
|
||||
@Override
|
||||
public SearchResponse<Group> search(SearchRequest request) throws SecurityManagementException {
|
||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_SEARCH_GROUPS);
|
||||
SearchResponse<Group> result = new SearchResponseImpl<>();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Group get(String identifier) throws SecurityManagementException {
|
||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_READ_GROUP);
|
||||
Group group = new GroupImpl(identifier);
|
||||
return group;
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
public Group create(Group entity) throws SecurityManagementException {
|
||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_ADD_GROUP);
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Group update(Group entity) throws SecurityManagementException {
|
||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_UPDATE_GROUP);
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String... identifiers) throws SecurityManagementException {
|
||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_DELETE_GROUP);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -110,7 +135,7 @@ public class KiePlatformGroupManager implements GroupManager, ContextualManager
|
|||
}
|
||||
|
||||
protected CapabilityStatus getCapabilityStatus(Capability capability) {
|
||||
/**
|
||||
|
||||
if (capability != null) {
|
||||
switch (capability) {
|
||||
case CAN_SEARCH_GROUPS:
|
||||
|
|
@ -121,13 +146,12 @@ public class KiePlatformGroupManager implements GroupManager, ContextualManager
|
|||
return CapabilityStatus.ENABLED;
|
||||
}
|
||||
}
|
||||
**/
|
||||
return CapabilityStatus.UNSUPPORTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assignUsers(String name,
|
||||
Collection<String> users) throws SecurityManagementException {
|
||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_ASSIGN_GROUPS);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,25 +16,31 @@
|
|||
|
||||
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.RoleImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.uberfire.commons.config.ConfigProperties;
|
||||
import org.uberfire.ext.security.management.api.*;
|
||||
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.search.GroupsIdentifierRuntimeSearchEngine;
|
||||
import org.uberfire.ext.security.management.search.IdentifierRuntimeSearchEngine;
|
||||
import org.uberfire.ext.security.management.impl.SearchResponseImpl;
|
||||
import org.uberfire.ext.security.management.util.SecurityManagementUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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>
|
||||
*
|
||||
* @since 0.8.0
|
||||
*/
|
||||
public class KiePlatformRoleManager implements RoleManager, ContextualManager {
|
||||
|
|
@ -42,15 +48,15 @@ public class KiePlatformRoleManager implements RoleManager,ContextualManager {
|
|||
private static final Logger LOG = LoggerFactory.getLogger(KiePlatformRoleManager.class);
|
||||
|
||||
|
||||
|
||||
IdentifierRuntimeSearchEngine<Group> groupsSearchEngine;
|
||||
private MongoClient mongoClient;
|
||||
private CodecRegistry pojoCodecRegistry;
|
||||
private MongoDatabase database;
|
||||
|
||||
public KiePlatformRoleManager() {
|
||||
this(new ConfigProperties(System.getProperties()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public KiePlatformRoleManager(final Map<String, String> gitPrefs) {
|
||||
this(new ConfigProperties(gitPrefs));
|
||||
}
|
||||
|
|
@ -59,9 +65,16 @@ public class KiePlatformRoleManager implements RoleManager,ContextualManager {
|
|||
// loadConfig(gitPrefs);
|
||||
}
|
||||
|
||||
public void setMongo(MongoClient mongoClient, CodecRegistry pojoCodecRegistry, MongoDatabase database) {
|
||||
this.mongoClient = mongoClient;
|
||||
this.pojoCodecRegistry = pojoCodecRegistry;
|
||||
this.database = database;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(UserSystemManager userSystemManager) throws Exception {
|
||||
groupsSearchEngine = new GroupsIdentifierRuntimeSearchEngine();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -72,39 +85,49 @@ public class KiePlatformRoleManager implements RoleManager,ContextualManager {
|
|||
|
||||
@Override
|
||||
public SearchResponse<Role> search(SearchRequest request) throws SecurityManagementException {
|
||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_SEARCH_ROLES);
|
||||
SearchResponse<Role> roleSearchResponse = new SearchResponseImpl<>();
|
||||
return roleSearchResponse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Role get(String identifier) throws SecurityManagementException {
|
||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_READ_ROLE);
|
||||
RoleImpl role = new RoleImpl(identifier);
|
||||
return role;
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
public Role create(Role entity) throws SecurityManagementException {
|
||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_ADD_ROLE);
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Role update(Role entity) throws SecurityManagementException {
|
||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_UPDATE_ROLE);
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void delete(String... identifiers) throws SecurityManagementException {
|
||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_DELETE_ROLE);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
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) {
|
||||
capabilityStatusMap.put(capability,
|
||||
getCapabilityStatus(capability));
|
||||
|
|
@ -113,18 +136,19 @@ public class KiePlatformRoleManager implements RoleManager,ContextualManager {
|
|||
}
|
||||
|
||||
protected CapabilityStatus getCapabilityStatus(Capability capability) {
|
||||
/**
|
||||
|
||||
if (capability != null) {
|
||||
switch (capability) {
|
||||
case CAN_SEARCH_ROLES:
|
||||
case CAN_READ_ROLE:
|
||||
return CapabilityStatus.ENABLED;
|
||||
case CAN_ADD_ROLE:
|
||||
case CAN_UPDATE_ROLE:
|
||||
case CAN_READ_ROLE:
|
||||
case CAN_DELETE_ROLE:
|
||||
return CapabilityStatus.ENABLED;
|
||||
return CapabilityStatus.UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
**/
|
||||
|
||||
return CapabilityStatus.UNSUPPORTED;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
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.RoleManager;
|
||||
import org.uberfire.ext.security.management.api.UserManagementService;
|
||||
|
|
@ -10,6 +16,9 @@ import javax.enterprise.context.Dependent;
|
|||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import static org.bson.codecs.configuration.CodecRegistries.fromProviders;
|
||||
import static org.bson.codecs.configuration.CodecRegistries.fromRegistries;
|
||||
|
||||
@Dependent
|
||||
@Named(value = "PymmaKieSecurityService")
|
||||
public class KiePlatformSecurityService implements UserManagementService {
|
||||
|
|
@ -20,46 +29,48 @@ public class KiePlatformSecurityService implements UserManagementService {
|
|||
|
||||
private String connectionString;
|
||||
private String databaseName;
|
||||
// private MongoClient mongoClient;
|
||||
// private CodecRegistry pojoCodecRegistry;
|
||||
//private MongoDatabase database;
|
||||
private MongoClient mongoClient;
|
||||
private CodecRegistry pojoCodecRegistry;
|
||||
private MongoDatabase database;
|
||||
|
||||
|
||||
public KiePlatformSecurityService() {
|
||||
System.out.println("KiePlatformSecurityService initialized with databaseName = " + connectionString );
|
||||
}
|
||||
|
||||
@Inject
|
||||
public KiePlatformSecurityService(KiePlatformUserManager userManager,
|
||||
KiePlatformGroupManager groupManager,
|
||||
KiePlatformRoleManager roleManager) {
|
||||
//-DconnectionString=localhost:28017 -Ddatabase=businessProxyDB
|
||||
|
||||
connectionString = System.getProperty("connectionString");
|
||||
databaseName=System.getProperty("name");
|
||||
this.connectionString = System.getProperty("connectionString");
|
||||
this.databaseName=System.getProperty("database");
|
||||
System.out.println("KiePlatformSecurityService initialized with databaseName = " + connectionString );
|
||||
//mongoClient = MongoClients.create(connectionString);
|
||||
//pojoCodecRegistry = fromRegistries(MongoClientSettings.getDefaultCodecRegistry(),
|
||||
// fromProviders(PojoCodecProvider.builder().automatic(true).build()));
|
||||
// database = mongoClient.getDatabase(databaseName).withCodecRegistry(pojoCodecRegistry);
|
||||
this.mongoClient = MongoClients.create(connectionString);
|
||||
this.pojoCodecRegistry = fromRegistries(MongoClientSettings.getDefaultCodecRegistry(),
|
||||
fromProviders(PojoCodecProvider.builder().automatic(true).build()));
|
||||
this.database = mongoClient.getDatabase(databaseName).withCodecRegistry(pojoCodecRegistry);
|
||||
System.out.println("All setup");
|
||||
this.userManager = userManager;
|
||||
this.groupManager = groupManager;
|
||||
this.roleManager = roleManager;
|
||||
this.userManager.setMongo(mongoClient,pojoCodecRegistry,database);
|
||||
this.groupManager.setMongo(mongoClient,pojoCodecRegistry,database);
|
||||
this.roleManager.setMongo(mongoClient,pojoCodecRegistry,database);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public UserManager users() {
|
||||
return new KiePlatformUserManager();
|
||||
return userManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GroupManager groups() {
|
||||
return new KiePlatformGroupManager();
|
||||
return groupManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoleManager roles() {
|
||||
return new KiePlatformRoleManager();
|
||||
return roleManager;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,19 +16,34 @@
|
|||
|
||||
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.UserImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.uberfire.commons.config.ConfigProperties;
|
||||
import org.uberfire.ext.security.management.api.*;
|
||||
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.search.IdentifierRuntimeSearchEngine;
|
||||
import org.uberfire.ext.security.management.search.UsersIdentifierRuntimeSearchEngine;
|
||||
import org.uberfire.ext.security.management.util.SecurityManagementUtils;
|
||||
|
||||
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>
|
||||
|
|
@ -39,10 +54,10 @@ public class KiePlatformUserManager implements UserManager, ContextualManager {
|
|||
|
||||
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() {
|
||||
this(new ConfigProperties(System.getProperties()));
|
||||
|
|
@ -56,12 +71,16 @@ public class KiePlatformUserManager implements UserManager, ContextualManager {
|
|||
//loadConfig(gitPrefs);
|
||||
}
|
||||
|
||||
public void setMongo(MongoClient mongoClient, CodecRegistry pojoCodecRegistry, MongoDatabase database) {
|
||||
this.mongoClient = mongoClient;
|
||||
this.pojoCodecRegistry = pojoCodecRegistry;
|
||||
this.database = database;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(final UserSystemManager userSystemManager) throws Exception {
|
||||
this.userSystemManager = userSystemManager;
|
||||
usersSearchEngine = new UsersIdentifierRuntimeSearchEngine();
|
||||
System.out.println("All setup");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -71,32 +90,89 @@ public class KiePlatformUserManager implements UserManager, ContextualManager {
|
|||
|
||||
@Override
|
||||
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
|
||||
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
|
||||
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
|
||||
public User create(User entity) throws SecurityManagementException {
|
||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_ADD_USER);
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public User update(User entity) throws SecurityManagementException {
|
||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_UPDATE_USER);
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String... identifiers) throws SecurityManagementException {
|
||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_DELETE_USER);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -114,17 +190,14 @@ public class KiePlatformUserManager implements UserManager, ContextualManager {
|
|||
@Override
|
||||
public void assignGroups(String username,
|
||||
Collection<String> groups) throws SecurityManagementException {
|
||||
Set<String> userRoles = SecurityManagementUtils.rolesToString(SecurityManagementUtils.getRoles(userSystemManager,
|
||||
username));
|
||||
userRoles.addAll(groups);
|
||||
doAssignGroups(username,
|
||||
userRoles);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assignRoles(String username,
|
||||
Collection<String> roles) throws SecurityManagementException {
|
||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_ASSIGN_ROLES);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void doAssignGroups(String username,
|
||||
|
|
@ -135,12 +208,12 @@ public class KiePlatformUserManager implements UserManager, ContextualManager {
|
|||
@Override
|
||||
public void changePassword(String username,
|
||||
String newPassword) throws SecurityManagementException {
|
||||
throw new UnsupportedServiceCapabilityException(Capability.CAN_CHANGE_PASSWORD);
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected CapabilityStatus getCapabilityStatus(Capability capability) {
|
||||
/**
|
||||
|
||||
if (capability != null) {
|
||||
switch (capability) {
|
||||
case CAN_SEARCH_USERS:
|
||||
|
|
@ -156,7 +229,7 @@ public class KiePlatformUserManager implements UserManager, ContextualManager {
|
|||
return CapabilityStatus.ENABLED;
|
||||
}
|
||||
}
|
||||
**/
|
||||
|
||||
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>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${basedir}/target//unpack-tmp/WEB-INF/classes/META-INF</outputDirectory>
|
||||
<outputDirectory>${basedir}/target/unpack-tmp/</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<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: 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: 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: 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: org.kie:kie-internal:7.40.0.20200703" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-api:7.40.0.20200703" 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:kie-internal:7.42.0.Final" 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.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: 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" />
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;
|
|||
import org.springframework.kafka.core.*;
|
||||
import org.springframework.kafka.support.serializer.JsonDeserializer;
|
||||
import org.springframework.kafka.support.serializer.JsonSerializer;
|
||||
import org.springframework.kafka.transaction.KafkaTransactionManager;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
|
@ -104,13 +105,21 @@ public class DroolsBusinessProxyServer {
|
|||
configProps.put(
|
||||
ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG,
|
||||
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
|
||||
public KafkaTemplate<String, KieContainerResponse> kafkaKieContainerUpdateResponsableTemplate() {
|
||||
return new KafkaTemplate<>(producerKieContainerResponseactory());
|
||||
}
|
||||
@Bean
|
||||
@Bean(name="deployFinish")
|
||||
public NewTopic actionDeployResponseTopic() {
|
||||
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 org.apache.camel.CamelContext;
|
||||
import org.apache.camel.Route;
|
||||
import org.apache.kafka.clients.admin.NewTopic;
|
||||
import org.chtijbug.drools.KieContainerResponse;
|
||||
import org.chtijbug.drools.KieContainerUpdate;
|
||||
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.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.kafka.annotation.KafkaListener;
|
||||
|
|
@ -91,6 +93,10 @@ public class KieServiceCommon {
|
|||
@Autowired
|
||||
KafkaTemplate<String, KieContainerResponse> kafkaKieContainerUpdateResponseTemplate;
|
||||
|
||||
@Qualifier("deployFinish")
|
||||
@Autowired
|
||||
NewTopic responseTopic;
|
||||
|
||||
public KieServiceCommon() {
|
||||
// for now, if no server impl is passed as parameter, create one
|
||||
// this.server = KieServerLocator.getInstance();
|
||||
|
|
@ -333,8 +339,8 @@ public class KieServiceCommon {
|
|||
}
|
||||
KieContainerResponse kieContainerResponse = new KieContainerResponse();
|
||||
kieContainerResponse.setStatus(KieContainerResponse.STATUS.SUCCESS);
|
||||
|
||||
kafkaKieContainerUpdateResponseTemplate.send(KafkaTopicConstants.RESPONSE_DEPLOY_TOPIC,kieContainerResponse);
|
||||
kafkaKieContainerUpdateResponseTemplate.executeInTransaction(kt ->
|
||||
kt.send(KafkaTopicConstants.RESPONSE_DEPLOY_TOPIC,kieContainerResponse));
|
||||
|
||||
}catch (Exception e){
|
||||
KieContainerResponse kieContainerResponse = new KieContainerResponse();
|
||||
|
|
@ -344,7 +350,9 @@ public class KieServiceCommon {
|
|||
for (StackTraceElement stackTraceElement : e.getStackTrace()){
|
||||
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:2.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: 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: org.kie:kie-internal:7.40.0.20200703" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-api:7.40.0.20200703" 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:kie-internal:7.42.0.Final" 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.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: 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" />
|
||||
|
|
|
|||
2
pom.xml
2
pom.xml
|
|
@ -17,7 +17,7 @@
|
|||
<packaging>pom</packaging>
|
||||
|
||||
<properties>
|
||||
<jbpm.version>7.40.0.20200703</jbpm.version>
|
||||
<jbpm.version>7.42.0.Final</jbpm.version>
|
||||
<node.version>v10.16.3</node.version>
|
||||
<npm.version>6.11.3</npm.version>
|
||||
<frontend-maven-plugin.version>1.8.0</frontend-maven-plugin.version>
|
||||
|
|
|
|||
Loading…
Add table
editor.link_modal.header
Reference in a new issue