work on login module
This commit is contained in:
parent
760ae20f49
commit
6c625e1edb
12 changed files with 151 additions and 46 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
|
||||
|
|
|
|||
|
|
@ -68,12 +68,11 @@
|
|||
<version>1</version>
|
||||
</dependency>
|
||||
|
||||
<!--dependency>
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongodb-driver</artifactId>
|
||||
<version>${version.mongodb.driver}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency-->
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@
|
|||
|
||||
package org.chtijbug.guvnor.uberfire.security;
|
||||
|
||||
import com.mongodb.client.MongoClient;
|
||||
import com.mongodb.client.MongoDatabase;
|
||||
import org.bson.codecs.configuration.CodecRegistry;
|
||||
import org.jboss.errai.security.shared.api.Group;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -45,6 +48,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 +66,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();
|
||||
|
|
|
|||
|
|
@ -16,41 +16,47 @@
|
|||
|
||||
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 {
|
||||
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,7 +136,7 @@ public class KiePlatformRoleManager implements RoleManager,ContextualManager {
|
|||
}
|
||||
|
||||
protected CapabilityStatus getCapabilityStatus(Capability capability) {
|
||||
/**
|
||||
|
||||
if (capability != null) {
|
||||
switch (capability) {
|
||||
case CAN_SEARCH_ROLES:
|
||||
|
|
@ -124,7 +147,7 @@ public class KiePlatformRoleManager implements RoleManager,ContextualManager {
|
|||
return CapabilityStatus.ENABLED;
|
||||
}
|
||||
}
|
||||
**/
|
||||
|
||||
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,30 +29,32 @@ 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");
|
||||
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);
|
||||
mongoClient = MongoClients.create(connectionString);
|
||||
pojoCodecRegistry = fromRegistries(MongoClientSettings.getDefaultCodecRegistry(),
|
||||
fromProviders(PojoCodecProvider.builder().automatic(true).build()));
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@
|
|||
|
||||
package org.chtijbug.guvnor.uberfire.security;
|
||||
|
||||
import com.mongodb.client.MongoClient;
|
||||
import com.mongodb.client.MongoDatabase;
|
||||
import org.bson.codecs.configuration.CodecRegistry;
|
||||
import org.jboss.errai.security.shared.api.identity.User;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -42,7 +45,9 @@ public class KiePlatformUserManager implements UserManager, ContextualManager {
|
|||
UserSystemManager userSystemManager;
|
||||
IdentifierRuntimeSearchEngine<User> usersSearchEngine;
|
||||
|
||||
|
||||
private MongoClient mongoClient;
|
||||
private CodecRegistry pojoCodecRegistry;
|
||||
private MongoDatabase database;
|
||||
|
||||
public KiePlatformUserManager() {
|
||||
this(new ConfigProperties(System.getProperties()));
|
||||
|
|
@ -56,7 +61,12 @@ 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 {
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
org.jboss.weld.level=DEBUG
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<jboss-deployment-structure>
|
||||
|
||||
<deployment>
|
||||
|
||||
<dependencies>
|
||||
<module name="com.pymmasoftware.pymma-kie-loginmodule" export="TRUE" />
|
||||
</dependencies>
|
||||
|
||||
</deployment>
|
||||
|
||||
</jboss-deployment-structure>
|
||||
|
|
@ -77,7 +77,7 @@
|
|||
<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" />
|
||||
|
|
|
|||
|
|
@ -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,7 +39,7 @@
|
|||
<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" />
|
||||
|
|
|
|||
Loading…
Add table
editor.link_modal.header
Reference in a new issue