├── .gitignore ├── README.md ├── amq ├── amq-concentrator │ ├── .sti │ │ └── bin │ │ │ └── run │ ├── README.md │ ├── amq62-funnel-s2i.json │ └── configuration │ │ └── openshift-activemq.xml └── amq-configuration │ ├── README.md │ └── configuration │ └── hello.xml ├── binary-cli-security-property ├── .s2i │ └── bin │ │ └── assemble ├── README.md └── TestDNSCaching.java ├── binary ├── deployments │ └── node-info.war └── top-level.war ├── custom-configuration ├── README.md └── configuration │ ├── standalone-openshift.xml │ └── standalone-openshift.xml.orig ├── custom-install-directories ├── README.md ├── bar │ └── deployments │ │ └── bar.jar ├── custom │ └── deployments │ │ └── node-info.war ├── foo │ └── deployments │ │ └── foo.jar └── top-level.war ├── custom-module ├── README.md ├── configuration │ ├── standalone-openshift.xml │ └── standalone-openshift.xml.orig └── modules │ └── org │ └── postgresql94 │ └── main │ ├── module.xml │ └── postgresql-9.4-1201.jdbc41.jar ├── demos └── sso │ ├── README.md │ ├── sso-all-in-one-demo-config.json │ ├── sso-demo-secret.json │ ├── sso70-eap64-all-in-one-demo.json │ ├── sso70-eap70-all-in-one-demo.json │ ├── sso71-eap64-all-in-one-demo.json │ └── sso71-eap70-all-in-one-demo.json ├── eap-dynamic-configuration ├── README.md ├── configuration │ └── .gitignore ├── pom.xml └── src │ └── configuration │ └── standalone-openshift.xml ├── eap-tests ├── README.md ├── cluster1 │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── org │ │ │ └── openshift │ │ │ └── examples │ │ │ └── cluster1 │ │ │ ├── Delay.java │ │ │ ├── Hi.java │ │ │ ├── ShowHeaders.java │ │ │ └── StoreInSession.java │ │ └── webapp │ │ ├── WEB-INF │ │ └── web.xml │ │ └── index.jsp └── jsengine │ ├── pom.xml │ └── src │ └── main │ └── java │ └── org │ └── openshift │ └── examples │ └── TestJSEngine.java ├── environment-only ├── .s2i │ └── environment └── .sti ├── helloworld-ws ├── README.html ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── jboss │ │ │ └── as │ │ │ └── quickstarts │ │ │ └── wshelloworld │ │ │ ├── HelloWorldService.java │ │ │ └── HelloWorldServiceImpl.java │ └── webapp │ │ ├── WEB-INF │ │ └── beans.xml │ │ └── index.html │ └── test │ ├── java │ └── org │ │ └── jboss │ │ └── as │ │ └── quickstarts │ │ └── wshelloworld │ │ ├── Client.java │ │ ├── ClientArqTest.java │ │ └── ClientTest.java │ └── resources │ └── arquillian.xml ├── helloworld ├── LICENSE.txt ├── README.html ├── README.md ├── configuration │ ├── standalone-openshift.xml │ └── standalone-openshift.xml.orig ├── modules │ └── org │ │ └── postgresql94 │ │ └── main │ │ ├── module.xml │ │ └── postgresql-9.4-1201.jdbc41.jar ├── pom.xml └── src │ └── main │ ├── java │ └── org │ │ └── jboss │ │ └── as │ │ └── quickstarts │ │ └── helloworld │ │ ├── HelloService.java │ │ └── HelloWorldServlet.java │ └── webapp │ ├── WEB-INF │ └── beans.xml │ └── index.html ├── jboss-fuse-eap ├── camel-cdi │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── org │ │ │ └── jboss │ │ │ └── openshift │ │ │ └── examples │ │ │ ├── MyRouteBuilder.java │ │ │ ├── SimpleServlet.java │ │ │ └── SomeBean.java │ │ └── webapp │ │ └── WEB-INF │ │ ├── beans.xml │ │ └── jboss-web.xml └── camel-spring │ ├── README.md │ ├── pom.xml │ └── src │ └── main │ └── resources │ └── META-INF │ └── spring-camel-context.xml ├── security-custom-configuration └── configuration │ ├── otherroles.properties │ ├── otherusers.properties │ ├── roles.properties │ └── users.properties ├── spring-boot-sample-simple ├── pom.xml ├── src │ └── main │ │ ├── java │ │ └── sample │ │ │ └── simple │ │ │ ├── ExitException.java │ │ │ ├── SampleSimpleApplication.java │ │ │ └── service │ │ │ └── HelloWorldService.java │ │ └── resources │ │ ├── application.properties │ │ ├── banner.jpg │ │ └── banner.txt └── target │ └── spring-boot-sample-simple-1.5.0.BUILD-SNAPSHOT.jar ├── spring-eap6-quickstart-custom-configuration ├── README.md ├── configuration │ └── settings.xml ├── deployments │ ├── .gitkeep │ └── ROOT.war └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── jboss │ │ │ └── tools │ │ │ └── example │ │ │ └── springmvc │ │ │ ├── domain │ │ │ └── Member.java │ │ │ ├── mvc │ │ │ ├── MemberController.java │ │ │ └── MemberRestController.java │ │ │ └── repo │ │ │ ├── MemberDao.java │ │ │ └── MemberDaoImpl.java │ ├── resources │ │ ├── META-INF │ │ │ ├── persistence.xml │ │ │ └── spring │ │ │ │ ├── applicationContext.xml │ │ │ │ └── infrastructure.xml │ │ └── import.sql │ └── webapp │ │ ├── WEB-INF │ │ ├── jboss-as-spring-mvc-context.xml │ │ ├── jboss-deployment-structure.xml │ │ ├── jboss-web.xml │ │ ├── spring-quickstart-ds.xml │ │ ├── views │ │ │ └── index.jsp │ │ └── web.xml │ │ └── resources │ │ ├── css │ │ └── screen.css │ │ └── gfx │ │ ├── asidebkg.png │ │ ├── banner.png │ │ ├── bkg-blkheader.png │ │ ├── dualbrand_as7eap.png │ │ ├── dualbrand_catapillarbutterfly.png │ │ ├── dualbrand_logo.png │ │ ├── headerbkg.png │ │ ├── icon_large.png │ │ ├── icon_medium.png │ │ ├── icon_small.png │ │ └── logo.png │ └── test │ ├── java │ └── org │ │ └── jboss │ │ └── tools │ │ └── example │ │ └── springmvc │ │ └── test │ │ └── MemberDaoTest.java │ └── resources │ ├── META-INF │ └── test-persistence.xml │ ├── import.sql │ └── test-context.xml ├── spring-eap6-quickstart ├── README.md ├── deployments │ ├── .gitkeep │ └── ROOT.war └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── jboss │ │ │ └── tools │ │ │ └── example │ │ │ └── springmvc │ │ │ ├── domain │ │ │ └── Member.java │ │ │ ├── mvc │ │ │ ├── MemberController.java │ │ │ └── MemberRestController.java │ │ │ └── repo │ │ │ ├── MemberDao.java │ │ │ └── MemberDaoImpl.java │ ├── resources │ │ ├── META-INF │ │ │ ├── persistence.xml │ │ │ └── spring │ │ │ │ ├── applicationContext.xml │ │ │ │ └── infrastructure.xml │ │ └── import.sql │ └── webapp │ │ ├── WEB-INF │ │ ├── jboss-as-spring-mvc-context.xml │ │ ├── jboss-deployment-structure.xml │ │ ├── jboss-web.xml │ │ ├── spring-quickstart-ds.xml │ │ ├── views │ │ │ └── index.jsp │ │ └── web.xml │ │ └── resources │ │ ├── css │ │ └── screen.css │ │ └── gfx │ │ ├── asidebkg.png │ │ ├── banner.png │ │ ├── bkg-blkheader.png │ │ ├── dualbrand_as7eap.png │ │ ├── dualbrand_catapillarbutterfly.png │ │ ├── dualbrand_logo.png │ │ ├── headerbkg.png │ │ ├── icon_large.png │ │ ├── icon_medium.png │ │ ├── icon_small.png │ │ └── logo.png │ └── test │ ├── java │ └── org │ │ └── jboss │ │ └── tools │ │ └── example │ │ └── springmvc │ │ └── test │ │ └── MemberDaoTest.java │ └── resources │ ├── META-INF │ └── test-persistence.xml │ ├── import.sql │ └── test-context.xml ├── sso-manual-db-migration ├── README.md └── configuration │ ├── standalone-openshift.xml │ └── standalone-openshift.xml.orig ├── sso-securedeployments ├── README.md ├── app-profile-jee-saml │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── org │ │ │ └── keycloak │ │ │ └── quickstart │ │ │ └── profilejee │ │ │ └── Controller.java │ │ └── webapp │ │ ├── WEB-INF │ │ ├── keycloak-saml.xml │ │ └── web.xml │ │ ├── index.jsp │ │ ├── profile.jsp │ │ └── styles.css ├── app-profile-jee │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── org │ │ │ └── keycloak │ │ │ └── quickstart │ │ │ └── profilejee │ │ │ └── Controller.java │ │ └── webapp │ │ ├── WEB-INF │ │ └── web.xml │ │ ├── index.jsp │ │ ├── profile.jsp │ │ └── styles.css ├── configuration │ ├── secure-deployments │ └── secure-saml-deployments └── pom.xml ├── tomcat-custom-configuration ├── README.md └── configuration │ ├── context-openshift.xml │ └── settings.xml ├── tomcat-dynamic-configuration ├── README.md ├── configuration │ └── .gitignore ├── pom.xml └── src │ └── configuration │ └── context-openshift.xml └── tomcat-helloworld ├── pom.xml └── src └── main ├── java └── org │ └── example │ └── HelloServlet.java └── webapp └── WEB-INF └── web.xml /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | *.iml 3 | *.ipr 4 | *.iws 5 | target/ 6 | .project 7 | .settings/ 8 | .classpath 9 | .metadata 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # openshift-examples 2 | -------------------------------------------------------------------------------- /amq/amq-concentrator/.sti/bin/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo Adding \"concentrator\" user to users file 4 | echo $CONCENTRATOR_USERNAME=$CONCENTRATOR_PASSWORD >> /opt/amq/conf/openshift-users.properties 5 | 6 | exec $AMQ_HOME/bin/launch.sh 7 | -------------------------------------------------------------------------------- /amq/amq-concentrator/README.md: -------------------------------------------------------------------------------- 1 | # AMQ Concentrator Topology Example # 2 | 3 | This example shows how to connect two separate networks of brokers, where the 4 | first network serves as a funnel for the second, which serves as a concentrator. 5 | 6 | This example uses custom configuration to connect the networks together. 7 | 8 | ## Firing it Up ## 9 | 10 | ### Create the Concentrator ### 11 | 12 | Create an application using the `amq62-basic` template with the following 13 | parameters: 14 | 15 | * `APPLICATION_NAME=concentrator` 16 | 17 | For example: 18 | 19 | $ oc process amq62-basic -v APPLICATION_NAME=concentrator,MQ_USERNAME=concentrator,MQ_PASSWORD=12345 -n openshift | oc create -f - 20 | 21 | This should create a single broker to serve as the concentrator. Verify that 22 | there is a *concentrator-amq-tcp* service. This is the service the funnels will 23 | use. 24 | 25 | ### Create the Funnel(s) ### 26 | 27 | Create an application using the [amq62-funnel-s2i.json](amq62-funnel-s2i.json) file located in this 28 | project. (This template adds an `ImageStream` and `BuildConfig` to the 29 | `amq62-basic` template and configures additional environment variables on the 30 | A-MQ container for connecting to the concentrator.) When processing the 31 | template, you'll need to specify the following parameters: 32 | 33 | * `CONCENTRATOR_SERVICE`: OpenWire (tcp) service name for the concentrator (e.g. *concentrator-amq-tcp*) 34 | * `CONCENTRATOR_USERNAME`: User name for the concentrator (e.g. *concentrator*) 35 | * `CONCENTRATOR_PASSWORD`: Password for the concentrator (e.g. *12345*) 36 | 37 | If you created the *concentrator* as documented above, create the first funnel: 38 | 39 | $ oc process -f amq62-funnel-s2i.json -v APPLICATION_NAME=funnel,CONCENTRATOR_SERVICE=concentrator-amq-tcp,CONCENTRATOR_USERNAME=concentrator,CONCENTRATOR_PASSWORD=12345 | oc create -f - 40 | 41 | This should create a single broker to serve as the funnel. Verify that the 42 | funnel is connected to the concentrator. You should see something like this 43 | in the logs: 44 | 45 | INFO | Network connection between vm://funnel-amq-1-uh01x#4 and tcp:///10.1.2.8:61616@57441 (concentrator-amq-1-5ks7g) has been established. 46 | 47 | Now scale up the funnel: 48 | 49 | $ oc scale dc funnel-amq --replicas=4 50 | 51 | You should now have a mesh of four brokers feeding into the concentrator. 52 | 53 | ## Cleaning Up ## 54 | 55 | To clean up: 56 | 57 | * The funnel: 58 | 59 | $ oc delete all -l application=funnel 60 | 61 | * The concentrator: 62 | 63 | $ oc delete all -l application=concentrator 64 | 65 | ## Customizations ## 66 | 67 | The concentrator broker's user needs to be configured on the funnel broker or 68 | the funnels will fail to connect to the concentrator. This project includes a 69 | customized [.sti/bin/run](.sti/bin/run) script which adds the concentrator user 70 | to the `conf/openshift-users.properties` file. 71 | 72 | The funnel broker also contains a custom openshift-activemq.xml file which 73 | adds a `networkConnector` that connects to the concentrator brokers. 74 | -------------------------------------------------------------------------------- /amq/amq-configuration/README.md: -------------------------------------------------------------------------------- 1 | == AMQ custom configuration example == 2 | 3 | This is a very simple example of providing a custom configuration 4 | file (a dummy 'hello world' file) that will be copied into the 5 | image's `conf` directory when built via STI. 6 | -------------------------------------------------------------------------------- /amq/amq-configuration/configuration/hello.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /binary-cli-security-property/.s2i/bin/assemble: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -ueo pipefail 3 | 4 | cd /tmp/src 5 | javac TestDNSCaching.java 6 | java TestDNSCaching # run this so S2I build logs contain the output 7 | jar cfe /deployments/TestDNSCaching.jar TestDNSCaching TestDNSCaching.class 8 | -------------------------------------------------------------------------------- /binary-cli-security-property/README.md: -------------------------------------------------------------------------------- 1 | This is a small example of a standalone Java CLI application and a 2 | custom s2i assemble script to build (and run) it. 3 | -------------------------------------------------------------------------------- /binary-cli-security-property/TestDNSCaching.java: -------------------------------------------------------------------------------- 1 | import java.security.Security; 2 | 3 | public class TestDNSCaching 4 | { 5 | public static void main(String[] args) 6 | { 7 | final String s = "networkaddress.cache.negative.ttl"; 8 | System.out.println(s + "=" + Security.getProperty(s)); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /binary/deployments/node-info.war: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/binary/deployments/node-info.war -------------------------------------------------------------------------------- /binary/top-level.war: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/binary/top-level.war -------------------------------------------------------------------------------- /custom-configuration/README.md: -------------------------------------------------------------------------------- 1 | # Custom configuration example 2 | 3 | This example shows how to add a custom configuration to the image. Expected result is to have the `DEBUG` log level enabled for console output. 4 | -------------------------------------------------------------------------------- /custom-install-directories/README.md: -------------------------------------------------------------------------------- 1 | Example application to verify proper work of images when the git source repository 2 | contains custom war, ear, jar, or rar modules in deployments/ directory present in 3 | the subdirectory of the source/ directory. 4 | 5 | Example environment variable usage: 6 | 7 | CUSTOM\_INSTALL\_DIRECTORIES=custom, 8 | 9 | or 10 | 11 | CUSTOM\_INSTALL\_DIRECTORIES=foo,bar 12 | -------------------------------------------------------------------------------- /custom-install-directories/bar/deployments/bar.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/custom-install-directories/bar/deployments/bar.jar -------------------------------------------------------------------------------- /custom-install-directories/custom/deployments/node-info.war: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/custom-install-directories/custom/deployments/node-info.war -------------------------------------------------------------------------------- /custom-install-directories/foo/deployments/foo.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/custom-install-directories/foo/deployments/foo.jar -------------------------------------------------------------------------------- /custom-install-directories/top-level.war: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/custom-install-directories/top-level.war -------------------------------------------------------------------------------- /custom-module/README.md: -------------------------------------------------------------------------------- 1 | # Custom module example 2 | 3 | This example shows how to add a custom module to JBoss EAP. By default a PostgreSQL 9.2 driver is being used. This example shows how to switch to version 9.4. 4 | 5 | When building the image you should see similar messages: 6 | 7 | ``` 8 | I0317 12:03:10.327088 18863 sti.go:357] Copying config files from project... 9 | I0317 12:03:10.331538 18863 sti.go:357] '/home/jboss/source/configuration/standalone-openshift.xml' -> '/opt/eap/standalone/configuration/standalone-openshift.xml' 10 | I0317 12:03:10.331587 18863 sti.go:357] Copying modules from project... 11 | I0317 12:03:10.337968 18863 sti.go:357] '/home/jboss/source/modules/org/postgresql94' -> '/opt/eap/modules/org/postgresql94' 12 | I0317 12:03:10.337997 18863 sti.go:357] '/home/jboss/source/modules/org/postgresql94/main' -> '/opt/eap/modules/org/postgresql94/main' 13 | I0317 12:03:10.338002 18863 sti.go:357] '/home/jboss/source/modules/org/postgresql94/main/module.xml' -> '/opt/eap/modules/org/postgresql94/main/module.xml' 14 | I0317 12:03:10.338007 18863 sti.go:357] '/home/jboss/source/modules/org/postgresql94/main/postgresql-9.4-1201.jdbc41.jar' -> '/opt/eap/modules/org/postgresql94/main/postgresql-9.4-1201.jdbc41.jar' 15 | ``` 16 | 17 | And when you boot you should see the correct driver being used: 18 | 19 | ``` 20 | 12:04:09,467 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 29) JBAS010404: Deploying non-JDBC-compliant driver class org.postgresql.Driver (version 9.4) 21 | ``` 22 | -------------------------------------------------------------------------------- /custom-module/modules/org/postgresql94/main/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /custom-module/modules/org/postgresql94/main/postgresql-9.4-1201.jdbc41.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/custom-module/modules/org/postgresql94/main/postgresql-9.4-1201.jdbc41.jar -------------------------------------------------------------------------------- /demos/sso/README.md: -------------------------------------------------------------------------------- 1 | #Application Templates 2 | This project contains OpenShift v3 all-in-one, demo application templates which support Red Hat SSO/Keycloak and SSO-enabled JEE applications 3 | 4 | ##Structure 5 | 6 | All-in-one example (SSO/Keycloak + various EAP applications utilizing SSO) in ../demos: 7 | * sso-demo-secret.json: Secret containing full SSO/Keycloak configuration used for import. Required for the all-in-one template 8 | * sso-all-in-one-demo-config.json: SSO configuration exported by the SSO Server used to create sso-demo-secret.json. Non-functional, for information only. 9 | * sso70-all-in-one-demo.json: All-in-one SSO/Keycloak template backed by Postgresql with integrated EAP-based example applications 10 | * sso70-all-in-one-demo-persistent.json: All-in-one SSO/Keycloak template backed by persistent Postgresql with integrated EAP-based example applications 11 | 12 | Templates are configured with the following basic parameters: 13 | * HOSTNAME_HTTP/HOSTNAME_HTTPS: Hostnames of the SSO-enabled JEE application (defaults to helloworld.cloudapps.example.com, secure-helloworld.cloudapps.example.com) 14 | * SSO_HOSTNAME_HTTP/SSO_HOSTNAME_HTTPS: Hostnames of the SSO server (defaults to sso.cloudapps.example.com, secure-sso.cloudapps.example.com) 15 | 16 | ##Username/Password 17 | For SSO/Keycloak User created in SSO/Server in All-in-One: demouser/demopass 18 | 19 | ##All-in-One Example 20 | 21 | NOTE: The all-in-one templates assume a domain of cloudapps.example.com. The templates will need to be modified (HOSTNAME_HTTP(S), SSO_HOSTNAME_HTTP(S)) when using another domain 22 | 23 | Create Secrets, SSO/Keycloak Server, and SSO/Keycloak-enabled EAP in user (e.g. "myproject") project/namespace: 24 | 25 | ``` 26 | $ oc create -n myproject -f sso-demo-secret.json 27 | $ oc process -f sso70-all-in-one-demo.json | oc create -n myproject -f - 28 | ``` 29 | 30 | After executing the above, you should be able to access the SSO/Keycloak-enabled applications at http://helloworld-myproject.hostname/app-context and https://secure-helloworld-myproject.hostname/app-context where app-context is app-jsp, app-profile-jsp, app-profile-saml-jsp, or service depending on the example application. 31 | 32 | -------------------------------------------------------------------------------- /eap-dynamic-configuration/README.md: -------------------------------------------------------------------------------- 1 | # Eap Dynamic Custom configuration example 2 | 3 | This example shows how to have the maven build, add a custom configuration to the image. Expected result is to have the `DEBUG` log level enabled for console output. 4 | -------------------------------------------------------------------------------- /eap-dynamic-configuration/configuration/.gitignore: -------------------------------------------------------------------------------- 1 | /standalone-openshift.xml 2 | -------------------------------------------------------------------------------- /eap-dynamic-configuration/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | org.example 5 | eap-dynamic-configuration 6 | pom 7 | 1.0-SNAPSHOT 8 | EAP Dynamic Configuration 9 | http://maven.apache.org 10 | 11 | 12 | 13 | maven-resources-plugin 14 | 2.5 15 | 16 | 17 | copy-resources 18 | validate 19 | 20 | copy-resources 21 | 22 | 23 | ${basedir}/configuration 24 | 25 | 26 | src/configuration 27 | true 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /eap-tests/README.md: -------------------------------------------------------------------------------- 1 | # EAP Tests 2 | 3 | Small apps that support the tests from https://github.com/jboss-openshift/ce-testsuite 4 | 5 | -------------------------------------------------------------------------------- /eap-tests/cluster1/README.md: -------------------------------------------------------------------------------- 1 | # Cluster1 2 | 3 | Small app that has 3 servlets: 4 | 5 | #### Hi 6 | It just prints something like `Served from node: machine-name/192.168.1.40`. Useful when you have a cluster and want to know which node has served you. 7 | 8 | #### ShowHeaders 9 | It just prints all request headers as well all request parameters. Useful for debugging. 10 | 11 | #### StoreInSession 12 | Accepts `POST` and `GET` requests and works like this: 13 | - You first `POST` to it, passing a value to the parameter named `key`. 14 | - Then you just `GET` the servlet. It will print the value previously stored in the `POST`. 15 | 16 | The interesting use case of this is to `POST` into a node and `GET` from another, to test if session replication is working. 17 | 18 | -------------------------------------------------------------------------------- /eap-tests/cluster1/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | org.openshift.examples 5 | org.openshift.examples.cluster1 6 | war 7 | 0.0.1-SNAPSHOT 8 | Small app for testing clustering in EAP 9 | https://github.com/jboss-openshift/openshift-examples/tree/master/eap-tests 10 | 11 | 12 | 13 | junit 14 | junit 15 | 3.8.1 16 | test 17 | 18 | 19 | 20 | javax.servlet 21 | javax.servlet-api 22 | 3.1.0 23 | 24 | 25 | 26 | 27 | cluster1 28 | 29 | 30 | 31 | 32 | org.jboss.as.plugins 33 | jboss-as-maven-plugin 34 | 7.4.Final 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /eap-tests/cluster1/src/main/java/org/openshift/examples/cluster1/Delay.java: -------------------------------------------------------------------------------- 1 | package org.openshift.examples.cluster1; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | import java.net.InetAddress; 6 | 7 | import javax.servlet.ServletException; 8 | import javax.servlet.http.HttpServlet; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | 12 | public class Delay extends HttpServlet { 13 | private static final long serialVersionUID = 1L; 14 | 15 | @Override 16 | protected void doGet(HttpServletRequest request, HttpServletResponse response) 17 | throws ServletException, IOException { 18 | PrintWriter out = response.getWriter(); 19 | 20 | String d = request.getParameter("d"); 21 | if (d == null || d.isEmpty()) 22 | d = "180"; 23 | int seconds; 24 | try { 25 | seconds = Integer.parseInt(d); 26 | if (seconds < 0) 27 | seconds = 0; 28 | } catch (NumberFormatException e) { 29 | seconds = 180; 30 | } 31 | 32 | out.println(String.format("Delaying %d seconds from node: %s", seconds, InetAddress.getLocalHost().toString())); 33 | out.flush(); 34 | 35 | for (int i = 0; i < seconds; i++) { 36 | try { 37 | out.println("*"); 38 | out.flush(); 39 | Thread.sleep(1000); 40 | } catch (InterruptedException e) { 41 | e.printStackTrace(); 42 | } 43 | } 44 | 45 | out.println("Bye"); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /eap-tests/cluster1/src/main/java/org/openshift/examples/cluster1/Hi.java: -------------------------------------------------------------------------------- 1 | package org.openshift.examples.cluster1; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | import java.net.InetAddress; 6 | 7 | import javax.servlet.ServletException; 8 | import javax.servlet.http.HttpServlet; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | 12 | public class Hi extends HttpServlet { 13 | private static final long serialVersionUID = 1L; 14 | 15 | @Override 16 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 17 | PrintWriter out = response.getWriter(); 18 | out.println("Served from node: " + InetAddress.getLocalHost().toString()); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /eap-tests/cluster1/src/main/java/org/openshift/examples/cluster1/ShowHeaders.java: -------------------------------------------------------------------------------- 1 | package org.openshift.examples.cluster1; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | import java.util.Enumeration; 6 | 7 | import javax.servlet.ServletException; 8 | import javax.servlet.http.HttpServlet; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | 12 | public class ShowHeaders extends HttpServlet { 13 | private static final long serialVersionUID = 1L; 14 | 15 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 16 | PrintWriter out = response.getWriter(); 17 | 18 | for (Enumeration e = request.getHeaderNames(); e.hasMoreElements();) { 19 | String headerName = e.nextElement(); 20 | out.println(String.format("%s: %s", headerName, request.getHeader(headerName))); 21 | } 22 | out.println(); 23 | 24 | for (Enumeration e = request.getParameterNames(); e.hasMoreElements();) { 25 | String paramName = e.nextElement(); 26 | out.println(String.format("%s: %s", paramName, request.getParameter(paramName))); 27 | } 28 | } 29 | 30 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 31 | doGet(request, response); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /eap-tests/cluster1/src/main/java/org/openshift/examples/cluster1/StoreInSession.java: -------------------------------------------------------------------------------- 1 | package org.openshift.examples.cluster1; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | 6 | import javax.servlet.ServletException; 7 | import javax.servlet.http.HttpServlet; 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | import javax.servlet.http.HttpSession; 11 | 12 | public class StoreInSession extends HttpServlet { 13 | private static final long serialVersionUID = 1L; 14 | private static final String KEY = "key"; 15 | 16 | @Override 17 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 18 | HttpSession session = request.getSession(); 19 | Object attribute = session.getAttribute(KEY); 20 | 21 | PrintWriter out = response.getWriter(); 22 | out.print(String.valueOf(attribute)); 23 | } 24 | 25 | @Override 26 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 27 | HttpSession session = request.getSession(); 28 | String value = request.getParameter(KEY); 29 | session.setAttribute(KEY, value); 30 | 31 | PrintWriter out = response.getWriter(); 32 | out.print("OK"); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /eap-tests/cluster1/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | Hi 10 | org.openshift.examples.cluster1.Hi 11 | 12 | 13 | 14 | StoreInSession 15 | org.openshift.examples.cluster1.StoreInSession 16 | 17 | 18 | 19 | ShowHeaders 20 | org.openshift.examples.cluster1.ShowHeaders 21 | 22 | 23 | 24 | Delay 25 | org.openshift.examples.cluster1.Delay 26 | 27 | 28 | 29 | Hi 30 | /Hi 31 | 32 | 33 | 34 | StoreInSession 35 | /StoreInSession 36 | 37 | 38 | 39 | ShowHeaders 40 | /ShowHeaders 41 | 42 | 43 | 44 | Delay 45 | /Delay 46 | 47 | 48 | -------------------------------------------------------------------------------- /eap-tests/cluster1/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Hello World!

4 | 5 | 6 | -------------------------------------------------------------------------------- /eap-tests/jsengine/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | jar 7 | org.openshift.examples 8 | js.engine 9 | 1.0 10 | 11 | 12 | UTF-8 13 | 1.8 14 | 1.8 15 | 1.0.3.Final 16 | 17 | 18 | 19 | 20 | 21 | 22 | org.jboss.spec 23 | jboss-javaee-7.0 24 | ${jboss.javaee7.version} 25 | pom 26 | import 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | org.jboss.spec.javax.ejb 37 | jboss-ejb-api_3.2_spec 38 | provided 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /eap-tests/jsengine/src/main/java/org/openshift/examples/TestJSEngine.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual 4 | * contributors by the @authors tag. See the copyright.txt in the 5 | * distribution for a full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.openshift.examples; 19 | 20 | import javax.annotation.PostConstruct; 21 | import javax.ejb.Singleton; 22 | import javax.ejb.Startup; 23 | import javax.script.ScriptEngine; 24 | import javax.script.ScriptEngineManager; 25 | import java.util.logging.Logger; 26 | 27 | /** 28 | * Created by fspolti on 7/1/16. 29 | */ 30 | 31 | @Singleton 32 | @Startup 33 | public class TestJSEngine { 34 | 35 | private Logger log = Logger.getLogger(TestJSEngine.class.getName()); 36 | 37 | /* 38 | * Test if the EAP has the native Java Script 39 | */ 40 | @PostConstruct 41 | private void testEngine () { 42 | 43 | try { 44 | // getting the available JavaScript engines 45 | ScriptEngine engineByName = new ScriptEngineManager().getEngineByName("JavaScript"); 46 | log.info("Engine found: " + engineByName); 47 | 48 | // checking for the JavaScript engine native class 49 | Class.forName("jdk.nashorn.api.scripting.NashornScriptEngine"); 50 | log.info("Engine class provider found."); 51 | 52 | } catch (ClassNotFoundException e) { 53 | log.warning("JavaScript engine not found."); 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /environment-only/.s2i/environment: -------------------------------------------------------------------------------- 1 | FOO=Iedieve8 2 | -------------------------------------------------------------------------------- /environment-only/.sti: -------------------------------------------------------------------------------- 1 | .s2i/ -------------------------------------------------------------------------------- /helloworld-ws/src/main/java/org/jboss/as/quickstarts/wshelloworld/HelloWorldService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual 4 | * contributors by the @authors tag. See the copyright.txt in the 5 | * distribution for a full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.as.quickstarts.wshelloworld; 18 | 19 | import java.util.List; 20 | 21 | import javax.jws.WebMethod; 22 | import javax.jws.WebService; 23 | 24 | /** 25 | * A simple example of how to setup a JAX-WS Web Service. It can say hello to everyone or to someone in particular. 26 | * 27 | * @author lnewson@redhat.com 28 | */ 29 | 30 | @WebService(targetNamespace = "http://www.jboss.org/jbossas/quickstarts/wshelloworld/HelloWorld") 31 | public interface HelloWorldService { 32 | 33 | /** 34 | * Say hello as a response 35 | * 36 | * @return A simple hello world message 37 | */ 38 | @WebMethod 39 | public String sayHello(); 40 | 41 | /** 42 | * Say hello to someone precisely 43 | * 44 | * @param name The name of the person to say hello to 45 | * @return the number of current bookings 46 | */ 47 | @WebMethod 48 | public String sayHelloToName(String name); 49 | 50 | /** 51 | * Say hello to a list of people 52 | * 53 | * @param names The list of names to say hello to 54 | * @return the number of current bookings 55 | */ 56 | @WebMethod 57 | public String sayHelloToNames(List names); 58 | } 59 | -------------------------------------------------------------------------------- /helloworld-ws/src/main/java/org/jboss/as/quickstarts/wshelloworld/HelloWorldServiceImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual 4 | * contributors by the @authors tag. See the copyright.txt in the 5 | * distribution for a full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.as.quickstarts.wshelloworld; 18 | 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | import javax.jws.WebService; 23 | 24 | /** 25 | * The implementation of the HelloWorld JAX-WS Web Service. 26 | * 27 | * @author lnewson@redhat.com 28 | */ 29 | @WebService(serviceName = "HelloWorldService", portName = "HelloWorld", name = "HelloWorld", endpointInterface = "org.jboss.as.quickstarts.wshelloworld.HelloWorldService", targetNamespace = "http://www.jboss.org/jbossas/quickstarts/wshelloworld/HelloWorld") 30 | public class HelloWorldServiceImpl implements HelloWorldService { 31 | 32 | @Override 33 | public String sayHello() { 34 | return "Hello World!"; 35 | } 36 | 37 | @Override 38 | public String sayHelloToName(final String name) { 39 | 40 | /* Create a list with just the one value */ 41 | final List names = new ArrayList(); 42 | names.add(name); 43 | 44 | return sayHelloToNames(names); 45 | } 46 | 47 | @Override 48 | public String sayHelloToNames(final List names) { 49 | return "Hello " + createNameListString(names); 50 | } 51 | 52 | /** 53 | * Creates a list of names separated by commas or an and symbol if its the last separation. This is then used to say hello to 54 | * the list of names. 55 | * 56 | * i.e. if the input was {John, Mary, Luke} the output would be John, Mary & Luke 57 | * 58 | * @param names A list of names 59 | * @return The list of names separated as described above. 60 | */ 61 | private String createNameListString(final List names) { 62 | 63 | /* 64 | * If the list is null or empty then assume the call was anonymous. 65 | */ 66 | if (names == null || names.isEmpty()) { 67 | return "Anonymous!"; 68 | } 69 | 70 | final StringBuilder nameBuilder = new StringBuilder(); 71 | for (int i = 0; i < names.size(); i++) { 72 | 73 | /* 74 | * Add the separator if its not the first string or the last separator since that should be an and (&) symbol. 75 | */ 76 | if (i != 0 && i != names.size() - 1) 77 | nameBuilder.append(", "); 78 | else if (i != 0 && i == names.size() - 1) 79 | nameBuilder.append(" & "); 80 | 81 | nameBuilder.append(names.get(i)); 82 | } 83 | 84 | nameBuilder.append("!"); 85 | 86 | return nameBuilder.toString(); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /helloworld-ws/src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 21 | 25 | 26 | -------------------------------------------------------------------------------- /helloworld-ws/src/main/webapp/index.html: -------------------------------------------------------------------------------- 1 | 17 | 18 | jboss-helloworld-ws Quickstart 19 | 20 | 21 | 22 |

helloworld-ws Quickstart

23 |

24 | The helloworld-ws quickstart demonstrates the use of JAX-WS in 25 | Red Hat JBoss Enterprise Application Platform as a simple Hello World application. 26 |

27 |

28 | There is no user interface for this quickstart. Instead, you can verify the 29 | Web Service is running and deployed correctly by accessing the following URL: 30 |

31 | 34 |

35 | This URL will display the WSDL definition for the deployed Web Service endpoint. 36 |

37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /helloworld-ws/src/test/java/org/jboss/as/quickstarts/wshelloworld/Client.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual 4 | * contributors by the @authors tag. See the copyright.txt in the 5 | * distribution for a full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.as.quickstarts.wshelloworld; 18 | 19 | import org.jboss.as.quickstarts.wshelloworld.HelloWorldService; 20 | 21 | import javax.xml.namespace.QName; 22 | import javax.xml.ws.Service; 23 | import java.net.MalformedURLException; 24 | import java.net.URL; 25 | import java.util.List; 26 | 27 | /** 28 | * A Client stub to the HelloWorld JAX-WS Web Service. 29 | * 30 | * @author lnewson@redhat.com 31 | */ 32 | public class Client implements HelloWorldService { 33 | private HelloWorldService helloWorldService; 34 | 35 | /** 36 | * Default constructor 37 | * 38 | * @param url The URL to the Hello World WSDL endpoint. 39 | */ 40 | public Client(final URL wsdlUrl) { 41 | QName serviceName = new QName("http://www.jboss.org/jbossas/quickstarts/wshelloworld/HelloWorld", "HelloWorldService"); 42 | 43 | Service service = Service.create(wsdlUrl, serviceName); 44 | helloWorldService = service.getPort(HelloWorldService.class); 45 | assert (helloWorldService != null); 46 | } 47 | 48 | /** 49 | * Default constructor 50 | * 51 | * @param url The URL to the Hello World WSDL endpoint. 52 | * @throws MalformedURLException if the WSDL url is malformed. 53 | */ 54 | public Client(final String url) throws MalformedURLException { 55 | this(new URL(url)); 56 | } 57 | 58 | /** 59 | * Gets the Web Service to say hello 60 | */ 61 | @Override 62 | public String sayHello() { 63 | return helloWorldService.sayHello(); 64 | } 65 | 66 | /** 67 | * Gets the Web Service to say hello to someone 68 | */ 69 | @Override 70 | public String sayHelloToName(final String name) { 71 | return helloWorldService.sayHelloToName(name); 72 | } 73 | 74 | /** 75 | * Gets the Web Service to say hello to a group of people 76 | */ 77 | @Override 78 | public String sayHelloToNames(final List names) { 79 | return helloWorldService.sayHelloToNames(names); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /helloworld-ws/src/test/java/org/jboss/as/quickstarts/wshelloworld/ClientArqTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual 4 | * contributors by the @authors tag. See the copyright.txt in the 5 | * distribution for a full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.as.quickstarts.wshelloworld; 18 | 19 | import static org.junit.Assert.*; 20 | 21 | import java.net.MalformedURLException; 22 | import java.net.URL; 23 | import java.util.ArrayList; 24 | import java.util.List; 25 | 26 | import org.jboss.arquillian.container.test.api.Deployment; 27 | import org.jboss.arquillian.junit.Arquillian; 28 | import org.jboss.arquillian.test.api.ArquillianResource; 29 | import org.jboss.as.quickstarts.wshelloworld.HelloWorldService; 30 | import org.jboss.shrinkwrap.api.ShrinkWrap; 31 | import org.jboss.shrinkwrap.api.spec.WebArchive; 32 | import org.junit.Before; 33 | import org.junit.Test; 34 | import org.junit.runner.RunWith; 35 | 36 | /** 37 | * Simple set of tests for the HelloWorld Web Service to demonstrate accessing the web service using a client 38 | * 39 | * @author lnewson@redhat.com 40 | */ 41 | @RunWith(Arquillian.class) 42 | public class ClientArqTest { 43 | /** 44 | * The name of the WAR Archive that will be used by Arquillian to deploy the application. 45 | */ 46 | private static final String APP_NAME = "jboss-helloworld-ws"; 47 | /** 48 | * The path of the WSDL endpoint in relation to the deployed web application. 49 | */ 50 | private static final String WSDL_PATH = "HelloWorldService?wsdl"; 51 | 52 | @ArquillianResource 53 | private URL deploymentUrl; 54 | 55 | private HelloWorldService client; 56 | 57 | @Deployment(testable = false) 58 | public static WebArchive createDeployment() { 59 | return ShrinkWrap.create(WebArchive.class, APP_NAME + ".war").addPackage(HelloWorldService.class.getPackage()); 60 | } 61 | 62 | @Before 63 | public void setup() { 64 | try { 65 | client = new Client(new URL(deploymentUrl, WSDL_PATH)); 66 | } catch (MalformedURLException e) { 67 | e.printStackTrace(); 68 | } 69 | } 70 | 71 | @Test 72 | public void testHello() { 73 | System.out.println("[Client] Requesting the WebService to say Hello."); 74 | 75 | // Get a response from the WebService 76 | final String response = client.sayHello(); 77 | assertEquals(response, "Hello World!"); 78 | 79 | System.out.println("[WebService] " + response); 80 | 81 | } 82 | 83 | @Test 84 | public void testHelloName() { 85 | System.out.println("[Client] Requesting the WebService to say Hello to John."); 86 | 87 | // Get a response from the WebService 88 | final String response = client.sayHelloToName("John"); 89 | assertEquals(response, "Hello John!"); 90 | 91 | System.out.println("[WebService] " + response); 92 | } 93 | 94 | @Test 95 | public void testHelloNames() { 96 | System.out.println("[Client] Requesting the WebService to say Hello to John, Mary and Mark."); 97 | 98 | // Create the array of names for the WebService to say hello to. 99 | final List names = new ArrayList(); 100 | names.add("John"); 101 | names.add("Mary"); 102 | names.add("Mark"); 103 | 104 | // Get a response from the WebService 105 | final String response = client.sayHelloToNames(names); 106 | assertEquals(response, "Hello John, Mary & Mark!"); 107 | 108 | System.out.println("[WebService] " + response); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /helloworld-ws/src/test/java/org/jboss/as/quickstarts/wshelloworld/ClientTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual 4 | * contributors by the @authors tag. See the copyright.txt in the 5 | * distribution for a full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.as.quickstarts.wshelloworld; 18 | 19 | import static org.junit.Assert.*; 20 | 21 | import java.net.MalformedURLException; 22 | import java.net.URL; 23 | import java.util.ArrayList; 24 | import java.util.List; 25 | 26 | import org.jboss.as.quickstarts.wshelloworld.HelloWorldService; 27 | import org.junit.Before; 28 | import org.junit.BeforeClass; 29 | import org.junit.Test; 30 | 31 | /** 32 | * Simple set of tests for the HelloWorld Web Service to demonstrate accessing the web service using a client 33 | * 34 | * @author lnewson@redhat.com 35 | */ 36 | public class ClientTest { 37 | /** 38 | * The name of the WAR Archive that will be used by Arquillian to deploy the application. 39 | */ 40 | private static final String APP_NAME = "jboss-helloworld-ws"; 41 | /** 42 | * The path of the WSDL endpoint in relation to the deployed web application. 43 | */ 44 | private static final String WSDL_PATH = "HelloWorldService?wsdl"; 45 | 46 | /** 47 | * The name for the Server URL System Property. 48 | */ 49 | private static final String SERVER_URL_PROPERTY = "serverUrl"; 50 | /** 51 | * The Default Server URL if one isn't specified as a System Property 52 | */ 53 | private static final String DEFAULT_SERVER_URL = "http://localhost:8080/"; 54 | 55 | private static URL deploymentUrl; 56 | 57 | private HelloWorldService client; 58 | 59 | @BeforeClass 60 | public static void beforeClass() throws MalformedURLException 61 | { 62 | String deploymentUrl = System.getProperty(SERVER_URL_PROPERTY); 63 | 64 | // Check that the server URL property was set. If it wasn't then use the default. 65 | if (deploymentUrl == null || deploymentUrl.isEmpty()) { 66 | deploymentUrl = DEFAULT_SERVER_URL; 67 | } 68 | 69 | // Ensure that the URL ends with a forward slash 70 | if (!deploymentUrl.endsWith("/")) { 71 | deploymentUrl += "/"; 72 | } 73 | 74 | // Ensure the App Name is specified in the URL 75 | if (!deploymentUrl.matches(".*" + APP_NAME + ".*")) 76 | { 77 | deploymentUrl += APP_NAME + "/"; 78 | } 79 | 80 | // Add the WDSL Document location to the URL 81 | deploymentUrl += WSDL_PATH; 82 | 83 | System.out.println("WSDL Deployment URL: " + deploymentUrl); 84 | 85 | // Set the deployment url 86 | ClientTest.deploymentUrl = new URL(deploymentUrl); 87 | } 88 | 89 | @Before 90 | public void setup() { 91 | try { 92 | client = new Client(new URL(deploymentUrl, WSDL_PATH)); 93 | } catch (MalformedURLException e) { 94 | e.printStackTrace(); 95 | } 96 | } 97 | 98 | @Test 99 | public void testHello() { 100 | System.out.println("[Client] Requesting the WebService to say Hello."); 101 | 102 | // Get a response from the WebService 103 | final String response = client.sayHello(); 104 | assertEquals(response, "Hello World!"); 105 | 106 | System.out.println("[WebService] " + response); 107 | 108 | } 109 | 110 | @Test 111 | public void testHelloName() { 112 | System.out.println("[Client] Requesting the WebService to say Hello to John."); 113 | 114 | // Get a response from the WebService 115 | final String response = client.sayHelloToName("John"); 116 | assertEquals(response, "Hello John!"); 117 | 118 | System.out.println("[WebService] " + response); 119 | } 120 | 121 | @Test 122 | public void testHelloNames() { 123 | System.out.println("[Client] Requesting the WebService to say Hello to John, Mary and Mark."); 124 | 125 | // Create the array of names for the WebService to say hello to. 126 | final List names = new ArrayList(); 127 | names.add("John"); 128 | names.add("Mary"); 129 | names.add("Mark"); 130 | 131 | // Get a response from the WebService 132 | final String response = client.sayHelloToNames(names); 133 | assertEquals(response, "Hello John, Mary & Mark!"); 134 | 135 | System.out.println("[WebService] " + response); 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /helloworld-ws/src/test/resources/arquillian.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /helloworld/README.md: -------------------------------------------------------------------------------- 1 | helloworld: Helloworld Example 2 | =============================== 3 | Author: Pete Muir 4 | Level: Beginner 5 | Technologies: CDI, Servlet 6 | Summary: The `helloworld` quickstart demonstrates the use of *CDI 1.0* and *Servlet 3* and is a good starting point to verify JBoss EAP is configured correctly. 7 | Target Product: JBoss EAP 8 | Source: 9 | 10 | What is it? 11 | ----------- 12 | 13 | The `helloworld` quickstart demonstrates the use of *CDI 1.0* and *Servlet 3* in Red Hat JBoss Enterprise Application Platform 6. 14 | 15 | 16 | System requirements 17 | ------------------- 18 | 19 | The application this project produces is designed to be run on Red Hat JBoss Enterprise Application Platform 6.1 or later. 20 | 21 | All you need to build this project is Java 6.0 (Java SDK 1.6) or later, Maven 3.0 or later. 22 | 23 | Configure Maven 24 | --------------- 25 | 26 | If you have not yet done so, you must [Configure Maven](https://github.com/jboss-developer/jboss-developer-shared-resources/blob/master/guides/CONFIGURE_MAVEN.md#configure-maven-to-build-and-deploy-the-quickstarts) before testing the quickstarts. 27 | 28 | 29 | Use of EAP_HOME 30 | --------------- 31 | 32 | In the following instructions, replace `EAP_HOME` with the actual path to your JBoss EAP 6 installation. The installation path is described in detail here: [Use of EAP_HOME and JBOSS_HOME Variables](https://github.com/jboss-developer/jboss-developer-shared-resources/blob/master/guides/USE_OF_EAP_HOME.md#use-of-eap_home-and-jboss_home-variables). 33 | 34 | 35 | Start the JBoss EAP Server 36 | ------------------------- 37 | 38 | 1. Open a command prompt and navigate to the root of the JBoss EAP directory. 39 | 2. The following shows the command line to start the server: 40 | 41 | For Linux: EAP_HOME/bin/standalone.sh 42 | For Windows: EAP_HOME\bin\standalone.bat 43 | 44 | 45 | Build and Deploy the Quickstart 46 | ------------------------- 47 | 48 | _NOTE: The following build command assumes you have configured your Maven user settings. If you have not, you must include Maven setting arguments on the command line. See [Build and Deploy the Quickstarts](https://github.com/jboss-developer/jboss-developer-shared-resources/blob/master/guides/BUILD_AND_DEPLOY.md#build-and-deploy-the-quickstarts) for complete instructions and additional options._ 49 | 50 | 1. Make sure you have started the JBoss EAP server as described above. 51 | 2. Open a command prompt and navigate to the root directory of this quickstart. 52 | 3. Type this command to build and deploy the archive: 53 | 54 | mvn clean install jboss-as:deploy 55 | 56 | 4. This will deploy `target/jboss-helloworld.war` to the running instance of the server. 57 | 58 | 59 | Access the application 60 | --------------------- 61 | 62 | The application will be running at the following URL: . 63 | 64 | 65 | Undeploy the Archive 66 | -------------------- 67 | 68 | 1. Make sure you have started the JBoss EAP server as described above. 69 | 2. Open a command prompt and navigate to the root directory of this quickstart. 70 | 3. When you are finished testing, type this command to undeploy the archive: 71 | 72 | mvn jboss-as:undeploy 73 | 74 | 75 | Run the Quickstart in Red Hat JBoss Developer Studio or Eclipse 76 | ------------------------------------- 77 | You can also start the server and deploy the quickstarts or run the Arquillian tests from Eclipse using JBoss tools. For general information about how to import a quickstart, add a JBoss EAP server, and build and deploy a quickstart, see [Use JBoss Developer Studio or Eclipse to Run the Quickstarts](https://github.com/jboss-developer/jboss-developer-shared-resources/blob/master/guides/USE_JBDS.md#use-jboss-developer-studio-or-eclipse-to-run-the-quickstarts) 78 | 79 | 80 | Debug the Application 81 | ------------------------------------ 82 | 83 | If you want to debug the source code of any library in the project, run the following command to pull the source into your local repository. The IDE should then detect it. 84 | 85 | mvn dependency:sources 86 | 87 | -------------------------------------------------------------------------------- /helloworld/modules/org/postgresql94/main/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /helloworld/modules/org/postgresql94/main/postgresql-9.4-1201.jdbc41.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/helloworld/modules/org/postgresql94/main/postgresql-9.4-1201.jdbc41.jar -------------------------------------------------------------------------------- /helloworld/src/main/java/org/jboss/as/quickstarts/helloworld/HelloService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual 4 | * contributors by the @authors tag. See the copyright.txt in the 5 | * distribution for a full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.as.quickstarts.helloworld; 18 | 19 | /** 20 | * A simple CDI service which is able to say hello to someone 21 | * 22 | * @author Pete Muir 23 | * 24 | */ 25 | public class HelloService { 26 | 27 | String createHelloMessage(String name) { 28 | return "Hello " + name + "!"; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /helloworld/src/main/java/org/jboss/as/quickstarts/helloworld/HelloWorldServlet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JBoss, Home of Professional Open Source 3 | * Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual 4 | * contributors by the @authors tag. See the copyright.txt in the 5 | * distribution for a full listing of individual contributors. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.jboss.as.quickstarts.helloworld; 18 | 19 | import java.io.IOException; 20 | import java.io.PrintWriter; 21 | 22 | import javax.inject.Inject; 23 | import javax.servlet.ServletException; 24 | import javax.servlet.annotation.WebServlet; 25 | import javax.servlet.http.HttpServlet; 26 | import javax.servlet.http.HttpServletRequest; 27 | import javax.servlet.http.HttpServletResponse; 28 | 29 | /** 30 | *

31 | * A simple servlet taking advantage of features added in 3.0. 32 | *

33 | * 34 | *

35 | * The servlet is registered and mapped to /HelloServlet using the {@linkplain WebServlet 36 | * @HttpServlet}. The {@link HelloService} is injected by CDI. 37 | *

38 | * 39 | * @author Pete Muir 40 | * 41 | */ 42 | @SuppressWarnings("serial") 43 | @WebServlet("/HelloWorld") 44 | public class HelloWorldServlet extends HttpServlet { 45 | 46 | static String PAGE_HEADER = "helloworld"; 47 | 48 | static String PAGE_FOOTER = ""; 49 | 50 | @Inject 51 | HelloService helloService; 52 | 53 | @Override 54 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 55 | resp.setContentType("text/html"); 56 | PrintWriter writer = resp.getWriter(); 57 | writer.println(PAGE_HEADER); 58 | writer.println("

" + helloService.createHelloMessage("World") + "

"); 59 | writer.println(PAGE_FOOTER); 60 | writer.close(); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /helloworld/src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 17 | 18 | 23 | 24 | -------------------------------------------------------------------------------- /helloworld/src/main/webapp/index.html: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /jboss-fuse-eap/camel-cdi/README.md: -------------------------------------------------------------------------------- 1 | Camel CDI Example 2 | ----------------- 3 | 4 | This example demonstrates using the camel-cdi component with JBoss Fuse on EAP to integrate CDI beans with Camel routes. 5 | 6 | In this example, a Camel route takes a message payload from a servlet HTTP GET request and passes it on to a direct endpoint. The payload 7 | is then passed onto a Camel CDI bean invocation to produce a message response which is displayed on the web browser page. 8 | 9 | Browse to http://localhost:8080/example-camel-cdi/?name=Kermit. 10 | 11 | You should see the message "Hello Kermit" output on the web page. 12 | 13 | The Camel route is very simple and looks like this: 14 | 15 | ``` 16 | from("direct:start").bean("helloBean"); 17 | ``` 18 | 19 | The `bean` DSL makes camel look for a bean named 'helloBean' in the bean registry. The magic that makes this bean 20 | available to Camel is found in the `SomeBean` class. 21 | 22 | ```java 23 | @Named("helloBean") 24 | public class SomeBean { 25 | 26 | public String someMethod(String message) { 27 | return "Hello " + message; 28 | } 29 | } 30 | ``` 31 | 32 | By using the `@Named` annotation, camel-cdi will add this bean to the Camel bean registry. 33 | -------------------------------------------------------------------------------- /jboss-fuse-eap/camel-cdi/pom.xml: -------------------------------------------------------------------------------- 1 | 20 | 21 | 4.0.0 22 | 23 | org.jboss.openshift.examples 24 | jboss-fuse-eap-camel-cdi 25 | 6.3.0 26 | war 27 | 28 | Openshift Examples :: JBoss Fuse EAP :: Camel CDI 29 | 30 | 31 | 32 | 2.17.0 33 | 3.0.3.Final 34 | 2.6 35 | 36 | 37 | 38 | 39 | 40 | org.jboss.spec 41 | jboss-javaee-6.0 42 | ${version.jboss.spec.javaee.6.0} 43 | pom 44 | import 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | org.apache.camel 53 | camel-cdi 54 | ${version.apache.camel} 55 | provided 56 | 57 | 58 | javax.enterprise 59 | cdi-api 60 | provided 61 | 62 | 63 | org.jboss.spec.javax.ejb 64 | jboss-ejb-api_3.1_spec 65 | provided 66 | 67 | 68 | org.jboss.spec.javax.servlet 69 | jboss-servlet-api_3.0_spec 70 | provided 71 | 72 | 73 | 74 | 75 | 76 | example-camel-cdi 77 | 78 | 79 | 80 | org.apache.maven.plugins 81 | maven-war-plugin 82 | ${version.maven.war.plugin} 83 | 84 | false 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /jboss-fuse-eap/camel-cdi/src/main/java/org/jboss/openshift/examples/MyRouteBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * #%L 3 | * 4 | * %% 5 | * Copyright (C) 2013 - 2016 RedHat 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package org.jboss.openshift.examples; 21 | 22 | import javax.ejb.Startup; 23 | import javax.enterprise.context.ApplicationScoped; 24 | 25 | import org.apache.camel.builder.RouteBuilder; 26 | import org.apache.camel.cdi.ContextName; 27 | 28 | @Startup 29 | @ApplicationScoped 30 | @ContextName("cdi-context") 31 | public class MyRouteBuilder extends RouteBuilder { 32 | 33 | @Override 34 | public void configure() throws Exception { 35 | from("direct:start").bean("helloBean"); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /jboss-fuse-eap/camel-cdi/src/main/java/org/jboss/openshift/examples/SimpleServlet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * #%L 3 | * 4 | * %% 5 | * Copyright (C) 2013 - 2016 RedHat 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package org.jboss.openshift.examples; 21 | 22 | import java.io.IOException; 23 | 24 | import javax.inject.Inject; 25 | import javax.servlet.ServletException; 26 | import javax.servlet.ServletOutputStream; 27 | import javax.servlet.annotation.WebServlet; 28 | import javax.servlet.http.HttpServlet; 29 | import javax.servlet.http.HttpServletRequest; 30 | import javax.servlet.http.HttpServletResponse; 31 | 32 | import org.apache.camel.CamelContext; 33 | import org.apache.camel.ProducerTemplate; 34 | 35 | @SuppressWarnings("serial") 36 | @WebServlet(name = "HttpServiceServlet", urlPatterns = {"/*"}, loadOnStartup = 1) 37 | public class SimpleServlet extends HttpServlet { 38 | @Inject 39 | private CamelContext camelctx; 40 | 41 | @Override 42 | protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { 43 | String name = req.getParameter("name"); 44 | ServletOutputStream out = res.getOutputStream(); 45 | ProducerTemplate producer = camelctx.createProducerTemplate(); 46 | String result = producer.requestBody("direct:start", name, String.class); 47 | out.print(result); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /jboss-fuse-eap/camel-cdi/src/main/java/org/jboss/openshift/examples/SomeBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * #%L 3 | * 4 | * %% 5 | * Copyright (C) 2013 - 2016 RedHat 6 | * %% 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * #L% 19 | */ 20 | package org.jboss.openshift.examples; 21 | 22 | import javax.inject.Named; 23 | 24 | @Named("helloBean") 25 | public class SomeBean { 26 | 27 | public String someMethod(String message) { 28 | return "Hello " + message; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /jboss-fuse-eap/camel-cdi/src/main/webapp/WEB-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /jboss-fuse-eap/camel-cdi/src/main/webapp/WEB-INF/jboss-web.xml: -------------------------------------------------------------------------------- 1 | 2 | example-camel-cdi 3 | 4 | -------------------------------------------------------------------------------- /jboss-fuse-eap/camel-spring/README.md: -------------------------------------------------------------------------------- 1 | Camel Spring Example 2 | -------------------- 3 | 4 | This example demonstrates using Spring with Camel to configure a simple route. 5 | 6 | The Spring XML Camel context is defined within `src/main/resources/META-INF/spring-camel-context.xml`. 7 | -------------------------------------------------------------------------------- /jboss-fuse-eap/camel-spring/pom.xml: -------------------------------------------------------------------------------- 1 | 20 | 21 | 4.0.0 22 | 23 | org.jboss.openshift.examples 24 | jboss-fuse-eap-camel-spring 25 | 6.3.0 26 | 27 | Openshift Examples :: JBoss Fuse EAP :: Camel Spring 28 | 29 | 30 | example-camel-spring 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /jboss-fuse-eap/camel-spring/src/main/resources/META-INF/spring-camel-context.xml: -------------------------------------------------------------------------------- 1 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /security-custom-configuration/configuration/otherroles.properties: -------------------------------------------------------------------------------- 1 | # Empty roles file for testing 2 | -------------------------------------------------------------------------------- /security-custom-configuration/configuration/otherusers.properties: -------------------------------------------------------------------------------- 1 | # Empty users file for testing 2 | -------------------------------------------------------------------------------- /security-custom-configuration/configuration/roles.properties: -------------------------------------------------------------------------------- 1 | # Empty roles file for testing 2 | -------------------------------------------------------------------------------- /security-custom-configuration/configuration/users.properties: -------------------------------------------------------------------------------- 1 | # Empty users file for testing 2 | -------------------------------------------------------------------------------- /spring-boot-sample-simple/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | org.springframework.boot 5 | spring-boot-sample-simple 6 | 1.5.0.BUILD-SNAPSHOT 7 | 8 | Spring Boot Simple Sample 9 | Spring Boot Simple Sample 10 | http://projects.spring.io/spring-boot/ 11 | 12 | Pivotal Software, Inc. 13 | http://www.spring.io 14 | 15 | 16 | 1.4.2.RELEASE 17 | 1.8 18 | 1.8 19 | 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-starter 24 | ${spring.boot.version} 25 | 26 | 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-maven-plugin 32 | ${spring.boot.version} 33 | 34 | 35 | 36 | repackage 37 | 38 | 39 | 40 | 41 | 42 | org.apache.maven.plugins 43 | maven-enforcer-plugin 44 | 1.4.1 45 | 46 | 47 | enforce-property 48 | 49 | enforce 50 | 51 | 52 | 53 | 54 | com.redhat.xpaas.repo.redhatga 55 | You must set com.redhat.xpaas.repo.redhatga! 56 | 57 | 58 | true 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /spring-boot-sample-simple/src/main/java/sample/simple/ExitException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package sample.simple; 18 | 19 | import org.springframework.boot.ExitCodeGenerator; 20 | 21 | public class ExitException extends RuntimeException implements ExitCodeGenerator { 22 | 23 | @Override 24 | public int getExitCode() { 25 | return 10; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /spring-boot-sample-simple/src/main/java/sample/simple/SampleSimpleApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package sample.simple; 18 | 19 | import sample.simple.service.HelloWorldService; 20 | 21 | import org.springframework.beans.factory.annotation.Autowired; 22 | import org.springframework.boot.CommandLineRunner; 23 | import org.springframework.boot.SpringApplication; 24 | import org.springframework.boot.autoconfigure.SpringBootApplication; 25 | 26 | @SpringBootApplication 27 | public class SampleSimpleApplication implements CommandLineRunner { 28 | 29 | // Simple example shows how a command line spring application can execute an 30 | // injected bean service. Also demonstrates how you can use @Value to inject 31 | // command line args ('--name=whatever') or application properties 32 | 33 | @Autowired 34 | private HelloWorldService helloWorldService; 35 | 36 | @Override 37 | public void run(String... args) { 38 | System.out.println(this.helloWorldService.getHelloMessage()); 39 | if (args.length > 0 && args[0].equals("exitcode")) { 40 | throw new ExitException(); 41 | } 42 | } 43 | 44 | public static void main(String[] args) throws Exception { 45 | SpringApplication.run(SampleSimpleApplication.class, args); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /spring-boot-sample-simple/src/main/java/sample/simple/service/HelloWorldService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package sample.simple.service; 18 | 19 | import org.springframework.beans.factory.annotation.Value; 20 | import org.springframework.stereotype.Component; 21 | 22 | @Component 23 | public class HelloWorldService { 24 | 25 | @Value("${name:World}") 26 | private String name; 27 | 28 | public String getHelloMessage() { 29 | return "Hello " + this.name; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /spring-boot-sample-simple/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | name: Phil 2 | -------------------------------------------------------------------------------- /spring-boot-sample-simple/src/main/resources/banner.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/spring-boot-sample-simple/src/main/resources/banner.jpg -------------------------------------------------------------------------------- /spring-boot-sample-simple/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | ${Ansi.GREEN} :: Sample application build with Spring Boot${spring-boot.formatted-version} ::${Ansi.DEFAULT} 2 | -------------------------------------------------------------------------------- /spring-boot-sample-simple/target/spring-boot-sample-simple-1.5.0.BUILD-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/spring-boot-sample-simple/target/spring-boot-sample-simple-1.5.0.BUILD-SNAPSHOT.jar -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/README.md: -------------------------------------------------------------------------------- 1 | Spring Framework on OpenShift with JBoss EAP 6 2 | ============================================== 3 | 4 | What is it? 5 | ----------- 6 | 7 | This is a sample Maven 3 project to help you get your foot in the door developing with Spring on JBoss Enterprise Application Platform 6 or JBoss AS 7.1, deployable on OpenShift (PaaS by Red Hat). 8 | 9 | This project is setup to allow you to create a compliant Spring 3.2 application using Spring MVC, JPA 2.0 and Bean Validation 1.0. It includes a persistence unit and some sample persistence and transaction code to introduce you to database access in enterprise Java. 10 | 11 | Quickstart 12 | ---------- 13 | 14 | 1) Create an account at https://www.openshift.com and follow the Getting Started guide to install the OpenShift command line tools. 15 | 16 | 2) Create a JBoss Enterprise Application Platform 6 app: 17 | 18 | rhc app create spring jbosseap-6 19 | 20 | 3) Add this upstream repo: 21 | 22 | cd spring 23 | git remote add upstream -m master git://github.com/openshift/spring-eap6-quickstart.git 24 | git pull -s recursive -X theirs upstream master 25 | 26 | 4) Remove the default index.html file and commit: 27 | 28 | git rm src/main/webapp/index.html 29 | git commit -m 'Removed default index.html' 30 | 31 | 5) Then push the repo upstream: 32 | 33 | git push 34 | 35 | 6) That's it, you can now browse to your application at: 36 | 37 | http://spring-$yournamespace.rhcloud.com 38 | 39 | Setting up a database 40 | --------------------- 41 | 42 | The example uses a H2 database configured and deployed by the application. You can easily change it to MySQL or PostgreSQL (available on OpenShift as cartridges): 43 | 44 | 1) Add a database cartridge to your OpenShift app (mysql-5.1 or postgresql-8.4): 45 | 46 | rhc cartridge add -a spring -c mysql-5.1 47 | 48 | 2) Edit `src/main/webapp/WEB-INF/jboss-web.xml` to use the appropriate datasource (java:jboss/datasources/MysqlDS or java:jboss/datasources/PostgreSQLDS): 49 | 50 | java:jboss/datasources/MysqlDS 51 | 52 | 3) Commit and push your changes: 53 | 54 | git commit -a -m 'Added MySQL database support' 55 | git push 56 | 57 | License 58 | ------- 59 | 60 | This code is dedicated to the public domain to the maximum extent permitted by applicable law, pursuant to CC0 (http://creativecommons.org/publicdomain/zero/1.0/) 61 | -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/deployments/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/spring-eap6-quickstart-custom-configuration/deployments/.gitkeep -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/deployments/ROOT.war: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/spring-eap6-quickstart-custom-configuration/deployments/ROOT.war -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/src/main/java/org/jboss/tools/example/springmvc/domain/Member.java: -------------------------------------------------------------------------------- 1 | package org.jboss.tools.example.springmvc.domain; 2 | 3 | import java.io.Serializable; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.Id; 9 | import javax.persistence.Table; 10 | import javax.persistence.UniqueConstraint; 11 | import javax.validation.constraints.Digits; 12 | import javax.validation.constraints.NotNull; 13 | import javax.validation.constraints.Pattern; 14 | import javax.validation.constraints.Size; 15 | 16 | import org.hibernate.validator.constraints.Email; 17 | import org.hibernate.validator.constraints.NotEmpty; 18 | 19 | @Entity 20 | @Table(uniqueConstraints = @UniqueConstraint(columnNames = "email")) 21 | public class Member implements Serializable 22 | { 23 | /** Default value included to remove warning. Remove or modify at will. **/ 24 | private static final long serialVersionUID = 1L; 25 | 26 | @Id 27 | @GeneratedValue 28 | private Long id; 29 | 30 | @NotNull 31 | @Size(min = 1, max = 25) 32 | @Pattern(regexp = "[A-Za-z ]*", message = "must contain only letters and spaces") 33 | private String name; 34 | 35 | @NotNull 36 | @NotEmpty 37 | @Email 38 | private String email; 39 | 40 | @NotNull 41 | @Size(min = 10, max = 12) 42 | @Digits(fraction = 0, integer = 12) 43 | @Column(name = "phone_number") 44 | private String phoneNumber; 45 | 46 | public Long getId() { 47 | return id; 48 | } 49 | 50 | public void setId(Long id) { 51 | this.id = id; 52 | } 53 | 54 | public String getName() { 55 | return name; 56 | } 57 | 58 | public void setName(String name) { 59 | this.name = name; 60 | } 61 | 62 | public String getEmail() { 63 | return email; 64 | } 65 | 66 | public void setEmail(String email) { 67 | this.email = email; 68 | } 69 | 70 | public String getPhoneNumber() { 71 | return phoneNumber; 72 | } 73 | 74 | public void setPhoneNumber(String phoneNumber) { 75 | this.phoneNumber = phoneNumber; 76 | } 77 | } -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/src/main/java/org/jboss/tools/example/springmvc/mvc/MemberController.java: -------------------------------------------------------------------------------- 1 | package org.jboss.tools.example.springmvc.mvc; 2 | 3 | import javax.validation.Valid; 4 | 5 | import org.jboss.tools.example.springmvc.domain.Member; 6 | import org.jboss.tools.example.springmvc.repo.MemberDao; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.ui.Model; 10 | import org.springframework.validation.BindingResult; 11 | import org.springframework.web.bind.annotation.ModelAttribute; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RequestMethod; 14 | 15 | @Controller 16 | @RequestMapping(value="/") 17 | public class MemberController 18 | { 19 | @Autowired 20 | private MemberDao memberDao; 21 | 22 | @RequestMapping(method=RequestMethod.GET) 23 | public String displaySortedMembers(Model model) 24 | { 25 | model.addAttribute("newMember", new Member()); 26 | model.addAttribute("members", memberDao.findAllOrderedByName()); 27 | return "index"; 28 | } 29 | 30 | @RequestMapping(method=RequestMethod.POST) 31 | public String registerNewMember(@Valid @ModelAttribute("newMember") Member newMember, BindingResult result, Model model) 32 | { 33 | if (!result.hasErrors()) { 34 | memberDao.register(newMember); 35 | return "redirect:/"; 36 | } 37 | else { 38 | model.addAttribute("members", memberDao.findAllOrderedByName()); 39 | return "index"; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/src/main/java/org/jboss/tools/example/springmvc/mvc/MemberRestController.java: -------------------------------------------------------------------------------- 1 | package org.jboss.tools.example.springmvc.mvc; 2 | 3 | import java.util.List; 4 | 5 | import org.jboss.tools.example.springmvc.domain.Member; 6 | import org.jboss.tools.example.springmvc.repo.MemberDao; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RequestMethod; 12 | import org.springframework.web.bind.annotation.ResponseBody; 13 | 14 | @Controller 15 | @RequestMapping("/rest/members") 16 | public class MemberRestController 17 | { 18 | @Autowired 19 | private MemberDao memberDao; 20 | 21 | @RequestMapping(method=RequestMethod.GET, produces="application/json") 22 | public @ResponseBody List listAllMembers() 23 | { 24 | return memberDao.findAllOrderedByName(); 25 | } 26 | 27 | @RequestMapping(value="/{id}", method=RequestMethod.GET, produces="application/json") 28 | public @ResponseBody Member lookupMemberById(@PathVariable("id") Long id) 29 | { 30 | return memberDao.findById(id); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/src/main/java/org/jboss/tools/example/springmvc/repo/MemberDao.java: -------------------------------------------------------------------------------- 1 | package org.jboss.tools.example.springmvc.repo; 2 | 3 | import java.util.List; 4 | 5 | import org.jboss.tools.example.springmvc.domain.Member; 6 | 7 | public interface MemberDao 8 | { 9 | public Member findById(Long id); 10 | 11 | public Member findByEmail(String email); 12 | 13 | public List findAllOrderedByName(); 14 | 15 | public void register(Member member); 16 | } 17 | -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/src/main/java/org/jboss/tools/example/springmvc/repo/MemberDaoImpl.java: -------------------------------------------------------------------------------- 1 | package org.jboss.tools.example.springmvc.repo; 2 | 3 | import java.util.List; 4 | 5 | import javax.persistence.EntityManager; 6 | import javax.persistence.criteria.CriteriaBuilder; 7 | import javax.persistence.criteria.CriteriaQuery; 8 | import javax.persistence.criteria.Root; 9 | 10 | import org.jboss.tools.example.springmvc.domain.Member; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Repository; 13 | import org.springframework.transaction.annotation.Transactional; 14 | 15 | @Repository 16 | @Transactional 17 | public class MemberDaoImpl implements MemberDao 18 | { 19 | @Autowired 20 | private EntityManager em; 21 | 22 | public Member findById(Long id) 23 | { 24 | return em.find(Member.class, id); 25 | } 26 | 27 | public Member findByEmail(String email) 28 | { 29 | CriteriaBuilder builder = em.getCriteriaBuilder(); 30 | CriteriaQuery criteria = builder.createQuery(Member.class); 31 | Root member = criteria.from(Member.class); 32 | 33 | /* 34 | * Swap criteria statements if you would like to try out type-safe criteria queries, a new 35 | * feature in JPA 2.0 criteria.select(member).orderBy(cb.asc(member.get(Member_.name))); 36 | */ 37 | 38 | criteria.select(member).where(builder.equal(member.get("email"), email)); 39 | return em.createQuery(criteria).getSingleResult(); 40 | } 41 | 42 | public List findAllOrderedByName() 43 | { 44 | CriteriaBuilder cb = em.getCriteriaBuilder(); 45 | CriteriaQuery criteria = cb.createQuery(Member.class); 46 | Root member = criteria.from(Member.class); 47 | 48 | /* 49 | * Swap criteria statements if you would like to try out type-safe criteria queries, a new 50 | * feature in JPA 2.0 criteria.select(member).orderBy(cb.asc(member.get(Member_.name))); 51 | */ 52 | 53 | criteria.select(member).orderBy(cb.asc(member.get("name"))); 54 | return em.createQuery(criteria).getResultList(); 55 | } 56 | 57 | public void register(Member member) 58 | { 59 | em.persist(member); 60 | return; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/src/main/resources/META-INF/persistence.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 9 | 11 | java:comp/env/jdbc/SpringQuickstartDS 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/src/main/resources/META-INF/spring/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/src/main/resources/META-INF/spring/infrastructure.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 13 | 14 | 15 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/src/main/resources/import.sql: -------------------------------------------------------------------------------- 1 | -- You can use this file to load seed data into the database using SQL statements 2 | insert into Member (id, name, email, phone_number) values (0, 'John Smith', 'john.smith@mailinator.com', '2125551212') 3 | insert into Member (id, name, email, phone_number) values (1, 'OpenShift PaaS by Red Hat', 'openshift@redhat.com', '19197543700') 4 | -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/src/main/webapp/WEB-INF/jboss-as-spring-mvc-context.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/src/main/webapp/WEB-INF/jboss-deployment-structure.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/src/main/webapp/WEB-INF/jboss-web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | jdbc/SpringQuickstartDS 5 | javax.sql.DataSource 6 | Container 7 | java:jboss/datasources/SpringQuickstartDS 8 | 9 | 10 | -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/src/main/webapp/WEB-INF/spring-quickstart-ds.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 10 | jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE 11 | h2 12 | 13 | sa 14 | sa 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/src/main/webapp/WEB-INF/views/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> 3 | 4 | 5 | 6 | 7 | Spring MVC Starter Application 8 | 9 | "/> 10 | 11 | 12 | 13 |
14 |
15 | "/> 16 |
17 |
18 |

Welcome to JBoss!

19 | 20 |
21 |

You have successfully deployed a Spring MVC web application.

22 |

Your application can run on:

23 | "/> 24 |
25 | 26 | 27 |

Member Registration

28 |

Enforces annotation-based constraints defined on the model class.

29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 44 | 45 | 46 | 47 | 48 |
Name:
Email:
Phone #: 43 |
49 | 50 | 51 | 54 | 55 |
52 | 53 |
56 |
57 |

Members

58 | 59 | 60 | No registered members. 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 |
IdNameEmailPhone #REST URL
${member.id}${member.name}${member.email}${member.phoneNumber}">/rest/members/${member.id}
84 | 85 | 86 | 89 | 90 |
87 | REST URL for all members: ">/rest/members 88 |
91 |
92 |
93 |
94 |
95 |

Learn more about JBoss Enterprise Application Platform 6.

96 | 101 |

Learn more about JBoss AS 7.

102 | 107 |
108 | 114 |
115 | 116 | 117 | -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | Java EE 6 Starter Application 9 | 10 | 11 | contextConfigLocation 12 | classpath:/META-INF/spring/applicationContext.xml, 13 | classpath:/META-INF/spring/infrastructure.xml 14 | 15 | 16 | 17 | org.jboss.as.jaxrs.disableSpringIntegration 18 | true 19 | 20 | 21 | 22 | org.springframework.web.context.ContextLoaderListener 23 | 24 | 25 | 26 | jboss-as-kitchensink 27 | org.springframework.web.servlet.DispatcherServlet 28 | 29 | contextConfigLocation 30 | /WEB-INF/jboss-as-spring-mvc-context.xml 31 | 32 | 1 33 | 34 | 35 | 36 | jboss-as-kitchensink 37 | / 38 | 39 | 40 | -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/src/main/webapp/resources/css/screen.css: -------------------------------------------------------------------------------- 1 | /* Core styles for the page */ 2 | body { 3 | margin: 0; 4 | padding: 0; 5 | background-color: #F1F1F1; 6 | font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif; 7 | font-size: 0.8em; 8 | color:#363636; 9 | } 10 | 11 | #container { 12 | margin: 0 auto; 13 | padding: 0 20px 10px 20px; 14 | border-top: 5px solid #000000; 15 | border-left: 5px solid #8c8f91; 16 | border-right: 5px solid #8c8f91; 17 | border-bottom: 25px solid #8c8f91; 18 | width: 865px; /* subtract 40px from banner width for padding */ 19 | background: #FFFFFF; 20 | background-image: url(../gfx/headerbkg.png); 21 | background-repeat: repeat-x; 22 | padding-top: 30px; 23 | box-shadow: 3px 3px 15px #d5d5d5; 24 | } 25 | #content { 26 | float: left; 27 | width: 500px; 28 | margin: 20px; 29 | } 30 | #aside { 31 | font-size: 0.9em; 32 | width: 275px; 33 | float: left; 34 | margin: 20px 0px; 35 | border: 1px solid #D5D5D5; 36 | background: #F1F1F1; 37 | background-image: url(../gfx/asidebkg.png); 38 | background-repeat: repeat-x; 39 | padding: 20px; 40 | } 41 | 42 | #aside ul { 43 | padding-left: 30px; 44 | } 45 | .dualbrand { 46 | float: right; 47 | padding-right: 10px; 48 | } 49 | #footer { 50 | clear: both; 51 | text-align: center; 52 | color: #666666; 53 | font-size: 0.85em; 54 | } 55 | code { 56 | font-size: 1.1em; 57 | } 58 | a { 59 | color: #4a5d75; 60 | text-decoration: none; 61 | } 62 | a:hover { 63 | color: #369; 64 | text-decoration: underline; 65 | } 66 | h1 { 67 | color:#243446; 68 | font-size: 2.25em; 69 | } 70 | h2 { 71 | font-size: 1em; 72 | } 73 | h3 { 74 | color:#243446; 75 | } 76 | h4 { 77 | } 78 | h5 { 79 | } 80 | h6 { 81 | } 82 | /* Member registration styles */ 83 | span.invalid { 84 | padding-left: 3px; 85 | color: red; 86 | font: 65%/1 sans-serif; 87 | } 88 | form { 89 | padding: 1em; 90 | font: 80%/1 sans-serif; 91 | width: 375px; 92 | border: 1px solid #D5D5D5; 93 | } 94 | label { 95 | color: #363636; 96 | float: left; 97 | font: 65%/1 sans-serif; 98 | font-weight: bold; 99 | margin-left: 20px; 100 | margin-right: 0.5em; 101 | padding-top: 0.2em; 102 | text-align: right; 103 | width: 15%; 104 | } 105 | input { 106 | margin-bottom: 8px; 107 | } 108 | .register { 109 | float: left; 110 | margin-left: 85px; 111 | } 112 | 113 | /* ----- table style ------- */ 114 | 115 | 116 | /* = Simple Table style (black header, grey/white stripes */ 117 | 118 | .simpletablestyle { 119 | background-color:#E6E7E8; 120 | clear:both; 121 | width: 550px; 122 | } 123 | 124 | .simpletablestyle img { 125 | border:0px; 126 | } 127 | 128 | .simpletablestyle td { 129 | height:2em; 130 | padding-left: 6px; 131 | font-size:11px; 132 | padding:5px 5px; 133 | } 134 | 135 | .simpletablestyle th { 136 | background: url(../gfx/bkg-blkheader.png) black repeat-x top left; 137 | font-size:12px; 138 | font-weight:normal; 139 | padding:0 10px 0 5px; 140 | border-bottom:#999999 dotted 1px; 141 | } 142 | 143 | .simpletablestyle thead { 144 | background: url(../gfx/bkg-blkheader.png) black repeat-x top left; 145 | height:31px; 146 | font-size:10px; 147 | font-weight:bold; 148 | color:#FFFFFF; 149 | text-align:left; 150 | } 151 | 152 | .simpletablestyle .header a { 153 | color:#94aebd; 154 | } 155 | 156 | .simpletablestype tfoot { 157 | height: 20px; 158 | font-size: 10px; 159 | font-weight: bold; 160 | background-color: #EAECEE; 161 | text-align: center; 162 | } 163 | 164 | .simpletablestyle tr.header td { 165 | padding: 0px 10px 0px 5px; 166 | } 167 | 168 | 169 | .simpletablestyle .subheader { 170 | background-color: #e6e7e8; 171 | font-size:10px; 172 | font-weight:bold; 173 | color:#000000; 174 | text-align:left; 175 | } 176 | 177 | /* Using new CSS3 selectors for styling*/ 178 | .simpletablestyle tr:nth-child(odd) { 179 | background: #f4f3f3; 180 | } 181 | .simpletablestyle tr:nth-child(even) { 182 | background: #ffffff; 183 | } 184 | 185 | .simpletablestyle td a:hover { 186 | color:#3883ce; 187 | text-decoration:none; 188 | } -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/src/main/webapp/resources/gfx/asidebkg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/spring-eap6-quickstart-custom-configuration/src/main/webapp/resources/gfx/asidebkg.png -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/src/main/webapp/resources/gfx/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/spring-eap6-quickstart-custom-configuration/src/main/webapp/resources/gfx/banner.png -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/src/main/webapp/resources/gfx/bkg-blkheader.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/spring-eap6-quickstart-custom-configuration/src/main/webapp/resources/gfx/bkg-blkheader.png -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/src/main/webapp/resources/gfx/dualbrand_as7eap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/spring-eap6-quickstart-custom-configuration/src/main/webapp/resources/gfx/dualbrand_as7eap.png -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/src/main/webapp/resources/gfx/dualbrand_catapillarbutterfly.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/spring-eap6-quickstart-custom-configuration/src/main/webapp/resources/gfx/dualbrand_catapillarbutterfly.png -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/src/main/webapp/resources/gfx/dualbrand_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/spring-eap6-quickstart-custom-configuration/src/main/webapp/resources/gfx/dualbrand_logo.png -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/src/main/webapp/resources/gfx/headerbkg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/spring-eap6-quickstart-custom-configuration/src/main/webapp/resources/gfx/headerbkg.png -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/src/main/webapp/resources/gfx/icon_large.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/spring-eap6-quickstart-custom-configuration/src/main/webapp/resources/gfx/icon_large.png -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/src/main/webapp/resources/gfx/icon_medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/spring-eap6-quickstart-custom-configuration/src/main/webapp/resources/gfx/icon_medium.png -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/src/main/webapp/resources/gfx/icon_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/spring-eap6-quickstart-custom-configuration/src/main/webapp/resources/gfx/icon_small.png -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/src/main/webapp/resources/gfx/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/spring-eap6-quickstart-custom-configuration/src/main/webapp/resources/gfx/logo.png -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/src/test/java/org/jboss/tools/example/springmvc/test/MemberDaoTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.tools.example.springmvc.test; 2 | 3 | import java.util.List; 4 | 5 | import junit.framework.Assert; 6 | 7 | import org.jboss.tools.example.springmvc.domain.Member; 8 | import org.jboss.tools.example.springmvc.repo.MemberDao; 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.test.context.ContextConfiguration; 13 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 14 | import org.springframework.test.context.transaction.TransactionConfiguration; 15 | import org.springframework.transaction.annotation.Transactional; 16 | 17 | @RunWith(SpringJUnit4ClassRunner.class) 18 | @ContextConfiguration(locations={"classpath:test-context.xml", 19 | "classpath:/META-INF/spring/applicationContext.xml"}) 20 | @Transactional 21 | @TransactionConfiguration(defaultRollback=true) 22 | public class MemberDaoTest 23 | { 24 | @Autowired 25 | private MemberDao memberDao; 26 | 27 | @Test 28 | public void testFindById() 29 | { 30 | Member member = memberDao.findById(0l); 31 | 32 | Assert.assertEquals("John Smith", member.getName()); 33 | Assert.assertEquals("john.smith@mailinator.com", member.getEmail()); 34 | Assert.assertEquals("2125551212", member.getPhoneNumber()); 35 | return; 36 | } 37 | 38 | @Test 39 | public void testFindByEmail() 40 | { 41 | Member member = memberDao.findByEmail("john.smith@mailinator.com"); 42 | 43 | Assert.assertEquals("John Smith", member.getName()); 44 | Assert.assertEquals("john.smith@mailinator.com", member.getEmail()); 45 | Assert.assertEquals("2125551212", member.getPhoneNumber()); 46 | return; 47 | } 48 | 49 | @Test 50 | public void testRegister() 51 | { 52 | Member member = new Member(); 53 | member.setEmail("jane.doe@mailinator.com"); 54 | member.setName("Jane Doe"); 55 | member.setPhoneNumber("2125552121"); 56 | 57 | memberDao.register(member); 58 | Long id = member.getId(); 59 | Assert.assertNotNull(id); 60 | 61 | Assert.assertEquals(2, memberDao.findAllOrderedByName().size()); 62 | Member newMember = memberDao.findById(id); 63 | 64 | Assert.assertEquals("Jane Doe", newMember.getName()); 65 | Assert.assertEquals("jane.doe@mailinator.com", newMember.getEmail()); 66 | Assert.assertEquals("2125552121", newMember.getPhoneNumber()); 67 | return; 68 | } 69 | 70 | @Test 71 | public void testFindAllOrderedByName() 72 | { 73 | Member member = new Member(); 74 | member.setEmail("jane.doe@mailinator.com"); 75 | member.setName("Jane Doe"); 76 | member.setPhoneNumber("2125552121"); 77 | memberDao.register(member); 78 | 79 | List members = memberDao.findAllOrderedByName(); 80 | Assert.assertEquals(2, members.size()); 81 | Member newMember = members.get(0); 82 | 83 | Assert.assertEquals("Jane Doe", newMember.getName()); 84 | Assert.assertEquals("jane.doe@mailinator.com", newMember.getEmail()); 85 | Assert.assertEquals("2125552121", newMember.getPhoneNumber()); 86 | return; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/src/test/resources/META-INF/test-persistence.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | org.hibernate.ejb.HibernatePersistence 6 | org.jboss.tools.example.springmvc.domain.Member 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/src/test/resources/import.sql: -------------------------------------------------------------------------------- 1 | -- You can use this file to load seed data into the database using SQL statements 2 | insert into Member (id, name, email, phone_number) values (0, 'John Smith', 'john.smith@mailinator.com', '2125551212') -------------------------------------------------------------------------------- /spring-eap6-quickstart-custom-configuration/src/test/resources/test-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /spring-eap6-quickstart/README.md: -------------------------------------------------------------------------------- 1 | Spring Framework on OpenShift with JBoss EAP 6 2 | ============================================== 3 | 4 | What is it? 5 | ----------- 6 | 7 | This is a sample Maven 3 project to help you get your foot in the door developing with Spring on JBoss Enterprise Application Platform 6 or JBoss AS 7.1, deployable on OpenShift (PaaS by Red Hat). 8 | 9 | This project is setup to allow you to create a compliant Spring 3.2 application using Spring MVC, JPA 2.0 and Bean Validation 1.0. It includes a persistence unit and some sample persistence and transaction code to introduce you to database access in enterprise Java. 10 | 11 | Quickstart 12 | ---------- 13 | 14 | 1) Create an account at https://www.openshift.com and follow the Getting Started guide to install the OpenShift command line tools. 15 | 16 | 2) Create a JBoss Enterprise Application Platform 6 app: 17 | 18 | rhc app create spring jbosseap-6 19 | 20 | 3) Add this upstream repo: 21 | 22 | cd spring 23 | git remote add upstream -m master git://github.com/openshift/spring-eap6-quickstart.git 24 | git pull -s recursive -X theirs upstream master 25 | 26 | 4) Remove the default index.html file and commit: 27 | 28 | git rm src/main/webapp/index.html 29 | git commit -m 'Removed default index.html' 30 | 31 | 5) Then push the repo upstream: 32 | 33 | git push 34 | 35 | 6) That's it, you can now browse to your application at: 36 | 37 | http://spring-$yournamespace.rhcloud.com 38 | 39 | Setting up a database 40 | --------------------- 41 | 42 | The example uses a H2 database configured and deployed by the application. You can easily change it to MySQL or PostgreSQL (available on OpenShift as cartridges): 43 | 44 | 1) Add a database cartridge to your OpenShift app (mysql-5.1 or postgresql-8.4): 45 | 46 | rhc cartridge add -a spring -c mysql-5.1 47 | 48 | 2) Edit `src/main/webapp/WEB-INF/jboss-web.xml` to use the appropriate datasource (java:jboss/datasources/MysqlDS or java:jboss/datasources/PostgreSQLDS): 49 | 50 | java:jboss/datasources/MysqlDS 51 | 52 | 3) Commit and push your changes: 53 | 54 | git commit -a -m 'Added MySQL database support' 55 | git push 56 | 57 | License 58 | ------- 59 | 60 | This code is dedicated to the public domain to the maximum extent permitted by applicable law, pursuant to CC0 (http://creativecommons.org/publicdomain/zero/1.0/) 61 | -------------------------------------------------------------------------------- /spring-eap6-quickstart/deployments/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/spring-eap6-quickstart/deployments/.gitkeep -------------------------------------------------------------------------------- /spring-eap6-quickstart/deployments/ROOT.war: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/spring-eap6-quickstart/deployments/ROOT.war -------------------------------------------------------------------------------- /spring-eap6-quickstart/src/main/java/org/jboss/tools/example/springmvc/domain/Member.java: -------------------------------------------------------------------------------- 1 | package org.jboss.tools.example.springmvc.domain; 2 | 3 | import java.io.Serializable; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.Id; 9 | import javax.persistence.Table; 10 | import javax.persistence.UniqueConstraint; 11 | import javax.validation.constraints.Digits; 12 | import javax.validation.constraints.NotNull; 13 | import javax.validation.constraints.Pattern; 14 | import javax.validation.constraints.Size; 15 | 16 | import org.hibernate.validator.constraints.Email; 17 | import org.hibernate.validator.constraints.NotEmpty; 18 | 19 | @Entity 20 | @Table(uniqueConstraints = @UniqueConstraint(columnNames = "email")) 21 | public class Member implements Serializable 22 | { 23 | /** Default value included to remove warning. Remove or modify at will. **/ 24 | private static final long serialVersionUID = 1L; 25 | 26 | @Id 27 | @GeneratedValue 28 | private Long id; 29 | 30 | @NotNull 31 | @Size(min = 1, max = 25) 32 | @Pattern(regexp = "[A-Za-z ]*", message = "must contain only letters and spaces") 33 | private String name; 34 | 35 | @NotNull 36 | @NotEmpty 37 | @Email 38 | private String email; 39 | 40 | @NotNull 41 | @Size(min = 10, max = 12) 42 | @Digits(fraction = 0, integer = 12) 43 | @Column(name = "phone_number") 44 | private String phoneNumber; 45 | 46 | public Long getId() { 47 | return id; 48 | } 49 | 50 | public void setId(Long id) { 51 | this.id = id; 52 | } 53 | 54 | public String getName() { 55 | return name; 56 | } 57 | 58 | public void setName(String name) { 59 | this.name = name; 60 | } 61 | 62 | public String getEmail() { 63 | return email; 64 | } 65 | 66 | public void setEmail(String email) { 67 | this.email = email; 68 | } 69 | 70 | public String getPhoneNumber() { 71 | return phoneNumber; 72 | } 73 | 74 | public void setPhoneNumber(String phoneNumber) { 75 | this.phoneNumber = phoneNumber; 76 | } 77 | } -------------------------------------------------------------------------------- /spring-eap6-quickstart/src/main/java/org/jboss/tools/example/springmvc/mvc/MemberController.java: -------------------------------------------------------------------------------- 1 | package org.jboss.tools.example.springmvc.mvc; 2 | 3 | import javax.validation.Valid; 4 | 5 | import org.jboss.tools.example.springmvc.domain.Member; 6 | import org.jboss.tools.example.springmvc.repo.MemberDao; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.ui.Model; 10 | import org.springframework.validation.BindingResult; 11 | import org.springframework.web.bind.annotation.ModelAttribute; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RequestMethod; 14 | 15 | @Controller 16 | @RequestMapping(value="/") 17 | public class MemberController 18 | { 19 | @Autowired 20 | private MemberDao memberDao; 21 | 22 | @RequestMapping(method=RequestMethod.GET) 23 | public String displaySortedMembers(Model model) 24 | { 25 | model.addAttribute("newMember", new Member()); 26 | model.addAttribute("members", memberDao.findAllOrderedByName()); 27 | return "index"; 28 | } 29 | 30 | @RequestMapping(method=RequestMethod.POST) 31 | public String registerNewMember(@Valid @ModelAttribute("newMember") Member newMember, BindingResult result, Model model) 32 | { 33 | if (!result.hasErrors()) { 34 | memberDao.register(newMember); 35 | return "redirect:/"; 36 | } 37 | else { 38 | model.addAttribute("members", memberDao.findAllOrderedByName()); 39 | return "index"; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /spring-eap6-quickstart/src/main/java/org/jboss/tools/example/springmvc/mvc/MemberRestController.java: -------------------------------------------------------------------------------- 1 | package org.jboss.tools.example.springmvc.mvc; 2 | 3 | import java.util.List; 4 | 5 | import org.jboss.tools.example.springmvc.domain.Member; 6 | import org.jboss.tools.example.springmvc.repo.MemberDao; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RequestMethod; 12 | import org.springframework.web.bind.annotation.ResponseBody; 13 | 14 | @Controller 15 | @RequestMapping("/rest/members") 16 | public class MemberRestController 17 | { 18 | @Autowired 19 | private MemberDao memberDao; 20 | 21 | @RequestMapping(method=RequestMethod.GET, produces="application/json") 22 | public @ResponseBody List listAllMembers() 23 | { 24 | return memberDao.findAllOrderedByName(); 25 | } 26 | 27 | @RequestMapping(value="/{id}", method=RequestMethod.GET, produces="application/json") 28 | public @ResponseBody Member lookupMemberById(@PathVariable("id") Long id) 29 | { 30 | return memberDao.findById(id); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spring-eap6-quickstart/src/main/java/org/jboss/tools/example/springmvc/repo/MemberDao.java: -------------------------------------------------------------------------------- 1 | package org.jboss.tools.example.springmvc.repo; 2 | 3 | import java.util.List; 4 | 5 | import org.jboss.tools.example.springmvc.domain.Member; 6 | 7 | public interface MemberDao 8 | { 9 | public Member findById(Long id); 10 | 11 | public Member findByEmail(String email); 12 | 13 | public List findAllOrderedByName(); 14 | 15 | public void register(Member member); 16 | } 17 | -------------------------------------------------------------------------------- /spring-eap6-quickstart/src/main/java/org/jboss/tools/example/springmvc/repo/MemberDaoImpl.java: -------------------------------------------------------------------------------- 1 | package org.jboss.tools.example.springmvc.repo; 2 | 3 | import java.util.List; 4 | 5 | import javax.persistence.EntityManager; 6 | import javax.persistence.criteria.CriteriaBuilder; 7 | import javax.persistence.criteria.CriteriaQuery; 8 | import javax.persistence.criteria.Root; 9 | 10 | import org.jboss.tools.example.springmvc.domain.Member; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Repository; 13 | import org.springframework.transaction.annotation.Transactional; 14 | 15 | @Repository 16 | @Transactional 17 | public class MemberDaoImpl implements MemberDao 18 | { 19 | @Autowired 20 | private EntityManager em; 21 | 22 | public Member findById(Long id) 23 | { 24 | return em.find(Member.class, id); 25 | } 26 | 27 | public Member findByEmail(String email) 28 | { 29 | CriteriaBuilder builder = em.getCriteriaBuilder(); 30 | CriteriaQuery criteria = builder.createQuery(Member.class); 31 | Root member = criteria.from(Member.class); 32 | 33 | /* 34 | * Swap criteria statements if you would like to try out type-safe criteria queries, a new 35 | * feature in JPA 2.0 criteria.select(member).orderBy(cb.asc(member.get(Member_.name))); 36 | */ 37 | 38 | criteria.select(member).where(builder.equal(member.get("email"), email)); 39 | return em.createQuery(criteria).getSingleResult(); 40 | } 41 | 42 | public List findAllOrderedByName() 43 | { 44 | CriteriaBuilder cb = em.getCriteriaBuilder(); 45 | CriteriaQuery criteria = cb.createQuery(Member.class); 46 | Root member = criteria.from(Member.class); 47 | 48 | /* 49 | * Swap criteria statements if you would like to try out type-safe criteria queries, a new 50 | * feature in JPA 2.0 criteria.select(member).orderBy(cb.asc(member.get(Member_.name))); 51 | */ 52 | 53 | criteria.select(member).orderBy(cb.asc(member.get("name"))); 54 | return em.createQuery(criteria).getResultList(); 55 | } 56 | 57 | public void register(Member member) 58 | { 59 | em.persist(member); 60 | return; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /spring-eap6-quickstart/src/main/resources/META-INF/persistence.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 9 | 11 | java:comp/env/jdbc/SpringQuickstartDS 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /spring-eap6-quickstart/src/main/resources/META-INF/spring/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /spring-eap6-quickstart/src/main/resources/META-INF/spring/infrastructure.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 13 | 14 | 15 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /spring-eap6-quickstart/src/main/resources/import.sql: -------------------------------------------------------------------------------- 1 | -- You can use this file to load seed data into the database using SQL statements 2 | insert into Member (id, name, email, phone_number) values (0, 'John Smith', 'john.smith@mailinator.com', '2125551212') 3 | insert into Member (id, name, email, phone_number) values (1, 'OpenShift PaaS by Red Hat', 'openshift@redhat.com', '19197543700') 4 | -------------------------------------------------------------------------------- /spring-eap6-quickstart/src/main/webapp/WEB-INF/jboss-as-spring-mvc-context.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /spring-eap6-quickstart/src/main/webapp/WEB-INF/jboss-deployment-structure.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /spring-eap6-quickstart/src/main/webapp/WEB-INF/jboss-web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | jdbc/SpringQuickstartDS 5 | javax.sql.DataSource 6 | Container 7 | java:jboss/datasources/SpringQuickstartDS 8 | 9 | 10 | -------------------------------------------------------------------------------- /spring-eap6-quickstart/src/main/webapp/WEB-INF/spring-quickstart-ds.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 10 | jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE 11 | h2 12 | 13 | sa 14 | sa 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /spring-eap6-quickstart/src/main/webapp/WEB-INF/views/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> 3 | 4 | 5 | 6 | 7 | Spring MVC Starter Application 8 | 9 | "/> 10 | 11 | 12 | 13 |
14 |
15 | "/> 16 |
17 |
18 |

Welcome to JBoss!

19 | 20 |
21 |

You have successfully deployed a Spring MVC web application.

22 |

Your application can run on:

23 | "/> 24 |
25 | 26 | 27 |

Member Registration

28 |

Enforces annotation-based constraints defined on the model class.

29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 44 | 45 | 46 | 47 | 48 |
Name:
Email:
Phone #: 43 |
49 | 50 | 51 | 54 | 55 |
52 | 53 |
56 |
57 |

Members

58 | 59 | 60 | No registered members. 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 |
IdNameEmailPhone #REST URL
${member.id}${member.name}${member.email}${member.phoneNumber}">/rest/members/${member.id}
84 | 85 | 86 | 89 | 90 |
87 | REST URL for all members: ">/rest/members 88 |
91 |
92 |
93 |
94 |
95 |

Learn more about JBoss Enterprise Application Platform 6.

96 | 101 |

Learn more about JBoss AS 7.

102 | 107 |
108 | 114 |
115 | 116 | 117 | -------------------------------------------------------------------------------- /spring-eap6-quickstart/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | Java EE 6 Starter Application 9 | 10 | 11 | contextConfigLocation 12 | classpath:/META-INF/spring/applicationContext.xml, 13 | classpath:/META-INF/spring/infrastructure.xml 14 | 15 | 16 | 17 | org.jboss.as.jaxrs.disableSpringIntegration 18 | true 19 | 20 | 21 | 22 | org.springframework.web.context.ContextLoaderListener 23 | 24 | 25 | 26 | jboss-as-kitchensink 27 | org.springframework.web.servlet.DispatcherServlet 28 | 29 | contextConfigLocation 30 | /WEB-INF/jboss-as-spring-mvc-context.xml 31 | 32 | 1 33 | 34 | 35 | 36 | jboss-as-kitchensink 37 | / 38 | 39 | 40 | -------------------------------------------------------------------------------- /spring-eap6-quickstart/src/main/webapp/resources/css/screen.css: -------------------------------------------------------------------------------- 1 | /* Core styles for the page */ 2 | body { 3 | margin: 0; 4 | padding: 0; 5 | background-color: #F1F1F1; 6 | font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif; 7 | font-size: 0.8em; 8 | color:#363636; 9 | } 10 | 11 | #container { 12 | margin: 0 auto; 13 | padding: 0 20px 10px 20px; 14 | border-top: 5px solid #000000; 15 | border-left: 5px solid #8c8f91; 16 | border-right: 5px solid #8c8f91; 17 | border-bottom: 25px solid #8c8f91; 18 | width: 865px; /* subtract 40px from banner width for padding */ 19 | background: #FFFFFF; 20 | background-image: url(../gfx/headerbkg.png); 21 | background-repeat: repeat-x; 22 | padding-top: 30px; 23 | box-shadow: 3px 3px 15px #d5d5d5; 24 | } 25 | #content { 26 | float: left; 27 | width: 500px; 28 | margin: 20px; 29 | } 30 | #aside { 31 | font-size: 0.9em; 32 | width: 275px; 33 | float: left; 34 | margin: 20px 0px; 35 | border: 1px solid #D5D5D5; 36 | background: #F1F1F1; 37 | background-image: url(../gfx/asidebkg.png); 38 | background-repeat: repeat-x; 39 | padding: 20px; 40 | } 41 | 42 | #aside ul { 43 | padding-left: 30px; 44 | } 45 | .dualbrand { 46 | float: right; 47 | padding-right: 10px; 48 | } 49 | #footer { 50 | clear: both; 51 | text-align: center; 52 | color: #666666; 53 | font-size: 0.85em; 54 | } 55 | code { 56 | font-size: 1.1em; 57 | } 58 | a { 59 | color: #4a5d75; 60 | text-decoration: none; 61 | } 62 | a:hover { 63 | color: #369; 64 | text-decoration: underline; 65 | } 66 | h1 { 67 | color:#243446; 68 | font-size: 2.25em; 69 | } 70 | h2 { 71 | font-size: 1em; 72 | } 73 | h3 { 74 | color:#243446; 75 | } 76 | h4 { 77 | } 78 | h5 { 79 | } 80 | h6 { 81 | } 82 | /* Member registration styles */ 83 | span.invalid { 84 | padding-left: 3px; 85 | color: red; 86 | font: 65%/1 sans-serif; 87 | } 88 | form { 89 | padding: 1em; 90 | font: 80%/1 sans-serif; 91 | width: 375px; 92 | border: 1px solid #D5D5D5; 93 | } 94 | label { 95 | color: #363636; 96 | float: left; 97 | font: 65%/1 sans-serif; 98 | font-weight: bold; 99 | margin-left: 20px; 100 | margin-right: 0.5em; 101 | padding-top: 0.2em; 102 | text-align: right; 103 | width: 15%; 104 | } 105 | input { 106 | margin-bottom: 8px; 107 | } 108 | .register { 109 | float: left; 110 | margin-left: 85px; 111 | } 112 | 113 | /* ----- table style ------- */ 114 | 115 | 116 | /* = Simple Table style (black header, grey/white stripes */ 117 | 118 | .simpletablestyle { 119 | background-color:#E6E7E8; 120 | clear:both; 121 | width: 550px; 122 | } 123 | 124 | .simpletablestyle img { 125 | border:0px; 126 | } 127 | 128 | .simpletablestyle td { 129 | height:2em; 130 | padding-left: 6px; 131 | font-size:11px; 132 | padding:5px 5px; 133 | } 134 | 135 | .simpletablestyle th { 136 | background: url(../gfx/bkg-blkheader.png) black repeat-x top left; 137 | font-size:12px; 138 | font-weight:normal; 139 | padding:0 10px 0 5px; 140 | border-bottom:#999999 dotted 1px; 141 | } 142 | 143 | .simpletablestyle thead { 144 | background: url(../gfx/bkg-blkheader.png) black repeat-x top left; 145 | height:31px; 146 | font-size:10px; 147 | font-weight:bold; 148 | color:#FFFFFF; 149 | text-align:left; 150 | } 151 | 152 | .simpletablestyle .header a { 153 | color:#94aebd; 154 | } 155 | 156 | .simpletablestype tfoot { 157 | height: 20px; 158 | font-size: 10px; 159 | font-weight: bold; 160 | background-color: #EAECEE; 161 | text-align: center; 162 | } 163 | 164 | .simpletablestyle tr.header td { 165 | padding: 0px 10px 0px 5px; 166 | } 167 | 168 | 169 | .simpletablestyle .subheader { 170 | background-color: #e6e7e8; 171 | font-size:10px; 172 | font-weight:bold; 173 | color:#000000; 174 | text-align:left; 175 | } 176 | 177 | /* Using new CSS3 selectors for styling*/ 178 | .simpletablestyle tr:nth-child(odd) { 179 | background: #f4f3f3; 180 | } 181 | .simpletablestyle tr:nth-child(even) { 182 | background: #ffffff; 183 | } 184 | 185 | .simpletablestyle td a:hover { 186 | color:#3883ce; 187 | text-decoration:none; 188 | } -------------------------------------------------------------------------------- /spring-eap6-quickstart/src/main/webapp/resources/gfx/asidebkg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/spring-eap6-quickstart/src/main/webapp/resources/gfx/asidebkg.png -------------------------------------------------------------------------------- /spring-eap6-quickstart/src/main/webapp/resources/gfx/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/spring-eap6-quickstart/src/main/webapp/resources/gfx/banner.png -------------------------------------------------------------------------------- /spring-eap6-quickstart/src/main/webapp/resources/gfx/bkg-blkheader.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/spring-eap6-quickstart/src/main/webapp/resources/gfx/bkg-blkheader.png -------------------------------------------------------------------------------- /spring-eap6-quickstart/src/main/webapp/resources/gfx/dualbrand_as7eap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/spring-eap6-quickstart/src/main/webapp/resources/gfx/dualbrand_as7eap.png -------------------------------------------------------------------------------- /spring-eap6-quickstart/src/main/webapp/resources/gfx/dualbrand_catapillarbutterfly.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/spring-eap6-quickstart/src/main/webapp/resources/gfx/dualbrand_catapillarbutterfly.png -------------------------------------------------------------------------------- /spring-eap6-quickstart/src/main/webapp/resources/gfx/dualbrand_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/spring-eap6-quickstart/src/main/webapp/resources/gfx/dualbrand_logo.png -------------------------------------------------------------------------------- /spring-eap6-quickstart/src/main/webapp/resources/gfx/headerbkg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/spring-eap6-quickstart/src/main/webapp/resources/gfx/headerbkg.png -------------------------------------------------------------------------------- /spring-eap6-quickstart/src/main/webapp/resources/gfx/icon_large.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/spring-eap6-quickstart/src/main/webapp/resources/gfx/icon_large.png -------------------------------------------------------------------------------- /spring-eap6-quickstart/src/main/webapp/resources/gfx/icon_medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/spring-eap6-quickstart/src/main/webapp/resources/gfx/icon_medium.png -------------------------------------------------------------------------------- /spring-eap6-quickstart/src/main/webapp/resources/gfx/icon_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/spring-eap6-quickstart/src/main/webapp/resources/gfx/icon_small.png -------------------------------------------------------------------------------- /spring-eap6-quickstart/src/main/webapp/resources/gfx/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jboss-openshift/openshift-examples/c2b2a30dacd062b6bdf57e5869179c5bf62b9cd3/spring-eap6-quickstart/src/main/webapp/resources/gfx/logo.png -------------------------------------------------------------------------------- /spring-eap6-quickstart/src/test/java/org/jboss/tools/example/springmvc/test/MemberDaoTest.java: -------------------------------------------------------------------------------- 1 | package org.jboss.tools.example.springmvc.test; 2 | 3 | import java.util.List; 4 | 5 | import junit.framework.Assert; 6 | 7 | import org.jboss.tools.example.springmvc.domain.Member; 8 | import org.jboss.tools.example.springmvc.repo.MemberDao; 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.test.context.ContextConfiguration; 13 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 14 | import org.springframework.test.context.transaction.TransactionConfiguration; 15 | import org.springframework.transaction.annotation.Transactional; 16 | 17 | @RunWith(SpringJUnit4ClassRunner.class) 18 | @ContextConfiguration(locations={"classpath:test-context.xml", 19 | "classpath:/META-INF/spring/applicationContext.xml"}) 20 | @Transactional 21 | @TransactionConfiguration(defaultRollback=true) 22 | public class MemberDaoTest 23 | { 24 | @Autowired 25 | private MemberDao memberDao; 26 | 27 | @Test 28 | public void testFindById() 29 | { 30 | Member member = memberDao.findById(0l); 31 | 32 | Assert.assertEquals("John Smith", member.getName()); 33 | Assert.assertEquals("john.smith@mailinator.com", member.getEmail()); 34 | Assert.assertEquals("2125551212", member.getPhoneNumber()); 35 | return; 36 | } 37 | 38 | @Test 39 | public void testFindByEmail() 40 | { 41 | Member member = memberDao.findByEmail("john.smith@mailinator.com"); 42 | 43 | Assert.assertEquals("John Smith", member.getName()); 44 | Assert.assertEquals("john.smith@mailinator.com", member.getEmail()); 45 | Assert.assertEquals("2125551212", member.getPhoneNumber()); 46 | return; 47 | } 48 | 49 | @Test 50 | public void testRegister() 51 | { 52 | Member member = new Member(); 53 | member.setEmail("jane.doe@mailinator.com"); 54 | member.setName("Jane Doe"); 55 | member.setPhoneNumber("2125552121"); 56 | 57 | memberDao.register(member); 58 | Long id = member.getId(); 59 | Assert.assertNotNull(id); 60 | 61 | Assert.assertEquals(2, memberDao.findAllOrderedByName().size()); 62 | Member newMember = memberDao.findById(id); 63 | 64 | Assert.assertEquals("Jane Doe", newMember.getName()); 65 | Assert.assertEquals("jane.doe@mailinator.com", newMember.getEmail()); 66 | Assert.assertEquals("2125552121", newMember.getPhoneNumber()); 67 | return; 68 | } 69 | 70 | @Test 71 | public void testFindAllOrderedByName() 72 | { 73 | Member member = new Member(); 74 | member.setEmail("jane.doe@mailinator.com"); 75 | member.setName("Jane Doe"); 76 | member.setPhoneNumber("2125552121"); 77 | memberDao.register(member); 78 | 79 | List members = memberDao.findAllOrderedByName(); 80 | Assert.assertEquals(2, members.size()); 81 | Member newMember = members.get(0); 82 | 83 | Assert.assertEquals("Jane Doe", newMember.getName()); 84 | Assert.assertEquals("jane.doe@mailinator.com", newMember.getEmail()); 85 | Assert.assertEquals("2125552121", newMember.getPhoneNumber()); 86 | return; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /spring-eap6-quickstart/src/test/resources/META-INF/test-persistence.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | org.hibernate.ejb.HibernatePersistence 6 | org.jboss.tools.example.springmvc.domain.Member 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /spring-eap6-quickstart/src/test/resources/import.sql: -------------------------------------------------------------------------------- 1 | -- You can use this file to load seed data into the database using SQL statements 2 | insert into Member (id, name, email, phone_number) values (0, 'John Smith', 'john.smith@mailinator.com', '2125551212') -------------------------------------------------------------------------------- /spring-eap6-quickstart/src/test/resources/test-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /sso-manual-db-migration/README.md: -------------------------------------------------------------------------------- 1 | # Example of custom Red Hat Single Sign-On 7.3 TP CD configuration to perform manual migration of the existing Red Hat Single Sign-On database 2 | 3 | This example illustrates custom configuration of the *_standalone-openshift.xml_* file to perform manual migration of the database used by previous version of the Red Hat Single Sign-On server to database format expected by the Red Hat Single Sign-On 7.3 Continuous Delivery for OpenShift (Technology Preview) release stream. 4 | 5 | For a step-by-step scenario on how to perform this migration, see the [Manual Database Migration](https://access.redhat.com/documentation/en-us/red_hat_single_sign-on_continuous_delivery/7.3.0.cd03/html-single/red_hat_single_sign-on_for_openshift/#manual-db-migration) section of the [Red Hat Single Sign-On Continuous Delivery for OpenShift guide](https://access.redhat.com/documentation/en-us/red_hat_single_sign-on_continuous_delivery/7.3.0.cd03/html-single/red_hat_single_sign-on_for_openshift/). 6 | -------------------------------------------------------------------------------- /sso-securedeployments/README.md: -------------------------------------------------------------------------------- 1 | # keycloak-examples 2 | 3 | With the exception of app-html5 and app-profile-html5, all examples are deployed as a WAR. These examples assume that a Keycloak server is running on localhost:8180 and a WildFly server is running on localhost:8080. 4 | 5 | If you want to change the address of the Keycloak server, edit the keycloak.json file in each example's WEB-INF directory. 6 | If you want to change the address of the WildFly server, edit each example's client detail in the UI of the Keycloak server. 7 | 8 | To install and run all the WAR-based examples: 9 | 10 | 1. Download this keycloak-examples repository. 11 | 2. [Download](http://keycloak.jboss.org/keycloak/downloads.html) and unzip the plain **keycloak** distribution. Do not download the demo dist. 12 | 3. [Download](http://wildfly.org/downloads/) an unzip WildFly. 13 | 4. [Download](http://keycloak.jboss.org/keycloak/downloads.html?dir=0%3Dadapters/keycloak-oidc%3B) the Keycloak OIDC adapter for WildFly. Unzip this adapter on top of WildFly. 14 | 5. [Download](http://keycloak.jboss.org/keycloak/downloads.html?dir=0%3Dadapters/saml%3B) the Keycloak SAML adapter for WildFly. Unzip this adapter on top of WildFly. It's OK to overwrite modules. 15 | 6. *cd <Keycloak Home>/bin* 16 | 7. *standalone(.bat or .sh) -Djboss.socket.binding.port-offset=100* 17 | 8. In your browser, go to 18 | 9. Login with admin/admin and change the password when prompted. 19 | 10. In the upper lefthand corner, click on Master->Add Realm 20 | 11. Click "Select File" and choose *examples-realm.json* from the root of the keycloak-examples repo from step 1. 21 | 12. *cd <WildFly Home>/bin* 22 | 13. *standalone(.bat or .sh)* 23 | 14. With WildFly running, open a new command prompt and *cd <WildFly Home>/bin* again. Then execute the following three commands to finish adapter install. 24 | 15. *jboss-cli -c --file=adapter-install.cli* 25 | 16. *jboss-cli -c --file=adapter-install-saml.cli* 26 | 17. *jboss-cli -c --command=:reload* 27 | 18. At the root of the keycloak-examples repo, run *mvn wildfly:deploy* 28 | 29 | The Examples realm you imported has two users, *secure-user* and *admin-user*. Both use "password" as the password. 30 | 31 | You can run each example with the following URLs: 32 | 33 | * 34 | * 35 | * 36 | * 37 | * 38 | -------------------------------------------------------------------------------- /sso-securedeployments/app-profile-jee-saml/README.md: -------------------------------------------------------------------------------- 1 | You need to create a client in Keycloak. The configuration options when creating the client should be: 2 | 3 | Settings 4 | ----------- 5 | * Client ID: app-profile-jee-saml 6 | * Enabled: ON 7 | * Consent Required: OFF 8 | * direct-grants-only: OFF 9 | * Client Protocol: saml 10 | * Include AuthnStatement: ON 11 | * Sign Documents: OFF 12 | * Sign Assertions: OFF 13 | * Encrypt Assertions: OFF 14 | * Client Signature Required: OFF 15 | * Force POST Binding: OFF 16 | * Front Channel Logout: OFF 17 | * Force Name ID Format: OFF 18 | * Name ID Format: username 19 | * Root URL: 20 | * Valid Redirect URIs: http://localhost:8080/app-profile-jee-saml/* 21 | * Base URL: http://localhost:8080/app-profile-jee-saml/ 22 | * Master SAML Processing URL: http://localhost:8080/app-profile-jee-saml/saml 23 | 24 | Mappers 25 | ------------ 26 | Add all builtin mappers 27 | 28 | Then, build the WAR with Maven and install as per the Adapter configuration for your server as described in the Keycloak documentation. -------------------------------------------------------------------------------- /sso-securedeployments/app-profile-jee-saml/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.keycloak.quickstart 7 | keycloak-quickstart-parent 8 | 0.5-SNAPSHOT 9 | 10 | 11 | org.keycloak.quickstart 12 | keycloak-quickstart-app-profile-jee-saml 13 | 0.5-SNAPSHOT 14 | 15 | Keycloak Quickstart App Profile JEE SAML 16 | 17 | 18 | war 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | org.jboss.spec.javax.servlet 27 | jboss-servlet-api_3.0_spec 28 | provided 29 | 30 | 31 | org.keycloak 32 | keycloak-core 33 | provided 34 | 35 | 36 | org.keycloak 37 | keycloak-adapter-core 38 | provided 39 | 40 | 41 | org.keycloak 42 | keycloak-saml-adapter-core 43 | provided 44 | 45 | 46 | org.keycloak 47 | keycloak-adapter-spi 48 | provided 49 | 50 | 56 | 57 | 58 | 59 | app-profile-jee-saml 60 | 61 | 62 | org.jboss.as.plugins 63 | jboss-as-maven-plugin 64 | 65 | false 66 | 67 | 68 | 69 | org.wildfly.plugins 70 | wildfly-maven-plugin 71 | 72 | false 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /sso-securedeployments/app-profile-jee-saml/src/main/java/org/keycloak/quickstart/profilejee/Controller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Red Hat Inc. and/or its affiliates and other contributors 3 | * as indicated by the @author tags. All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 6 | * use this file except in compliance with the License. You may obtain a copy of 7 | * the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package org.keycloak.quickstart.profilejee; 18 | 19 | import javax.servlet.http.HttpServletRequest; 20 | import javax.servlet.http.HttpSession; 21 | 22 | import org.keycloak.adapters.saml.SamlDeploymentContext; 23 | import org.keycloak.adapters.saml.SamlPrincipal; 24 | import org.keycloak.adapters.saml.SamlSession; 25 | import org.keycloak.common.util.KeycloakUriBuilder; 26 | import org.keycloak.constants.ServiceUrlConstants; 27 | 28 | /** 29 | * Controller simplifies access to the server environment from the JSP. 30 | * 31 | * @author Stan Silvert ssilvert@redhat.com (C) 2015 Red Hat Inc. 32 | */ 33 | public class Controller { 34 | 35 | public String getFirstName(HttpServletRequest req) { 36 | return getFriendlyAttrib(req, "givenName"); 37 | } 38 | 39 | public String getLastName(HttpServletRequest req) { 40 | return getFriendlyAttrib(req, "surname"); 41 | } 42 | 43 | public String getEmail(HttpServletRequest req) { 44 | return getFriendlyAttrib(req, "email"); 45 | } 46 | 47 | public String getUsername(HttpServletRequest req) { 48 | return req.getUserPrincipal().getName(); 49 | } 50 | 51 | private String getFriendlyAttrib(HttpServletRequest req, String attribName) { 52 | SamlPrincipal principal = getAccount(req); 53 | return principal.getFriendlyAttribute(attribName); 54 | } 55 | 56 | private SamlPrincipal getAccount(HttpServletRequest req) { 57 | SamlPrincipal principal = (SamlPrincipal)req.getUserPrincipal(); 58 | return principal; 59 | } 60 | 61 | public boolean isLoggedIn(HttpServletRequest req) { 62 | return getAccount(req) != null; 63 | } 64 | 65 | public String getAccountUri(HttpServletRequest req) { 66 | String serverPath = findKeycloakServerPath(req); 67 | String realm = findRealmName(req); 68 | return KeycloakUriBuilder.fromUri(serverPath).path(ServiceUrlConstants.ACCOUNT_SERVICE_PATH) 69 | .queryParam("referrer", "app-profile-jee-saml").build(realm).toString(); 70 | } 71 | 72 | // HACK: This is a really bad way to find the realm name, but I can't 73 | // figure out a better way to do it with the SAML adapter. It parses 74 | // the URL specified in keycloak-saml.xml 75 | private String findRealmName(HttpServletRequest req) { 76 | String bindingUrl = getBindingUrl(req); 77 | // bindingUrl looks like http://localhost:8080/auth/realms/master/protocol/saml 78 | int beginIndex = bindingUrl.indexOf("/realms/") + "/realms/".length(); 79 | return bindingUrl.substring(beginIndex, bindingUrl.indexOf('/', beginIndex)); 80 | } 81 | 82 | private String findKeycloakServerPath(HttpServletRequest req) { 83 | String bindingUrl = getBindingUrl(req); 84 | // bindingUrl looks like http://localhost:8080/auth/realms/master/protocol/saml 85 | return bindingUrl.substring(0, bindingUrl.indexOf("/auth")) + "/auth"; 86 | } 87 | 88 | private String getBindingUrl(HttpServletRequest req) { 89 | SamlDeploymentContext ctx = (SamlDeploymentContext)req.getServletContext().getAttribute(SamlDeploymentContext.class.getName()); 90 | return ctx.resolveDeployment(null).getIDP().getSingleSignOnService().getRequestBindingUrl(); 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /sso-securedeployments/app-profile-jee-saml/src/main/webapp/WEB-INF/keycloak-saml.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 17 | 18 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /sso-securedeployments/app-profile-jee-saml/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 22 | 23 | app-profile-jee-saml 24 | 25 | 26 | 27 | /profile.jsp 28 | 29 | 30 | user 31 | 32 | 33 | 34 | 35 | 36 | /saml 37 | 38 | 39 | * 40 | 41 | 42 | 43 | 44 | KEYCLOAK-SAML 45 | 46 | 47 | 48 | user 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /sso-securedeployments/app-profile-jee-saml/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | * Copyright 2015 Red Hat Inc. and/or its affiliates and other contributors 3 | * as indicated by the @author tags. All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 6 | * use this file except in compliance with the License. You may obtain a copy of 7 | * the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | --%> 17 | 18 | <%@page contentType="text/html" pageEncoding="ISO-8859-1"%> 19 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 20 | 21 | 22 | 23 | 24 | Keycloak Example App 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 |
37 | 40 | 41 |
42 |
Please login
43 |
44 |
45 | 46 | 47 | -------------------------------------------------------------------------------- /sso-securedeployments/app-profile-jee-saml/src/main/webapp/profile.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | * Copyright 2015 Red Hat Inc. and/or its affiliates and other contributors 3 | * as indicated by the @author tags. All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 6 | * use this file except in compliance with the License. You may obtain a copy of 7 | * the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | --%> 17 | 18 | <%@page contentType="text/html" pageEncoding="ISO-8859-1"%> 19 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 20 | 21 | 22 | 23 | 24 | Keycloak SAML Example App 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 |
33 | 37 | 38 |
39 |
40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 |
First name${controller.getFirstName(req)}
Last name${controller.getLastName(req)}
Username${controller.getUsername(req)}
Email${controller.getEmail(req)}
58 |
59 |
60 |
61 | 62 | 63 | -------------------------------------------------------------------------------- /sso-securedeployments/app-profile-jee-saml/src/main/webapp/styles.css: -------------------------------------------------------------------------------- 1 | 2 | body { 3 | background-color: #333; 4 | font-family: sans-serif; 5 | font-size: 30px; 6 | } 7 | 8 | button { 9 | font-family: sans-serif; 10 | font-size: 30px; 11 | width: 200px; 12 | 13 | background-color: #0085cf; 14 | background-image: linear-gradient(to bottom, #00a8e1 0%, #0085cf 100%); 15 | background-repeat: repeat-x; 16 | 17 | border: 2px solid #ccc; 18 | color: #fff; 19 | -webkit-border-radius: 30px; 20 | 21 | text-transform: uppercase; 22 | 23 | -webkit-box-shadow: 2px 2px 10px 0px rgba(0,0,0,0.5); 24 | -moz-box-shadow: 2px 2px 10px 0px rgba(0,0,0,0.5); 25 | box-shadow: 2px 2px 10px 0px rgba(0,0,0,0.5); 26 | } 27 | 28 | button:hover { 29 | background-color: #006ba6; 30 | background-image: none; 31 | -webkit-box-shadow: none; 32 | -moz-box-shadow: none; 33 | box-shadow: none; 34 | } 35 | 36 | hr { 37 | border: none; 38 | background-color: #eee; 39 | height: 10px; 40 | } 41 | 42 | .menu { 43 | padding: 10px; 44 | margin-bottom: 10px; 45 | } 46 | 47 | .content { 48 | background-color: #eee; 49 | border: 1px solid #ccc; 50 | padding: 10px; 51 | -webkit-border-radius: 10px; 52 | 53 | -webkit-box-shadow: 2px 2px 10px 0px rgba(0,0,0,0.5); 54 | -moz-box-shadow: 2px 2px 10px 0px rgba(0,0,0,0.5); 55 | box-shadow: 2px 2px 10px 0px rgba(0,0,0,0.5); 56 | } 57 | 58 | .content .message { 59 | padding: 10px; 60 | background-color: #fff; 61 | border: 1px solid #ccc; 62 | font-size: 40px; 63 | -webkit-border-radius: 10px; 64 | } 65 | 66 | #token .content .message { 67 | font-size: 20px; 68 | overflow: scroll; 69 | padding: 5px; 70 | white-space: pre; 71 | text-transform: none; 72 | } 73 | 74 | .wrapper { 75 | position: absolute; 76 | left: 10px; 77 | top: 10px; 78 | bottom: 10px; 79 | right: 10px; 80 | } 81 | 82 | .error { 83 | color: #a21e22; 84 | } 85 | 86 | table { 87 | width: 100%; 88 | } 89 | 90 | tr.even { 91 | background-color: #eee; 92 | } 93 | 94 | td { 95 | padding: 5px; 96 | } 97 | 98 | td.label { 99 | font-weight: bold; 100 | width: 250px; 101 | } 102 | -------------------------------------------------------------------------------- /sso-securedeployments/app-profile-jee/README.md: -------------------------------------------------------------------------------- 1 | You need to create a client in Keycloak. The configuration options when creating the client should be: 2 | 3 | * Client ID: You choose 4 | * Access Type: confidential 5 | * Root URL: Root URL for where you're hosting the application (for example http://localhost:8080) 6 | * Valie Redirect URIs: /app-profile-jee/* 7 | * Base URL: /app-profile-jee/ 8 | * Admin URL: /app-profile-jee/ 9 | 10 | Then, build the WAR with Maven and install as per the Adapter configuration for your server as described in the Keycloak documentation. -------------------------------------------------------------------------------- /sso-securedeployments/app-profile-jee/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.keycloak.quickstart 7 | keycloak-quickstart-parent 8 | 0.5-SNAPSHOT 9 | 10 | 11 | org.keycloak.quickstart 12 | keycloak-quickstart-app-profile-jee 13 | 0.5-SNAPSHOT 14 | 15 | Keycloak Quickstart App Profile JEE 16 | 17 | 18 | war 19 | 20 | 21 | 22 | 23 | 24 | 25 | org.jboss.spec.javax.servlet 26 | jboss-servlet-api_3.0_spec 27 | provided 28 | 29 | 30 | org.keycloak 31 | keycloak-core 32 | provided 33 | 34 | 35 | org.keycloak 36 | keycloak-adapter-core 37 | provided 38 | 39 | 40 | org.keycloak 41 | keycloak-adapter-spi 42 | provided 43 | 44 | 45 | 46 | 47 | app-profile-jee 48 | 49 | 50 | org.wildfly.plugins 51 | wildfly-maven-plugin 52 | 53 | false 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /sso-securedeployments/app-profile-jee/src/main/java/org/keycloak/quickstart/profilejee/Controller.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Red Hat Inc. and/or its affiliates and other contributors 3 | * as indicated by the @author tags. All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 6 | * use this file except in compliance with the License. You may obtain a copy of 7 | * the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package org.keycloak.quickstart.profilejee; 18 | 19 | import java.io.IOException; 20 | import javax.servlet.ServletException; 21 | import javax.servlet.http.HttpServletRequest; 22 | import org.keycloak.KeycloakSecurityContext; 23 | import org.keycloak.adapters.AdapterDeploymentContext; 24 | import org.keycloak.adapters.KeycloakDeployment; 25 | import org.keycloak.common.util.KeycloakUriBuilder; 26 | import org.keycloak.constants.ServiceUrlConstants; 27 | import org.keycloak.representations.IDToken; 28 | import org.keycloak.util.JsonSerialization; 29 | 30 | /** 31 | * Controller simplifies access to the server environment from the JSP. 32 | * 33 | * @author Stan Silvert ssilvert@redhat.com (C) 2015 Red Hat Inc. 34 | */ 35 | public class Controller { 36 | 37 | public void handleLogout(HttpServletRequest req) throws ServletException { 38 | if (req.getParameter("logout") != null) { 39 | req.logout(); 40 | } 41 | } 42 | 43 | public boolean isLoggedIn(HttpServletRequest req) { 44 | return getSession(req) != null; 45 | } 46 | 47 | public boolean showToken(HttpServletRequest req) { 48 | return req.getParameter("showToken") != null; 49 | } 50 | 51 | public IDToken getIDToken(HttpServletRequest req) { 52 | return getSession(req).getIdToken(); 53 | } 54 | 55 | public String getAccountUri(HttpServletRequest req) { 56 | KeycloakSecurityContext session = getSession(req); 57 | String baseUrl = getAuthServerBaseUrl(req); 58 | String realm = session.getRealm(); 59 | return KeycloakUriBuilder.fromUri(baseUrl).path(ServiceUrlConstants.ACCOUNT_SERVICE_PATH) 60 | .queryParam("referrer", "app-profile-jee").build(realm).toString(); 61 | 62 | } 63 | 64 | private String getAuthServerBaseUrl(HttpServletRequest req) { 65 | AdapterDeploymentContext deploymentContext = (AdapterDeploymentContext) req.getServletContext().getAttribute(AdapterDeploymentContext.class.getName()); 66 | KeycloakDeployment deployment = deploymentContext.resolveDeployment(null); 67 | return deployment.getAuthServerBaseUrl(); 68 | } 69 | 70 | public String getTokenString(HttpServletRequest req) throws IOException { 71 | return JsonSerialization.writeValueAsPrettyString(getIDToken(req)); 72 | } 73 | 74 | private KeycloakSecurityContext getSession(HttpServletRequest req) { 75 | return (KeycloakSecurityContext) req.getAttribute(KeycloakSecurityContext.class.getName()); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /sso-securedeployments/app-profile-jee/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 22 | 23 | app-profile-jee 24 | 25 | 26 | 27 | /profile.jsp 28 | 29 | 30 | user 31 | 32 | 33 | 34 | 35 | KEYCLOAK 36 | 37 | 38 | 39 | user 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /sso-securedeployments/app-profile-jee/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | * Copyright 2015 Red Hat Inc. and/or its affiliates and other contributors 3 | * as indicated by the @author tags. All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 6 | * use this file except in compliance with the License. You may obtain a copy of 7 | * the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | --%> 17 | 18 | <%@page contentType="text/html" pageEncoding="ISO-8859-1"%> 19 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 20 | 21 | 22 | 23 | 24 | Keycloak Example App 25 | 26 | 27 | 28 | 29 | 30 | <% controller.handleLogout(request); %> 31 | 32 | 33 | 34 | 35 | 36 | 37 |
38 | 41 | 42 |
43 |
Please login
44 |
45 |
46 | 47 | 48 | -------------------------------------------------------------------------------- /sso-securedeployments/app-profile-jee/src/main/webapp/profile.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | * Copyright 2015 Red Hat Inc. and/or its affiliates and other contributors 3 | * as indicated by the @author tags. All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 6 | * use this file except in compliance with the License. You may obtain a copy of 7 | * the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | --%> 17 | 18 | <%@page contentType="text/html" pageEncoding="ISO-8859-1"%> 19 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 20 | 21 | 22 | 23 | 24 | Keycloak Example App 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 |
35 | 45 | 46 | 47 |
48 |
${tokenString}
49 | 50 |
51 |
52 | 53 | 54 |
55 |
56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 |
First name${idToken.givenName}
Last name${idToken.familyName}
Username${idToken.preferredUsername}
Email${idToken.email}
74 |
75 |
76 |
77 |
78 | 79 | 80 | -------------------------------------------------------------------------------- /sso-securedeployments/app-profile-jee/src/main/webapp/styles.css: -------------------------------------------------------------------------------- 1 | 2 | body { 3 | background-color: #333; 4 | font-family: sans-serif; 5 | font-size: 30px; 6 | } 7 | 8 | button { 9 | font-family: sans-serif; 10 | font-size: 30px; 11 | width: 200px; 12 | 13 | background-color: #0085cf; 14 | background-image: linear-gradient(to bottom, #00a8e1 0%, #0085cf 100%); 15 | background-repeat: repeat-x; 16 | 17 | border: 2px solid #ccc; 18 | color: #fff; 19 | -webkit-border-radius: 30px; 20 | 21 | text-transform: uppercase; 22 | 23 | -webkit-box-shadow: 2px 2px 10px 0px rgba(0,0,0,0.5); 24 | -moz-box-shadow: 2px 2px 10px 0px rgba(0,0,0,0.5); 25 | box-shadow: 2px 2px 10px 0px rgba(0,0,0,0.5); 26 | } 27 | 28 | button:hover { 29 | background-color: #006ba6; 30 | background-image: none; 31 | -webkit-box-shadow: none; 32 | -moz-box-shadow: none; 33 | box-shadow: none; 34 | } 35 | 36 | hr { 37 | border: none; 38 | background-color: #eee; 39 | height: 10px; 40 | } 41 | 42 | .menu { 43 | padding: 10px; 44 | margin-bottom: 10px; 45 | } 46 | 47 | .content { 48 | background-color: #eee; 49 | border: 1px solid #ccc; 50 | padding: 10px; 51 | -webkit-border-radius: 10px; 52 | 53 | -webkit-box-shadow: 2px 2px 10px 0px rgba(0,0,0,0.5); 54 | -moz-box-shadow: 2px 2px 10px 0px rgba(0,0,0,0.5); 55 | box-shadow: 2px 2px 10px 0px rgba(0,0,0,0.5); 56 | } 57 | 58 | .content .message { 59 | padding: 10px; 60 | background-color: #fff; 61 | border: 1px solid #ccc; 62 | font-size: 40px; 63 | -webkit-border-radius: 10px; 64 | } 65 | 66 | #token .content .message { 67 | font-size: 20px; 68 | overflow: scroll; 69 | padding: 5px; 70 | white-space: pre; 71 | text-transform: none; 72 | } 73 | 74 | .wrapper { 75 | position: absolute; 76 | left: 10px; 77 | top: 10px; 78 | bottom: 10px; 79 | right: 10px; 80 | } 81 | 82 | .error { 83 | color: #a21e22; 84 | } 85 | 86 | table { 87 | width: 100%; 88 | } 89 | 90 | tr.even { 91 | background-color: #eee; 92 | } 93 | 94 | td { 95 | padding: 5px; 96 | } 97 | 98 | td.label { 99 | font-weight: bold; 100 | width: 250px; 101 | } 102 | -------------------------------------------------------------------------------- /sso-securedeployments/configuration/secure-deployments: -------------------------------------------------------------------------------- 1 | 2 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArujsIJfA8JYuInj9r1InmUsWZPewBeTOcVPB8dj5CxanDwNANtqPKaSKUFRUm/FWkcelkQlQSmETauxHVG3fYCqpsCWe9fte7JQal/qwGfUca0tkVUIfd7rfiCa1Z2JdgUsiVCeD4PJjM2YWzzrm1inoUBXSXavzBzV9GsinMXjtjjeihSCJwxNyyEn7wBSO9RbYMjVvkGbE5YOHDqgsnIL/nNwV59kvMSRU1i6pwqrbkltKYx5jkCJSzIaSgJv0lXuhbAzT/hLdDwIxjC1HF42/SeJRY3VPKvUvZceIJEs4vBljkujmHmjgSjAXRiMYbAT2AioRmCR5/ddUtb3BPQIDAQAB 3 | https://secure-sso-demo.cloudapps.example.com/auth 4 | external 5 | true 6 | true 7 | 8 | 9 | demo 10 | app-profile-jee 11 | https://secure-sso-demo.cloudapps.example.com/auth 12 | true 13 | true 14 | KICe8sS2 15 | false 16 | 17 | -------------------------------------------------------------------------------- /sso-securedeployments/configuration/secure-saml-deployments: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCTTNsa16b4h//+PDQ5OzMhylfjJ04ILQ96qS26ViSbikbSoRUEH4e4yPvJ5MFzUoIOXbGb5Dos95PNS5+TsFcUSDhG7WXc9JbvQvIkF8fLmezR1gTkzUjQC+/2u+OALVVOyIGZ1eH60ghAM+Scgqlalyzv1c85REYu+4aN/KPTwRlYW8BnNiuTeUrCRx4MelhhvmL7PEVHPkrqh/+H2BD0LOyWo13u7HG/LL/JO00WTYnv3tWTeEq1uIBOpz356AQdwRCvMAN6M9iiXmR7cMDU09EGoUaS7mfbXmLZ5jNi9VXXGaJ8gP/eXO81Y3RtaU7GXvhWw+dZr/Yk8/eFnqnlAgMBAAECggEBAI9+KFeuyx6DRhMBzRIPpJD/T7yeVnrKgrDITB6gukq3WqTnfNSmbo3JZNdZvEY+kymxhkrJ+w5BJD+yssKp3zqH3CLkMv4bW0m7Wq1kaSLjUPtdVSka/hqF9n7SrB36i4cS9oXJALpZjuYUZ1k8RARXDtSY4aT06LXuGzcIbQPjNbYUno6JMMyQ1jv24i4ThzQv8vLdFIAhwXVFDMBNWgZCoR4rtymIVAysqh6TM+u8gEkonKRMM93jfiCNYFpLeuRanqRGHHrD7w543yTpFEM8jpa/Y1KW2I1oGilUcvITtBcW1d0yb7uHSKGW+pJJC7dZzYgBQLcVYwoWOXBbXUECgYEA04kUoUxHkZqu+Kdu7j2c6dE85J12dAL63hPyNrRLKquxgvx4TPhTKHF+CmNlYALhdAEKV8sOGYy7VQ/iH8l+AbjyWXOQNP8M/3QQ4OW/WHG6fZLjRIHkOxXfQN9IXeFTv1QAxkuIinIr3TVJ6OmtNLKtjqEZbO27D+vH5MYqEvUCgYEAskM3h1kqbECuHME5YnXiREIBMLl+XV2Qfel5MLQrQ0G7HHtZayvscrFmdMc/0/A+AjCakvWM1yKJIdiQtKrmNIyqzsReYhBHqVyoI0oVJtlcnJs6KAYVjeJ7KSSPnTCrhQaqBkAWH60pukgeNjdedMUS9vcE5KQT8WaeXAeBRTECgYBwVNEhvpIa3huga7laxlk3SSee94dZn+N8Xvc22ZM4+6fuOQfhR9VRGsOl3JaO37i9k3fcmzXHl5Y7W43m92b0nzQDEH05x18toIL+CsMLwokX+hK55IhAYCMIHgod4HRKm981bhL6AhsNAylWiBC0dVX48c/AqpW1pK2n7RuWqQKBgQCUz2HqfffZGIGAhZjW5du16Xe+6gpf/Hxjb+R4UN8QrS160EnMGoWvFQKXl8Fjtli9UT+oUI17Blx9waDDAStdUNRB+VFlAXwhGLVPiEdx/9+86CQ7RyD1KcxwgxHUQc3dJbwHrbYKSW7dD9kQn1YdmmqDeaA/Ee2IBodKAgXa8QKBgQClyOfpZ9qK9xJN9yG3YtE3UQLQBoPGdFO+ASrjI9xB5d8tUsP+LmLFHJoQbFeHI7oCh16PHuO6uvuSL63thhdzxCm1XK8nJBZTvued8mtC9jMuo6awuKXcLfOk8ojqW1DiEzORunpiupCjQKAhRnQ0n3rd5IrEnPNyoGy4iGB1FA== 6 | MIIDdTCCAl2gAwIBAgIEZ6Si8TANBgkqhkiG9w0BAQsFADBrMQswCQYDVQQGEwJVUzELMAkGA1UECBMCTkMxEDAOBgNVBAcTB1JhbGVpZ2gxFjAUBgNVBAoTDW15Y29tcGFueS5jb20xFDASBgNVBAsTC0VuZ2luZWVyaW5nMQ8wDQYDVQQDEwZqc21pdGgwHhcNMTUwNTE5MTgwNjE4WhcNMTUwODE3MTgwNjE4WjBrMQswCQYDVQQGEwJVUzELMAkGA1UECBMCTkMxEDAOBgNVBAcTB1JhbGVpZ2gxFjAUBgNVBAoTDW15Y29tcGFueS5jb20xFDASBgNVBAsTC0VuZ2luZWVyaW5nMQ8wDQYDVQQDEwZqc21pdGgwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCTTNsa16b4h//+PDQ5OzMhylfjJ04ILQ96qS26ViSbikbSoRUEH4e4yPvJ5MFzUoIOXbGb5Dos95PNS5+TsFcUSDhG7WXc9JbvQvIkF8fLmezR1gTkzUjQC+/2u+OALVVOyIGZ1eH60ghAM+Scgqlalyzv1c85REYu+4aN/KPTwRlYW8BnNiuTeUrCRx4MelhhvmL7PEVHPkrqh/+H2BD0LOyWo13u7HG/LL/JO00WTYnv3tWTeEq1uIBOpz356AQdwRCvMAN6M9iiXmR7cMDU09EGoUaS7mfbXmLZ5jNi9VXXGaJ8gP/eXO81Y3RtaU7GXvhWw+dZr/Yk8/eFnqnlAgMBAAGjITAfMB0GA1UdDgQWBBREskqT+BpKsyMPJfyJi0LM+1MGoDANBgkqhkiG9w0BAQsFAAOCAQEADgRJMqxZ6+/jSEW/XW36UY0dPXq7xeT5ae8HgqjmxmNWG9FZNMo4QETlsNh8yF/R6yfyCDQHhC2bhFvm3095ob/R3rHEPQEhXp5aKElW0QY4fjtZ/9TN8Lzx+qgjFnowwE+KT9Z5p+84r4cgd9lLACaqVeCXic1UN0w0e0GE0C+KQveizGtJup2Ld7IjuupKlvjUub2/48X69lM4ZFB/bYarfT8h7zkOWq6C1EqKZYclgvYd4vjLBO1AqB17okNEI4fBsNyyXoJsyO6C3fLIjtij0Ql0pvmnpihU6mcLPvfr1b1SKb5euXYQtlYzlZOJAXF3pLfpCXZNST6zzOP8ag== 7 | 8 | 9 | 17 | 18 | 19 | 20 | 21 | 22 | MIIClzCCAX8CBgFTeld7pDANBgkqhkiG9w0BAQsFADAPMQ0wCwYDVQQDDARkZW1vMB4XDTE2MDMxNTEyNTI0NloXDTI2MDMxNTEyNTQyNlowDzENMAsGA1UEAwwEZGVtbzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAK7o7CCXwPCWLiJ4/a9SJ5lLFmT3sAXkznFTwfHY+QsWpw8DQDbajymkilBUVJvxVpHHpZEJUEphE2rsR1Rt32AqqbAlnvX7XuyUGpf6sBn1HGtLZFVCH3e634gmtWdiXYFLIlQng+DyYzNmFs865tYp6FAV0l2r8wc1fRrIpzF47Y43ooUgicMTcshJ+8AUjvUW2DI1b5BmxOWDhw6oLJyC/5zcFefZLzEkVNYuqcKq25JbSmMeY5AiUsyGkoCb9JV7oWwM0/4S3Q8CMYwtRxeNv0niUWN1Tyr1L2XHiCRLOLwZY5Lo5h5o4EowF0YjGGwE9gIqEZgkef3XVLW9wT0CAwEAATANBgkqhkiG9w0BAQsFAAOCAQEARZOR05B90p1/xZRIUz3fKwkdo3A4J235tEhxID8Kvy0iIR8PDJXu4UGYQoLgV1QnTbWSakIjlScdrmtUp+xxe6aTXYb1xQLD46Q/vvX++f8uZ48hisF1vrW7v02pcTGBObZJuPla527GDdwTON9qJiKGZuzJkxT3XWtEWiwTo8HSpi4gnfKsBWQPximrKv1e8npObEMrFoGtcjjkPKboR7jk5B40ddATYnd/0j9f/qJurPKuyyJJoggN42WPbYp0aSoyIK21NCdg20SoxllDAAgI09zku0vDYrMXJVpJLB0BFd4DQObuTxWtQK6Cvx2LmSiaubbnXtX5G3+Eb0eVAA== 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /sso-securedeployments/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | Keycloak Quickstart Parent 6 | Keycloak Quickstart Parent 7 | org.keycloak.quickstart 8 | keycloak-quickstart-parent 9 | 0.5-SNAPSHOT 10 | pom 11 | 12 | 13 | 3.0.12.Final 14 | 1.0.1.Final 15 | 17.0.1 16 | 4.5.13 17 | 1.0.2.Final 18 | 19 | 20 | http://keycloak.org 21 | 22 | 23 | 24 | Apache License, Version 2.0 25 | http://www.apache.org/licenses/LICENSE-2.0 26 | repo 27 | 28 | 29 | 30 | 31 | scm:git:git://github.com/keycloak/keycloak-examples.git 32 | scm:git:git@github.com:keycloak/keycloak-examples.git 33 | https://github.com/keycloak/keycloak-examples/tree/master 34 | 35 | 36 | 37 | 38 | jboss-releases-repository 39 | JBoss Releases Repository 40 | https://repository.jboss.org/nexus/service/local/staging/deploy/maven2/ 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | app-profile-jee 52 | app-profile-jee-saml 53 | 54 | 55 | 56 | 57 | 58 | org.jboss.resteasy 59 | jaxrs-api 60 | ${version.resteasy} 61 | 62 | 63 | org.jboss.spec.javax.servlet 64 | jboss-servlet-api_3.0_spec 65 | ${version.jboss.servlet-api} 66 | 67 | 68 | org.keycloak 69 | keycloak-core 70 | ${version.keycloak} 71 | 72 | 73 | org.keycloak 74 | keycloak-adapter-core 75 | ${version.keycloak} 76 | 77 | 78 | org.keycloak 79 | keycloak-adapter-spi 80 | ${version.keycloak} 81 | 82 | 83 | org.keycloak 84 | keycloak-saml-adapter-core 85 | ${version.keycloak} 86 | 87 | 88 | org.keycloak 89 | keycloak-adapter-spi 90 | ${version.keycloak} 91 | 92 | 93 | org.apache.httpcomponents 94 | httpclient 95 | ${version.httpclient} 96 | 97 | 98 | 99 | 100 | 101 | 102 | jboss 103 | http://repository.jboss.org/nexus/content/groups/public/ 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | org.wildfly.plugins 112 | wildfly-maven-plugin 113 | ${version.wildfly.plugin} 114 | 115 | true 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /tomcat-custom-configuration/README.md: -------------------------------------------------------------------------------- 1 | # Custom configuration example 2 | 3 | This example shows how to add a custom configuration to the image. 4 | 5 | The custom configuration adds a element to enable httpd-style 6 | logging. 7 | 8 | The configuration file retains ##DATASOURCES##, which is substituted 9 | by the run-time wrapper script. 10 | -------------------------------------------------------------------------------- /tomcat-custom-configuration/configuration/context-openshift.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | WEB-INF/web.xml 24 | ${catalina.base}/conf/web.xml 25 | 26 | 27 | 30 | 31 | 33 | 36 | 40 | 41 | ##DATASOURCES## 42 | 43 | 44 | -------------------------------------------------------------------------------- /tomcat-dynamic-configuration/README.md: -------------------------------------------------------------------------------- 1 | # Dynamic build created Custom configuration example 2 | 3 | This example shows how to have maven add a custom configuration to the image at build time.. 4 | 5 | The custom configuration adds a element to enable httpd-style 6 | logging. 7 | 8 | -------------------------------------------------------------------------------- /tomcat-dynamic-configuration/configuration/.gitignore: -------------------------------------------------------------------------------- 1 | /context-openshift.xml 2 | -------------------------------------------------------------------------------- /tomcat-dynamic-configuration/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | org.example 5 | tomcat-dynamic-configuration 6 | pom 7 | 1.0-SNAPSHOT 8 | Tomcat Dynamic Configuration 9 | http://maven.apache.org 10 | 11 | 12 | 13 | maven-resources-plugin 14 | 2.5 15 | 16 | 17 | copy-resources 18 | validate 19 | 20 | copy-resources 21 | 22 | 23 | ${basedir}/configuration 24 | 25 | 26 | src/configuration 27 | true 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /tomcat-dynamic-configuration/src/configuration/context-openshift.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | WEB-INF/web.xml 24 | ${catalina.base}/conf/web.xml 25 | 26 | 27 | 30 | 31 | 33 | 36 | 40 | 41 | ##DATASOURCES## 42 | 43 | 44 | -------------------------------------------------------------------------------- /tomcat-helloworld/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | org.example 5 | hello 6 | war 7 | 1.0-SNAPSHOT 8 | hello Maven Webapp 9 | http://maven.apache.org 10 | 11 | 12 | javax.servlet 13 | javax.servlet-api 14 | 3.0.1 15 | provided 16 | 17 | 18 | junit 19 | junit 20 | 3.8.1 21 | test 22 | 23 | 24 | 25 | hello 26 | 27 | 28 | -------------------------------------------------------------------------------- /tomcat-helloworld/src/main/java/org/example/HelloServlet.java: -------------------------------------------------------------------------------- 1 | // very simple hello world app 2 | package org.example; 3 | 4 | import javax.servlet.http.HttpServlet; 5 | import javax.servlet.ServletException; 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletResponse; 8 | import java.io.IOException; 9 | 10 | public class HelloServlet extends HttpServlet 11 | { 12 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) 13 | throws ServletException, IOException 14 | { 15 | resp.getWriter().print("Hello world"); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tomcat-helloworld/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | Hello World WebApp 7 | 8 | HelloServlet 9 | org.example.HelloServlet 10 | 11 | 12 | HelloServlet 13 | / 14 | 15 | 16 | --------------------------------------------------------------------------------