diff --git a/dashbuilder/README.md b/dashbuilder/README.md index 1a84f20d7d..b348f0b41b 100644 --- a/dashbuilder/README.md +++ b/dashbuilder/README.md @@ -112,7 +112,7 @@ composite dashboards using an straightforward API. Feature set: * Showcase App. providing a built-in displayer gallery plus some dashboard samples * Default renderer based on the Google Visualization library * Additional table renderer based on the Uberfire PagedTable widget -* Tomcat 7 and JBoss AS 7 distributions provided +* JBoss AS 7 distribution provided Build & run =========== @@ -173,6 +173,6 @@ In order to build the production mode: cd dashbuilder mvn clean install -DskipTests -Dfull -Once build is finished, you'll find the WAR distributions for Wildfly and Tomcat into dashbuilder/dashbuilder-distros/target/. +Once build is finished, you'll find the WAR distribution for Wildfly in dashbuilder/dashbuilder-distros/target/. Just deploy the WAR file into your application server! diff --git a/dashbuilder/dashbuilder-distros/README.md b/dashbuilder/dashbuilder-distros/README.md index 2733f57369..07aa22c72e 100644 --- a/dashbuilder/dashbuilder-distros/README.md +++ b/dashbuilder/dashbuilder-distros/README.md @@ -20,12 +20,9 @@ This module is not build by default. You can build it in two ways: Distributions ------------- -Currently, the following artifacts are generated: +Currently, the following artifact is generated: * **dashbuilder-wildfly10.war:** Product distribution for the JBoss WildFly 10.x application server. Detailed installation instructions [here](./src/main/wildfly10/README.md). -* **dashbuilder-tomcat8.war:** Product distribution for Apache Tomcat 8 server. - - Detailed installation instructions [here](./src/main/tomcat8/README.md). diff --git a/dashbuilder/dashbuilder-distros/pom.xml b/dashbuilder/dashbuilder-distros/pom.xml index 8f8e2b8bc9..47eff9a05d 100644 --- a/dashbuilder/dashbuilder-distros/pom.xml +++ b/dashbuilder/dashbuilder-distros/pom.xml @@ -34,7 +34,6 @@ dashbuilder-${project.version} - src/main/assembly/assembly-tomcat-8.xml src/main/assembly/assembly-wildfly-10.xml @@ -154,18 +153,6 @@ weld-se-core - - - org.uberfire - uberfire-security-management-tomcat - - - javax.annotation - javax.annotation-api - - - - diff --git a/dashbuilder/dashbuilder-distros/src/main/assembly/assembly-tomcat-8.xml b/dashbuilder/dashbuilder-distros/src/main/assembly/assembly-tomcat-8.xml deleted file mode 100644 index c3cb5c64fc..0000000000 --- a/dashbuilder/dashbuilder-distros/src/main/assembly/assembly-tomcat-8.xml +++ /dev/null @@ -1,117 +0,0 @@ - - - - tomcat8 - - war - dir - - - false - - - ${project.basedir}/src/main/tomcat8 - . - - - - - - - antlr:antlr - org.apache.cxf:* - org.apache.neethi:neethi - org.dom4j:dom4j - com.sun.xml.bind:jaxb-xjc - org.jboss.logging:jboss-logging - org.slf4j:slf4j-api:jar - org.slf4j:jcl-over-slf4j - org.codehaus.woodstox:woodstox-core-asl - org.codehaus.woodstox:stax2-api - wsdl4j:wsdl4j - - com.h2database:h2 - ch.qos.cal10n:cal10n-api - jakarta.activation:jakarta.activation-api - jakarta.enterprise:jakarta.enterprise.cdi-api - jakarta.inject:jakarta.inject-api - jakarta.mail:jakarta.mail-api - com.sun.mail:jakarta.mail - javax.validation:validation-api - - jakarta.annotation:jakarta.annotation-api - jakarta.interceptor:jakarta.interceptor-api - jakarta.servlet.jsp.jstl:jakarta.servlet.jsp.jstl-api - jakarta.jms:jakarta.jms-api - jakarta.xml.ws:jakarta.xml.ws-api - jakarta.ws.rs:jakarta.ws.rs-api - jakarta.xml.bind:jakarta.xml.bind-api - jakarta.ejb:jakarta.ejb-api - jakarta.security.jacc:jakarta.security.jacc-api - org.jboss.logging:jboss-logging - org.jboss.resteasy:resteasy-jaxrs - org.jboss.resteasy:resteasy-cdi - org.jboss.resteasy:resteasy-jackson-provider - org.jboss.resteasy:resteasy-jaxb-provider - org.jboss.resteasy:resteasy servlet-initializer - org.scannotation:scannotation - org.codehaus.jackson:jackson-jaxrs - - org.jboss.weld:weld-api - org.jboss.weld:weld-core-impl - org.jboss.weld.se:weld-se-core - org.jboss.weld.servlet:weld-servlet-core - org.jboss.weld:weld-spi - org.jboss.weld.environment:weld-environment-common - org.jboss.classfilewriter:jboss-classfilewriter - - jakarta.persistence:jakarta.persistence-api:jar - org.jboss.logging:jboss-logging:jar - - net.jcip:jcip-annotations - xalan:xalan - xalan:serializer - xerces:xercesImpl - xml-resolver:xml-resolver - - - org.uberfire:uberfire-security-management-tomcat - - false - WEB-INF/lib - - - - org.dashbuilder:dashbuilder-webapp:war - - . - true - - - - META-INF/jboss-all.xml - META-INF/MANIFEST.MF - WEB-INF/beans.xml - WEB-INF/web.xml - WEB-INF/ejb-jar.xml - WEB-INF/jboss-deployment-structure.xml - WEB-INF/jboss-web.xml - - WEB-INF/classes/application-roles.properties - WEB-INF/classes/application-users.properties - - - WEB-INF/lib/errai-jboss-as-support-*.jar - - - WEB-INF/lib/uberfire-security-management-wildfly-*.jar - WEB-INF/classes/security-management.properties - - - true - - - - diff --git a/dashbuilder/dashbuilder-distros/src/main/tomcat8/META-INF/context.xml b/dashbuilder/dashbuilder-distros/src/main/tomcat8/META-INF/context.xml deleted file mode 100644 index 3300e73608..0000000000 --- a/dashbuilder/dashbuilder-distros/src/main/tomcat8/META-INF/context.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - diff --git a/dashbuilder/dashbuilder-distros/src/main/tomcat8/README.md b/dashbuilder/dashbuilder-distros/src/main/tomcat8/README.md deleted file mode 100644 index 9b6f86b0c2..0000000000 --- a/dashbuilder/dashbuilder-distros/src/main/tomcat8/README.md +++ /dev/null @@ -1,48 +0,0 @@ -Deployment onto Apache Tomcat 8.x -================================= - -This module contains all the artifacts to build the distribution for Apache Tomcat 8, in the simplest way possible and using a default configuration with the H2 database. - -Please follow the next steps in order to deploy the application. - -Authentication and authorization ---------------------------------- - -The dashboard builder module uses container managed authentication and authorization. - -The `admin` role must be defined in tomcat's realm, as is the default role configured in the application's `web.xml`. Therefore, you must define this role and create -a user with the `admin` role assigned in order to be able to log in and use the application. - -In a default Tomcat installation, edit `$CATALINA_HOME/conf/tomcat-users.xml` and customize and add the following lines: - - - - -Deploy the application --------------------------- -Before deploying the WAR artifact for Dashbuilder please follow these steps: - -* Copy the JACC jar into `$CATALINA_HOME/lib`. This JAR has the Maven coordinates `javax.security.jacc:javax.security.jacc-api:jar:1.5` and can be found at the JBoss Maven Repository. - -Get the proper war file `dashbuilder--tomcat8.war` and copy it to `$CATALINA_HOME/webapps` or deploy it using the Tomcat Manager application. - -User Authentication --------------------------- - -Once started, open a browser and type the following URL: -`http://localhost:8080/dashbuilder--tomcat8/`. A login page should be displayed. - -File System provider ---------------------- -Dashbuilder stores all the internal artifacts (such as the data set definition files, the uploaded files, etc) into a GIT repository. You can clone the repository and noddle around with it if you need to. - -By default, the GIT repository is created when the application starts for first time at `$WORKING_DIR/.niogit`, considering `$WORKING_DIR` as the current directory where the application server is started. - -You can specify a custom repository location by setting the following Java system property to your target file system directory: - - -Dorg.uberfire.nio.git.dir=/home/youruser/some/path - -If necessary you can make GIT repositories available from outside localhost using the following Java system property: - - -org.uberfire.nio.git.ssh.host=0.0.0.0 - diff --git a/dashbuilder/dashbuilder-distros/src/main/tomcat8/WEB-INF/beans.xml b/dashbuilder/dashbuilder-distros/src/main/tomcat8/WEB-INF/beans.xml deleted file mode 100644 index 076c241116..0000000000 --- a/dashbuilder/dashbuilder-distros/src/main/tomcat8/WEB-INF/beans.xml +++ /dev/null @@ -1,5 +0,0 @@ - - diff --git a/dashbuilder/dashbuilder-distros/src/main/tomcat8/WEB-INF/classes/security-management.properties b/dashbuilder/dashbuilder-distros/src/main/tomcat8/WEB-INF/classes/security-management.properties deleted file mode 100644 index 21a2425ed8..0000000000 --- a/dashbuilder/dashbuilder-distros/src/main/tomcat8/WEB-INF/classes/security-management.properties +++ /dev/null @@ -1,16 +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. -# -org.uberfire.ext.security.management.api.userManagementServices=TomcatUserManagementService diff --git a/dashbuilder/dashbuilder-distros/src/main/tomcat8/WEB-INF/web.xml b/dashbuilder/dashbuilder-distros/src/main/tomcat8/WEB-INF/web.xml deleted file mode 100644 index f3b008f071..0000000000 --- a/dashbuilder/dashbuilder-distros/src/main/tomcat8/WEB-INF/web.xml +++ /dev/null @@ -1,235 +0,0 @@ - - - - - - - - - org.jboss.weld.environment.servlet.Listener - - - - Object factory for the CDI Bean Manager - BeanManager - javax.enterprise.inject.spi.BeanManager - - - - Object factory for the Errai Service - ErraiService - org.jboss.errai.bus.server.service.ErraiService - - - - - - - - - request-capture - org.uberfire.ext.security.server.SecurityIntegrationFilter - - - - request-capture - * - - - - Avoid Host Page Cache - org.uberfire.ext.security.server.CacheHeadersFilter - - - - Avoid Host Page Cache - /dashbuilder.html - - - - Host Page Patch - org.jboss.errai.security.server.servlet.UserHostPageFilter - - - - Host Page Patch - /dashbuilder.html - - - - GWT Locale Filter - org.uberfire.server.locale.GWTLocaleHeaderFilter - - - - GWT Locale Filter - /dashbuilder.html - - - - UberFire Security Headers Filter - org.uberfire.ext.security.server.SecureHeadersFilter - - x-frame-options - SAMEORIGIN - - - x-xss-protection-enable - true - - - x-xss-protection-block - true - - - - - UberFire Security Headers Filter - * - - - - LoginRedirectServlet - org.uberfire.ext.security.server.LoginRedirectServlet - - display-after-login - /dashbuilder.html - - - - - LoginRedirectServlet - /login - - - - FORM - - /login.jsp - /login.jsp?message=Login failed: Invalid UserName or Password - - - - - ErraiServlet - org.jboss.errai.bus.server.servlet.DefaultBlockingServlet - - - service-locator - org.jboss.errai.cdi.server.CDIServiceLocator - - 1 - - - - ErraiServlet - *.erraiBus - - - - UberfireFileUploadServlet - org.uberfire.server.FileUploadServlet - - includes-path - git://**,default://** - - - excludes-path - file://** - - - - UberfireFileUploadServlet - /org.dashbuilder.DashbuilderShowcase/defaulteditor/upload/* - - - - UberfireFileDownloadServlet - org.uberfire.server.FileDownloadServlet - - includes-path - git://**,default://** - - - excludes-path - file://** - - - - UberfireFileDownloadServlet - /org.dashbuilder.DashbuilderShowcase/defaulteditor/download/* - - - - - - Administrator - Manages application configuration and creates dashboards - admin - - - - User - Consumes existing dashboards - user - - - - - - openResources - /org.dashbuilder.DashbuilderShowcase/patternfly/* - - - - - - - default - /dashbuilder.html - /org.dashbuilder.DashbuilderShowcase/* - *.erraiBus - /plugins/* - - - admin - user - - - - - - - download - /org.dashbuilder.DashbuilderShowcase/archive - /org.dashbuilder.DashbuilderShowcase/defaulteditor/upload/* - /org.dashbuilder.DashbuilderShowcase/defaulteditor/download/* - - - admin - user - - - - - - - public - /org.dashbuilder.DashbuilderShowcase/css/* - /org.dashbuilder.DashbuilderShowcase/fonts/* - /org.dashbuilder.DashbuilderShowcase/img/* - - - - - 403 - /not_authorized.jsp - - - - index.jsp - - - diff --git a/pom.xml b/pom.xml index 09ffb2afa1..9b102bea4c 100644 --- a/pom.xml +++ b/pom.xml @@ -52,7 +52,6 @@ ${project.version} ${version.org.kie} - 7.0.61 3.18.1 1.0.4 1.10.0 @@ -807,22 +806,6 @@ ${version.org.keycloak} - - org.apache.tomcat - tomcat-catalina - ${version.org.apache.tomcat} - - - org.apache.tomcat - tomcat-coyote - ${version.org.apache.tomcat} - - - org.apache.tomcat - tomcat-util - ${version.org.apache.tomcat} - - com.google.jsinterop base diff --git a/uberfire-extensions/uberfire-security/uberfire-security-management/README.md b/uberfire-extensions/uberfire-security/uberfire-security-management/README.md index f60feac081..e35ad943d8 100644 --- a/uberfire-extensions/uberfire-security/uberfire-security-management/README.md +++ b/uberfire-extensions/uberfire-security/uberfire-security-management/README.md @@ -19,7 +19,6 @@ So the users, groups and roles potentially come from different realms, such as t Due to this fact, the UF users management feature is based on services and their implementations. It defaults with the users, groups and roles services and three concrete implementations for: * JBoss Wildfly / EAP - Properties based realms * JBoss KeyCloak based realms -* Tomcat XML based realms NOTE: If you are using the application against another security system, you can build your own users, groups and roles service provider implementations. @@ -33,7 +32,7 @@ which can be potentially supported by the provider implementation or not, Pleas UberFire Users, Roles and Groups -------------------------------- -UberFire's security system provides an entities model based on users, groups and roles. As many security realms, such as the default for Wildfly, EAP, Tomcat or Keycloak, does either support groups or roles, not both, here is how UF behaves: +UberFire's security system provides an entities model based on users, groups and roles. As many security realms, such as the default for Wildfly, EAP or Keycloak, does either support groups or roles, not both, here is how UF behaves: * The users are the users that come from the security realm * The roles are the groups or roles, depending on what the concrete realm provides, that come from the security realm and are registered in the Roles Registry (see `org.uberfire.ext.security.server.RolesRegistry`) @@ -55,7 +54,6 @@ Here is a short summary of the project sub-modules: * [`uberfire-security-management-client`](./uberfire-security-management-client/) - Provides the different classes and implementations for the users, groups and roles management client stuff. * [`uberfire-security-management-client-wb`](./uberfire-security-management-client-wb/README.md) - Provides the perspectives and screens for the client side integration into the UF workbench. * [`uberfire-security-management-keycloak`](./uberfire-security-management-keycloak/README.md) - Provides the concrete users, groups and roles service provider implementations for JBoss KeyCloak. -* [`uberfire-security-management-tomcat`](./uberfire-security-management-tomcat/README.md) - Provides the concrete users, groups and roles service provider implementations for Apache Tomcat. * [`uberfire-security-management-wildfly`](./uberfire-security-management-wildfly/README.md) - Provides the concrete users, groups and roles service provider implementations for JBoss Wildfly or JBoss EAP. * [`uberfire-widgets-security-management`](./uberfire-widgets-security-management/README.md) - Provides the widgets for the users, groups and roles management, such as explorers, editors, etc. * [`uberfire-security-management-webapp`](./uberfire-security-management-webapp/README.md) - A simple web application that defaults with the users and group management perspectives and uses, by default, the embedded wildfly's realm. diff --git a/uberfire-extensions/uberfire-security/uberfire-security-management/pom.xml b/uberfire-extensions/uberfire-security/uberfire-security-management/pom.xml index 577ca3b0e6..5fd4a6b0bc 100644 --- a/uberfire-extensions/uberfire-security/uberfire-security-management/pom.xml +++ b/uberfire-extensions/uberfire-security/uberfire-security-management/pom.xml @@ -35,7 +35,6 @@ uberfire-security-management-backend uberfire-security-management-keycloak uberfire-security-management-wildfly - uberfire-security-management-tomcat uberfire-security-management-client uberfire-widgets-security-management uberfire-security-management-client-wb diff --git a/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-client-wb/README.md b/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-client-wb/README.md index f5696258a6..036ef47657 100644 --- a/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-client-wb/README.md +++ b/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-client-wb/README.md @@ -66,11 +66,6 @@ To use the perspectives, screens and widgets provided by this module, please fol uberfire-security-management-wildfly - - org.uberfire - uberfire-security-management-tomcat - - 2.1.- Specifying the provider to use using a properties file * You can specify the concrete provider to use by adding a properties file named `security-management.properties` in your web application root classpath. (e.g. `src/main/resources/security-management.properties`) diff --git a/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-keycloak/README.md b/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-keycloak/README.md index 1a9dc2fc6f..37c1f6760b 100644 --- a/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-keycloak/README.md +++ b/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-keycloak/README.md @@ -135,7 +135,7 @@ Follow these steps in order to update or enable the Keycloak users and group man * Add if no present the uberfire-security-management-keycloak-X.Y.Z.jar * Add keycloak-core-X.Y.Z.Final.jar * Add keycloak-common-X.Y.Z.Final.jar -* Remove any existing provider implementation, if any (ex: uberfire-security-management-wildfly-X.Y.Z.jar, remove uberfire-security-management-tomcat-X.Y.Z.jar,etc) +* Remove any existing provider implementation, if any (ex: uberfire-security-management-wildfly-X.Y.Z.jar, etc) 2.- Replace the whole content for file `WEB-INF/classes/security-management.properties`, if not present, create it: diff --git a/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/.gitignore b/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/.gitignore deleted file mode 100644 index c676f4094c..0000000000 --- a/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/.gitignore +++ /dev/null @@ -1,18 +0,0 @@ -/target -/local -target -# Eclipse, Netbeans and IntelliJ files -/.* -/**/.* -!.gitignore -/nbproject -*.ipr -*.iws -*.iml - -# Repository wide ignore mac DS_Store files -.DS_Store - -# Created by Zanata -/org.uberfire - diff --git a/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/README.md b/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/README.md deleted file mode 100644 index adb2565784..0000000000 --- a/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/README.md +++ /dev/null @@ -1,103 +0,0 @@ -Tomcat provider for user and group management services -======================================================== - -Introduction ------------- -The classes in this package contain the user and group manager implementations for Apache Tomcat. - -This provider supports realm types based on XML files (the default ones in Tomcat server), such as `tomcat-users.xml` - -* The user, group and role implementations are provided by `org.uberfire.ext.security.management.tomcat.TomcatUserManagementService` - -* The concrete user manager implementation is `org.uberfire.ext.security.management.tomcat.TomcatUserManager` which maps the Tomcat users for the given realm to application users. - -* The concrete group manager implementation is `org.uberfire.ext.security.management.tomcat.TomcatGroupManager` which maps the Tomcat roles for the given realm to application groups or roles. Tomcat's default realm does not have support for both groups and roles. The available roles are the ones statically defined in `org.uberfire.ext.security.server.RolesRegistry`. All other roles defined in Tomcat are considered groups. - -Installation notes ------------------- - -**Apache Tomcat** -If you are deploying the application in an Apache Tomcat, you can exclude the following libraries as they are provided by Tomcat's default library. - - - org.apache.tomcat - tomcat-catalina - - - - org.apache.tomcat - tomcat-coyote - - - - org.apache.tomcat - tomcat-util - - -**Other containers** -If you are deploying the application in other containers different than Tomcat, please make sure the following dependencies are in your application's classpath: - - - org.apache.tomcat - tomcat-catalina - 7.0.61 - - - - org.apache.tomcat - tomcat-coyote - 7.0.61 - - - - org.apache.tomcat - tomcat-util - 7.0.61 - - - -Usage ------ -To use this provider implementation for the users and groups management services, please choose one of the following options: - -a) Specify the concrete provider to use by adding a properties file named `security-management.properties` in your web application root classpath. -(e.g. `src/main/resources/security-management.properties`), with the following keys and your concrete provider name as value: - - org.uberfire.ext.security.management.api.userManagementServices=TomcatUserManagementService - -b) Specify the following Java system properties at container startup: - - -Dorg.uberfire.ext.security.management.api.userManagementServices=TomcatUserManagementService - -In order to use this provider, the following system properties are required to be present at startup: - -* `org.uberfire.ext.security.management.tomcat.catalina-base` - The filesystem's path for the Tomcat's base directory (CATALINA_BASE). By default it's read from the system properties, so running tomcat aready provides it. It is mandatory. Defaults to: `/opt/tomcat`. -* `org.uberfire.ext.security.management.tomcat.users-file` - The Tomcat's users XML file path relative to the previous given value for `org.uberfire.ext.security.management.tomcat.catalina-base` . Property is mandatory. Defaults to: `conf/tomcat-users.xml`. - -If you use the default Tomcat realm's configuration, you don't have to specify any of the above system properties, as the default values provided works with Tomcat's defaults. - -Provider capabilities ---------------------- -The Tomcat provider for users and groups management services provides the following features: - -**User service capabilities** -* User search - Can search or list users. Search by `username`. -* Read user - Can read a user -* Create user - Can add new users -* Update user - Can update a user -* Delete user - Can delete a user -* User attributes - Can manage user attributes -* Group assignment - Can manage groups for a user -* Role assignment - Can manage roles for a user -* Change password - Can change user's password - -**Group service capabilities** -* Group search - Can search or list groups. Search by `name` attribute. -* Read group - Can read a group -* Create group - Can add new groups -* Delete group - Can delete a group - -Notes ------ -* Java7+ -* This implementation has been tested for an Apache Tomcat version `7.0.61`. diff --git a/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/pom.xml b/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/pom.xml deleted file mode 100644 index 8025a852d7..0000000000 --- a/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/pom.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - uberfire-security-management - org.uberfire - 7.67.2-SNAPSHOT - - 4.0.0 - - uberfire-security-management-tomcat - jar - - Uberfire Security Management - Provider Implementation for Tomcat - Uberfire Security Management - Provider Implementation for Tomcat - - - - - org.uberfire - uberfire-api - - - - org.uberfire - uberfire-commons - - - - org.kie.soup - kie-soup-commons - - - - org.uberfire - uberfire-security-management-api - - - - org.uberfire - uberfire-security-management-backend - - - - jakarta.inject - jakarta.inject-api - - - - org.jboss.errai - errai-security-server - - - - org.jboss.errai - errai-bus - - - - org.slf4j - slf4j-api - - - - - org.apache.tomcat - tomcat-catalina - - - org.apache.tomcat - tomcat-annotations-api - - - org.apache.tomcat - tomcat-servlet-api - - - - - - org.apache.tomcat - tomcat-coyote - - - org.apache.tomcat - tomcat-servlet-api - - - - - - org.apache.tomcat - tomcat-util - - - - - - org.uberfire - uberfire-security-management-backend - test-jar - test - - - - - diff --git a/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/src/main/java/org/uberfire/ext/security/management/tomcat/BaseTomcatManager.java b/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/src/main/java/org/uberfire/ext/security/management/tomcat/BaseTomcatManager.java deleted file mode 100644 index 751e29cf83..0000000000 --- a/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/src/main/java/org/uberfire/ext/security/management/tomcat/BaseTomcatManager.java +++ /dev/null @@ -1,183 +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.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import org.apache.catalina.users.MemoryUserDatabase; -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.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.uberfire.commons.config.ConfigProperties; -import org.uberfire.ext.security.management.api.UserManager; -import org.uberfire.ext.security.management.api.exception.GroupNotFoundException; -import org.uberfire.ext.security.management.api.exception.SecurityManagementException; -import org.uberfire.ext.security.management.api.exception.UserNotFoundException; -import org.uberfire.ext.security.management.impl.UserAttributeImpl; -import org.uberfire.ext.security.management.util.SecurityManagementUtils; - -/** - *

Base users and groups management methods for the tomcat provider implementations.

- * @since 0.8.0 - */ -public abstract class BaseTomcatManager { - - public static final String DEFAULT_CATALINA_BASE = "/opt/tomcat"; - public static final String USERS_FILE = "conf/tomcat-users.xml"; - public static final String DATABASE_NAME = "UserDatabase"; - public static final String ATTRIBUTE_USER_FULLNAME = "user.fullName"; - protected static final String CATALINA_BASE_PROPERTY = "catalina.base"; - protected static final UserManager.UserAttribute USER_FULLNAME = new UserAttributeImpl(ATTRIBUTE_USER_FULLNAME, - false, - true, - "Full name"); - protected static final Collection USER_ATTRIBUTES = Arrays.asList(USER_FULLNAME); - private static final Logger LOG = LoggerFactory.getLogger(BaseTomcatManager.class); - protected String defaultCatalinaBase = DEFAULT_CATALINA_BASE; - protected String usersFile = USERS_FILE; - - protected static boolean isConfigPropertySet(ConfigProperties.ConfigProperty property) { - if (property == null) { - return false; - } - String value = property.getValue(); - return !isEmpty(value); - } - - protected static boolean isEmpty(String s) { - return s == null || s.trim().length() == 0; - } - - protected void loadConfig(final ConfigProperties config) { - final ConfigProperties.ConfigProperty catalinaBasePath = config.get("org.uberfire.ext.security.management.tomcat.catalina-base", - DEFAULT_CATALINA_BASE); - final ConfigProperties.ConfigProperty usersName = config.get("org.uberfire.ext.security.management.tomcat.users-file", - USERS_FILE); - - // Check mandatory properties. - if (!isConfigPropertySet(catalinaBasePath)) { - throw new IllegalArgumentException("Property 'org.uberfire.ext.security.management.tomcat.catalina-base' is mandatory and not set."); - } - if (!isConfigPropertySet(usersName)) { - throw new IllegalArgumentException("Property 'org.uberfire.ext.security.management.tomcat.users-file' is mandatory and not set."); - } - - this.defaultCatalinaBase = catalinaBasePath.getValue(); - this.usersFile = usersName.getValue(); - initializeTomcatProperties(); - } - - protected void initializeTomcatProperties() { - // If not running in a tomcat server environment, add the necessary catalina.base property to work with Tomcat's API and libraries. - if (isEmpty(System.getProperty(CATALINA_BASE_PROPERTY))) { - System.setProperty(CATALINA_BASE_PROPERTY, - defaultCatalinaBase); - } - } - - protected MemoryUserDatabase getDatabase() throws SecurityManagementException { - MemoryUserDatabase database = new MemoryUserDatabase(DATABASE_NAME); - database.setPathname(usersFile); - database.setReadonly(false); - try { - database.open(); - if (!database.getReadonly()) { - database.save(); - } - } catch (Exception e) { - throw new SecurityManagementException(e); - } - return (database); - } - - protected void saveDatabase(MemoryUserDatabase database) throws SecurityManagementException { - try { - database.save(); - } catch (Exception e) { - throw new SecurityManagementException(e); - } - } - - protected void closeDatabase(MemoryUserDatabase database) throws SecurityManagementException { - try { - database.close(); - } catch (Exception e) { - throw new SecurityManagementException(e); - } - } - - protected org.apache.catalina.User getUser(MemoryUserDatabase database, - String identifier) { - org.apache.catalina.User user = database.findUser(identifier); - if (user == null) { - throw new UserNotFoundException(identifier); - } - return user; - } - - protected org.apache.catalina.Role getRole(MemoryUserDatabase database, - String identifier) { - org.apache.catalina.Role group = database.findRole(identifier); - if (group == null) { - throw new GroupNotFoundException(identifier); - } - return group; - } - - protected User createUser(org.apache.catalina.User user, - Iterator groups) { - if (user == null) { - return null; - } - final Set _groups = new HashSet(); - final Set _roles = new HashSet(); - final Set registeredRoles = SecurityManagementUtils.getRegisteredRoleNames(); - if (groups != null && groups.hasNext()) { - while (groups.hasNext()) { - org.apache.catalina.Role group = groups.next(); - String name = group.getRolename(); - SecurityManagementUtils.populateGroupOrRoles(name, - registeredRoles, - _groups, - _roles); - } - } - return SecurityManagementUtils.createUser(user.getName(), - _groups, - _roles); - } - - protected Group createGroup(org.apache.catalina.Role group) { - if (group == null) { - return null; - } - return SecurityManagementUtils.createGroup(group.getRolename()); - } - - protected Role createRole(org.apache.catalina.Role group) { - if (group == null) { - return null; - } - return SecurityManagementUtils.createRole(group.getRolename()); - } -} diff --git a/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/src/main/java/org/uberfire/ext/security/management/tomcat/TomcatGroupManager.java b/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/src/main/java/org/uberfire/ext/security/management/tomcat/TomcatGroupManager.java deleted file mode 100644 index ca33adf7d1..0000000000 --- a/uberfire-extensions/uberfire-security/uberfire-security-management/uberfire-security-management-tomcat/src/main/java/org/uberfire/ext/security/management/tomcat/TomcatGroupManager.java +++ /dev/null @@ -1,200 +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 org.apache.catalina.users.MemoryUserDatabase; -import org.jboss.errai.security.shared.api.Group; -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.GroupManager; -import org.uberfire.ext.security.management.api.GroupManagerSettings; -import org.uberfire.ext.security.management.api.UserSystemManager; -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.search.GroupsIdentifierRuntimeSearchEngine; -import org.uberfire.ext.security.management.search.IdentifierRuntimeSearchEngine; -import org.uberfire.ext.security.management.util.SecurityManagementUtils; - -/** - *

Groups manager service provider implementation for Apache tomcat, when using default realm based on properties files.

- * @since 0.8.0 - */ -public class TomcatGroupManager extends BaseTomcatManager implements GroupManager, - ContextualManager { - - private static final Logger LOG = LoggerFactory.getLogger(TomcatGroupManager.class); - - IdentifierRuntimeSearchEngine groupsSearchEngine; - - public TomcatGroupManager() { - this(new ConfigProperties(System.getProperties())); - } - - public TomcatGroupManager(final Map gitPrefs) { - this(new ConfigProperties(gitPrefs)); - } - - public TomcatGroupManager(final ConfigProperties gitPrefs) { - loadConfig(gitPrefs); - } - - @Override - public void initialize(UserSystemManager userSystemManager) throws Exception { - groupsSearchEngine = new GroupsIdentifierRuntimeSearchEngine(); - } - - @Override - public void destroy() throws Exception { - - } - - @Override - public SearchResponse search(SearchRequest request) throws SecurityManagementException { - List groups = getAll(); - return groupsSearchEngine.search(groups, request); - } - - @Override - public Group get(String identifier) throws SecurityManagementException { - MemoryUserDatabase userDatabase = getDatabase(); - try { - org.apache.catalina.Role group = getRole(userDatabase, - identifier); - return createGroup(group); - } finally { - closeDatabase(userDatabase); - } - } - - @Override - public List getAll() throws SecurityManagementException { - MemoryUserDatabase userDatabase = getDatabase(); - try { - Iterator groupIterator = userDatabase.getRoles(); - List groups = new ArrayList<>(); - if (groupIterator != null) { - while (groupIterator.hasNext()) { - org.apache.catalina.Role group = groupIterator.next(); - Group groupname = SecurityManagementUtils.createGroup(group.getRolename()); - groups.add(groupname); - } - } - return groups; - } finally { - closeDatabase(userDatabase); - } - } - - @Override - public Group create(Group entity) throws SecurityManagementException { - if (entity == null) { - throw new NullPointerException(); - } - MemoryUserDatabase userDatabase = getDatabase(); - try { - String name = entity.getName(); - userDatabase.createRole(name, - name); - saveDatabase(userDatabase); - return entity; - } finally { - closeDatabase(userDatabase); - } - } - - @Override - public Group update(Group entity) throws SecurityManagementException { - throw new UnsupportedServiceCapabilityException(Capability.CAN_UPDATE_GROUP); - } - - @Override - public void delete(String... identifiers) throws SecurityManagementException { - if (identifiers == null) { - throw new NullPointerException(); - } - MemoryUserDatabase userDatabase = getDatabase(); - try { - for (String identifier : identifiers) { - org.apache.catalina.Role group = getRole(userDatabase, - identifier); - userDatabase.removeRole(group); - } - saveDatabase(userDatabase); - } finally { - closeDatabase(userDatabase); - } - } - - @Override - public GroupManagerSettings getSettings() { - final Map capabilityStatusMap = new HashMap(8); - for (final Capability capability : SecurityManagementUtils.GROUPS_CAPABILITIES) { - capabilityStatusMap.put(capability, - getCapabilityStatus(capability)); - } - return new GroupManagerSettingsImpl(capabilityStatusMap, - true); - } - - protected CapabilityStatus getCapabilityStatus(Capability capability) { - if (capability != null) { - switch (capability) { - case CAN_SEARCH_GROUPS: - case CAN_ADD_GROUP: - case CAN_READ_GROUP: - case CAN_DELETE_GROUP: - return CapabilityStatus.ENABLED; - } - } - return CapabilityStatus.UNSUPPORTED; - } - - @Override - public void assignUsers(String name, - Collection 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 - - - - - -