Skip to content

Commit

Permalink
Merge pull request #751 from PrarthonaPaul/ejb-security-context-propa…
Browse files Browse the repository at this point in the history
…gation-enhancements

[WFLY-18466] ejb-security-context-propagation Quickstart Common Enhan…
  • Loading branch information
emmartins authored Oct 26, 2023
2 parents becf34d + b857d9f commit af84e8e
Show file tree
Hide file tree
Showing 16 changed files with 371 additions and 99 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/quickstart_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ jobs:
cd ${{ inputs.QUICKSTART_PATH }}
echo "Building provisioned server..."
mvn -U -B -fae clean package -Pprovisioned-server
echo "Add quickstartUser..."
target/server/bin/add-user.sh -a -u 'quickstartUser' -p 'quickstartPwd1!' -g 'guest,user,JBossAdmin,Users'
echo "Add quickstartAdmin..."
target/server/bin/add-user.sh -a -u 'quickstartAdmin' -p 'adminPwd1!' -g 'guest,user,admin'
echo "Starting provisioned server..."
mvn -U -B -fae wildfly:start -DjbossHome=target/server -Dstartup-timeout=120
echo "Testing provisioned server..."
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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'

jobs:
call-quickstart_ci:
uses: ./.github/workflows/quickstart_ci.yml
with:
QUICKSTART_PATH: ejb-security-context-propagation
TEST_PROVISIONED_SERVER: true
TEST_OPENSHIFT: false
46 changes: 10 additions & 36 deletions ejb-security-context-propagation/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -195,20 +195,12 @@ Note that the `http-connector` in the `remoting` subsystem uses this `applicatio
// Build and Deploy the Quickstart JAR
include::../shared-doc/build-and-deploy-the-quickstart.adoc[leveloffset=+1]

== Run the Client

Before you run the client, make sure you have already successfully deployed the EJBs to the server in the previous step and that your terminal is still in the same folder.

Type this command to execute the client:

[source,options="nowrap"]
----
$ mvn exec:exec
----
// Server Distribution Testing
include::../shared-doc/run-integration-tests-with-server-distribution.adoc[leveloffset=+2]

== Investigate the Console Output

When you run the `mvn exec:exec` command, you see the following output. Note there may be other log messages interspersed between these.
When you run the integration tests, you see the following output. Note there may be other log messages interspersed between these.

[source,options="nowrap"]
----
Expand Down Expand Up @@ -279,6 +271,8 @@ ERROR [org.jboss.as.ejb3.invocation] (default task-57) WFLYEJB0034: EJB Invocati
at java.lang.Thread.run(Thread.java:745)
----

// Server Distribution Testing
include::../shared-doc/run-integration-tests-with-server-distribution.adoc[leveloffset=+2]
// Undeploy the Quickstart
include::../shared-doc/undeploy-the-quickstart.adoc[leveloffset=+1]
// Restore the {productName} Standalone Server Configuration
Expand All @@ -305,30 +299,10 @@ The batch executed successfully

// Restore the {productName} Standalone Server Configuration Manually
include::../shared-doc/restore-standalone-server-configuration-manual.adoc[leveloffset=+2]
// Run the Quickstart in Red Hat CodeReady Studio or Eclipse
include::../shared-doc/run-the-quickstart-in-jboss-developer-studio.adoc[leveloffset=+1]

// Additional Red Hat CodeReady Studio instructions
This quickstart requires additional configuration and deploys and runs differently in {JBDSProductName} than the other quickstarts.

. Make sure you xref:add_the_application_users[Add the Application Users] as described above.
. Follow the steps above to xref:configure_the_server[Configure the Server]. Stop the server at the end of that step.
. To deploy the application to the {productName} server, right-click on the *{artifactId}* project and choose *Run As* -> *Run on Server*.
. To access the application, right-click on the *{artifactId}* project and choose *Run As* -> *Java Application*.
. Choose *RemoteClient - org.jboss.as.quickstarts.ejb_security_context_propagation* and click *OK*.
. Review the output in the console window.
. To undeploy the project, right-click on the *{artifactId}* project and choose *Run As* -> *Maven build*. Enter `wildfly:undeploy` for the *Goals* and click *Run*.
. Make sure you xref:restore_the_server_configuration[restore the server configuration] when you have completed testing this quickstart.

// Debug the Application
include::../shared-doc/debug-the-application.adoc[leveloffset=+1]

//*************************************************
// Product Release content only
//*************************************************
ifdef::ProductRelease[]
// 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::[]

// Quickstart not compatible with OpenShift
include::../shared-doc/openshift-incompatibility.adoc[leveloffset=+1]
endif::[]
include::../shared-doc/openshift-incompatibility.adoc[leveloffset=+1]
2 changes: 1 addition & 1 deletion ejb-security-context-propagation/configure-elytron.cli
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ batch
run-batch

# Reload the server configuration
reload
#reload


Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ batch
run-batch

# Reload the server configuration
reload
#reload


144 changes: 105 additions & 39 deletions ejb-security-context-propagation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</parent>
<artifactId>ejb-security-context-propagation</artifactId>
<version>31.0.0.Beta1-SNAPSHOT</version>
<packaging>ejb</packaging>
<packaging>war</packaging>
<name>Quickstart: ejb-security-context-propagation</name>
<description>This project demonstrates the security context propagation between remote EJBs</description>

Expand All @@ -43,10 +43,12 @@
</licenses>

<properties>
<!-- To run this quickstart in Eclipse, we must turn on JDT APT to activate annotation processing-->
<m2e.apt.activation>jdt_apt</m2e.apt.activation>
<!-- the version for the Server -->
<version.server>30.0.0.Final</version.server>
<!-- The versions for BOMs, Dependencies and Plugins -->
<version.server.bom>30.0.0.Final</version.server.bom>
<version.bom.ee>${version.server}</version.bom.ee>
<version.pack.cloud>5.0.0.Final</version.pack.cloud>
<version.plugin.wildfly>4.2.0.Final</version.plugin.wildfly>
</properties>

<repositories>
Expand Down Expand Up @@ -110,7 +112,7 @@
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>wildfly-ee-with-tools</artifactId>
<version>${version.server.bom}</version>
<version>${version.bom.ee}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -144,44 +146,108 @@
<artifactId>jakarta.ejb-api</artifactId>
</dependency>

<!-- Import the Servlet API, we use provided scope as the API is included in JBoss EAP -->
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<scope>provided</scope>
</dependency>

<!-- Tests -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<!-- Set the name of the WAR, used as the context root when the app is deployed -->
<finalName>${project.artifactId}</finalName>
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<configuration>
<ejbVersion>3.2</ejbVersion>
<generateClient>true</generateClient>
</configuration>
</plugin>
<!-- Add the Maven exec plug-in to allow us to run a Java program via Maven -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
<executable>java</executable>
<workingDirectory>${project.build.directory}/exec-working-directory</workingDirectory>
<arguments>
<!-- automatically creates the classpath using all project dependencies,
also adding the project build directory -->
<argument>-classpath</argument>
<classpath></classpath>
<argument>org.jboss.as.quickstarts.ejb_security_context_propagation.RemoteClient</argument>
</arguments>
</configuration>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<configuration>
<ejbVersion>3.2</ejbVersion>
<generateClient>true</generateClient>
</configuration>
</plugin>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>${version.plugin.wildfly}</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>provisioned-server</id>
<build>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<configuration>
<feature-packs>
<feature-pack>
<location>org.wildfly:wildfly-galleon-pack:${version.server}</location>
</feature-pack>
</feature-packs>
<layers>
<!-- layers may be used to customize the server to provision -->
<layer>cloud-server</layer>
<layer>ejb</layer>
</layers>
<!-- use cli script(s) to configure the server -->
<packaging-scripts>
<packaging-script>
<scripts>
<script>${basedir}/configure-elytron.cli</script>
</scripts>
<!-- Expressions resolved during server execution -->
<resolve-expressions>false</resolve-expressions>
</packaging-script>
</packaging-scripts>
<!-- deploys the quickstart on root web context -->
<name>ROOT.war</name>
</configuration>
<executions>
<execution>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>integration-testing</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<includes>
<include>**/*IT</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -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;
/**
* <p>
* A simple servlet which indicates successful deployment of the quickstart.
* </p>
*
* <p>
* The servlet is registered and mapped to /ejb-security-context-propagation using the {@linkplain WebServlet
* @HttpServlet}.
* </p>
*
* @author Prarthona Paul
*
*/

@WebServlet("/ejb-security-context-propagation")
public class EJBServlet extends HttpServlet {

static String PAGE_HEADER = "<html><head><title>ejb-security-context-propagation</title></head><body>";

static String PAGE_FOOTER = "</body></html>";

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
resp.setContentType("text/html");
PrintWriter writer = resp.getWriter();
writer.println(PAGE_HEADER);
writer.println("ejb-security-context-propagation quickstart deployed successfully. You can find the available operations in the included README file.");
writer.println(PAGE_FOOTER);
writer.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
@PermitAll
public class IntermediateEJB implements IntermediateEJBRemote {

@EJB(lookup="ejb:/ejb-security-context-propagation/SecuredEJB!org.jboss.as.quickstarts.ejb_security_context_propagation.SecuredEJBRemote")
@EJB
private SecuredEJBRemote remote;

@Resource
Expand Down
22 changes: 22 additions & 0 deletions ejb-security-context-propagation/src/main/webapp/WEB-INF/beans.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->

<!-- Marker file indicating CDI should be enabled -->
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd" bean-discovery-mode="all">
</beans>
Loading

0 comments on commit af84e8e

Please sign in to comment.