diff --git a/README.md b/README.md index a4d5fe39b5f2c69543b72e9bd4cf9e2f1e763811..c29f79612ea6e24ab473808399061977aa4ed1ae 100644 --- a/README.md +++ b/README.md @@ -40,10 +40,13 @@ curl --cacert localhost.pem \ Avec un reverse proxy : ``` echo quit | openssl s_client -showcerts \ - -servername localhost -connect localhost:8888 >! nginx.pem + -servername localhost -connect localhost:8888 >! localhost.pem curl --cacert localhost.pem \ https://localhost:8181/restApp-1.0-SNAPSHOT/resources/sample/persons/843c8236-6c6b-450e-9aa3-211a9b897403 + +keytool -noprompt -storepass storepass -import \ + -trustcacerts -alias mycert -file localhost.pem -keystore mycert-pub.jks ``` diff --git a/docker/nginx/Dockerfile b/docker/nginx/Dockerfile index ad968fb04bdd8353b59fead26f048387c2df3664..656ee95b24dae039519089b0341c0e590b31346f 100644 --- a/docker/nginx/Dockerfile +++ b/docker/nginx/Dockerfile @@ -2,8 +2,8 @@ FROM nginx:1.20.2-alpine RUN apk add openssl RUN openssl req -x509 -nodes \ -days 365 \ - -subj "/C=CA/ST=QC/O=Company, Inc./CN=mydomain.com" \ - -addext "subjectAltName=DNS:mydomain.com" \ + -subj "/C=CA/ST=QC/O=Company, Inc./CN=localhost" \ + -addext "subjectAltName=DNS:localhost" \ -newkey rsa:2048 \ -keyout /etc/ssl/private/nginx-selfsigned.key \ -out /etc/ssl/certs/nginx-selfsigned.crt; \ No newline at end of file diff --git a/docker/nginx/nginx.conf b/docker/nginx/nginx.conf index d4626c148e20148f1be0574737a1d581bcec60df..c54e65465079ee1d7f16a3c4034dc3cd6d933077 100644 --- a/docker/nginx/nginx.conf +++ b/docker/nginx/nginx.conf @@ -10,6 +10,13 @@ http { ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt; ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key; + location /wsapp/ { + proxy_pass http://jakartaEE:8686; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; + } + location / { proxy_pass http://jakartaEE:8080; } diff --git a/wsApp/src/main/java/fr/univtln/bruno/samples/jee91/ws/WSServer.java b/wsApp/src/main/java/fr/univtln/bruno/samples/jee91/ws/WSServer.java index eacbdf6085d1d708af0a5e9b48bcf2aca643c092..bea8ec0223a929f9a865d11ac5f56bedc870ddda 100644 --- a/wsApp/src/main/java/fr/univtln/bruno/samples/jee91/ws/WSServer.java +++ b/wsApp/src/main/java/fr/univtln/bruno/samples/jee91/ws/WSServer.java @@ -20,10 +20,11 @@ import java.io.IOException; @Log public class WSServer { - @Inject + @Inject @SpokenLanguage(SpokenLanguage.Language.ENGLISH) Hello hello; + @Inject MainDAO dao1; @@ -36,8 +37,8 @@ public class WSServer { } @OnMessage - public void onMessage(Session session, - String message) throws IOException { + public void onMessage(String message, Session session + ) throws IOException { session.getBasicRemote().sendText("Echo :" + message); } } diff --git a/wsApp/src/main/resources/META-INF/beans.xml b/wsApp/src/main/resources/META-INF/beans.xml new file mode 100644 index 0000000000000000000000000000000000000000..f8e254275530a1d3ce18bae65334cd014bf184c4 --- /dev/null +++ b/wsApp/src/main/resources/META-INF/beans.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd" + bean-discovery-mode="all"> +</beans> \ No newline at end of file diff --git a/wsApp/src/main/webapp/WEB-INF/beans.xml b/wsApp/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 0000000000000000000000000000000000000000..f8e254275530a1d3ce18bae65334cd014bf184c4 --- /dev/null +++ b/wsApp/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd" + bean-discovery-mode="all"> +</beans> \ No newline at end of file diff --git a/wsClient/src/main/java/fr/univtln/bruno/samples/jee91/wsclient/WsClient.java b/wsClient/src/main/java/fr/univtln/bruno/samples/jee91/wsclient/WsClient.java index 9711a211297d0b51a05a621558a4e5060612b038..71ab0208648b55c1563ae275a2e53273e1e0e559 100644 --- a/wsClient/src/main/java/fr/univtln/bruno/samples/jee91/wsclient/WsClient.java +++ b/wsClient/src/main/java/fr/univtln/bruno/samples/jee91/wsclient/WsClient.java @@ -41,8 +41,10 @@ public class WsClient { public static void main(String[] args) { try { - - final WsClient clientEndPoint = new WsClient(new URI("wss://localhost:8686/wsApp-1.0-SNAPSHOT/hellows")); + URI uri = new URI("ws://localhost:8686/wsApp-1.0-SNAPSHOT/hellows"); + //URI uri = new URI("wss://localhost:8888/wsapp/wsApp-1.0-SNAPSHOT/hellows"); + log.info("Connecting to "+uri); + final WsClient clientEndPoint = new WsClient(uri); clientEndPoint.sendMessage("Hello 1 !"); Thread.sleep(5000); clientEndPoint.sendMessage("Hello 2 !");