Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide compliance with both javax.servlet and jakarta.servlet #379

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,23 @@ The toolkit is hosted on github. You can download it from:
The toolkit is hosted at [Sonatype OSSRH (OSS Repository Hosting)](http://central.sonatype.org/pages/ossrh-guide.html) that is synced to the Central Repository.

Install it as a maven dependency:

To be compliant with JEE 8 (javax.servlet.*):
```xml
<dependency>
<groupId>com.onelogin</groupId>
<artifactId>java-saml</artifactId>
<version>2.9.0</version>
</dependency>
```

To be compliant with Jakarta EE 9+ (jakarta.servlet.*):
```xml
<dependency>
<groupId>com.onelogin</groupId>
<artifactId>java-saml</artifactId>
<version>2.9.0</version>
<qualifier>jakarta</qualifier>
</dependency>
```

Expand Down Expand Up @@ -164,7 +176,8 @@ also the [Java Cryptography Extension (JCE)](https://en.wikipedia.org/wiki/Java_

*toolkit:*
* com.onelogin:java-saml-core
* javax.servlet:servlet-api
* javax.servlet:servlet-api (default build `mvn ...`, or with javax profile `mvn -Pjavax ...`)
* jakarta.servlet:servlet-api (with javax profile `mvn -Pjakarta ...`)

*maven:*
* org.apache.maven.plugins:maven-jar-plugin
Expand Down Expand Up @@ -207,7 +220,7 @@ In the repo, at *src/main/java* you will find the source; at *src/main/resources


#### toolkit (com.onelogin:java-saml) ####
This folder contains a maven project with the Auth class to handle the low level classes of java-saml-core and the ServletUtils class to handle javax.servlet.http objects, used on the Auth class.
This folder contains a maven project with the Auth class to handle the low level classes of java-saml-core and the ServletUtils class to handle servlet objects (javax.servlet.http with javax profile (default) or jakarta.servlet.http with jakarta profile), used on the Auth class.
In the repo, at *src/main/java* you will find the source and at *src/test/java* the junit tests for the classes Auth and ServletUtils.

#### samples (com.onelogin:java-saml-tookit-samples) ####
Expand Down Expand Up @@ -490,9 +503,9 @@ Auth auth = new Auth(settings, request, response);
#### The HttpRequest
java-saml-core uses HttpRequest class, a framework-agnostic representation of an HTTP request.

java-saml depends on javax.servlet:servlet-api, and the classes Auth and ServletUtils use HttpServletRequest and HttpServletResponse objects.
java-saml depends on javax.servlet:servlet-api (default javax profile) or jakarta.servlet:servlet-api (jakarta profile), and the classes Auth and ServletUtils use HttpServletRequest and HttpServletResponse objects.

If you want to use anything different than javax.servlet.http, you will need to reimplement Auth and ServletUtils based on that new representation of the HTTP request/responses.
If you want to use anything different than javax.servlet.http or jakarta.servlet.http, you will need to reimplement Auth and ServletUtils based on that new representation of the HTTP request/responses.

#### Initiate SSO
In order to send an AuthNRequest to the IdP:
Expand Down
63 changes: 50 additions & 13 deletions samples/java-saml-tookit-jspsample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,55 @@
<packaging>war</packaging>
<name>OneLogin java-saml Toolkit Sample Webapp</name>

<dependencies>
<dependency>
<groupId>com.onelogin</groupId>
<artifactId>java-saml</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>javax</id>
<activation>
<activeByDefault>true</activeByDefault></activation>
<dependencies>
<dependency>
<groupId>com.onelogin</groupId>
<artifactId>java-saml</artifactId>
<version>${project.version}</version>
</dependency>

<!-- httprequest and httpresponse with profile javax -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>jakarta</id>
<dependencies>
<dependency>
<groupId>com.onelogin</groupId>
<artifactId>java-saml</artifactId>
<version>${project.version}</version>
<classifier>jakarta</classifier>
</dependency>

<!-- httprequest and httpresponse with profile jakarta -->
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>5.0.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<classifier>jakarta</classifier>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
94 changes: 86 additions & 8 deletions toolkit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,6 @@
<optional>true</optional>
</dependency>

<!-- httprequest and httpresponse -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>

<!-- date and time library for Java -->
<dependency>
<groupId>joda-time</groupId>
Expand All @@ -91,6 +83,8 @@
</dependencies>

<build>
<sourceDirectory>${src.dir}</sourceDirectory>
<testSourceDirectory>${src.test.dir}</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
Expand Down Expand Up @@ -121,6 +115,90 @@
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>javax</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>

<properties>
<src.dir>${basedir}/src/main/java</src.dir>
<src.test.dir>${basedir}/src/test/java</src.test.dir>
</properties>

<dependencies>
<!-- httprequest and httpresponse with profile javax -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>jakarta</id>

<properties>
<src.dir>${project.build.directory}/generated-sources/jakarta</src.dir>
<src.test.dir>${project.build.directory}/generated-test-sources/jakarta</src.test.dir>
</properties>

<dependencies>

<!-- httprequest and httpresponse with profile jakarta -->
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>5.0.0</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>jakarta-converter</id>
<phase>generate-sources</phase>
<configuration>
<tasks>
<mkdir dir="${project.build.directory}/generated-sources/jakarta"/>
<mkdir dir="${project.build.directory}/generated-test-sources/jakarta"/>

<copy todir="${project.build.directory}/generated-sources/jakarta">
<fileset dir="${basedir}/src/main/java"/>
</copy>
<copy todir="${project.build.directory}/generated-test-sources/jakarta">
<fileset dir="${basedir}/src/test/java"/>
</copy>

<replace dir="${project.build.directory}/generated-sources/jakarta" token="javax.servlet" value="jakarta.servlet"/>
<replace dir="${project.build.directory}/generated-test-sources/jakarta" token="javax.servlet" value="jakarta.servlet"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<classifier>jakarta</classifier>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<!--
<properties>
<jacoco.agent.argLine />
Expand Down