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

Migrate the spengo library to Jakarta EE 10. #1

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
41 changes: 28 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
#Silverpeas-Spnego

###This project is a fork of the spnego.sourceforge.net project
* Fork of [https://github.com/joval/SPNEGO](https://github.com/joval/SPNEGO) which corresponds to stable spnego-r7.jar (2010-OCT-15)
* Install Guide, Reference and API Documentation can be found at: [http://spnego.sourceforge.net](http://spnego.sourceforge.net)
* Before getting started, the pre-flight doc is a must read [http://spnego.sourceforge.net/pre_flight.html](http://spnego.sourceforge.net/pre_flight.html)
* Need JDK 1.6 or higher and servlet-api.jar required to compile source

In order to perform user authentication in our Silverpeas product by SSO mechanism using SPNEGO and Kerberos, we were interested in the Sourceforge Spnego project.
Despite several successful integration tests, we identified some additional needs in order to manage more precisely in a JEE application, such as Silverpeas, the different possible errors that can happen during the SSO process for a user.
We then made ​​the necessary developments and have proposed them as a contribution to the project [https://github.com/joval/SPNEGO] (https://github.com/joval/SPNEGO).
As it has not been integrated, and after several months without any response, we decided to make our own fork of the project that includes our needs.
* Fork of [https://github.com/joval/SPNEGO](https://github.com/joval/SPNEGO) which corresponds to
stable spnego-r7.jar (2010-OCT-15)
* Install Guide, Reference and API Documentation can be found
at: [http://spnego.sourceforge.net](http://spnego.sourceforge.net)
* Before getting started, the pre-flight doc is a must
read [http://spnego.sourceforge.net/pre_flight.html](http://spnego.sourceforge.net/pre_flight.html)
* Require JDK 11 or higher and Jakarta EE 10 servlet && SOAP APIs to compile source

###The contributions of Silverpeas's version :
* adding apache maven building capabilities
* adding typed runtime exception that can be used to handle SSO errors in the JEE application (not activated by default, to activate it set the added filter parameter "spnego.throw.typedRuntimeException" to true)
* upgrading the SPNEGO HTTP Filter so that it can be used in several URL matching (filter mapping)
* modifying the extraction of remote user name (removing from the Kerberos Principal only the part of the Kerberos REALM)
In order to perform user authentication in our Silverpeas product by SSO using the SPNEGO
mechanism within the Kerberos protocol, we were interested in the Sourceforge Spnego project.
Despite several successful integration tests, we identified some additional requirements in
order to manage more precisely, in a Jakarta EE application such as Silverpeas, the different
possible errors that can happen during the SSO negotiation process for a user.

We then made the necessary developments and have proposed them as a contribution to the
project [https://github.com/joval/SPNEGO] (https://github.com/joval/SPNEGO).
As it has not been integrated, and after several months without any responses or feedbacks, we
decided to make our own fork of the project that includes our needs.

###The contributions of Silverpeas's version:

* Adding apache maven building capabilities
* Migrating to Jakarta EE
* Adding typed runtime exceptions that can be used to handle SSO errors in the Jakarta EE
application (not enabled by default, this feature can be enabled by setting the filter
parameter `spnego.throw.typedRuntimeException` to `true`)
* Updating the SPNEGO HTTP Filter so that it can be used in several URL matchers (filter mapping)
* Modifying the extraction of the remote user name (removing from the Kerberos Principal only the
part of the Kerberos REALM)
41 changes: 33 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,29 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<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">
<modelVersion>4.0.0</modelVersion>

<groupId>org.silverpeas.spnego</groupId>
<artifactId>silverpeas-spnego</artifactId>
<version>1.1-SNAPSHOT</version>
<version>2.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Silverpeas SPNEGO</name>


<properties>
<maven.compiler.release>11</maven.compiler.release>
</properties>

<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.xml.soap</groupId>
<artifactId>jakarta.xml.soap-api</artifactId>
<version>3.0.0</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<release>${maven.compiler.release}</release>
<encoding>UTF-8</encoding>
<forceJavacCompilerUse>true</forceJavacCompilerUse>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.4.1</version>
<version>3.0.1</version>
<configuration>
<localCheckout>true</localCheckout>
<pushChanges>false</pushChanges>
Expand All @@ -35,6 +58,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>attach-sources</id>
Expand Down Expand Up @@ -68,7 +92,8 @@

<scm>
<connection>scm:git:[email protected]:Silverpeas/Silverpeas-Spnego.git</connection>
<developerConnection>scm:git:[email protected]:Silverpeas/Silverpeas-Spnego.git</developerConnection>
<developerConnection>scm:git:[email protected]:Silverpeas/Silverpeas-Spnego.git
</developerConnection>
<url>https://gitub.com/Silverpeas/Silverpeas-Spnego.git</url>
<tag>HEAD</tag>
</scm>
Expand Down
105 changes: 0 additions & 105 deletions src/main/java/org/silverpeas/spnego/Base64.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
/*
* Copyright (C) 2014-2023 Silverpeas
* Copyright (C) 2009 "Darwin V. Felix" <[email protected]>
*
* This library is free software; you can redistribute it and/or
Expand All @@ -20,7 +21,7 @@

import org.ietf.jgss.GSSCredential;

import javax.servlet.ServletRequest;
import jakarta.servlet.ServletRequest;

/**
* The default installation of Internet Explorer and Active Directory
Expand Down Expand Up @@ -82,5 +83,6 @@ public interface DelegateServletRequest extends ServletRequest {
* </p>
* @return delegated credential or null
*/
@SuppressWarnings("unused")
GSSCredential getDelegatedCredential();
}
14 changes: 9 additions & 5 deletions src/main/java/org/silverpeas/spnego/SpnegoAuthScheme.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
/*
* Copyright (C) 2014-2023 Silverpeas
* Copyright (C) 2009 "Darwin V. Felix" <[email protected]>
*
* This library is free software; you can redistribute it and/or
Expand All @@ -20,6 +21,8 @@

import org.silverpeas.spnego.SpnegoHttpFilter.Constants;

import java.util.Base64;

/**
* Example schemes are "Negotiate" and "Basic".
* <p/>
Expand All @@ -33,7 +36,7 @@ final class SpnegoAuthScheme {
/**
* Zero length byte array.
*/
private static final transient byte[] EMPTY_BYTE_ARRAY = new byte[0];
private static final byte[] EMPTY_BYTE_ARRAY = new byte[0];

/**
* HTTP (Request) "Authorization" Header scheme.
Expand Down Expand Up @@ -61,8 +64,9 @@ final class SpnegoAuthScheme {
private final transient boolean ntlm;

/**
* @param authScheme
* @param authToken
* Constructs a Spnego authentication scheme.
* @param authScheme the authentication scheme used in the authentication parameter.
* @param authToken the authentication token carried with the authentication parameter.
*/
public SpnegoAuthScheme(final String authScheme, final String authToken) {
this.scheme = authScheme;
Expand Down Expand Up @@ -115,6 +119,6 @@ public String getScheme() {
* @return copy of token
*/
public byte[] getToken() {
return (null == this.token) ? EMPTY_BYTE_ARRAY : Base64.decode(this.token);
return (null == this.token) ? EMPTY_BYTE_ARRAY : Base64.getDecoder().decode(this.token);
}
}
Loading