This repository is a maintained fork of the original OpenID4Java library, maintained by Amarula Solutions.
Note: OpenID Authentication 2.0 is a deprecated specification. This fork maintains the library for existing deployments; new projects should use OpenID Connect.
This fork is not affiliated with or endorsed by the OpenID Foundation or the original maintainers.
This library allows you to OpenID-enable your Java webapp.
The following specifications are supported:
- OpenID Authentication 2.0
- OpenID Authentication 1.1 (in compatibility mode)
- OpenID Attribute Exchange 1.0
- OpenID Simple Registration 1.0 and 1.1, draft 1
- OpenID Provider Authentication Policy Extension 1.0
<dependency>
<groupId>com.amarulasolutions</groupId>
<artifactId>openid4java</artifactId>
<version>2.0.0</version>
</dependency>
Artifacts are published to GitHub Packages. See INSTALL for the repository and authentication setup.
For Jenkins plugins and other environments that need a single JAR with relocated third-party dependencies:
<dependency>
<groupId>com.amarulasolutions</groupId>
<artifactId>openid4java-shaded</artifactId>
<version>2.0.0</version>
</dependency>
Guice, Guava, HttpClient 5, jsoup and the injection APIs are relocated
under org.openid4java.shaded.*. commons-codec remains an external
dependency and slf4j-api is provided by the runtime (Jenkins provides
it). The shaded artifact is published to GitHub Packages; see
INSTALL.
OpenID starts with the concept that anyone can identify themselves on the Internet the same way websites do - with a URI. Since URIs are at the very core of Web architecture, they provide a solid foundation for user-centric identity.
The first piece of the OpenID framework is authentication -- how you prove ownership of a URI. Today, websites require usernames and passwords to login, which means that many people use the same password everywhere. With OpenID Authentication, your username is your URI, and your password (or other credentials) stays safely stored on your OpenID Provider (which you can run yourself, or use a third-party identity provider).
For more information about the OpenID protocol please refer to the specification at: http://openid.net/specs.bml
To OpenID-enable a website - a Relying Party (RP) in OpenID terms, or Consumer at code-level, you need to do the following:
-
Install the libraries
-
Instead (or as an alternative to) prompting the user for their username/password, obtain their OpenID (URL) identifier
-
Create an authentication request for this identifier, and redirect the user to their OpenID Provider (with this request)
-
Receive the OpenID Provider's authentication response at your webapp's ReturnURL, and verify it
Have a look at the usage pattern in src/overview.html for a code-level walk-through of the above, and at test/src/org/openid4java/consumer/SampleConsumer.java for the full code.
The bulk of the action amounts to about a dozen lines of code.
A working example of a simple (6 JSP files) OpenID Provider and Relying Party can be found under samples/simple-openid/. Start it with:
mvn jetty:run
And access it at http://localhost:8080/simple-openid/
For more details see the README.txt file included in that folder.
The library requires JDK 17 or newer and Maven 3.9 or newer:
mvn clean verify
The build is tested on JDK 17, 21 and 25.
CHANGELOG Version highlight changes.
INSTALL Installation and usage instructions.
LICENSE OpenID4Java Library license (Apache 2.0).
MAINTAINERS List of code and documentation maintainers.
README.md This file!
TODO Tasks remaining and/or ongoing.
samples/ Sample implementation projects. See samples/README for details.
src/ Source code.
test/ Test cases source code and test data.
pom.xml Maven POM.
