users) throws SecurityManagementException {
- if (name == null) {
- throw new NullPointerException();
- }
- if (users != null) {
- MemoryUserDatabase userDatabase = getDatabase();
- org.apache.catalina.Role role = getRole(userDatabase,
- name);
- try {
- for (String username : users) {
- org.apache.catalina.User user = getUser(userDatabase,
- username);
- user.addRole(role);
- }
- saveDatabase(userDatabase);
- } finally {
- closeDatabase(userDatabase);
- }
- }
- }
-}
diff --git a/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/src/main/java/org/uberfire/ext/security/management/tomcat/TomcatUserManagementService.java b/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/src/main/java/org/uberfire/ext/security/management/tomcat/TomcatUserManagementService.java
deleted file mode 100644
index 22feb66171..0000000000
--- a/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/src/main/java/org/uberfire/ext/security/management/tomcat/TomcatUserManagementService.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2016 Red Hat, Inc. and/or its affiliates.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.uberfire.ext.security.management.tomcat;
-
-import javax.enterprise.context.Dependent;
-import javax.inject.Inject;
-import javax.inject.Named;
-
-import org.uberfire.ext.security.management.UberfireRoleManager;
-import org.uberfire.ext.security.management.api.GroupManager;
-import org.uberfire.ext.security.management.api.UserManager;
-import org.uberfire.ext.security.management.service.AbstractUserManagementService;
-
-/**
- * The Tomcat management service beans.
- * @since 0.8.0
- */
-@Dependent
-@Named(value = "TomcatUserManagementService")
-public class TomcatUserManagementService extends AbstractUserManagementService {
-
- TomcatUserManager userManager;
- TomcatGroupManager groupManager;
-
- @Inject
- public TomcatUserManagementService(final TomcatUserManager userManager,
- final TomcatGroupManager groupManager,
- final @Named("uberfireRoleManager") UberfireRoleManager roleManager) {
- super(roleManager);
- this.userManager = userManager;
- this.groupManager = groupManager;
- }
-
- @Override
- public UserManager users() {
- return userManager;
- }
-
- @Override
- public GroupManager groups() {
- return groupManager;
- }
-}
diff --git a/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/src/main/java/org/uberfire/ext/security/management/tomcat/TomcatUserManager.java b/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/src/main/java/org/uberfire/ext/security/management/tomcat/TomcatUserManager.java
deleted file mode 100644
index 2417ecc104..0000000000
--- a/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/src/main/java/org/uberfire/ext/security/management/tomcat/TomcatUserManager.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Copyright 2016 Red Hat, Inc. and/or its affiliates.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.uberfire.ext.security.management.tomcat;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.catalina.Role;
-import org.apache.catalina.users.MemoryUserDatabase;
-import org.jboss.errai.security.shared.api.identity.User;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.uberfire.commons.config.ConfigProperties;
-import org.uberfire.ext.security.management.api.Capability;
-import org.uberfire.ext.security.management.api.CapabilityStatus;
-import org.uberfire.ext.security.management.api.ContextualManager;
-import org.uberfire.ext.security.management.api.UserManager;
-import org.uberfire.ext.security.management.api.UserManagerSettings;
-import org.uberfire.ext.security.management.api.UserSystemManager;
-import org.uberfire.ext.security.management.api.exception.SecurityManagementException;
-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 static org.kie.soup.commons.validation.PortablePreconditions.checkNotNull;
-
-/**
- * Users manager service provider implementation for Apache tomcat, when using default realm based on properties files.
- *
- * @since 0.8.0
- */
-public class TomcatUserManager extends BaseTomcatManager implements UserManager,
- ContextualManager {
-
- private static final Logger LOG = LoggerFactory.getLogger(TomcatUserManager.class);
-
- UserSystemManager userSystemManager;
- IdentifierRuntimeSearchEngine usersSearchEngine;
-
- public TomcatUserManager() {
- this(new ConfigProperties(System.getProperties()));
- }
-
- public TomcatUserManager(final Map gitPrefs) {
- this(new ConfigProperties(gitPrefs));
- }
-
- public TomcatUserManager(final ConfigProperties gitPrefs) {
- loadConfig(gitPrefs);
- }
-
- @Override
- public void initialize(final UserSystemManager userSystemManager) throws Exception {
- this.userSystemManager = userSystemManager;
- usersSearchEngine = new UsersIdentifierRuntimeSearchEngine();
- }
-
- @Override
- public void destroy() throws Exception {
-
- }
-
- @Override
- public SearchResponse search(SearchRequest request) throws SecurityManagementException {
- List users = getAll();
- return usersSearchEngine.search(users, request);
- }
-
- @Override
- public User get(String identifier) throws SecurityManagementException {
- MemoryUserDatabase userDatabase = getDatabase();
- try {
- org.apache.catalina.User user = getUser(userDatabase,
- identifier);
- Iterator groups = user.getRoles();
-
- User u = createUser(user,
- groups);
- u.setProperty(ATTRIBUTE_USER_FULLNAME,
- user.getFullName() != null ? user.getFullName() : "");
- return u;
- } finally {
- closeDatabase(userDatabase);
- }
- }
-
- @Override
- public List getAll() throws SecurityManagementException {
- MemoryUserDatabase userDatabase = getDatabase();
- try {
- Iterator userIterator = userDatabase.getUsers();
- List users = new ArrayList<>();
- if (userIterator != null) {
- while (userIterator.hasNext()) {
- org.apache.catalina.User user = userIterator.next();
- Iterator groups = user.getRoles();
- users.add(createUser(user, groups));
- }
- }
- return users;
- } finally {
- closeDatabase(userDatabase);
- }
- }
-
- @Override
- public User create(User entity) throws SecurityManagementException {
- checkNotNull("entity",
- entity);
-
- MemoryUserDatabase userDatabase = getDatabase();
- try {
- String username = entity.getIdentifier();
- String fullName = entity.getProperty(ATTRIBUTE_USER_FULLNAME);
- userDatabase.createUser(username,
- "",
- fullName != null ? fullName : "");
- saveDatabase(userDatabase);
- return entity;
- } finally {
- closeDatabase(userDatabase);
- }
- }
-
- @Override
- public User update(User entity) throws SecurityManagementException {
- checkNotNull("entity",
- entity);
-
- MemoryUserDatabase userDatabase = getDatabase();
- try {
- org.apache.catalina.User user = getUser(userDatabase,
- entity.getIdentifier());
- String fName = entity.getProperty(ATTRIBUTE_USER_FULLNAME);
- user.setFullName(fName != null ? fName : "");
- saveDatabase(userDatabase);
- return entity;
- } finally {
- closeDatabase(userDatabase);
- }
- }
-
- @Override
- public void delete(String... identifiers) throws SecurityManagementException {
- checkNotNull("identifiers",
- identifiers);
- MemoryUserDatabase userDatabase = getDatabase();
- try {
- for (String identifier : identifiers) {
- org.apache.catalina.User user = getUser(userDatabase,
- identifier);
- userDatabase.removeUser(user);
- }
- saveDatabase(userDatabase);
- } finally {
- closeDatabase(userDatabase);
- }
- }
-
- @Override
- public UserManagerSettings getSettings() {
- final Map capabilityStatusMap = new HashMap(8);
- for (final Capability capability : SecurityManagementUtils.USERS_CAPABILITIES) {
- capabilityStatusMap.put(capability,
- getCapabilityStatus(capability));
- }
- return new UserManagerSettingsImpl(capabilityStatusMap,
- USER_ATTRIBUTES);
- }
-
- @Override
- public void assignGroups(String username,
- Collection groups) throws SecurityManagementException {
- Set userRoles = SecurityManagementUtils.rolesToString(SecurityManagementUtils.getRoles(userSystemManager,
- username));
- userRoles.addAll(groups);
- doAssignGroups(username,
- userRoles);
- }
-
- @Override
- public void assignRoles(String username,
- Collection roles) throws SecurityManagementException {
- Set userGroups = SecurityManagementUtils.groupsToString(SecurityManagementUtils.getGroups(userSystemManager,
- username));
- userGroups.addAll(roles);
- doAssignGroups(username,
- userGroups);
- }
-
- private void doAssignGroups(String username,
- Collection ids) throws SecurityManagementException {
- MemoryUserDatabase userDatabase = getDatabase();
- try {
- org.apache.catalina.User user = getUser(userDatabase,
- username);
- user.removeRoles();
- if (!ids.isEmpty()) {
- for (String roleName : ids) {
- org.apache.catalina.Role role = getRole(userDatabase,
- roleName);
- user.addRole(role);
- }
- }
- saveDatabase(userDatabase);
- } finally {
- closeDatabase(userDatabase);
- }
- }
-
- @Override
- public void changePassword(String username,
- String newPassword) throws SecurityManagementException {
- checkNotNull("username",
- username);
-
- MemoryUserDatabase userDatabase = getDatabase();
- try {
- org.apache.catalina.User user = getUser(userDatabase,
- username);
- user.setPassword(newPassword);
- saveDatabase(userDatabase);
- } finally {
- closeDatabase(userDatabase);
- }
- }
-
- protected CapabilityStatus getCapabilityStatus(Capability capability) {
- if (capability != null) {
- switch (capability) {
- case CAN_SEARCH_USERS:
- case CAN_ADD_USER:
- case CAN_UPDATE_USER:
- case CAN_DELETE_USER:
- case CAN_READ_USER:
- case CAN_MANAGE_ATTRIBUTES:
- case CAN_ASSIGN_GROUPS:
- /** As it is using the UberfireRoleManager. **/
- case CAN_ASSIGN_ROLES:
- case CAN_CHANGE_PASSWORD:
- return CapabilityStatus.ENABLED;
- }
- }
- return CapabilityStatus.UNSUPPORTED;
- }
-}
diff --git a/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/src/main/resources/META-INF/beans.xml b/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/src/main/resources/META-INF/beans.xml
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/src/test/java/org/uberfire/ext/security/management/tomcat/TomcatGroupManagerTest.java b/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/src/test/java/org/uberfire/ext/security/management/tomcat/TomcatGroupManagerTest.java
deleted file mode 100644
index 68dd74494a..0000000000
--- a/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/src/test/java/org/uberfire/ext/security/management/tomcat/TomcatGroupManagerTest.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Copyright 2016 Red Hat, Inc. and/or its affiliates.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.uberfire.ext.security.management.tomcat;
-
-import java.io.File;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.io.FileUtils;
-import org.jboss.errai.security.shared.api.Group;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.junit.runner.RunWith;
-import org.mockito.Spy;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.uberfire.commons.config.ConfigProperties;
-import org.uberfire.ext.security.management.BaseTest;
-import org.uberfire.ext.security.management.api.AbstractEntityManager;
-import org.uberfire.ext.security.management.api.Capability;
-import org.uberfire.ext.security.management.api.CapabilityStatus;
-import org.uberfire.ext.security.management.api.exception.GroupNotFoundException;
-import org.uberfire.ext.security.management.api.exception.UnsupportedServiceCapabilityException;
-import org.uberfire.ext.security.management.util.SecurityManagementUtils;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
-
-/**
- * This tests create temporary working copy of the "tomcat-users.xml" file as the tests are run using the real tomcat admin api for realm management.
- */
-@RunWith(MockitoJUnitRunner.Silent.class)
-public class TomcatGroupManagerTest extends BaseTest {
-
- protected static final String ADMIN = "admin";
- protected static final String USERS_FILE_PATH = "org/uberfire/ext/security/management/tomcat/";
- protected static final String USERS_FILE_NAME = "tomcat-users.xml";
-
- @ClassRule
- public static TemporaryFolder tempFolder = new TemporaryFolder();
-
- private static File elHome;
-
- @Spy
- private TomcatGroupManager groupsManager = new TomcatGroupManager();
-
- @BeforeClass
- public static void initWorkspace() throws Exception {
- elHome = tempFolder.newFolder("uf-extensions-security-management-tomcat");
- }
-
- @Before
- public void setup() throws Exception {
- URL templateURL = Thread.currentThread().getContextClassLoader().getResource(USERS_FILE_PATH + USERS_FILE_NAME);
- File templateFile = new File(templateURL.getFile());
- FileUtils.cleanDirectory(elHome);
- FileUtils.copyFileToDirectory(templateFile,
- elHome);
- String full = new File(elHome,
- templateFile.getName()).getAbsolutePath();
- String path = full.substring(0,
- full.lastIndexOf(File.separator));
- String name = full.substring(full.lastIndexOf(File.separator) + 1,
- full.length());
- Map props = new HashMap(1);
- props.put("org.uberfire.ext.security.management.tomcat.catalina-base",
- path);
- props.put("org.uberfire.ext.security.management.tomcat.users-file",
- name);
- System.setProperty(BaseTomcatManager.CATALINA_BASE_PROPERTY,
- "");
- groupsManager.loadConfig(new ConfigProperties(props));
- groupsManager.initialize(userSystemManager);
- }
-
- @After
- public void finishIt() throws Exception {
- groupsManager.destroy();
- }
-
- @Test
- public void testCapabilities() {
- assertEquals(groupsManager.getCapabilityStatus(Capability.CAN_SEARCH_GROUPS),
- CapabilityStatus.ENABLED);
- assertEquals(groupsManager.getCapabilityStatus(Capability.CAN_READ_GROUP),
- CapabilityStatus.ENABLED);
- assertEquals(groupsManager.getCapabilityStatus(Capability.CAN_ADD_GROUP),
- CapabilityStatus.ENABLED);
- assertEquals(groupsManager.getCapabilityStatus(Capability.CAN_DELETE_GROUP),
- CapabilityStatus.ENABLED);
- assertEquals(groupsManager.getCapabilityStatus(Capability.CAN_UPDATE_GROUP),
- CapabilityStatus.UNSUPPORTED);
- }
-
- @Test
- public void testAllowsEmpty() {
- assertTrue(groupsManager.getSettings().allowEmpty());
- }
-
- @Test(expected = RuntimeException.class)
- public void testSearchPageZero() {
- AbstractEntityManager.SearchRequest request = buildSearchRequestMock("",
- 0,
- 5);
- AbstractEntityManager.SearchResponse response = groupsManager.search(request);
- }
-
- @Test
- public void testSearchAll() {
- AbstractEntityManager.SearchRequest request = buildSearchRequestMock("",
- 1,
- 5);
- AbstractEntityManager.SearchResponse response = groupsManager.search(request);
- assertNotNull(response);
- List groups = response.getResults();
- int total = response.getTotal();
- boolean hasNextPage = response.hasNextPage();
- assertEquals(total,
- 4);
- assertTrue(!hasNextPage);
- assertEquals(groups.size(),
- 4);
- List expectedGroups = createGroupList(ADMIN,
- "role3",
- "role2",
- "role1");
- assertEquals(new HashSet(expectedGroups),
- new HashSet(groups));
- }
-
- @Test
- public void testGet() {
- assertGet(ADMIN);
- assertGet("role1");
- assertGet("role2");
- assertGet("role3");
- }
-
- @Test
- public void testGetAllGroups() {
- List groups = groupsManager.getAll();
- assertEquals(groups.size(),
- 4);
- }
-
- @Test
- public void testCreateGroup() {
- Group group = mock(Group.class);
- when(group.getName()).thenReturn("role10");
- groupsManager.create(group);
- Group created = groupsManager.get("role10");
- assertNotNull(created);
- assertEquals("role10",
- created.getName());
- }
-
- @Test(expected = UnsupportedServiceCapabilityException.class)
- public void testUpdateGroup() {
- Group group = mock(Group.class);
- groupsManager.update(group);
- }
-
- @Test(expected = GroupNotFoundException.class)
- public void testDeleteGroup() {
- groupsManager.delete("role3");
- groupsManager.get("role3");
- }
-
- private List createGroupList(String... names) {
- if (names != null) {
- List result = new ArrayList(names.length);
- for (int x = 0; x < names.length; x++) {
- String name = names[x];
- Group g = SecurityManagementUtils.createGroup(name);
- result.add(g);
- }
- return result;
- }
- return null;
- }
-
- private void assertGet(String name) {
- Group group = groupsManager.get(name);
- assertNotNull(group);
- assertEquals(group.getName(),
- name);
- }
-}
diff --git a/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/src/test/java/org/uberfire/ext/security/management/tomcat/TomcatUserManagerTest.java b/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/src/test/java/org/uberfire/ext/security/management/tomcat/TomcatUserManagerTest.java
deleted file mode 100644
index 90aca9bf6e..0000000000
--- a/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/src/test/java/org/uberfire/ext/security/management/tomcat/TomcatUserManagerTest.java
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
- * Copyright 2016 Red Hat, Inc. and/or its affiliates.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.uberfire.ext.security.management.tomcat;
-
-import java.io.File;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.catalina.users.MemoryUserDatabase;
-import org.apache.commons.io.FileUtils;
-import org.jboss.errai.security.shared.api.Group;
-import org.jboss.errai.security.shared.api.Role;
-import org.jboss.errai.security.shared.api.identity.User;
-import org.jboss.errai.security.shared.api.identity.UserImpl;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.junit.runner.RunWith;
-import org.mockito.Spy;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.mockito.stubbing.Answer;
-import org.uberfire.backend.server.security.RoleRegistry;
-import org.uberfire.commons.config.ConfigProperties;
-import org.uberfire.ext.security.management.BaseTest;
-import org.uberfire.ext.security.management.api.AbstractEntityManager;
-import org.uberfire.ext.security.management.api.Capability;
-import org.uberfire.ext.security.management.api.CapabilityStatus;
-import org.uberfire.ext.security.management.api.UserManager;
-import org.uberfire.ext.security.management.api.exception.UserNotFoundException;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
-
-/**
- * This tests create temporary working copy of the "tomcat-users.xml" file as the tests are run using the real tomcat admin api for realm management.
- */
-@RunWith(MockitoJUnitRunner.Silent.class)
-public class TomcatUserManagerTest extends BaseTest {
-
- protected static final String ADMIN = "admin";
- protected static final String USERS_FILE_PATH = "org/uberfire/ext/security/management/tomcat/";
- protected static final String USERS_FILE_NAME = "tomcat-users.xml";
-
- @ClassRule
- public static TemporaryFolder tempFolder = new TemporaryFolder();
-
- private static File elHome;
-
- @Spy
- private TomcatUserManager usersManager = new TomcatUserManager();
-
- @BeforeClass
- public static void initWorkspace() throws Exception {
- elHome = tempFolder.newFolder("uf-extensions-security-management-tomcat");
- RoleRegistry.get().clear();
- }
-
- @Before
- public void setup() throws Exception {
- URL templateURL = Thread.currentThread().getContextClassLoader().getResource(USERS_FILE_PATH + USERS_FILE_NAME);
- File templateFile = new File(templateURL.getFile());
- FileUtils.cleanDirectory(elHome);
- FileUtils.copyFileToDirectory(templateFile,
- elHome);
- String full = new File(elHome,
- templateFile.getName()).getAbsolutePath();
- String path = full.substring(0,
- full.lastIndexOf(File.separator));
- String name = full.substring(full.lastIndexOf(File.separator) + 1,
- full.length());
- Map props = new HashMap(1);
- props.put("org.uberfire.ext.security.management.tomcat.catalina-base",
- path);
- props.put("org.uberfire.ext.security.management.tomcat.users-file",
- name);
- System.setProperty(BaseTomcatManager.CATALINA_BASE_PROPERTY,
- "");
- usersManager.loadConfig(new ConfigProperties(props));
- usersManager.initialize(userSystemManager);
- }
-
- @After
- public void finishIt() throws Exception {
- usersManager.destroy();
- }
-
- @Test
- public void testCapabilities() {
- assertEquals(usersManager.getCapabilityStatus(Capability.CAN_SEARCH_USERS),
- CapabilityStatus.ENABLED);
- assertEquals(usersManager.getCapabilityStatus(Capability.CAN_READ_USER),
- CapabilityStatus.ENABLED);
- assertEquals(usersManager.getCapabilityStatus(Capability.CAN_UPDATE_USER),
- CapabilityStatus.ENABLED);
- assertEquals(usersManager.getCapabilityStatus(Capability.CAN_ADD_USER),
- CapabilityStatus.ENABLED);
- assertEquals(usersManager.getCapabilityStatus(Capability.CAN_DELETE_USER),
- CapabilityStatus.ENABLED);
- assertEquals(usersManager.getCapabilityStatus(Capability.CAN_MANAGE_ATTRIBUTES),
- CapabilityStatus.ENABLED);
- assertEquals(usersManager.getCapabilityStatus(Capability.CAN_ASSIGN_GROUPS),
- CapabilityStatus.ENABLED);
- assertEquals(usersManager.getCapabilityStatus(Capability.CAN_CHANGE_PASSWORD),
- CapabilityStatus.ENABLED);
- assertEquals(usersManager.getCapabilityStatus(Capability.CAN_ASSIGN_ROLES),
- CapabilityStatus.ENABLED);
- }
-
- @Test
- public void testAttributes() {
- final Collection USER_ATTRIBUTES = Arrays.asList(BaseTomcatManager.USER_FULLNAME);
- Collection attributes = usersManager.getSettings().getSupportedAttributes();
- assertEquals(attributes,
- USER_ATTRIBUTES);
- }
-
- @Test(expected = RuntimeException.class)
- public void testSearchPageZero() {
- AbstractEntityManager.SearchRequest request = buildSearchRequestMock("",
- 0,
- 5);
- AbstractEntityManager.SearchResponse response = usersManager.search(request);
- }
-
- @Test
- public void testSearchAll() {
- AbstractEntityManager.SearchRequest request = buildSearchRequestMock("",
- 1,
- 5);
- AbstractEntityManager.SearchResponse response = usersManager.search(request);
- assertNotNull(response);
- List users = response.getResults();
- int total = response.getTotal();
- boolean hasNextPage = response.hasNextPage();
- assertEquals(total,
- 4);
- assertTrue(!hasNextPage);
- assertEquals(users.size(),
- 4);
- Set expectedUsers = new HashSet(4);
- expectedUsers.add(create(ADMIN));
- expectedUsers.add(create("user1"));
- expectedUsers.add(create("user2"));
- expectedUsers.add(create("user3"));
- assertThat(new HashSet(users),
- is(expectedUsers));
- }
-
- @Test
- public void testGetAdmin() {
- User user = usersManager.get(ADMIN);
- assertUser(user,
- ADMIN);
- }
-
- @Test
- public void testGetUser1() {
- User user = usersManager.get("user1");
- assertUser(user,
- "user1");
- }
-
- @Test
- public void testGetUser2() {
- User user = usersManager.get("user2");
- assertUser(user,
- "user2");
- }
-
- @Test
- public void testGetUser3() {
- User user = usersManager.get("user3");
- assertUser(user,
- "user3");
- }
-
- @Test
- public void testGetAllUsers() {
- List users = usersManager.getAll();
- assertEquals(4, users.size());
- }
-
- @Test
- public void testCreateUser() {
- User user = mock(User.class);
- when(user.getIdentifier()).thenReturn("user4");
- User userCreated = usersManager.create(user);
- assertUser(userCreated,
- "user4");
- }
-
- @Test
- public void testUpdateUser() {
- User user = mock(User.class);
- when(user.getIdentifier()).thenReturn("user1");
- Map properties = new HashMap(1);
- properties.put(BaseTomcatManager.ATTRIBUTE_USER_FULLNAME,
- "user1 Full Name");
- when(user.getProperty(BaseTomcatManager.ATTRIBUTE_USER_FULLNAME)).thenReturn("user1 Full Name");
- User userUpdated = usersManager.update(user);
- assertNotNull(userUpdated);
- assertEquals("user1 Full Name",
- userUpdated.getProperty(BaseTomcatManager.ATTRIBUTE_USER_FULLNAME));
- }
-
- @Test(expected = UserNotFoundException.class)
- public void testDeleteUser() {
- usersManager.delete("user1");
- usersManager.get("user1");
- }
-
- @Test
- public void testAssignGroups() {
- final User user = mock(User.class);
- when(user.getRoles()).thenReturn(new HashSet());
- UserManager userManagerMock = mock(UserManager.class);
- doAnswer(new Answer() {
- @Override
- public User answer(InvocationOnMock invocationOnMock) throws Throwable {
- return user;
- }
- }).when(userManagerMock).get("user1");
- when(userSystemManager.users()).thenReturn(userManagerMock);
- Collection groups = new ArrayList();
- groups.add("role1");
- groups.add("role3");
- usersManager.assignGroups("user1",
- groups);
- Set result = usersManager.get("user1").getGroups();
- assertNotNull(result);
- assertEquals(2,
- result.size());
- }
-
- @Test
- public void testAssignRoles() {
- RoleRegistry.get().registerRole("role1");
- RoleRegistry.get().registerRole("role3");
- final User user = mock(User.class);
- when(user.getGroups()).thenReturn(new HashSet());
- UserManager userManagerMock = mock(UserManager.class);
- doAnswer(new Answer() {
- @Override
- public User answer(InvocationOnMock invocationOnMock) throws Throwable {
- return user;
- }
- }).when(userManagerMock).get("user1");
- when(userSystemManager.users()).thenReturn(userManagerMock);
- Collection roles = new ArrayList();
- roles.add("role1");
- roles.add("role3");
- usersManager.assignRoles("user1",
- roles);
- Set result = usersManager.get("user1").getRoles();
- assertNotNull(result);
- assertEquals(2,
- result.size());
- }
-
- // Note that role3 cannot be assigned as it's not registered in the Roles Registry.
- @Test
- public void testAssignRolesNotAllRegistered() {
- RoleRegistry.get().registerRole("role1");
- final User user = mock(User.class);
- when(user.getGroups()).thenReturn(new HashSet());
- UserManager userManagerMock = mock(UserManager.class);
- doAnswer(new Answer() {
- @Override
- public User answer(InvocationOnMock invocationOnMock) throws Throwable {
- return user;
- }
- }).when(userManagerMock).get("user1");
- when(userSystemManager.users()).thenReturn(userManagerMock);
- Collection roles = new ArrayList();
- roles.add("role1");
- roles.add("role3");
- usersManager.assignRoles("user1",
- roles);
- Set result = usersManager.get("user1").getRoles();
- assertNotNull(result);
- assertEquals(1,
- result.size());
- }
-
- @Test
- public void testChangePassword() {
- usersManager.changePassword("user1",
- "newUser1Password");
- MemoryUserDatabase database = usersManager.getDatabase();
- org.apache.catalina.User catalinaUser = usersManager.getUser(database,
- "user1");
- assertEquals("newUser1Password",
- catalinaUser.getPassword());
- }
-
- private User create(String username) {
- return new UserImpl(username);
- }
-
- private void assertUser(User user,
- String username) {
- assertNotNull(user);
- assertEquals(user.getIdentifier(),
- username);
- }
-}
diff --git a/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/src/test/resources/org/uberfire/ext/security/management/tomcat/tomcat-users.xml b/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/src/test/resources/org/uberfire/ext/security/management/tomcat/tomcat-users.xml
deleted file mode 100644
index c2315ea30c..0000000000
--- a/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/src/test/resources/org/uberfire/ext/security/management/tomcat/tomcat-users.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/uberfire-showcase/showcase-distribution-wars/pom.xml b/uberfire-showcase/showcase-distribution-wars/pom.xml
deleted file mode 100644
index 09a82e33bc..0000000000
--- a/uberfire-showcase/showcase-distribution-wars/pom.xml
+++ /dev/null
@@ -1,143 +0,0 @@
-
-
-
-
-
- 4.0.0
-
- org.uberfire
- uberfire-showcase
- 7.68.0-SNAPSHOT
-
-
- showcase-distribution-wars
- pom
-
- Showcase distribution wars
-
- This module builds the download wars for different application servers.
-
-
-
-
-
- org.apache.maven.plugins
- maven-assembly-plugin
-
-
- package
-
- single
-
-
-
-
- uberfire-showcase-${project.version}
-
- src/main/assembly/assembly-showcase-tomcat-7_0.xml
- src/main/assembly/assembly-showcase-wildfly.xml
-
-
- false
-
-
-
-
-
-
-
-
- org.uberfire
- uberfire-webapp
- war
-
-
-
- jakarta.inject
- jakarta.inject-api
-
-
- jakarta.enterprise
- jakarta.enterprise.cdi-api
-
-
- jakarta.activation
- jakarta.activation-api
-
-
- jakarta.annotation
- jakarta.annotation-api
-
-
- jakarta.interceptor
- jakarta.interceptor-api
-
-
- jakarta.ws.rs
- jakarta.ws.rs-api
-
-
-
- com.sun.xml.bind
- jaxb-impl
-
-
- com.sun.xml.bind
- jaxb-xjc
-
-
-
- org.slf4j
- slf4j-api
-
-
- org.slf4j
- slf4j-jdk14
-
-
-
- org.jboss.weld
- weld-api
-
-
- org.jboss.weld.servlet
- weld-servlet-core
-
-
- org.jboss.weld
- weld-spi
-
-
-
- org.picketlink
- picketlink-api
-
-
-
- jakarta.persistence
- jakarta.persistence-api
-
-
-
- org.jboss.classfilewriter
- jboss-classfilewriter
-
-
-
-
-
diff --git a/uberfire-showcase/showcase-distribution-wars/src/main/assembly/assembly-showcase-tomcat-7_0.xml b/uberfire-showcase/showcase-distribution-wars/src/main/assembly/assembly-showcase-tomcat-7_0.xml
deleted file mode 100644
index 98df244566..0000000000
--- a/uberfire-showcase/showcase-distribution-wars/src/main/assembly/assembly-showcase-tomcat-7_0.xml
+++ /dev/null
@@ -1,80 +0,0 @@
-
-
-
-
-
- tomcat7.0
-
- war
-
-
- false
-
-
- ${project.basedir}/src/main/tomcat7
- .
-
-
-
-
-
- jakarta.enterprise:jakarta.enterprise.cdi-api:jar
-
- jakarta.interceptor:jakarta.interceptor-api
- jakarta.annotation:jakarta.annotation-api:jar
- jakarta.persistence:jakarta.persistence-api:jar
- jakarta.ws.rs:jakarta.ws.rs-api
- com.sun.xml.bind:jaxb-impl:jar
- com.sun.xml.bind:jaxb-xjc:jar
- jakarta.inject:jakarta.inject-api:jar
- jakarta.activation:jakarta.activation-api:jar
-
- org.slf4j:slf4j-api:jar
-
- org.slf4j:slf4j-jdk14
- ch.qos.cal10n:cal10n-api:jar
- org.jboss.logging:jboss-logging:jar
-
- org.jboss.weld:weld-api:jar
- org.jboss.weld:weld-spi:jar
- org.jboss.weld:weld-core-impl:jar
- org.jboss.weld.servlet:weld-servlet-core:jar
- org.jboss.classfilewriter:jboss-classfilewriter:jar
-
- false
- WEB-INF/lib
-
-
-
- org.uberfire:uberfire-webapp:war
-
- .
- true
-
-
- WEB-INF/web.xml
- WEB-INF/lib/errai-jboss-as-support-*.jar
- WEB-INF/lib/log4j-1*.jar
- WEB-INF/lib/logback-*.jar
-
-
-
-
-
-