From bf4701dba6d9e159848a4c40f18adba72a12207d Mon Sep 17 00:00:00 2001 From: Prarthona Paul Date: Tue, 17 Oct 2023 13:44:41 -0400 Subject: [PATCH] [WFLY-18466] ejb-security-context-propagation Quickstart Common Enhancements CY2023Q3 --- ...rt_ejb_security_context_propagation_ci.yml | 21 +++ ejb-security-context-propagation/README.adoc | 4 + ejb-security-context-propagation/pom.xml | 154 +++++++++++++----- .../EJBServlet.java | 56 +++++++ .../src/main/webapp/WEB-INF/beans.xml | 22 +++ .../src/main/webapp/index.html | 20 +++ .../BasicRuntimeIT.java | 58 +++++++ 7 files changed, 298 insertions(+), 37 deletions(-) create mode 100644 .github/workflows/quickstart_ejb_security_context_propagation_ci.yml create mode 100644 ejb-security-context-propagation/src/main/java/org/jboss/as/quickstarts/ejb_security_context_propagation/EJBServlet.java create mode 100644 ejb-security-context-propagation/src/main/webapp/WEB-INF/beans.xml create mode 100644 ejb-security-context-propagation/src/main/webapp/index.html create mode 100644 ejb-security-context-propagation/src/test/java/org/jboss/as/quickstarts/ejb_security_context_propagation/BasicRuntimeIT.java diff --git a/.github/workflows/quickstart_ejb_security_context_propagation_ci.yml b/.github/workflows/quickstart_ejb_security_context_propagation_ci.yml new file mode 100644 index 0000000000..9e51314421 --- /dev/null +++ b/.github/workflows/quickstart_ejb_security_context_propagation_ci.yml @@ -0,0 +1,21 @@ +name: WildFly ejb-security-context-propagation Quickstart CI + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + paths: + - 'ejb-security-context-propagation/**' + - '.github/workflows/quickstart_ci.yml' + +# Only run the latest job +concurrency: + group: '${{ github.workflow }} @ ${{ github.ref || github.run_id }}' + cancel-in-progress: true + +jobs: + call-quickstart_ci: + uses: ./.github/workflows/quickstart_ci.yml + with: + QUICKSTART_PATH: ejb-security-context-propagation + TEST_PROVISIONED_SERVER: true + TEST_OPENSHIFT: false \ No newline at end of file diff --git a/ejb-security-context-propagation/README.adoc b/ejb-security-context-propagation/README.adoc index ef5f414e11..6a134920c8 100644 --- a/ejb-security-context-propagation/README.adoc +++ b/ejb-security-context-propagation/README.adoc @@ -322,6 +322,10 @@ This quickstart requires additional configuration and deploys and runs different // Debug the Application include::../shared-doc/debug-the-application.adoc[leveloffset=+1] +// Build and run sections for other environments/builds +ifndef::ProductRelease,EAPXPRelease[] +include::../shared-doc/build-and-run-the-quickstart-with-provisioned-server.adoc[leveloffset=+1] +endif::[] //************************************************* // Product Release content only diff --git a/ejb-security-context-propagation/pom.xml b/ejb-security-context-propagation/pom.xml index 151676346f..75f637f908 100644 --- a/ejb-security-context-propagation/pom.xml +++ b/ejb-security-context-propagation/pom.xml @@ -30,7 +30,7 @@ ejb-security-context-propagation 31.0.0.Beta1-SNAPSHOT - ejb + war Quickstart: ejb-security-context-propagation This project demonstrates the security context propagation between remote EJBs @@ -43,10 +43,14 @@ + + 30.0.0.Final jdt_apt - 30.0.0.Final + ${version.server} + 5.0.0.Final + 4.2.0.Final @@ -110,7 +114,7 @@ org.wildfly.bom wildfly-ee-with-tools - ${version.server.bom} + ${version.bom.ee} pom import @@ -144,44 +148,120 @@ jakarta.ejb-api + + + jakarta.servlet + jakarta.servlet-api + provided + + + + + junit + junit + test + ${project.artifactId} - - - - org.apache.maven.plugins - maven-ejb-plugin - - 3.2 - true - - - - - org.codehaus.mojo - exec-maven-plugin - - java - ${project.build.directory}/exec-working-directory - - - -classpath - - org.jboss.as.quickstarts.ejb_security_context_propagation.RemoteClient - - - - - - exec - - - - - + + + + org.apache.maven.plugins + maven-ejb-plugin + + 3.2 + true + + + + + org.codehaus.mojo + exec-maven-plugin + + java + ${project.build.directory}/exec-working-directory + + + -classpath + + org.jboss.as.quickstarts.ejb_security_context_propagation.RemoteClient + + + + + + exec + + + + + + org.wildfly.plugins + wildfly-maven-plugin + ${version.plugin.wildfly} + + + + + + provisioned-server + + + + org.wildfly.plugins + wildfly-maven-plugin + + + + org.wildfly:wildfly-galleon-pack:${version.server} + + + + + cloud-server + + + ROOT.war + + + + + package + + + + + + + + + integration-testing + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + **/*IT + + + + + + integration-test + verify + + + + + + + + diff --git a/ejb-security-context-propagation/src/main/java/org/jboss/as/quickstarts/ejb_security_context_propagation/EJBServlet.java b/ejb-security-context-propagation/src/main/java/org/jboss/as/quickstarts/ejb_security_context_propagation/EJBServlet.java new file mode 100644 index 0000000000..f66955c496 --- /dev/null +++ b/ejb-security-context-propagation/src/main/java/org/jboss/as/quickstarts/ejb_security_context_propagation/EJBServlet.java @@ -0,0 +1,56 @@ +/* + * Copyright 2023 JBoss by Red Hat. + * + * 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.jboss.as.quickstarts.ejb_security_context_propagation; + +import java.io.IOException; +import java.io.PrintWriter; + +import jakarta.servlet.annotation.WebServlet; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +/** + *

+ * A simple servlet taking advantage of features added in 3.0. + *

+ * + *

+ * The servlet is registered and mapped to /EJBServlet using the {@linkplain WebServlet + * @HttpServlet}. + *

+ * + * @author Prarthona Paul + * + */ + +@WebServlet("/ejb-security-context-propagation") +public class EJBServlet extends HttpServlet { + + static String PAGE_HEADER = "helloworld"; + + static String PAGE_FOOTER = ""; + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { + resp.setContentType("text/html"); + PrintWriter writer = resp.getWriter(); + writer.println(PAGE_HEADER); + writer.println("

Hello World!

"); + writer.println(PAGE_FOOTER); + writer.close(); + } +} \ No newline at end of file diff --git a/ejb-security-context-propagation/src/main/webapp/WEB-INF/beans.xml b/ejb-security-context-propagation/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 0000000000..f418aba2f0 --- /dev/null +++ b/ejb-security-context-propagation/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,22 @@ + + + + + + diff --git a/ejb-security-context-propagation/src/main/webapp/index.html b/ejb-security-context-propagation/src/main/webapp/index.html new file mode 100644 index 0000000000..09fa6ed02b --- /dev/null +++ b/ejb-security-context-propagation/src/main/webapp/index.html @@ -0,0 +1,20 @@ + + + + + + + + diff --git a/ejb-security-context-propagation/src/test/java/org/jboss/as/quickstarts/ejb_security_context_propagation/BasicRuntimeIT.java b/ejb-security-context-propagation/src/test/java/org/jboss/as/quickstarts/ejb_security_context_propagation/BasicRuntimeIT.java new file mode 100644 index 0000000000..1f87cdac82 --- /dev/null +++ b/ejb-security-context-propagation/src/test/java/org/jboss/as/quickstarts/ejb_security_context_propagation/BasicRuntimeIT.java @@ -0,0 +1,58 @@ +/* + * Copyright 2023 JBoss by Red Hat. + * + * 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.jboss.as.quickstarts.ejb_security_context_propagation; + +import org.junit.Test; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Duration; + +import static org.junit.Assert.assertEquals; + +/** + * The very basic runtime integration testing. + * @author Prarthona Paul + * @author emartins + */ +public class BasicRuntimeIT { + private static final String DEFAULT_SERVER_HOST = "http://localhost:8080/ejb-security-context-propagation"; + + @Test + public void testHTTPEndpointIsAvailable() throws IOException, InterruptedException, URISyntaxException { + String serverHost = System.getenv("SERVER_HOST"); + if (serverHost == null) { + serverHost = System.getProperty("server.host"); + } + if (serverHost == null) { + serverHost = DEFAULT_SERVER_HOST; + } + final HttpRequest request = HttpRequest.newBuilder() + .uri(new URI(serverHost+"/")) + .GET() + .build(); + final HttpClient client = HttpClient.newBuilder() + .followRedirects(HttpClient.Redirect.ALWAYS) + .connectTimeout(Duration.ofMinutes(1)) + .build(); + final HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); + assertEquals(200, response.statusCode()); + } +}