Skip to content
Snippets Groups Projects
Commit ff779090 authored by Emmanuel Bruno's avatar Emmanuel Bruno
Browse files

fixes certs.

parents 50b659fe f5debcd1
No related branches found
No related tags found
No related merge requests found
Showing
with 117 additions and 76 deletions
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
<groupId>fr.univtln.bruno.samples.jee91</groupId> <groupId>fr.univtln.bruno.samples.jee91</groupId>
<artifactId>business</artifactId> <artifactId>business</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<type>ejb</type>
<!--type>ejb-client</type--> <!--type>ejb-client</type-->
</dependency> </dependency>
...@@ -29,11 +30,6 @@ ...@@ -29,11 +30,6 @@
<groupId>jakarta.platform</groupId> <groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId> <artifactId>jakarta.jakartaee-api</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.eclipse.microprofile</groupId>
<artifactId>microprofile</artifactId>
<type>pom</type>
</dependency>
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId> <artifactId>junit-jupiter</artifactId>
......
...@@ -4,7 +4,7 @@ package fr.univtln.bruno.samples.jee91.rs; ...@@ -4,7 +4,7 @@ package fr.univtln.bruno.samples.jee91.rs;
import jakarta.ws.rs.ApplicationPath; import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application; import jakarta.ws.rs.core.Application;
@ApplicationPath("resources") @ApplicationPath("/")
public class JAXRSConfiguration extends Application { public class JAXRSConfiguration extends Application {
} }
\ No newline at end of file
...@@ -6,19 +6,19 @@ import fr.univtln.bruno.samples.jee91.dao.Person; ...@@ -6,19 +6,19 @@ import fr.univtln.bruno.samples.jee91.dao.Person;
import fr.univtln.bruno.samples.jee91.dao.PersonDAO; import fr.univtln.bruno.samples.jee91.dao.PersonDAO;
import fr.univtln.bruno.samples.jee91.ejb.Hello; import fr.univtln.bruno.samples.jee91.ejb.Hello;
import fr.univtln.bruno.samples.jee91.ejb.qualifiers.SpokenLanguage; import fr.univtln.bruno.samples.jee91.ejb.qualifiers.SpokenLanguage;
import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.transaction.Transactional; import jakarta.transaction.Transactional;
import jakarta.ws.rs.*; import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response; import jakarta.ws.rs.core.Response;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
@RequestScoped
@Path("sample") @Path("sample")
//@Stateless
@Produces({MediaType.APPLICATION_JSON,MediaType.TEXT_XML}) @Produces({MediaType.APPLICATION_JSON,MediaType.TEXT_XML})
public class SampleResource { public class SampleResource {
...@@ -32,9 +32,7 @@ public class SampleResource { ...@@ -32,9 +32,7 @@ public class SampleResource {
@Inject @Inject
PersonDAO personDAO; PersonDAO personDAO;
@Inject private final String message = "Hello";
@ConfigProperty(name = "message")
private String message;
@GET @GET
public Response message() { public Response message() {
......
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/beans_3_0.xsd"
bean-discovery-mode="all">
</beans>
\ No newline at end of file
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
<groupId>fr.univtln.bruno.samples.jee91</groupId> <groupId>fr.univtln.bruno.samples.jee91</groupId>
<artifactId>business</artifactId> <artifactId>business</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<type>ejb</type>
<!--type>ejb-client</type--> <!--type>ejb-client</type-->
</dependency> </dependency>
......
...@@ -3,31 +3,25 @@ ...@@ -3,31 +3,25 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>fr.univtln.bruno.samples.jee91</groupId> <groupId>fr.univtln.bruno.samples.jee91</groupId>
<artifactId>jee9.1</artifactId> <artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules> <modules>
<module>business</module>
<module>restApp</module>
<module>wsApp</module>
<module>dao</module>
<module>wsClient</module>
<module>entites</module> <module>entites</module>
<module>utils</module> <module>utils</module>
<module>jee</module>
<module>websocketClient</module>
</modules> </modules>
<packaging>pom</packaging>
<properties> <properties>
<maven.compiler.source>11</maven.compiler.source> <maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target> <maven.compiler.target>11</maven.compiler.target>
<failOnMissingWebXml>false</failOnMissingWebXml> <jakarta.jakartaee-api.version>9.0.0</jakarta.jakartaee-api.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<junit-jupiter.version>5.8.2</junit-jupiter.version>
<jakarta.jakartaee-api.version>9.1.0</jakarta.jakartaee-api.version>
<microprofile.version>3.0</microprofile.version>
<junit-jupiter.version>5.8.1</junit-jupiter.version>
</properties> </properties>
<dependencyManagement> <dependencyManagement>
...@@ -38,13 +32,6 @@ ...@@ -38,13 +32,6 @@
<version>${jakarta.jakartaee-api.version}</version> <version>${jakarta.jakartaee-api.version}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.eclipse.microprofile</groupId>
<artifactId>microprofile</artifactId>
<version>${microprofile.version}</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId> <artifactId>junit-jupiter</artifactId>
...@@ -54,7 +41,7 @@ ...@@ -54,7 +41,7 @@
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<version>1.18.20</version> <version>1.18.22</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
...@@ -68,15 +55,62 @@ ...@@ -68,15 +55,62 @@
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version> <version>3.8.1</version>
<configuration>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
</configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version> <version>2.22.2</version>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>enforce-maven</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>3.8</version>
</requireMavenVersion>
<dependencyConvergence/>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.0.0-M1</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>3.0.0-M1</version>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.9.1</version>
</plugin>
</plugins> </plugins>
</pluginManagement>
</build> </build>
</project> </project>
\ No newline at end of file
message=Hello World Jakarta EE 9.1
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<ruleset xmlns="http://mojo.codehaus.org/versions-maven-plugin/rule/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" comparisonMethod="maven" xsi:schemaLocation="http://mojo.codehaus.org/versions-maven-plugin/rule/2.0.0 http://mojo.codehaus.org/versions-maven-plugin/xsd/rule-2.0.0.xsd">
<ignoreVersions>
<!-- Ignore Alpha's, Beta's, release candidates and milestones -->
<ignoreVersion type="regex">(?i).*Alpha(?:-?\d+)?</ignoreVersion>
<ignoreVersion type="regex">(?i).*a(?:-?\d+)?</ignoreVersion>
<ignoreVersion type="regex">(?i).*Beta(?:-?\d+)?</ignoreVersion>
<ignoreVersion type="regex">(?i).*-B(?:-?\d+)?</ignoreVersion>
<ignoreVersion type="regex">(?i).*RC(?:-?\d+)?</ignoreVersion>
<ignoreVersion type="regex">(?i).*CR(?:-?\d+)?</ignoreVersion>
<ignoreVersion type="regex">(?i).*M(?:-?\d+)?</ignoreVersion>
<ignoreVersion type="regex">.*jre[0-9]+$</ignoreVersion>
</ignoreVersions>
<rules>
</rules>
</ruleset>
<?xml version="1.0" encoding="UTF-8"?>
<server description="new server">
<featureManager>
<feature>javaee-9.1</feature>
<feature>microProfile-3.0</feature>
</featureManager>
<httpEndpoint id="defaultHttpEndpoint" httpPort="9080" httpsPort="9443"/>
<quickStartSecurity userName="duke" userPassword="dukeduke"/>
</server>
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>jee9.1</artifactId> <artifactId>parent</artifactId>
<groupId>fr.univtln.bruno.samples.jee91</groupId> <groupId>fr.univtln.bruno.samples.jee91</groupId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</parent> </parent>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>jee9.1</artifactId> <artifactId>parent</artifactId>
<groupId>fr.univtln.bruno.samples.jee91</groupId> <groupId>fr.univtln.bruno.samples.jee91</groupId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</parent> </parent>
...@@ -25,12 +25,6 @@ ...@@ -25,12 +25,6 @@
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>slf4j-log4j12</artifactId>
</dependency> </dependency>
<dependency>
<groupId>fr.univtln.bruno.samples.jee91</groupId>
<artifactId>utils</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
...@@ -12,7 +12,6 @@ import java.util.Map; ...@@ -12,7 +12,6 @@ import java.util.Map;
@ClientEndpoint @ClientEndpoint
@Slf4j @Slf4j
public class WsClient { public class WsClient {
Session userSession = null; Session userSession = null;
private MessageHandler messageHandler; private MessageHandler messageHandler;
private Map<String, Object> properties; private Map<String, Object> properties;
...@@ -20,18 +19,18 @@ public class WsClient { ...@@ -20,18 +19,18 @@ public class WsClient {
public WsClient(URI endpointURI) { public WsClient(URI endpointURI) {
try { try {
WebSocketContainer container = ContainerProvider.getWebSocketContainer(); WebSocketContainer container = ContainerProvider.getWebSocketContainer();
var url = getClass().getClassLoader().getResource("mycert-pub.jks");
String pathtoCert = getClass().getClassLoader().getResource("mycert-pub.jks").toURI().getPath();
System.getProperties().put("javax.net.debug", "ssl"); System.getProperties().put("javax.net.debug", "ssl");
if (url != null) {
String pathtoCert = url.toURI().getPath();
System.getProperties().put(SSLContextConfigurator.KEY_STORE_FILE, pathtoCert); System.getProperties().put(SSLContextConfigurator.KEY_STORE_FILE, pathtoCert);
System.getProperties().put(SSLContextConfigurator.KEY_STORE_TYPE, "JKS"); System.getProperties().put(SSLContextConfigurator.KEY_STORE_TYPE, "JKS");
System.getProperties().put(SSLContextConfigurator.TRUST_STORE_FILE, pathtoCert); System.getProperties().put(SSLContextConfigurator.TRUST_STORE_FILE, pathtoCert);
System.getProperties().put(SSLContextConfigurator.TRUST_STORE_TYPE, "JKS"); System.getProperties().put(SSLContextConfigurator.TRUST_STORE_TYPE, "JKS");
System.getProperties().put(SSLContextConfigurator.KEY_STORE_PASSWORD, "storepass"); System.getProperties().put(SSLContextConfigurator.KEY_STORE_PASSWORD, "storepass");
System.getProperties().put(SSLContextConfigurator.TRUST_STORE_PASSWORD, "storepass"); System.getProperties().put(SSLContextConfigurator.TRUST_STORE_PASSWORD, "storepass");
}
final SSLContextConfigurator defaultConfig = new SSLContextConfigurator(); final SSLContextConfigurator defaultConfig = new SSLContextConfigurator();
defaultConfig.retrieve(System.getProperties()); defaultConfig.retrieve(System.getProperties());
container.connectToServer(this, endpointURI); container.connectToServer(this, endpointURI);
} catch (Exception e) { } catch (Exception e) {
...@@ -41,10 +40,8 @@ public class WsClient { ...@@ -41,10 +40,8 @@ public class WsClient {
public static void main(String[] args) { public static void main(String[] args) {
try { try {
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"); final WsClient clientEndPoint = new WsClient(new URI("ws://localhost:8686/wsApp/hellows"));
log.info("Connecting to "+uri);
final WsClient clientEndPoint = new WsClient(uri);
clientEndPoint.sendMessage("Hello 1 !"); clientEndPoint.sendMessage("Hello 1 !");
Thread.sleep(5000); Thread.sleep(5000);
clientEndPoint.sendMessage("Hello 2 !"); clientEndPoint.sendMessage("Hello 2 !");
......
log4j.rootLogger=debug, stdout, R
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=wsClient.log
log4j.appender.R.MaxFileSize=100KB
# Keep one backup file
log4j.appender.R.MaxBackupIndex=1
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
\ No newline at end of file
#!/bin/bash
openssl s_client -showcerts -servername localhost -connect localhost:8181 </dev/null | openssl x509 -outform DER > localhost.der
keytool -import -noprompt -trustcacerts -storepass storepass -alias localhost -keystore mycert-pub.jks -file localhost.der
<?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
message=Hello World Jakarta EE 9.1
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment