diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..eaef2aa3 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,22 @@ +version: 2 +updates: + - package-ecosystem: maven + directory: / + schedule: + interval: weekly + open-pull-requests-limit: 10 + - package-ecosystem: maven + directory: /samples + schedule: + interval: weekly + open-pull-requests-limit: 5 + - package-ecosystem: maven + directory: /samples/consumer-servlet + schedule: + interval: weekly + open-pull-requests-limit: 5 + - package-ecosystem: maven + directory: /samples/simple-openid + schedule: + interval: weekly + open-pull-requests-limit: 5 diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 00000000..97489507 --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,28 @@ +name: Java CI + +on: + push: + branches: [ master, java25-modernization ] + pull_request: + workflow_dispatch: + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + java: [ '17', '21', '25' ] + steps: + - uses: actions/checkout@v4 + - name: Set up JDK ${{ matrix.java }} + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: ${{ matrix.java }} + cache: maven + - name: Build and test + run: mvn -B verify diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..e4e65bc6 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,29 @@ +name: Publish to GitHub Packages + +on: + push: + tags: [ 'v*' ] + workflow_dispatch: + +permissions: + contents: read + packages: write + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '17' + cache: maven + server-id: github + server-username: GITHUB_ACTOR + server-password: GITHUB_TOKEN + - name: Publish + run: mvn -B deploy + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..d0c923ba --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +target/ +build/ +*.versionsBackup +.classpath +.project +.settings/ diff --git a/CHANGELOG b/CHANGELOG index 22d7313a..ecda2fbc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,8 +5,56 @@ This document highlights the major changes in the OpenID4Java library. Please see the TODO file for outstanding items. - For the detailed logs please see the commit comments at: - - http://code.google.com/p/openid4java + For the detailed logs please see the commit history at: + - https://github.com/amarula/openid4java/commits/master + +2.0.0: + +This is the Amarula Solutions fork, published as +com.amarulasolutions:openid4java from github.com/amarula/openid4java. + +Notable changes: + +Java 17 or newer is required. The build runs on JDK 25 and produces +Java 17 bytecode. + +Removed the OpenID Information Cards (Higgins STS) support. + +Removed the local XRI resolver, which depended on the abandoned OpenXRI +libraries. The HTTP-based XriDotNetProxyResolver remains available. + +Removed the Ant build and the bundled lib/ JARs. Maven is the supported +build. + +Moved the SampleConsumer and SampleServer demo classes out of the main +artifact and into the test sources. The main JAR no longer depends on +the servlet API. + +Removed the end-of-life log4j 1.x dependency and the unused xmlsec +dependency. + +Replaced the end-of-life Apache HttpClient 4.5 with HttpClient 5.6. +The HTTP types exposed by HttpFetcherFactory, HttpCache, +HttpClientFactory, HttpResponse and ProxyProperties now use +HttpClient 5. + +Replaced the end-of-life Ehcache 2 with Ehcache 3.10. +EhcacheNonceVerifier.setCache now accepts org.ehcache.Cache. + +Replaced the unmaintained NekoHTML and Xerces HTML parsing stack +with jsoup. The discovery.html.parser and discovery.yadis.html.parser +defaults now point to JsoupHtmlParser and JsoupYadisHtmlParser. +The CyberNekoDOM* parsers and OpenID4JavaDOMParser were removed; +custom parser configurations must use the new classes. + +Upgraded the test-only JDOM dependency from 1.0 to JDOM 2. + +Replaced deprecated reflective instantiation and boxed constructors, +hardened default property loading, and moved the HTTP connection +setup to the current HttpClient 5 APIs. + +Updated the Maven plugins and added Automatic-Module-Name to the JAR +manifest. 20150208: @@ -142,12 +190,11 @@ Under the hood: Copyright 2006-2008 Sxip Identity Corporation Project home page and package distribution: - => http://code.google.com/p/openid4java - => http://code.google.com/p/openid4java/downloads/ + => https://github.com/amarula/openid4java + => https://github.com/amarula/openid4java/releases -For support, please visit the wiki and join the Google Groups! +For support, please join the Google Group: => http://groups.google.com/group/openid4java/ - => http://code.google.com/p/openid4java/w/ OpenID => http://openid.net/ diff --git a/INSTALL b/INSTALL index 1ca3534e..afb7d32f 100644 --- a/INSTALL +++ b/INSTALL @@ -6,350 +6,97 @@ INSTALLATION AND USAGE INSTRUCTIONS Introduction: -This document describes how to install and use the OpenID4Java library. -For general information about the package please see the README document. +This document describes how to build and use the OpenID4Java library. +For general information about the package please see the README.md file. Requirements: - - Java 1.5 JVM (or higher) + - JDK 17 or newer. The build is tested on JDK 17, 21 and 25. + - Maven 3.9 or newer. - - Ant (optional: needed for building the package and running the tests) - - Maven (optional: alternative to Ant) - - JUnit (optional: needed for running the tests) +Building: -Installation: + Run the full build and test suite: - 1. Installing the package + mvn clean verify - => To make the OpenID4Java library available to a (web) application - the following JAR files need to be copied to the application's - classpath: - - openid4java-*.jar - - library dependencies (see below) + This produces: - => Library dependencies: + target/openid4java-.jar + target/openid4java--sources.jar + target/openid4java--javadoc.jar - lib/*jar : Required. Core OpenID4Java library dependencies. - lib/optional/ : Optional. Libraries supporting alternative deployments. - - spring-*.jar : JdbcServerAssociationStore - - ehcache-1.2.4.jar : EhcacheNonceVerifier - - log4j-1.2.8.jar + To install the artifacts into the local Maven repository: - lib/extra/ : Extra/development libraries, not needed for deployments. - (JUnit tests, Jetty servlet container, SVN/Ant utilities) + mvn install - lib/xri/ : Optional. Local OpenXRI resolver dependencies. - Included only in the "openid4java-xri" and - "openid4java-full" packages. (A dependency-less - proxy XRI resolver is included in the standard package) - lib/infocard/ : Optional. OpenID-Infocards/Higgins STS dependencies. - Included only in the "openid4java-infocard" and - "openid4java-full" packages. +Using the library: + Add the dependency to your project: - => Relying Party Discovery: + + com.amarulasolutions + openid4java + 2.0.0 + - Relying Parties must publish their endpoints in order for the OpenID - Providers to be able to verify authentication requests and prevent - proxy attacks. The Yadis protocol and realm verification mechanisms - are used for this purpose. See the section "Discovering OpenID - Relying Parties" of the OpenID Authentication specification for - details. + The Amarula Solutions fork is published to GitHub Packages. Add the + repository to your project: - Example: + + + github + https://maven.pkg.github.com/amarula/openid4java + + - - http://specs.openid.net/auth/2.0/return_to - http://consumer.example.com/return - + GitHub Packages requires authentication. Add a server entry to + ~/.m2/settings.xml with your GitHub username and a personal access + token that has the read:packages scope: - The RP should publish the above element at their realm URL. - All OpenID Authentication request sent by this RP should contain - openid.return_to values matching the http://consumer.example.com/return - realm. + + + github + YOUR_GITHUB_USERNAME + YOUR_PAT + + - OpenID Providers: + The core dependencies are resolved transitively by Maven. - Validation of openid.return_to values against Relying Party Discovery - endpoints is enabled by default. This feature can be disabled with - ServerManager.setEnforceRpId(false). + The Spring JDBC and Ehcache integrations are optional. Add spring-jdbc + or ehcache explicitly when using JdbcConsumerAssociationStore, + JdbcServerAssociationStore, JdbcNonceVerifier or EhcacheNonceVerifier. + Logging uses Apache Commons Logging. - => Java 1.4 compatibility - The official OpenID4Java distribution is compiled with a Java 1.5 - compiler. The source, however, can be compiled with Java 1.4. - See the "Building the package" section below. +Usage examples: - 2. OPTIONAL: Configuring logging + See README.md and the Javadoc overview for the Relying Party and + OpenID Provider usage patterns. - OpenID4Java uses Apache's commons-logging API. This allows the - application developers to choose (or change) their preferred logging - implementations, without the need to modify or recompile the library. + A complete Relying Party implementation is in: + test/src/org/openid4java/consumer/SampleConsumer.java - http://commons.apache.org/logging/guide.html#Configuration + A complete Provider implementation is in: + test/src/org/openid4java/server/SampleServer.java - => Log4J configuration - Log4J v1.2 is used as the logging implementation for the sample - projects included with the OpenID4Java library. Commons-logging - uses Log4J as the primary default and automatically detects if - Log4J is available when discoverying available logging - implementations. +Samples: - A typical way to configure Log4J is using a log4j.properties file - in the classpath which should contain the following (adjust log - levels as desired): - - log4j.rootLogger=INFO, A1 - log4j.logger.org.openid4java=DEBUG, A1 - log4j.appender.A1=org.apache.log4j.ConsoleAppender - log4j.appender.A1.layout=org.apache.log4j.PatternLayout - - http://logging.apache.org/log4j/1.2/ - - - 3. OPTIONAL: Enabling 256bit cryptographic support - - => Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy - - Download and install (under JAVA_HOME/jre/lib/security) the JCE - unlimited strength policy files, usually distributed along with JVMs - (but not included in standard packages). SUN's Java JCE policy files - can be found as separate downloads at the following URLs: - - http://java.sun.com/javase/downloads/index_jdk5.jsp - - => Third party libraries - - Third party libraries that provide unlimited strength JCE - implementations can also be used. One such library is provided by - Bouncy Castle: - - http://www.bouncycastle.org/java.html - - - 4. OPTIONAL: Building the package - - To build the package from source Ant is also needed. The following - build targets are provided: - - - Packages compiled class files into a JAR archive - - ant jar - - - Builds official distributable archive - - ant dist - - - 5. OPTIONAL: Testing the package - - JUnit test classes and data files are found under the test/ folder. - JUnit and Ant are needed for running the tests: - - A servlet is provided for generating custom OpenID URIs and the HTTP - responses needed during discovery. The servlet is run inside the - lightweight Jetty servlet container. - - - To run the tests execute the following Ant target: - - ant test - - Alternatively, if Ant is not used, the following need to be configured: - - - The port on which the servlet will listen - SERVLET_PORT system property - - - The path where the test data is available to the servlet - TEST_DATA system property - - The test data files need to be updated with the actual servlet port, - which is part of the YadisURLs - - -API Usage and Examples: - - Following is the general usage pattern of the library. - - => NOTE: For extended usage see the JavaDoc API documentation - under apidoc/ - - - The main interaction points between a web application acting as a - Relying Party (Consumer) and the library are the Discovery and - ConsumerManager classes. - See also the SampleConsumer.java implementation in the consumer package. - - // instantiate a ConsumerManager object - public static manager = new ConsumerManager(); - - // --- placing the authentication request --- - - // determine a return_to URL where your application will receive - // the authentication responses from the OpenID provider - String returnToUrl = "http://example.com/openid"; - - // perform discovery on the user-supplied identifier - List discoveries = manager.discover(userSuppliedString); - - // attempt to associate with an OpenID provider - // and retrieve one service endpoint for authentication - DiscoveryInformation discovered = manager.associate(discoveries); - - // store the discovery information in the user's session - session.setAttribute("openid-disco", discovered); - - // Attribute Exchange example: fetching the 'email' attribute - FetchRequest fetch = new FetchRequest(); - fetch.addAttribute("email", // attribute alias - "http://schema.openid.net/contact/email", // type URI - true); // required - - // obtain a AuthRequest message to be sent to the OpenID provider - AuthRequest authReq = manager.authenticate(discovered, returnToUrl); - - // attach the extension to the authentication request - authReq.addExtensionParams(fetch); - - if (! discovered.isVersion2() ) - { - // Option 1: GET HTTP-redirect to the OpenID Provider endpoint - // The only method supported in OpenID 1.x - // redirect-URL usually limited to 255 bytes - return authReq.getRedirectUrl(); - } - else - { - // Option 2: HTML FORM Redirection - // Allows payloads > 255 bytes - - //
- // see samples/formredirection.jsp for a JSP example - authReq.getOPEndpoint(); - - // build a HTML FORM with the message parameters - authReq.getParameterMap(); - } - - // --- processing the authentication response - - // extract the parameters from the authentication response - // (which comes in as a HTTP request from the OpenID provider) - ParameterList response = new ParameterList(httpReq.getParameterMap()); - - // retrieve the previously stored discovery information - DiscoveryInformation discovered - = (DiscoveryInformation) session.getAttribute("openid-disco"); - - // verify the response; ConsumerManager needs to be the same - // (static) instance used to place the authentication request - VerificationResult verification = manager.verify( - httpReq.getRequestURL().toString(), - response, discovered); - - // examine the verification result and extract the verified identifier - Identifier verified = verification.getVerifiedId(); - if (verified != null) - { - // Attribute Exchange: retrieving the fetched "email" attribute - AuthSuccess authSuccess = AuthSuccess.createAuthSuccess(response); - MessageExtension ext = - authSuccess.getExtension(AxMessage.OPENID_NS_AX); - if (ext != null) - { - FetchResponse fetchResp = - new FetchResponse(ext.getParameters()); - String email = fetchResp.getParameter("email"); - } - - return verified; // success - } - - The main interaction point between a web application acting as a - OpenID Provider (Server) and the library is the ServerManager class. - See also the SampleServer.java implementation in the server package. - - // instantiate a ServerManager object - public static ServerManager manager = new ServerManager(); - - // configure the OpenID Provider's endpoint URL - static - { - manager.setOPEndpointUrl("Http://my.openidprovider.com/server"); - } - - // extract the parameters from the request - ParameterList request = new ParameterList(httpReq.getParameterMap()); - - String mode = request.hasParameter("openid.mode") ? - request.getParameterValue("openid.mode") : null; - - Message response; - String responseText; - - if ("associate".equals(mode)) - { - // --- process an association request --- - response = manager.associationResponse(request); - responseText = response.keyValueFormEncoding(); - } - else if ("checkid_setup".equals(mode) - || "checkid_immediate".equals(mode)) - { - // interact with the user and obtain data needed to continue - List userData = userInteraction(request); - - String userSelectedId = (String) userData.get(0); - String userSelectedClaimedId = (String) userData.get(1); - Boolean authenticatedAndApproved = (Boolean) userData.get(2); - - // --- process an authentication request --- - response = manager.authResponse(request, - userSelectedId, - userSelectedClaimedId, - authenticatedAndApproved.booleanValue()); - - // caller will need to decide which of the following to use: - // - GET HTTP-redirect to the return_to URL - // - HTML FORM Redirection - responseText = response.wwwFormEncoding(); - } - else if ("check_authentication".equals(mode)) - { - // --- processing a verification request --- - response = manager.verify(request); - responseText = response.keyValueFormEncoding(); - } - else - { - // --- error response --- - response = DirectError.createDirectError("Unknown request"); - responseText = response.keyValueFormEncoding(); - } - - // return the result to the user - return responseText; + See samples/README for the available sample projects. Contacts: - If you want freely available support, to participate in active - development, and to be informed about new code releases, bug fixes, - security fixes, general news and information about the OpenID4Java - Library, subscribe to the Google Group at: + For support and general discussion, subscribe to the Google Group: http://groups.google.com/group/openid4java - If you find a bug in the OpenID4Java Library please submit a defect - in the tracking database after verifying that it hasn't already been - submitted. - - http://code.google.com/p/openid4java/issues/list - Thanks for running OpenID! @@ -357,14 +104,6 @@ Thanks for running OpenID! ======================================================================== Copyright 2006-2008 Sxip Identity Corporation -Project home page and package distribution: - => http://code.google.com/p/openid4java - => http://code.google.com/p/openid4java/downloads/ - -For support, please visit the wiki and join the Google Groups! - => http://groups.google.com/group/openid4java/ - => http://code.google.com/p/openid4java/w/ - OpenID => http://openid.net/ diff --git a/MAINTAINERS b/MAINTAINERS index 5276a1dc..c7243c2d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -28,16 +28,22 @@ Entire Library, including documentation: M: Justen Stepka S: fixes/patches +------------------------------------------------------------------------ + +Amarula Solutions fork: + + M: Michael Trimarchi + S: maintained + ======================================================================== Copyright 2006-2008 Sxip Identity Corporation Project home page and package distribution: - => http://code.google.com/p/openid4java - => http://code.google.com/p/openid4java/downloads/ + => https://github.com/amarula/openid4java + => https://github.com/amarula/openid4java/releases -For support, please visit the wiki and join the Google Groups! +For support, please join the Google Group: => http://groups.google.com/group/openid4java/ - => http://code.google.com/p/openid4java/w/ OpenID => http://openid.net/ diff --git a/NOTICE b/NOTICE new file mode 100644 index 00000000..42cc3145 --- /dev/null +++ b/NOTICE @@ -0,0 +1,9 @@ +OpenID4Java +Copyright 2006-2008 Sxip Identity Corporation +Copyright 2026 Amarula Solutions + +This product includes software developed by the OpenID4Java project. + +This is an independent fork maintained by Amarula Solutions. It is not +affiliated with or endorsed by the OpenID Foundation or the original +maintainers. diff --git a/README.md b/README.md index 424cc0fb..6f451cc3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,14 @@ ![OpenID4Java](openid4java.png) -**[中文(简体)](http://code.google.com/p/openid4java/wiki/ProjectHome_zh_CN)** +This repository is a maintained fork of the original OpenID4Java library, +maintained by [Amarula Solutions](https://github.com/amarula). +> **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. # What is this package? # @@ -13,7 +20,19 @@ The following specifications are supported: * [OpenID Attribute Exchange 1.0](http://openid.net/specs/openid-attribute-exchange-1_0.html) * [OpenID Simple Registration 1.0](http://openid.net/specs/openid-simple-registration-extension-1_0.html) and [1.1, draft 1](http://openid.net/specs/openid-simple-registration-extension-1_1-01.html) * [OpenID Provider Authentication Policy Extension 1.0](http://openid.net/specs/openid-provider-authentication-policy-extension-1_0.html) - * [OpenID Information Cards 1.0, draft 1](https://openidcards.sxip.com/spec/openid-infocards.html) + +# Maven coordinates # + +``` + + com.amarulasolutions + openid4java + 2.0.0 + +``` + +Artifacts are published to GitHub Packages. See [INSTALL](INSTALL) for +the repository and authentication setup. # What is OpenID? # @@ -36,7 +55,7 @@ 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](Installation.md) the libraries + * [Install](INSTALL) the libraries * Instead (or as an alternative to) prompting the user for their username/password, obtain their OpenID (URL) identifier @@ -44,7 +63,7 @@ To OpenID-enable a website - a Relying Party (RP) in OpenID terms, or Consumer a * Receive the OpenID Provider's authentication response at your webapp's ReturnURL, and verify it -Have a look at the QuickStart page for a code-level walk-through the above, and at the SampleConsumer class for the full code. +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. @@ -59,19 +78,27 @@ And access it at http://localhost:8080/simple-openid/ For more details see the README.txt file included in that folder. -# See also # +# Building # + +The library requires JDK 17 or newer and Maven 3.9 or newer: + +``` +mvn clean verify +``` -[Requirements](Requirements.md) +The build is tested on JDK 17, 21 and 25. -[Installation](Installation.md) +# See also # -[Documentation](Documentation.md) +[Requirements](INSTALL) -BuildFromSource +[Installation](INSTALL) -SampleConsumer +[Documentation](README.md) -SampleServer +[SampleConsumer](test/src/org/openid4java/consumer/SampleConsumer.java) + +[SampleServer](test/src/org/openid4java/server/SampleServer.java) # Package contents # @@ -93,12 +120,6 @@ This file! [TODO](TODO) Tasks remaining and/or ongoing. -[VERSION](VERSION) -The released version of this package. - -[apidoc/](apidoc) -JavaDoc API documentation. - [samples/](samples) Sample implementation projects. See samples/README for details. @@ -108,14 +129,5 @@ Source code. [test/](test) Test cases source code and test data. -[lib/](lib) -Library dependencies. - -[build.xml](build.xml) -Ant build file; see INSTALL / Building the package. - -[project.properties](project.properties) -Build properties file. - [pom.xml](pom.xml) Maven POM. diff --git a/TODO b/TODO index d41e7490..40fa04ea 100644 --- a/TODO +++ b/TODO @@ -43,13 +43,12 @@ Copyright 2006-2008 Sxip Identity Corporation Package distribution: - => http://code.google.com/p/openid4java/downloads/list - => http://code.google.com/p/openid4java/wiki/MavenHowTo + => https://github.com/amarula/openid4java/releases Source code and defect management: - => http://code.google.com/p/openid4java + => https://github.com/amarula/openid4java -For support, please join the Google Groups! +For support, please join the Google Group: => http://groups.google.com/group/openid4java OpenID diff --git a/build.xml b/build.xml deleted file mode 100644 index dba5c1e3..00000000 --- a/build.xml +++ /dev/null @@ -1,280 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Version: ${version} - - - - - - -
- - - - - -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OpenID4Java Library - - Copyright 2006-2008 Sxip Identity Corporation]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - set version to ${component.ver} - - - - - - -
diff --git a/lib/commons-codec-1.3.jar b/lib/commons-codec-1.3.jar deleted file mode 100644 index 957b6752..00000000 Binary files a/lib/commons-codec-1.3.jar and /dev/null differ diff --git a/lib/commons-logging-1.03.jar b/lib/commons-logging-1.03.jar deleted file mode 100644 index b99c9375..00000000 Binary files a/lib/commons-logging-1.03.jar and /dev/null differ diff --git a/lib/extra/jcip-annotations.jar b/lib/extra/jcip-annotations.jar deleted file mode 100644 index 06e9066b..00000000 Binary files a/lib/extra/jcip-annotations.jar and /dev/null differ diff --git a/lib/extra/jdom-1.0.jar b/lib/extra/jdom-1.0.jar deleted file mode 100644 index 288e64cb..00000000 Binary files a/lib/extra/jdom-1.0.jar and /dev/null differ diff --git a/lib/extra/maven-ant-tasks-2.1.3.jar b/lib/extra/maven-ant-tasks-2.1.3.jar deleted file mode 100644 index bec446ff..00000000 Binary files a/lib/extra/maven-ant-tasks-2.1.3.jar and /dev/null differ diff --git a/lib/extra/servlet-api-2.4.jar b/lib/extra/servlet-api-2.4.jar deleted file mode 100644 index 93186f6a..00000000 Binary files a/lib/extra/servlet-api-2.4.jar and /dev/null differ diff --git a/lib/extra/svnClientAdapter-1.0.0.jar b/lib/extra/svnClientAdapter-1.0.0.jar deleted file mode 100644 index a6ce6dff..00000000 Binary files a/lib/extra/svnClientAdapter-1.0.0.jar and /dev/null differ diff --git a/lib/extra/svnant-1.0.0.jar b/lib/extra/svnant-1.0.0.jar deleted file mode 100644 index ef9563a7..00000000 Binary files a/lib/extra/svnant-1.0.0.jar and /dev/null differ diff --git a/lib/extra/svnjavahl-1.0.0.jar b/lib/extra/svnjavahl-1.0.0.jar deleted file mode 100644 index dd23d43d..00000000 Binary files a/lib/extra/svnjavahl-1.0.0.jar and /dev/null differ diff --git a/lib/guice-2.0.jar b/lib/guice-2.0.jar deleted file mode 100644 index ef058df5..00000000 Binary files a/lib/guice-2.0.jar and /dev/null differ diff --git a/lib/httpclient-4.2.2.jar b/lib/httpclient-4.2.2.jar deleted file mode 100644 index 5f768c46..00000000 Binary files a/lib/httpclient-4.2.2.jar and /dev/null differ diff --git a/lib/httpcore-4.2.2.jar b/lib/httpcore-4.2.2.jar deleted file mode 100644 index a64cd2f5..00000000 Binary files a/lib/httpcore-4.2.2.jar and /dev/null differ diff --git a/lib/infocard/axiom-api-1.2.2.jar b/lib/infocard/axiom-api-1.2.2.jar deleted file mode 100644 index f63efc8b..00000000 Binary files a/lib/infocard/axiom-api-1.2.2.jar and /dev/null differ diff --git a/lib/infocard/higgins-configuration-api.jar b/lib/infocard/higgins-configuration-api.jar deleted file mode 100644 index adb3c200..00000000 Binary files a/lib/infocard/higgins-configuration-api.jar and /dev/null differ diff --git a/lib/infocard/higgins-sts-api.jar b/lib/infocard/higgins-sts-api.jar deleted file mode 100644 index 4129517b..00000000 Binary files a/lib/infocard/higgins-sts-api.jar and /dev/null differ diff --git a/lib/infocard/higgins-sts-common.jar b/lib/infocard/higgins-sts-common.jar deleted file mode 100644 index 419460d3..00000000 Binary files a/lib/infocard/higgins-sts-common.jar and /dev/null differ diff --git a/lib/infocard/higgins-sts-server-token-handler.jar b/lib/infocard/higgins-sts-server-token-handler.jar deleted file mode 100644 index 46165e7d..00000000 Binary files a/lib/infocard/higgins-sts-server-token-handler.jar and /dev/null differ diff --git a/lib/infocard/higgins-sts-spi.jar b/lib/infocard/higgins-sts-spi.jar deleted file mode 100644 index 6ed5950e..00000000 Binary files a/lib/infocard/higgins-sts-spi.jar and /dev/null differ diff --git a/lib/infocard/stax-api-1.0.1.jar b/lib/infocard/stax-api-1.0.1.jar deleted file mode 100644 index d9a16651..00000000 Binary files a/lib/infocard/stax-api-1.0.1.jar and /dev/null differ diff --git a/lib/nekohtml-1.9.14.jar b/lib/nekohtml-1.9.14.jar deleted file mode 100644 index ba65542c..00000000 Binary files a/lib/nekohtml-1.9.14.jar and /dev/null differ diff --git a/lib/optional/ehcache-1.2.4.jar b/lib/optional/ehcache-1.2.4.jar deleted file mode 100644 index a149f432..00000000 Binary files a/lib/optional/ehcache-1.2.4.jar and /dev/null differ diff --git a/lib/optional/log4j-1.2.8.jar b/lib/optional/log4j-1.2.8.jar deleted file mode 100644 index 493a3ccc..00000000 Binary files a/lib/optional/log4j-1.2.8.jar and /dev/null differ diff --git a/lib/optional/spring-2.0-beans.jar b/lib/optional/spring-2.0-beans.jar deleted file mode 100644 index c82f5e61..00000000 Binary files a/lib/optional/spring-2.0-beans.jar and /dev/null differ diff --git a/lib/optional/spring-2.0-core.jar b/lib/optional/spring-2.0-core.jar deleted file mode 100644 index 1e939cc4..00000000 Binary files a/lib/optional/spring-2.0-core.jar and /dev/null differ diff --git a/lib/optional/spring-2.0-dao.jar b/lib/optional/spring-2.0-dao.jar deleted file mode 100644 index 7ee0006c..00000000 Binary files a/lib/optional/spring-2.0-dao.jar and /dev/null differ diff --git a/lib/optional/spring-2.0-jdbc.jar b/lib/optional/spring-2.0-jdbc.jar deleted file mode 100644 index fe46f36a..00000000 Binary files a/lib/optional/spring-2.0-jdbc.jar and /dev/null differ diff --git a/lib/xercesImpl-2.8.1.jar b/lib/xercesImpl-2.8.1.jar deleted file mode 100644 index 3b351f6e..00000000 Binary files a/lib/xercesImpl-2.8.1.jar and /dev/null differ diff --git a/lib/xri/icu4j-3.4.4.jar b/lib/xri/icu4j-3.4.4.jar deleted file mode 100644 index f5e8c167..00000000 Binary files a/lib/xri/icu4j-3.4.4.jar and /dev/null differ diff --git a/lib/xri/jug-1.1.2.jar b/lib/xri/jug-1.1.2.jar deleted file mode 100644 index 780f2d14..00000000 Binary files a/lib/xri/jug-1.1.2.jar and /dev/null differ diff --git a/lib/xri/openxri-client-1.2.0.jar b/lib/xri/openxri-client-1.2.0.jar deleted file mode 100644 index dfb512f0..00000000 Binary files a/lib/xri/openxri-client-1.2.0.jar and /dev/null differ diff --git a/lib/xri/openxri-syntax-1.2.0.jar b/lib/xri/openxri-syntax-1.2.0.jar deleted file mode 100644 index 8398e9fa..00000000 Binary files a/lib/xri/openxri-syntax-1.2.0.jar and /dev/null differ diff --git a/lib/xri/xalan-2.7.0.jar b/lib/xri/xalan-2.7.0.jar deleted file mode 100644 index 007be396..00000000 Binary files a/lib/xri/xalan-2.7.0.jar and /dev/null differ diff --git a/lib/xri/xml-apis-1.0.b2.jar b/lib/xri/xml-apis-1.0.b2.jar deleted file mode 100644 index ad33a5af..00000000 Binary files a/lib/xri/xml-apis-1.0.b2.jar and /dev/null differ diff --git a/lib/xri/xmlsec-1.3.0.jar b/lib/xri/xmlsec-1.3.0.jar deleted file mode 100644 index 6b69b807..00000000 Binary files a/lib/xri/xmlsec-1.3.0.jar and /dev/null differ diff --git a/pom.xml b/pom.xml index 4f5754e4..409eee54 100644 --- a/pom.xml +++ b/pom.xml @@ -3,20 +3,17 @@ http://maven.apache.org/maven-v4_0_0.xsd" > 4.0.0 - org.openid4java + com.amarulasolutions openid4java - 1.0.0 + 2.0.0 jar OpenID4Java OpenID4Java library offers support for OpenID-enabling a consumer site or implementing an OpenID Provider server. + This is the Amarula Solutions fork. - http://code.google.com/p/openid4java/ - - - 2.2.1 - + https://github.com/amarula/openid4java UTF-8 @@ -24,6 +21,7 @@ 6.0.2 ${basedir}/test/yadisdata ${basedir}/target/test-data + 8989 @@ -52,117 +50,57 @@ org.apache.maven.plugins maven-antrun-plugin - 1.7 + 3.1.0 org.apache.maven.plugins maven-assembly-plugin - 2.4 + 3.7.1 org.apache.maven.plugins maven-clean-plugin - 2.5 + 3.4.1 org.apache.maven.plugins maven-compiler-plugin - 3.0 + 3.13.0 org.apache.maven.plugins maven-deploy-plugin - 2.7 - - - org.apache.maven.plugins - maven-eclipse-plugin - 2.9 + 3.1.4 org.apache.maven.plugins maven-install-plugin - 2.4 + 3.1.4 org.apache.maven.plugins maven-jar-plugin - 2.4 + 3.4.2 org.apache.maven.plugins maven-javadoc-plugin - 2.9 - - - org.apache.maven.plugins - maven-jxr-plugin - 2.2 - - - org.apache.maven.plugins - maven-pmd-plugin - 2.5 - - - org.apache.maven.plugins - maven-project-info-reports-plugin - 2.3.1 + 3.11.2 org.apache.maven.plugins maven-resources-plugin - 2.5 - - - org.apache.maven.plugins - maven-site-plugin - 3.2 + 3.3.1 org.apache.maven.plugins maven-source-plugin - 2.2.1 + 3.3.1 org.apache.maven.plugins maven-surefire-plugin - 2.12.4 - - - org.apache.maven.plugins - maven-surefire-report-plugin - 2.10 - - - org.codehaus.mojo - cobertura-maven-plugin - 2.5 - - - org.codehaus.mojo - findbugs-maven-plugin - 2.3.2 - - - org.codehaus.mojo - properties-maven-plugin - 1.0-alpha-2 - - - org.codehaus.mojo - rat-maven-plugin - 1.0-alpha-3 - - - org.codehaus.mojo - taglist-maven-plugin - 2.4 - - - org.codehaus.mojo - versions-maven-plugin - 2.0 + 3.5.2 @@ -170,23 +108,43 @@ org.apache.maven.plugins maven-compiler-plugin - + + 17 true true - - **/xri/** - **/infocard/** - - - **/infocard/** - + + org.apache.maven.plugins + maven-enforcer-plugin + 3.5.0 + + + enforce + + enforce + + + + + [17,) + + + [3.9,) + + + + + + org.apache.maven.plugins maven-jar-plugin + + org.openid4java + openid4java @@ -202,36 +160,6 @@ - - - org.codehaus.mojo - properties-maven-plugin - - - initialize - - read-project-properties - - - - project.properties - - - - - - - - org.codehaus.mojo - cobertura-maven-plugin - - - - clean - - - - org.apache.maven.plugins maven-antrun-plugin @@ -239,45 +167,30 @@ process-test-resources - + - + run - - - **/xri/** - **/infocard/** - - org.apache.maven.plugins maven-surefire-plugin - - - YADIS_TEST_DATA - ${test.data.build} - - - SERVLET_PORT - ${test.servlet.port} - - - TEST_DATA - ${basedir}/test/src/org/openid4java/ - - + + ${test.data.build} + ${test.servlet.port} + ${basedir}/test/src/org/openid4java/ + @@ -302,16 +215,14 @@ - - - **/xri/** - **/infocard/** - - org.apache.maven.plugins maven-javadoc-plugin + + 17 + none + attach-javadocs @@ -321,184 +232,69 @@ - - org.apache.maven.plugins - maven-site-plugin - - - org.apache.maven.plugins - maven-eclipse-plugin - - true - true - - - - - - org.apache.maven.plugins - maven-project-info-reports-plugin - 2.3.1 - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.9 - - 128m - 512m - - - - org.apache.maven.plugins - maven-jxr-plugin - 2.2 - - true - apidocs - - - - org.codehaus.mojo - taglist-maven-plugin - 2.4 - - - TODO - FIXME - @todo - @deprecated - - - - - org.codehaus.mojo - cobertura-maven-plugin - 2.5 - - - org.apache.maven.plugins - maven-surefire-report-plugin - 2.10 - - false - - - - - report-only - - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - 2.6 - - ${basedir}/openid4java_checks.xml - - - - org.codehaus.mojo - findbugs-maven-plugin - 2.3.2 - - - org.apache.maven.plugins - maven-pmd-plugin - 2.5 - - true - 100 - ${jvm.ver} - - - - - pmd - cpd - - - - - - org.codehaus.mojo - rat-maven-plugin - 1.0-alpha-3 - - - - - - openid4java-snapshots - OpenID4Java Snapshot Repository - https://oss.sonatype.org/content/repositories/openid4java-snapshots/ - - - com.google.inject guice - 2.0 + 7.0.0 - net.sf.ehcache + org.ehcache ehcache - 1.3.0 - - - log4j - log4j - 1.2.14 + 3.10.9 javax.servlet - servlet-api - 2.3 - provided + javax.servlet-api + 4.0.1 + test commons-logging commons-logging - 1.1.1 + 1.3.4 commons-codec commons-codec - 1.3 + 1.17.1 - org.apache.httpcomponents - httpclient - 4.1 + org.apache.httpcomponents.client5 + httpclient5 + 5.6.5 org.springframework spring-jdbc - 2.0.6 + 6.2.1 + + + org.jsoup + jsoup + 1.24.1 net.sourceforge.nekohtml nekohtml - 1.9.10 + 1.9.22 + test junit junit - 3.8.2 + 4.13.2 - jdom - jdom - 1.0 + org.jdom + jdom2 + 2.0.6.1 jetty @@ -513,7 +309,7 @@ net.sourceforge.jwebunit jwebunit-htmlunit-plugin - 1.4.1 + 3.3 javax.servlet @@ -530,12 +326,8 @@ xerces xercesImpl - 2.8.1 - - - xml-security - xmlsec - 1.3.0 + 2.12.2 + test @@ -546,22 +338,20 @@ commons-logging - org.apache.httpcomponents - httpclient + commons-codec + commons-codec - net.sourceforge.nekohtml - nekohtml + org.apache.httpcomponents.client5 + httpclient5 - com.google.inject - guice + org.jsoup + jsoup - - - xerces - xercesImpl + com.google.inject + guice @@ -572,28 +362,41 @@ - net.sf.ehcache + org.ehcache ehcache true - - - log4j - log4j - true + + + + org.glassfish.jaxb + jaxb-runtime + + - + javax.servlet - servlet-api - provided + javax.servlet-api + test - hsqldb + org.hsqldb hsqldb - 1.8.0.10 + 2.7.4 + test + + + + net.sourceforge.nekohtml + nekohtml + test + + + xerces + xercesImpl test @@ -602,8 +405,8 @@ test - jdom - jdom + org.jdom + jdom2 test @@ -631,6 +434,25 @@ + + + org.slf4j + slf4j-api + 1.7.36 + test + + + org.slf4j + slf4j-simple + 1.7.36 + test + + + commons-io + commons-io + 2.18.0 + test + @@ -642,10 +464,19 @@ - Sxip - http://sxip.com/ + Amarula Solutions + https://github.com/amarula + + mtrimarchi + Michael Trimarchi + michael@amarulasolutions.com + Amarula Solutions + + maintainer + + dick.hardt dick.hardt @@ -765,51 +596,24 @@ - Google Code Issue - http://code.google.com/p/openid4java/issues/list + GitHub + https://github.com/amarula/openid4java/issues - scm:svn:http://openid4java.googlecode.com/svn/trunk/ - scm:svn:https://openid4java.googlecode.com/svn/trunk/ + scm:git:https://github.com/amarula/openid4java.git + scm:git:ssh://git@github.com/amarula/openid4java.git HEAD - http://openid4java.googlecode.com/svn/trunk/ + https://github.com/amarula/openid4java - - openid4java-staging - OpenID4Java Staging Repository - http://oss.sonatype.org/service/local/staging/deploy/maven2/ + github + GitHub Packages + https://maven.pkg.github.com/amarula/openid4java - - openid4java-snapshots - OpenID4Java Snapshot Repository - http://oss.sonatype.org/content/repositories/openid4java-snapshots/ - - - alchim-deploy - - - alchim.sf.net - sourceforge - scp://alchim.sf.net/home/groups/a/al/alchim/htdocs/download/releases - - - alchim.sf.net - sourceforge - scp://alchim.sf.net/home/groups/a/al/alchim/htdocs/download/snapshots - false - - - alchim.sf.net - sourceforge - scp://alchim.sf.net/home/groups/a/al/alchim/htdocs/openid4java - - - release @@ -817,6 +621,7 @@ org.apache.maven.plugins maven-gpg-plugin + 3.2.7 sign-artifacts diff --git a/project.properties b/project.properties deleted file mode 100644 index b664ed6b..00000000 --- a/project.properties +++ /dev/null @@ -1,37 +0,0 @@ -# -# Copyright 2006-2008 Sxip Identity Corporation -# - -component.name=openid4java -component.ver=1.0.0 - -jvm.ver=1.5 -debug=true -eol.style=unix - -# sources -src=${basedir}/src - -# libs -lib.dir=${basedir}/lib -libext.dir=${lib.dir}/extra -endorsed.dir=${lib.dir}/endorsed - -# tests -test.dir=${basedir}/test -test.src=${test.dir}/src -test.data=${test.dir}/yadisdata -test.servlet.port=8989 - -# compiled classes -classes=${build}/classes -classes.test=${build}/test/classes - -# build and distribution -build=${basedir}/build - -# documentation -apidoc=${basedir}/apidoc - - - diff --git a/samples/README b/samples/README index c11e3789..0662fd19 100644 --- a/samples/README +++ b/samples/README @@ -1,22 +1,7 @@ OpenID4Java Samples -* formredirection - JSP helper file for generating indirect messages (Authentication Requests - and Responses) through HTML FORM Redirection. - * simple-openid - An openid demo consumer and provider using only JSPs. + An OpenID demo consumer and provider using only JSPs. * consumer-servlet - An openid demo consumer using servlet. - -* demorp - Demonstrative Relying Party implementation, featuring Attribute Exchange - and OpenID Infocards support. - See demorp/INSTALL for installation and configuration instructions. - -* infocardop - Stripped down OpenID Provider implementation, adapted for the protocol flow - described by the OpenID Information Cards specification : handles only direct - verification (openid.mode=check_authentication) requests. - See infocardop/INSTALL for installation and configuration instructions. + An OpenID demo consumer using servlets. diff --git a/samples/appengine-consumer/README b/samples/appengine-consumer/README deleted file mode 100644 index df8ef3e4..00000000 --- a/samples/appengine-consumer/README +++ /dev/null @@ -1,24 +0,0 @@ - -This directory contains a simple example for how to run an -openid4java-based OpenID Relying Party on Google AppEngine. - -First, create the WAR directory: - -$ mvn package - -Now, test the server locally: - -$ $PATH_TO_APPENGINE/dev_appserver.sh -a -p 8080 \ - target/appengine-consumer - -Point your browser to http://:8080 to test. - -Finally, to deploy on AppEngine, you have to first claim an application -name for yourself, and then edit the configuration file -src/main/webapp/WEB-INF/appengine-web.xml. Change the name of the -application from "openid4java" to the name you own. Then, rebuild and -upload the application: - -$ mvn package -$ $PATH_TO_APPENGINE/appcfg.sh update target/appengine-consumer - diff --git a/samples/appengine-consumer/pom.xml b/samples/appengine-consumer/pom.xml deleted file mode 100644 index 886a1710..00000000 --- a/samples/appengine-consumer/pom.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - org.openid4java - openid4java-samples - 1.0.0 - ../pom.xml - - 4.0.0 - appengine-consumer - war - Example for Google AppEngine-based Consumer - http://maven.apache.org - - - javax.servlet - jstl - 1.1.2 - - - junit - junit - 3.8.1 - test - - - com.google.appengine - appengine.api - 1.2.5 - system - ${basedir}/src/main/webapp/WEB-INF/lib/appengine-api-1.0-sdk-1.2.5.jar - - - com.google.inject - guice-servlet - 2.0 - - - com.google.collections - google-collections - 1.0-rc4 - - - - appengine-consumer - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.5 - 1.5 - - - - - diff --git a/samples/appengine-consumer/src/main/java/org/openid4java/appengine/AppEngineGuiceModule.java b/samples/appengine-consumer/src/main/java/org/openid4java/appengine/AppEngineGuiceModule.java deleted file mode 100644 index 16ed5fa9..00000000 --- a/samples/appengine-consumer/src/main/java/org/openid4java/appengine/AppEngineGuiceModule.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright 2009 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.openid4java.appengine; - -import com.google.appengine.api.urlfetch.URLFetchService; -import com.google.appengine.api.urlfetch.URLFetchServiceFactory; -import com.google.inject.AbstractModule; -import com.google.inject.Provides; -import com.google.inject.Scopes; -import com.google.inject.Singleton; - -import org.openid4java.util.HttpFetcher; - -public class AppEngineGuiceModule extends AbstractModule { - - @Override - protected void configure() { - bind(HttpFetcher.class).to(AppEngineHttpFetcher.class).in(Scopes.SINGLETON); - } - - @Provides @Singleton - public URLFetchService providerUrlFetchService() { - return URLFetchServiceFactory.getURLFetchService(); - } -} diff --git a/samples/appengine-consumer/src/main/java/org/openid4java/appengine/AppEngineHttpFetcher.java b/samples/appengine-consumer/src/main/java/org/openid4java/appengine/AppEngineHttpFetcher.java deleted file mode 100644 index 8ff22f05..00000000 --- a/samples/appengine-consumer/src/main/java/org/openid4java/appengine/AppEngineHttpFetcher.java +++ /dev/null @@ -1,274 +0,0 @@ -/** - * Copyright 2009 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.openid4java.appengine; - -import com.google.appengine.api.urlfetch.FetchOptions; -import com.google.appengine.api.urlfetch.HTTPHeader; -import com.google.appengine.api.urlfetch.HTTPMethod; -import com.google.appengine.api.urlfetch.HTTPRequest; -import com.google.appengine.api.urlfetch.HTTPResponse; -import com.google.appengine.api.urlfetch.ResponseTooLargeException; -import com.google.appengine.api.urlfetch.URLFetchService; -import com.google.common.base.Joiner; -import com.google.common.collect.Maps; -import com.google.inject.Inject; -import com.google.inject.Singleton; - -import org.apache.http.Header; -import org.apache.http.message.BasicHeader; -import org.openid4java.util.AbstractHttpFetcher; -import org.openid4java.util.HttpRequestOptions; -import org.openid4java.util.HttpResponse; - -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.net.URL; -import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import javax.servlet.http.HttpServletResponse; - -/** - * Implementation of HttpFetcher for AppEngine. - */ -@Singleton -public class AppEngineHttpFetcher extends AbstractHttpFetcher { - - private final URLFetchService fetchService; - - @Inject - public AppEngineHttpFetcher(URLFetchService fetchService) { - this.fetchService = fetchService; - } - - @Override - public HttpResponse get(String url, HttpRequestOptions requestOptions) - throws IOException { - return fetch(url, requestOptions, HTTPMethod.GET, null); - } - - @Override - public HttpResponse head(String url, HttpRequestOptions requestOptions) - throws IOException { - return fetch(url, requestOptions, HTTPMethod.HEAD, null); - } - - @Override - public HttpResponse post(String url, Map parameters, - HttpRequestOptions requestOptions) throws IOException { - return fetch(url, requestOptions, HTTPMethod.POST, encodeParameters(parameters )); - } - - private String encodeParameters(Map params) { - Map escapedParams = Maps.newHashMap(); - for (Entry entry : params.entrySet()) { - try { - escapedParams.put(URLEncoder.encode(entry.getKey(), "UTF-8"), - URLEncoder.encode(entry.getValue(), "UTF-8")); - } catch (UnsupportedEncodingException e) { - // this should not happen - throw new RuntimeException("platform does not support UTF-8", e); - } - } - return Joiner.on("&").withKeyValueSeparator("=").join(escapedParams); - } - - private HttpResponse fetch(String url, HttpRequestOptions requestOptions, - HTTPMethod method, String content) throws IOException { - - final FetchOptions options = getFetchOptions(requestOptions); - - String currentUrl = url; - - for (int i = 0; i <= requestOptions.getMaxRedirects(); i++) { - - HTTPRequest httpRequest = new HTTPRequest(new URL(currentUrl), - method, options); - - addHeaders(httpRequest, requestOptions); - - if (method == HTTPMethod.POST && content != null) { - httpRequest.setPayload(content.getBytes()); - } - - HTTPResponse httpResponse; - try { - httpResponse = fetchService.fetch(httpRequest); - } catch (ResponseTooLargeException e) { - return new TooLargeResponse(currentUrl); - } - - if (!isRedirect(httpResponse.getResponseCode())) { - boolean isResponseTooLarge = - (getContentLength(httpResponse) > requestOptions.getMaxBodySize()); - return new AppEngineFetchResponse(httpResponse, - isResponseTooLarge, currentUrl); - } else { - currentUrl = getResponseHeader(httpResponse, "Location").getValue(); - } - } - throw new IOException("exceeded maximum number of redirects"); - } - - private static int getContentLength(HTTPResponse httpResponse) { - byte[] content = httpResponse.getContent(); - if (content == null) { - return 0; - } else { - return content.length; - } - } - - private static void addHeaders(HTTPRequest httpRequest, - HttpRequestOptions requestOptions) { - - String contentType = requestOptions.getContentType(); - - if (contentType != null) { - httpRequest.addHeader(new HTTPHeader("Content-Type", contentType)); - } - - Map headers = getRequestHeaders(requestOptions); - - if (headers != null) { - for (Map.Entry header : headers.entrySet()) { - httpRequest.addHeader(new HTTPHeader(header.getKey(), header.getValue())); - } - } - } - - @SuppressWarnings("unchecked") - private static Map getRequestHeaders( - HttpRequestOptions requestOptions) { - return requestOptions.getRequestHeaders(); - } - - private static Header getResponseHeader(HTTPResponse httpResponse, String headerName) { - Header[] allHeaders = getResponseHeaders(httpResponse, headerName); - if (allHeaders.length == 0) { - return null; - } else { - return allHeaders[0]; - } - } - - private static Header[] getResponseHeaders(HTTPResponse httpResponse, String headerName) { - List allHeaders = httpResponse.getHeaders(); - List
matchingHeaders = new ArrayList
(); - for (HTTPHeader header : allHeaders) { - if (header.getName().equalsIgnoreCase(headerName)) { - matchingHeaders.add(new BasicHeader(header.getName(), header.getValue())); - } - } - return matchingHeaders.toArray(new Header[matchingHeaders.size()]); - } - - private static boolean isRedirect(int responseCode) { - switch (responseCode) { - case HttpServletResponse.SC_MOVED_PERMANENTLY: - case HttpServletResponse.SC_MOVED_TEMPORARILY: - case HttpServletResponse.SC_SEE_OTHER: - case HttpServletResponse.SC_TEMPORARY_REDIRECT: - return true; - default: - return false; - } - } - - private FetchOptions getFetchOptions(HttpRequestOptions requestOptions) { - return FetchOptions.Builder.disallowTruncate() - .doNotFollowRedirects() - .setDeadline(requestOptions.getConnTimeout() / 1000.0); - } - - private static class AppEngineFetchResponse implements HttpResponse { - - private final com.google.appengine.api.urlfetch.HTTPResponse httpResponse; - private final boolean bodySizeExceeded; - private String finalUri; - - public AppEngineFetchResponse( - com.google.appengine.api.urlfetch.HTTPResponse httpResponse, - boolean bodySizeExceeded, - String finalUri) { - this.httpResponse = httpResponse; - this.bodySizeExceeded = bodySizeExceeded; - this.finalUri = finalUri; - } - - public String getBody() { - byte[] content = httpResponse.getContent(); - return (content == null || content.length == 0) ? null : new String(content); - } - - public String getFinalUri() { - return finalUri; - } - - public Header getResponseHeader(String headerName) { - return AppEngineHttpFetcher.getResponseHeader(httpResponse, headerName); - } - - public Header[] getResponseHeaders(String headerName) { - return AppEngineHttpFetcher.getResponseHeaders(httpResponse, headerName); - } - - public boolean isBodySizeExceeded() { - return bodySizeExceeded; - } - - public int getStatusCode() { - return httpResponse.getResponseCode(); - } - } - - private static class TooLargeResponse implements HttpResponse { - - private String finalUri; - - public TooLargeResponse(String finalUri) { - this.finalUri = finalUri; - } - - public String getBody() { - throw new ResponseTooLargeException(finalUri); - } - - public String getFinalUri() { - return finalUri; - } - - public Header getResponseHeader(String headerName) { - throw new ResponseTooLargeException(finalUri); - } - - public Header[] getResponseHeaders(String headerName) { - throw new ResponseTooLargeException(finalUri); - } - - public boolean isBodySizeExceeded() { - return true; - } - - public int getStatusCode() { - throw new ResponseTooLargeException(finalUri); - } - } -} diff --git a/samples/appengine-consumer/src/main/java/org/openid4java/samples/servlet/PrepareRequestAttributesFilter.java b/samples/appengine-consumer/src/main/java/org/openid4java/samples/servlet/PrepareRequestAttributesFilter.java deleted file mode 100644 index 53682d85..00000000 --- a/samples/appengine-consumer/src/main/java/org/openid4java/samples/servlet/PrepareRequestAttributesFilter.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.openid4java.samples.servlet; - -import com.google.inject.Inject; -import com.google.inject.Singleton; - -import org.openid4java.consumer.ConsumerManager; - -import java.io.IOException; - -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; - -@Singleton -public class PrepareRequestAttributesFilter implements Filter { - - private final ConsumerManager consumerManager; - - @Inject - public PrepareRequestAttributesFilter(ConsumerManager consumerManager) { - this.consumerManager = consumerManager; - } - - public void doFilter(ServletRequest req, ServletResponse resp, - FilterChain chain) throws IOException, ServletException { - req.setAttribute("consumermanager", consumerManager); - chain.doFilter(req, resp); - } - - public void init(FilterConfig config) { - } - - public void destroy() { - } -} diff --git a/samples/appengine-consumer/src/main/java/org/openid4java/samples/servlet/ServletContextListener.java b/samples/appengine-consumer/src/main/java/org/openid4java/samples/servlet/ServletContextListener.java deleted file mode 100644 index 20675522..00000000 --- a/samples/appengine-consumer/src/main/java/org/openid4java/samples/servlet/ServletContextListener.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright 2009 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.openid4java.samples.servlet; - -import com.google.inject.Guice; -import com.google.inject.Injector; -import com.google.inject.servlet.GuiceServletContextListener; -import com.google.inject.servlet.ServletModule; - -import org.openid4java.appengine.AppEngineGuiceModule; - -import javax.servlet.ServletContextEvent; - -public class ServletContextListener extends GuiceServletContextListener { - - @Override - public void contextInitialized(ServletContextEvent servletContextEvent) { - super.contextInitialized(servletContextEvent); - } - - @Override - protected Injector getInjector() { - return Guice.createInjector( - new ServletModule() { - @Override - protected void configureServlets() { - filter("/*").through(PrepareRequestAttributesFilter.class); - } - }, - new AppEngineGuiceModule()); - } -} diff --git a/samples/appengine-consumer/src/main/webapp/WEB-INF/appengine-web.xml b/samples/appengine-consumer/src/main/webapp/WEB-INF/appengine-web.xml deleted file mode 100644 index 4854bb99..00000000 --- a/samples/appengine-consumer/src/main/webapp/WEB-INF/appengine-web.xml +++ /dev/null @@ -1,24 +0,0 @@ - - openid4java - 1 - - true - - - - - - - - - - - - - - - - diff --git a/samples/appengine-consumer/src/main/webapp/WEB-INF/lib/appengine-api-1.0-sdk-1.2.5.jar b/samples/appengine-consumer/src/main/webapp/WEB-INF/lib/appengine-api-1.0-sdk-1.2.5.jar deleted file mode 100644 index 5e461a1b..00000000 Binary files a/samples/appengine-consumer/src/main/webapp/WEB-INF/lib/appengine-api-1.0-sdk-1.2.5.jar and /dev/null differ diff --git a/samples/appengine-consumer/src/main/webapp/WEB-INF/logging.properties b/samples/appengine-consumer/src/main/webapp/WEB-INF/logging.properties deleted file mode 100644 index 4a78b7f3..00000000 --- a/samples/appengine-consumer/src/main/webapp/WEB-INF/logging.properties +++ /dev/null @@ -1,28 +0,0 @@ -# A default java.util.logging configuration. -# (All App Engine logging is through java.util.logging by default). -# -# To use this configuration, copy it into your application's WEB-INF -# folder and add the following to your appengine-web.xml: -# -# -# -# -# - -# Set the default logging level for all loggers to WARNING -.level = WARNING - -# Set the default logging level for ORM, specifically, to WARNING -DataNucleus.JDO.level=WARNING -DataNucleus.Persistence.level=WARNING -DataNucleus.Cache.level=WARNING -DataNucleus.MetaData.level=WARNING -DataNucleus.General.level=WARNING -DataNucleus.Utility.level=WARNING -DataNucleus.Transaction.level=WARNING -DataNucleus.Datastore.level=WARNING -DataNucleus.ClassLoading.level=WARNING -DataNucleus.Plugin.level=WARNING -DataNucleus.ValueGeneration.level=WARNING -DataNucleus.Enhancer.level=WARNING -DataNucleus.SchemaTool.level=WARNING diff --git a/samples/appengine-consumer/src/main/webapp/WEB-INF/web.xml b/samples/appengine-consumer/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index ff41a2c1..00000000 --- a/samples/appengine-consumer/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - Archetype Created Web Application - - - guiceFilter - com.google.inject.servlet.GuiceFilter - - - - guiceFilter - /* - - - - org.openid4java.samples.servlet.ServletContextListener - - - diff --git a/samples/appengine-consumer/src/main/webapp/consumer_redirect.jsp b/samples/appengine-consumer/src/main/webapp/consumer_redirect.jsp deleted file mode 100644 index 08edc8cd..00000000 --- a/samples/appengine-consumer/src/main/webapp/consumer_redirect.jsp +++ /dev/null @@ -1,105 +0,0 @@ -<%@ page session="true" %> -<%@ page import="java.util.Map,java.util.Iterator,org.openid4java.discovery.Identifier, org.openid4java.discovery.DiscoveryInformation, org.openid4java.message.ax.FetchRequest, org.openid4java.message.ax.FetchResponse, org.openid4java.message.ax.AxMessage, org.openid4java.message.*, org.openid4java.OpenIDException, java.util.List, java.io.IOException, javax.servlet.http.HttpSession, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.openid4java.consumer.ConsumerManager, org.openid4java.consumer.InMemoryConsumerAssociationStore, org.openid4java.consumer.InMemoryNonceVerifier, org.openid4java.discovery.DiscoveryException" %> - -<% - // README: - // Set the returnToUrl string to the appropriate value for this JSP - // Since you may be deployed behind apache, etc, the jsp has no real idea what the - // absolute URI is to get back here. - - ConsumerManager manager=(ConsumerManager) request.getAttribute("consumermanager"); - String openid=request.getParameter("openid"); - - try - { - // determine a return_to URL where your application will receive - // the authentication responses from the OpenID provider - // YOU SHOULD CHANGE THIS TO GO TO THE - - String port = (request.getServerPort() == 80) ? "" : (":" + request.getServerPort()); - String returnToUrl = request.getScheme() + "://" + request.getServerName() + port + "/consumer_returnurl.jsp"; - - // perform discovery on the user-supplied identifier - List discoveries = null; - - try { - discoveries = manager.discover(openid); - } catch (DiscoveryException e) { - throw new ServletException(e); - } - - // attempt to associate with an OpenID provider - // and retrieve one service endpoint for authentication - DiscoveryInformation discovered = manager.associate(discoveries); - - // store the discovery information in the user's session - session.setAttribute("openid-disco", discovered); - - // obtain a AuthRequest message to be sent to the OpenID provider - AuthRequest authReq = manager.authenticate(discovered, returnToUrl); - - // Attribute Exchange example: fetching the 'email' attribute - //FetchRequest fetch = FetchRequest.createFetchRequest(); - //fetch.addAttribute("email", - // attribute alias - // "http://schema.openid.net/contact/email", // type URI - // true); // required - - // attach the extension to the authentication request - //authReq.addExtension(fetch); - - if (! discovered.isVersion2() ) - { - // Option 1: GET HTTP-redirect to the OpenID Provider endpoint - // The only method supported in OpenID 1.x - // redirect-URL usually limited ~2048 bytes - response.sendRedirect(authReq.getDestinationUrl(true)); - } - else - { - // Option 2: HTML FORM Redirection - // Allows payloads > 2048 bytes - - // - // see samples/formredirection.jsp for a JSP example - //authReq.getOPEndpoint(); - - // build a HTML FORM with the message parameters - //authReq.getParameterMap(); - -%> - - - OpenID HTML FORM Redirection - - - - -<% - Map pm=authReq.getParameterMap(); - Iterator keyit=pm.keySet().iterator(); - - Object key; - Object value; - - while (keyit.hasNext()) - { - key=keyit.next(); - value=pm.get(key); - %> - - <% - } - %> - - - - -<% - } - } - catch (OpenIDException e) { - // present error to the user - response.sendError(500); - } -%> diff --git a/samples/appengine-consumer/src/main/webapp/consumer_returnurl.jsp b/samples/appengine-consumer/src/main/webapp/consumer_returnurl.jsp deleted file mode 100644 index 9ef96d55..00000000 --- a/samples/appengine-consumer/src/main/webapp/consumer_returnurl.jsp +++ /dev/null @@ -1,58 +0,0 @@ -<%@ page session="true" %> -<%@ page import="org.openid4java.discovery.Identifier, org.openid4java.discovery.DiscoveryInformation, org.openid4java.message.ax.FetchRequest, org.openid4java.message.ax.FetchResponse, org.openid4java.message.ax.AxMessage, org.openid4java.message.*, org.openid4java.OpenIDException, java.util.List, java.io.IOException, javax.servlet.http.HttpSession, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.openid4java.consumer.ConsumerManager, org.openid4java.consumer.InMemoryConsumerAssociationStore, org.openid4java.consumer.VerificationResult" %> - -<% - - ConsumerManager manager=(ConsumerManager) request.getAttribute("consumermanager"); -try - { - // --- processing the authentication response - - // extract the parameters from the authentication response - // (which comes in as a HTTP request from the OpenID provider) - ParameterList responselist = - new ParameterList(request.getParameterMap()); - - // retrieve the previously stored discovery information - DiscoveryInformation discovered = - (DiscoveryInformation) session.getAttribute("openid-disco"); - - // extract the receiving URL from the HTTP request - StringBuffer receivingURL = request.getRequestURL(); - String queryString = request.getQueryString(); - if (queryString != null && queryString.length() > 0) - receivingURL.append("?").append(request.getQueryString()); - - // verify the response; ConsumerManager needs to be the same - // (static) instance used to place the authentication request - VerificationResult verification = manager.verify( - receivingURL.toString(), - responselist, discovered); - - // examine the verification result and extract the verified identifier - Identifier verified = verification.getVerifiedId(); - if (verified != null) - { - AuthSuccess authSuccess = - (AuthSuccess) verification.getAuthResponse(); - - session.setAttribute("openid", authSuccess.getIdentity()); - session.setAttribute("openid-claimed", authSuccess.getClaimed()); - response.sendRedirect("."); // success - } - else - { -%> - Failed to login! -<% - } - } - catch (OpenIDException e) - { -%> - Login error! -<% - // present error to the user - } - -%> diff --git a/samples/appengine-consumer/src/main/webapp/index.jsp b/samples/appengine-consumer/src/main/webapp/index.jsp deleted file mode 100644 index 2dc0c118..00000000 --- a/samples/appengine-consumer/src/main/webapp/index.jsp +++ /dev/null @@ -1,29 +0,0 @@ -<%@ page session="true" %> - - -<% - if (request.getParameter("logout")!=null) - { - session.removeAttribute("openid"); - session.removeAttribute("openid-claimed"); -%> - Logged out!

-<% - } - if (session.getAttribute("openid")==null) { -%> -

-OpenID: -
- -
-<% -} else { - -%> -Logged in as <%= session.getAttribute("openid") %>

-Log out - -<% } %> - - diff --git a/samples/consumer-servlet/README.txt b/samples/consumer-servlet/README.txt index 103e4507..6af44dda 100644 --- a/samples/consumer-servlet/README.txt +++ b/samples/consumer-servlet/README.txt @@ -1,15 +1,14 @@ -How to run the demo. - -Step 1. Install openid4java library. - -% cd openid4java -% mvn package install - -Step 2. Run the demo. - -% cd samples/consumer-servlet -% mvn jetty:run - -Step 3. OK. - -Open http://localhost:8080/consumer-servlet/ by browser. +How to run the demo. + +Step 1. Build and install the openid4java library from the repository root: + + mvn install -DskipTests + +Step 2. Run the demo: + + cd samples/consumer-servlet + mvn jetty:run + +Step 3. Open http://localhost:8080/consumer-servlet/ in a browser. + +The demo requires JDK 17 or newer and uses Jakarta EE 10 (Jetty 12). diff --git a/samples/consumer-servlet/pom.xml b/samples/consumer-servlet/pom.xml index 47d6f4f4..79ce2f45 100644 --- a/samples/consumer-servlet/pom.xml +++ b/samples/consumer-servlet/pom.xml @@ -2,65 +2,68 @@ - org.openid4java + com.amarulasolutions openid4java-samples - 1.0.0 + 2.0.0 ../pom.xml 4.0.0 consumer-servlet war OpenID consumer demo using servlet - http://openid4java.org + https://github.com/amarula/openid4java consumer-servlet - org.mortbay.jetty - maven-jetty-plugin - - - org.apache.maven.plugins - maven-eclipse-plugin + org.eclipse.jetty.ee10 + jetty-ee10-maven-plugin + 12.1.15 - true - true - 1.5 + + /consumer-servlet + - junit - junit - 3.8.1 - test + com.amarulasolutions + openid4java - javax.servlet - servlet-api - 2.3 + jakarta.servlet + jakarta.servlet-api + 6.0.0 provided - javax.servlet - jstl - 1.1.2 + jakarta.servlet.jsp + jakarta.servlet.jsp-api + 3.1.1 + provided - taglibs - standard - 1.1.2 + jakarta.servlet.jsp.jstl + jakarta.servlet.jsp.jstl-api + 3.0.2 - commons-lang - commons-lang - 2.5 + org.glassfish.web + jakarta.servlet.jsp.jstl + 3.0.1 - org.openid4java - openid4java + org.apache.commons + commons-lang3 + 3.22.0 + + + junit + junit + 4.13.2 + test diff --git a/samples/consumer-servlet/src/main/java/org/openid4java/samples/consumerservlet/ConsumerServlet.java b/samples/consumer-servlet/src/main/java/org/openid4java/samples/consumerservlet/ConsumerServlet.java index 54d56bf2..da2a1886 100644 --- a/samples/consumer-servlet/src/main/java/org/openid4java/samples/consumerservlet/ConsumerServlet.java +++ b/samples/consumer-servlet/src/main/java/org/openid4java/samples/consumerservlet/ConsumerServlet.java @@ -9,15 +9,15 @@ import java.util.List; import java.util.Map; -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletConfig; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.math.NumberUtils; +import jakarta.servlet.RequestDispatcher; +import jakarta.servlet.ServletConfig; +import jakarta.servlet.ServletContext; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.openid4java.OpenIDException; @@ -45,7 +45,7 @@ /** * @author Sutra Zhou */ -public class ConsumerServlet extends javax.servlet.http.HttpServlet { +public class ConsumerServlet extends jakarta.servlet.http.HttpServlet { /** * @@ -182,7 +182,6 @@ public String authRequest(String userSuppliedString, * @param httpReq * @param authReq * @throws MessageException - * @see Simple Registration HowTo * @see OpenID Simple Registration Extension 1.0 */ private void addSimpleRegistrationToAuthRequest(HttpServletRequest httpReq, @@ -215,7 +214,6 @@ private void addSimpleRegistrationToAuthRequest(HttpServletRequest httpReq, * @param httpReq * @param authReq * @throws MessageException - * @see Attribute Exchange HowTo * @see OpenID Attribute Exchange 1.0 - Final */ private void addAttributeExchangeToAuthRequest(HttpServletRequest httpReq, diff --git a/samples/consumer-servlet/src/main/resources/log4j.properties b/samples/consumer-servlet/src/main/resources/log4j.properties deleted file mode 100644 index b3a3e1d2..00000000 --- a/samples/consumer-servlet/src/main/resources/log4j.properties +++ /dev/null @@ -1,14 +0,0 @@ -log4j.rootLogger=WARN, stdout, logfile -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n - -log4j.appender.logfile=org.apache.log4j.RollingFileAppender -log4j.appender.logfile.File=${java.io.tmpdir}/consumer-servlet.log -log4j.appender.logfile.Encoding=UTF-8 -log4j.appender.logfile.MaxFileSize=4096KB -log4j.appender.logfile.MaxBackupIndex=3 -log4j.appender.logfile.layout=org.apache.log4j.PatternLayout -log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n - -log4j.logger.org.openid4java.samples=DEBUG \ No newline at end of file diff --git a/samples/consumer-servlet/src/main/webapp/WEB-INF/web.xml b/samples/consumer-servlet/src/main/webapp/WEB-INF/web.xml index 44f070b4..64c1d32e 100644 --- a/samples/consumer-servlet/src/main/webapp/WEB-INF/web.xml +++ b/samples/consumer-servlet/src/main/webapp/WEB-INF/web.xml @@ -1,7 +1,8 @@ - + xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd" + version="6.0"> Consumer Servlet Web Application Consumer Servlet diff --git a/samples/consumer-servlet/src/main/webapp/formredirection.jsp b/samples/consumer-servlet/src/main/webapp/formredirection.jsp index 8631f140..dd0cc445 100644 --- a/samples/consumer-servlet/src/main/webapp/formredirection.jsp +++ b/samples/consumer-servlet/src/main/webapp/formredirection.jsp @@ -4,7 +4,7 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@ taglib prefix="c" uri="jakarta.tags.core" %> OpenID HTML FORM Redirection diff --git a/samples/consumer-servlet/src/main/webapp/index.jsp b/samples/consumer-servlet/src/main/webapp/index.jsp index b915b410..07e107c8 100644 --- a/samples/consumer-servlet/src/main/webapp/index.jsp +++ b/samples/consumer-servlet/src/main/webapp/index.jsp @@ -1,6 +1,6 @@ <%@ page contentType="text/html; charset=UTF-8" import="java.util.Map,java.util.LinkedHashMap" %> -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="jakarta.tags.core" prefix="c"%> @@ -35,7 +35,7 @@

- Sample 2: using the Simple Registration extension(doc: SRegHowTo) + Sample 2: using the Simple Registration extension(see the OpenID Simple Registration extension spec)
@@ -79,7 +79,7 @@
- Sample 3: using the Attribute Exchange extension(doc: AttributeExchangeHowTo) + Sample 3: using the Attribute Exchange extension(see the OpenID Attribute Exchange extension spec)
diff --git a/samples/consumer-servlet/src/main/webapp/return.jsp b/samples/consumer-servlet/src/main/webapp/return.jsp index 8511cc0d..84c19a79 100644 --- a/samples/consumer-servlet/src/main/webapp/return.jsp +++ b/samples/consumer-servlet/src/main/webapp/return.jsp @@ -1,6 +1,6 @@ <%@page contentType="text/html; charset=UTF-8" import="java.util.Map" %> -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="jakarta.tags.core" prefix="c"%> diff --git a/samples/demorp/DemoRP.iml b/samples/demorp/DemoRP.iml deleted file mode 100644 index 30d49b05..00000000 --- a/samples/demorp/DemoRP.iml +++ /dev/null @@ -1,459 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - jar://$MODULE_DIR$/lib/commons-codec-1.3.jar!/ - - - - - jar://$MODULE_DIR$/lib/commons-httpclient-3.0.1.jar!/ - - - - - jar://$MODULE_DIR$/lib/commons-logging-1.03.jar!/ - - - - - jar://$MODULE_DIR$/lib/htmlparser.jar!/ - - - - - jar://$MODULE_DIR$/lib/icu4j_3_4_1.jar!/ - - - - - jar://$MODULE_DIR$/lib/java-openid-sxip.jar!/ - - - - - jar://$MODULE_DIR$/lib/jstl.jar!/ - - - - - jar://$MODULE_DIR$/lib/jug-1.1.jar!/ - - - - - jar://$MODULE_DIR$/lib/log4j-1.2.8.jar!/ - - - - - jar://$MODULE_DIR$/lib/openxri-client.jar!/ - - - - - jar://$MODULE_DIR$/lib/openxri-syntax.jar!/ - - - - - jar://$MODULE_DIR$/lib/spring.jar!/ - - - - - jar://$MODULE_DIR$/lib/standard.jar!/ - - - - - jar://$MODULE_DIR$/lib/xmlsec-1.1.jar!/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/demorp/DemoRP.ipr b/samples/demorp/DemoRP.ipr deleted file mode 100644 index 910d7fc9..00000000 --- a/samples/demorp/DemoRP.ipr +++ /dev/null @@ -1,322 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/demorp/INSTALL b/samples/demorp/INSTALL deleted file mode 100644 index 0106984a..00000000 --- a/samples/demorp/INSTALL +++ /dev/null @@ -1,52 +0,0 @@ -... OpenID Demo RP - featuring Attribute Exchange and OpenID Infocards - -======================================================================== - -INSTALLATION AND CONFIGURATION INSTRUCTIONS - - -=> Introduction: - -This document describes how to install, configure and use the sample -OpenID Demo Relying Party. - -The Relying Party requires an OpenID Identifier for login; the identifier -is requested and can be provided through either of the following -two mechanisms: - - - the regular form-based text entry - - - using OpenID Information Cards - - -=> OpenID Infocard login - -The OpenID protocol transactions are enhanced with the use of a -client-side (Information Card) Identity Selector, as described in: - - https://openidcards.sxip.com/spec/openid-infocards.html - -The Relying Party's login page contains an additional -"application/x-informationCard" element -(see www/WEB-INF/jsp/login.jsp). - -The Relying Party extracts the OpenID Authentication Response -from the xmlToken parameter POST'ed by Identity Selector, after -which point the regular OpenID (direct) verification is performed. - - -=> Configuration: - - www/WEB-INF/classes/config.properties : - - - base.url : The base URL (without the context path) - where the RP will be deployed - - -=> Build and Installation: - - In the project's folder, run - - ant - - This will create a deployable dist/demo.war file. diff --git a/samples/demorp/build.xml b/samples/demorp/build.xml deleted file mode 100644 index 8b5eb633..00000000 --- a/samples/demorp/build.xml +++ /dev/null @@ -1,298 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Last Changed Rev (local): : ${svn.rev.local} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Copyright © 2006-2008 Sxip Identity Corp. All Rights Reserved.]]> - - - - - - - - - - - - - - - - Tomcat home directory: ${tomcat.home.dir} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/demorp/lib/jstl.jar b/samples/demorp/lib/jstl.jar deleted file mode 100644 index a02abecc..00000000 Binary files a/samples/demorp/lib/jstl.jar and /dev/null differ diff --git a/samples/demorp/lib/spring-context-2.0.jar b/samples/demorp/lib/spring-context-2.0.jar deleted file mode 100644 index 9a1ca559..00000000 Binary files a/samples/demorp/lib/spring-context-2.0.jar and /dev/null differ diff --git a/samples/demorp/lib/spring-web-2.0.jar b/samples/demorp/lib/spring-web-2.0.jar deleted file mode 100644 index 7cb2e43b..00000000 Binary files a/samples/demorp/lib/spring-web-2.0.jar and /dev/null differ diff --git a/samples/demorp/lib/spring-webmvc-2.0.jar b/samples/demorp/lib/spring-webmvc-2.0.jar deleted file mode 100644 index 24ca4c6d..00000000 Binary files a/samples/demorp/lib/spring-webmvc-2.0.jar and /dev/null differ diff --git a/samples/demorp/lib/standard.jar b/samples/demorp/lib/standard.jar deleted file mode 100644 index bc528acb..00000000 Binary files a/samples/demorp/lib/standard.jar and /dev/null differ diff --git a/samples/demorp/project.properties b/samples/demorp/project.properties deleted file mode 100644 index a8117d9b..00000000 --- a/samples/demorp/project.properties +++ /dev/null @@ -1,15 +0,0 @@ -# -# Copyright 2006-2008 Sxip Identity Corporation -# - -component.name=demorp - -compile.debug=yes -compile.debuglevel=source,lines,vars -compile.optimize=off -compile.deprecation=off -compile.target=1.5 -compile.source=${compile.target} - -openid4java.dir=../.. -openid4java.lib.dir=${openid4java.dir}/lib diff --git a/samples/demorp/src/net/sxip/openidcards/icdemo/web/IndexController.java b/samples/demorp/src/net/sxip/openidcards/icdemo/web/IndexController.java deleted file mode 100644 index e8ab5312..00000000 --- a/samples/demorp/src/net/sxip/openidcards/icdemo/web/IndexController.java +++ /dev/null @@ -1,359 +0,0 @@ -package net.sxip.openidcards.icdemo.web; - -import org.springframework.web.servlet.mvc.AbstractController; -import org.springframework.web.servlet.ModelAndView; -import org.apache.log4j.Logger; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; -import java.util.Map; -import java.util.List; -import java.util.HashMap; -import java.util.LinkedHashMap; - -import org.openid4java.discovery.DiscoveryInformation; -import org.openid4java.discovery.Identifier; -import org.openid4java.discovery.DiscoveryException; -import org.openid4java.message.ax.FetchRequest; -import org.openid4java.message.ax.FetchResponse; -import org.openid4java.message.ax.AxMessage; -import org.openid4java.message.*; -import org.openid4java.consumer.ConsumerManager; -import org.openid4java.consumer.VerificationResult; -import org.openid4java.infocard.InfocardException; -import org.openid4java.OpenIDException; -import org.openid4java.infocard.OpenIDToken; - -/** - * @author Marius Scurtescu - */ -public class IndexController extends AbstractController -{ - private static Logger _logger = Logger.getLogger(IndexController.class); - - private static final String LOGGEDIN ="loggedin"; - - // attribute typeUri -> "nice label / alias" - private static HashMap _attributes = new HashMap(); - - static - { - _attributes.put("http://axschema.org/contact/email", "Email"); - _attributes.put("http://axschema.org/namePerson/first", "FirstName"); - _attributes.put("http://axschema.org/namePerson/last", "LastName"); - _attributes.put("http://axschema.org/contact/phone/default", "Phone"); - _attributes.put("http://axschema.org/contact/postalAddress/home", "Address"); - _attributes.put("http://axschema.org/contact/city/home", "City"); - _attributes.put("http://axschema.org/contact/postalCode/home", "ZipCode"); - _attributes.put("http://axschema.org/contact/country/home", "Country"); - _attributes.put("http://axschema.org/contact/web/blog", "Blog"); - } - - private String _loginView; - private String _homeView; - private String _postView; - private String _errorView; - - private String _stsUrl; - private String _axUrl; - - private ConsumerManager _consumerManager; - - private String _baseUrl; - - public void setConsumerManager(ConsumerManager consumerManager) - { - this._consumerManager = consumerManager; - } - - public void setLoginView(String loginView) - { - _loginView = loginView; - } - - public void setHomeView(String homeView) - { - _homeView = homeView; - } - - public void setPostView(String postView) - { - _postView = postView; - } - - - public void setErrorView(String _errorView) - { - this._errorView = _errorView; - } - - public void setStsUrl(String stsUrl) - { - this._stsUrl = stsUrl; - } - - public void setAxUrl(String axUrl) - { - this._axUrl = axUrl; - } - - public void setBaseUrl(String baseUrl) - { - _baseUrl = baseUrl; - } - - protected ModelAndView handleRequestInternal(HttpServletRequest request, - HttpServletResponse response) - { - HttpSession session = request.getSession(); - String return_to = _baseUrl + request.getContextPath() + "/"; - String mode = request.getParameter("openid.mode"); - String xmlToken = request.getParameter("xmlToken"); - String openIdIdentifier = request.getParameter("openid_identifier"); - - try - { - if (mode != null) - { - // received a standard OpenID response - ParameterList openidResp = extractFromOpenIDPost(request); - return processOpenIDResp(request, session, openidResp); - } - else if (xmlToken != null) - { - // received an xmlToken from an identity selector - ParameterList openidResp = extractFromInfocardPost(request); - return processOpenIDResp(request, session, openidResp); - } - else if (openIdIdentifier != null) - { - return buildFetchReq(openIdIdentifier, session, return_to); - } - else - { - if (request.getParameter("logout") != null) - { - _logger.info("Logging out..."); - - session.removeAttribute(LOGGEDIN); - session.removeAttribute("message"); - } - - if (session.getAttribute(LOGGEDIN) == null) - { - _logger.info("Showing login page..."); - - return showLoginPage(); - } - else - { - _logger.info("(Re)Showing home / data view..."); - - return new ModelAndView(_homeView); - } - } - } - catch (Exception e) - { - _logger.error("Error encountered: ", e); - - return new ModelAndView(_errorView); - } - } - - private ModelAndView showLoginPage() - { - Map model = new HashMap(); - - model.put("title", "OpenID Infocards Demo"); - - String loginMessage1 = - "This is a demonstration of using OpenID Information Cards" + - "* to log into an OpenID Relying Party.

\n" + - "Besides OpenID Authentication, the Relying Party " + - "also requests profile data using Information Card conventions, " + - "and the values are returned in the OpenID assertion, " + - "using the OpenID Attribute Exchange** extension.\n"; - - String loginMessage2 = - "* You can get an OpenID Information Card " + - "here." + - "The OpenID Information Cards spec can be found " + - "here." + - "
** The OpenID Attribute Exchange spec " + - "can be found here\""; - - model.put("contents", loginMessage1); - model.put("contents2", loginMessage2); - - return new ModelAndView(_loginView, model); - } - - private ModelAndView buildFetchReq(String identifier, HttpSession session, String return_to) - throws OpenIDException - { - _logger.info("Building auth + fetch request for: " + identifier); - - Map model = new HashMap(); - List discoveries; - String errorMsg = ""; - - try - { - discoveries = _consumerManager.discover(identifier); - } - catch (DiscoveryException e) - { - _logger.error("Error while performing HTML discovery on " - + identifier, e); - discoveries = null; - errorMsg = "

" + e.getMessage() + ""; - } - - if (discoveries == null || discoveries.size() == 0) - { - _logger.error("Discovery failed on: " + identifier); - - model.put("message", "The " + identifier + " identifier could not be resolved." + errorMsg); - - return new ModelAndView(_loginView, model); - } - - DiscoveryInformation discovered = _consumerManager.associate(discoveries); - - // store the discovery information in the session for later use - session.setAttribute("discovered", discovered); - - FetchRequest fetch = FetchRequest.createFetchRequest(); - - for (String typeUri : _attributes.keySet()) - { - fetch.addAttribute(_attributes.get(typeUri), typeUri, false); - } - - AuthRequest req = _consumerManager.authenticate(discovered, return_to); - req.addExtension(fetch); - - model.put("message", req); - - _logger.info("Sending fetch request / auto-post view..."); - - return new ModelAndView(_postView, model); - } - - private ParameterList extractFromInfocardPost(HttpServletRequest request) - throws InfocardException - { - _logger.info("Extracting OpenID AuthResponse / Fetch Response from Infocard POST..." ); - - String xmlToken = request.getParameter("xmlToken"); - - request.getSession().setAttribute("openidAssertion", xmlToken); - - OpenIDToken token = OpenIDToken.createFromXmlToken(xmlToken); - - return token.getOpenIDParams(); - } - - private ParameterList extractFromOpenIDPost(HttpServletRequest request) - throws MessageException - { - _logger.info("Extracting OpenID AuthResponse / Fetch Response from OpenID POST..." ); - - ParameterList openidAssertion = new ParameterList(request.getParameterMap()); - - request.getSession().setAttribute("openidAssertion", openidAssertion.toString()); - - return openidAssertion; - } - - private ModelAndView processOpenIDResp(HttpServletRequest request, - HttpSession session, - ParameterList openidResp) - throws OpenIDException - { - _logger.info("Processing OpenID auth / fetch response..." ); - - Map model = new HashMap(); - model.put("title", "OpenID 2.0 OpenID InfoCards Demo"); - - // retrieve the previously stored discovery information - DiscoveryInformation discovered = (DiscoveryInformation) session.getAttribute("discovered"); - - StringBuffer receivingURL = request.getRequestURL(); - String queryString = request.getQueryString(); - if (queryString != null && queryString.length() > 0) - receivingURL.append("?").append(request.getQueryString()); - - // verify the response - VerificationResult verification = _consumerManager.verify( - receivingURL.toString(), openidResp, discovered); - - verification.getVerifiedId(); - - Message authResponse = verification.getAuthResponse(); - - if (!(authResponse instanceof AuthSuccess)) - { - _logger.error("Negative auth response received; showing login view..."); - - model.put("message", "Negative authentication response received from the OpenID Provider."); - - return new ModelAndView(_loginView, model); - } - - Identifier verified = verification.getVerifiedId(); - String identifier; - - if (verified == null) - { - _logger.error("OpenID verification failed; showing login view..."); - - model.put("message", verification.getStatusMsg()); - - return new ModelAndView(_loginView, model); - } - else - { - identifier = verified.getIdentifier(); - } - - AuthSuccess authSuccess = (AuthSuccess) authResponse; - - FetchResponse fetchResp = null; - - Map attributes = new LinkedHashMap(); - - MessageExtension ext; - if ( authSuccess.hasExtension(AxMessage.OPENID_NS_AX) && - (ext = authSuccess.getExtension(AxMessage.OPENID_NS_AX)) instanceof FetchResponse) - { - fetchResp = (FetchResponse) ext; - - // extract the rest of the optional attributes - List aliases = fetchResp.getAttributeAliases(); - Map types = fetchResp.getAttributeTypes(); - String alias; - List values; - for (Object a : aliases) - { - alias = (String) a; - values = fetchResp.getAttributeValues(alias); - attributes.put(_attributes.get(types.get(alias)), - values.size() > 0 ? (String) values.get(0) : null); - } - } - - session.setAttribute(LOGGEDIN, ""); - - session.setAttribute("attributes", attributes); - - session.setAttribute("identifier", identifier); - session.setAttribute("message", fetchResp); - - _logger.info("AX success; showing home / data view..."); - - return new ModelAndView(_homeView, model); - } -} diff --git a/samples/demorp/www/META-INF/context.xml b/samples/demorp/www/META-INF/context.xml deleted file mode 100644 index a86bd8f5..00000000 --- a/samples/demorp/www/META-INF/context.xml +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/samples/demorp/www/WEB-INF/applicationContext.xml b/samples/demorp/www/WEB-INF/applicationContext.xml deleted file mode 100644 index b643e23d..00000000 --- a/samples/demorp/www/WEB-INF/applicationContext.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - classpath:config.defaults.properties - - - - - - - - classpath:config.properties - file:/www/sxweb/server/openidcards/icdemo/conf/config.properties - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/demorp/www/WEB-INF/classes/config.defaults.properties b/samples/demorp/www/WEB-INF/classes/config.defaults.properties deleted file mode 100644 index 83ceab85..00000000 --- a/samples/demorp/www/WEB-INF/classes/config.defaults.properties +++ /dev/null @@ -1,7 +0,0 @@ -# -# Copyright 2006-2008 Sxip Identity Corporation -# - -base.url=http://localhost:8080 -sts.url=https://openidcards.sxip.com/TokenService/ -ax.url=http://openid.net/specs/openid-attribute-exchange-1_0-07.html diff --git a/samples/demorp/www/WEB-INF/classes/log4j.properties b/samples/demorp/www/WEB-INF/classes/log4j.properties deleted file mode 100644 index b692975e..00000000 --- a/samples/demorp/www/WEB-INF/classes/log4j.properties +++ /dev/null @@ -1,106 +0,0 @@ -# -# Copyright 2006-2008 Sxip Identity Corporation -# - -################################################################ -# -# Sxip Access logging controls -# -################################################################ - -log4j.rootLogger=INFO, A1 -# INFO - log level, possible values: DEBUG, INFO, WARN, ERROR -# If DEBUG is used passwords will be dumped to log files! -# Do not use in production. -# A2 - general daily rolling file appender -# A3 - errors only file appender -# Add A1 to also log to console (and catalina.out) -# Add A4 to also log to syslog - -log4j.logger.org.openid4java=DEBUG, A2, A3 -log4j.logger.net.sxip=DEBUG, A2, A3 - -# A1 is set to be ConsoleAppender sending its output to System.out -log4j.appender.A1=org.apache.log4j.ConsoleAppender - -# A1 uses PatternLayout. -log4j.appender.A1.layout=org.apache.log4j.PatternLayout - -# The conversion pattern consists of date in ISO8601 format, level, -# thread name, logger name truncated to its rightmost two components -# and left justified to 17 characters, location information consisting -# of file name (padded to 13 characters) and line number, nested -# diagnostic context, the and the application supplied message - -log4j.appender.A1.layout.ConversionPattern=%d{yyyy-MM-dd'T'HH:mm:ss'Z'} %-5p %m CLASS:%C{2} %t %x %n - -################################################################ -# -# Send Errors, Warnings and Infos to an audit log -# -################################################################ - -# Appender A2 writes all messages to the file "sxip-tng.log". -# Define the location where the log file will be created. -# Ensure the directory already exists with appropriate -# write permissions. Refer to the "Troubleshooting" section -# of the Sxip Access documentation for further information about -# error messages. - -log4j.appender.A2=org.apache.log4j.DailyRollingFileAppender -log4j.appender.A2.DatePattern=yyMMdd'.log' -log4j.appender.A2.File=${catalina.home}/logs/openidcards.sxip.com_demorp.log - - -# Append to the log. -log4j.appender.A2.Append=true - -# Appender A2 uses the PatternLayout. -log4j.appender.A2.layout=org.apache.log4j.PatternLayout -log4j.appender.A2.layout.ConversionPattern=%d{yyyy-MM-dd'T'HH:mm:ss'Z'} %-5p %m CLASS:%C{2} %t %x %n - - -################################################################ -# -# Send Errors to an error log -# -################################################################ - -# Appender A3 writes "error" class messages to the file "sxip-tng-error.log". -# Define the location where the log file will be created. -# Ensure the directory already exists with appropriate -# write permissions. Refer to the "Troubleshooting" section -# of the Sxip Access documentation for further information about -# error messages. - -log4j.appender.A3=org.apache.log4j.DailyRollingFileAppender -log4j.appender.A3.DatePattern=yyMMdd'.log' -log4j.appender.A3.File=${catalina.home}/logs/openidcards.sxip.com_demorp_error.log - -# Append to the log. -log4j.appender.A3.Append=true - -log4j.appender.A3.threshold=ERROR - -# Appender A3 uses the PatternLayout. -log4j.appender.A3.layout=org.apache.log4j.PatternLayout -log4j.appender.A3.layout.ConversionPattern=%d{yyyy-MM-dd'T'HH:mm:ss'Z'} %-5p %m CLASS:%C{2} %t %x %n - - -################################################################ -# -# Send Errors to the SysLog -# -################################################################ - -# Appender A4 writes to the syslog. -log4j.appender.A4=org.apache.log4j.net.SyslogAppender - -log4j.appender.A4.threshold=ERROR -# Specify host name of the syslog service -log4j.appender.A4.SyslogHost=localhost - -# Appender A4 uses the PatternLayout. -log4j.appender.A4.layout=org.apache.log4j.PatternLayout -log4j.appender.A4.layout.ConversionPattern=%m CLASS:%C{2} %n - diff --git a/samples/demorp/www/WEB-INF/jsp/error.jsp b/samples/demorp/www/WEB-INF/jsp/error.jsp deleted file mode 100644 index be5d3830..00000000 --- a/samples/demorp/www/WEB-INF/jsp/error.jsp +++ /dev/null @@ -1,33 +0,0 @@ -<%-- - ~ Copyright 2006-2008 Sxip Identity Corporation - --%> - -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> - - - OpenID Error - - - -
- -

Whoops!

- -

- An error was encountered while processing the OpenID request. -
-

- -

- If you would like to help us troubleshoot the error, please - contact - us with details about the site you were trying to log into and - the time when this error occured. -
-

- - -
- - diff --git a/samples/demorp/www/WEB-INF/jsp/home.jsp b/samples/demorp/www/WEB-INF/jsp/home.jsp deleted file mode 100644 index 82a5f21e..00000000 --- a/samples/demorp/www/WEB-INF/jsp/home.jsp +++ /dev/null @@ -1,92 +0,0 @@ -<%-- - ~ Copyright 2006-2008 Sxip Identity Corporation - --%> - -<%@ page import="java.util.Calendar"%> - -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> -<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> - - - - - ${title} - - - - - - - -
- - -
-

Welcome! You have logged in using your ${identifier} OpenID identifier.

- - - - - - - - - - - - - - - - - - -
${parameter.key}:${parameter.value}
${parameter.key}:N/A
- - [Show / hide OpenID Assertion] - -
-${fn:escapeXml(openidAssertion)}
-        
- -
- - - - - - - -
${contents}
-
- - -
- - diff --git a/samples/demorp/www/WEB-INF/jsp/login.jsp b/samples/demorp/www/WEB-INF/jsp/login.jsp deleted file mode 100644 index ad30b5b6..00000000 --- a/samples/demorp/www/WEB-INF/jsp/login.jsp +++ /dev/null @@ -1,163 +0,0 @@ -<%-- - ~ Copyright 2006-2008 Sxip Identity Corporation - --%> - -<%@ page import="java.util.Calendar"%> - -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> - - - - - ${title} - - - - -
- - -
- -
-

- -

-
-
- -
-

- - -

-
- -
- -
- - - - - -
- - - -
-
- -<%-- -
- - - - - - - - -
---%> - -
- - -

Login with an OpenID-InfoCard:

- - - - - - - -
- -
- - -
-

- -

-
-
- -
- - - -
- - - diff --git a/samples/demorp/www/WEB-INF/jsp/post.jsp b/samples/demorp/www/WEB-INF/jsp/post.jsp deleted file mode 100644 index 1a3d0b86..00000000 --- a/samples/demorp/www/WEB-INF/jsp/post.jsp +++ /dev/null @@ -1,22 +0,0 @@ -<%-- - ~ Copyright 2006-2008 Sxip Identity Corporation - --%> - - -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> - -${title} - -
- - - - -
- - diff --git a/samples/demorp/www/WEB-INF/springController-servlet.xml b/samples/demorp/www/WEB-INF/springController-servlet.xml deleted file mode 100644 index c198b029..00000000 --- a/samples/demorp/www/WEB-INF/springController-servlet.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - classpath:config.defaults.properties - - - - - - - - classpath:config.properties - file:/www/sxweb/server/openidcards/icdemo/conf/config.properties - - - - - - - - - - - /index.jsp=indexController - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/demorp/www/WEB-INF/web.xml b/samples/demorp/www/WEB-INF/web.xml deleted file mode 100644 index 8dd417a8..00000000 --- a/samples/demorp/www/WEB-INF/web.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - OpenID InfoCards Demo - - - org.springframework.web.context.ContextLoaderListener - - - - springController - org.springframework.web.servlet.DispatcherServlet - 2 - - - - springController - /index.jsp - - - diff --git a/samples/demorp/www/images/infocard.png b/samples/demorp/www/images/infocard.png deleted file mode 100644 index 6dba25fb..00000000 Binary files a/samples/demorp/www/images/infocard.png and /dev/null differ diff --git a/samples/demorp/www/images/login_openid_bg.gif b/samples/demorp/www/images/login_openid_bg.gif deleted file mode 100644 index cde836c8..00000000 Binary files a/samples/demorp/www/images/login_openid_bg.gif and /dev/null differ diff --git a/samples/demorp/www/images/logo.gif b/samples/demorp/www/images/logo.gif deleted file mode 100644 index 7c4f2608..00000000 Binary files a/samples/demorp/www/images/logo.gif and /dev/null differ diff --git a/samples/demorp/www/images/openid_infocard.png b/samples/demorp/www/images/openid_infocard.png deleted file mode 100644 index 1f641576..00000000 Binary files a/samples/demorp/www/images/openid_infocard.png and /dev/null differ diff --git a/samples/demorp/www/images/openid_information_cards_demo.png b/samples/demorp/www/images/openid_information_cards_demo.png deleted file mode 100644 index 73730108..00000000 Binary files a/samples/demorp/www/images/openid_information_cards_demo.png and /dev/null differ diff --git a/samples/demorp/www/style.css b/samples/demorp/www/style.css deleted file mode 100644 index 52d4b0c4..00000000 --- a/samples/demorp/www/style.css +++ /dev/null @@ -1,991 +0,0 @@ -/* - * Copyright 2006-2008 Sxip Identity Corporation - */ - -@import 'legacy.css'; - - -body, html { -/* background: url(newwebsite.png) #fff center top no-repeat; */ - font-family: "verdana", "arial", "bitstream vera sans", sans; - margin: 0; - font-size: 11px; - padding: 0; - color: #434343; -} - -p { - color: #434343; - font-weight: normal; - padding-bottom: 5px; - line-height: 16px; -} - -a{ - text-decoration: none;} - -a img { - border: 0; -} - -a { - color: #00209f; - text-decoration: underline; -} - -h4 { -margin: 10px 0 3px 0; -} - -table, tr, td{ - font-size: 11px; - vertical-align: top; -} - -td { - padding-bottom: 15px; - padding-left: 15px; -} - -table li { - padding: 2px; -} - -table h3 { - font-size: 1em; - text-align: right; - padding: 0; - margin: 0; - padding-left: 5px; -} - -table p { - padding: 0 !important; - margin: 0; -} - -pre { - font-size: 11px; -} - -#wrapper{ - width: 750px; - margin-left: auto; - margin-right: auto; -} - -#header { - border-bottom: solid 1px #c0c0c0; - background-color: #fff; - margin-top: 15px; - padding-bottom: 15px; -} - -#header img{ - border: 0; -} - -#header h1{display: none;} - -#header h2{ - margin: 0px; - margin-top: -20px; - padding: 0px; - color: #00209f; - text-align: right; - font-size: 18px; - font-weight: 500; - font-family: sans-serif; -} - -#navigation { - float: left; - width: 140px; - padding-top: 5px; - margin-left: 5px; -} - - -#navigation h3{ - font-size: 12px; - color: #363636; - margin: 0; - padding: 0; - margin-top: 11px; - margin-bottom: 4px; - font-weight: 700; - font-size: 11px; -} - - -#navigation ul { - margin: 0; - padding: 0; - padding-left: 2px; - text-indent: 0px; - color: #00209f; - font-weight: normal; -} - -#navigation li { - padding: 1px 0; - list-style: none; -} - -#navigation li a { - margin-left: 0px; - text-indent: 0px; - padding-left: 10px; - background: url(/themes/sxip.com/icons/arrow.png) no-repeat 0 3px; -} - - -#navigation ul ul li a{ - background: url(/themes/sxip.com/icons/arrow2.png) no-repeat 1px 3px !important; -} - -#navigation li.phone { - padding-left: 10px; - background: url(/themes/sxip.com/icons/phone.png) no-repeat -1px 4px !important; - } - -#navigation li.email a { - background: url(/themes/sxip.com/icons/mail.png) no-repeat -1px 1px !important; - } - -#navigation a.current { - background: url(/themes/sxip.com/icons/arrowfill.png) no-repeat 0 3px; - font-weight: bold; - } - -#navigation a:hover { - background: url(/themes/sxip.com/icons/arrowfill.png) no-repeat 0 3px; - font-weight: bold; - } - -#navigation ul ul li a.current { - background: url(/themes/sxip.com/icons/arrow2fill.png) no-repeat 1px 3px !important; -} - -#navigation ul ul li a:hover { - background: url(/themes/sxip.com/icons/arrow2fill.png) no-repeat 1px 3px !important; -} - -.feedbuttons { - margin: 20px 10px ; -} - - -/* blogmenu */ - - -#blogmenu { - width: 130px; - margin: 0; - padding: 0; - float: right; - border-left: solid 1px #919191; - margin-left: 25px; - padding-top: 0px; - line-height: 1.3em; - padding-left: 0px; - padding-bottom: 50px; -} -#blogmenu a{ - text-decoration: none; -} - -#blogmenu h4 { - padding-left: 20px; - margin: 10px 0; - color: #df008f; - font-weight: bold; - font-size: 14px; -} -#blogmenu ul { -} - -#blogmenu li { - list-style: none; -} - -#blogmenu img{ - margin-bottom: 10px; -} - -#content { - /*margin-left: 140px;*/ - /*padding-left: 20px;*/ - padding-top: 15px; - /*padding-bottom: 30px;*/ -} - -#content h1 { - color: #363636; - margin: 0; - padding: 0 0 10px 0; - font-size: 1.8em; -} - -#content h2 { - color: #363636; - margin: 0; - padding: 0; -} - -#content h2 span { - font-size: 12px; - font-weight: 200; -} - -#content p { - margin: 0; - line-height: 1.7; -} - -#infocardSupport p { - border: solid 1px #fff32a; - padding: 10px; - background: #fff79b; - margin-bottom: 14px; -} - -#content em { - color: #e50f9f; - font-weight: 700; - font-size: 11px; -} - -#content ul, #content li { - padding-bottom: 3px; - padding-left: 2px; - margin-left: 10px; - text-indent: 0; -} - -#intro { - padding-top: 20px; - margin-bottom: 20px; -} - -#intro p { - margin-bottom: 4px; - font-size: 120%; - /*color: #7e8083;*/ -} - -#intro h2 { - font-size: 24px; -} - -#summary { - margin-bottom: 35px; -} - -#summary h2 { - margin-bottom: -15px; - - font-size: 20px; -} - -#summary h3 { - margin: 0px; - margin-top: 25px; - font-size: 14px; - font-weight: bold; - color: #00209f; - line-height: 20px; -} - -#summary h3 span { - color: #4e4e4e; -} - -#summary p { - font-size: 11px; -} - - - -.blog { -} - -.blog h2{ - margin-bottom: -5px; -} - -.blog H3 { - font-weight: Bold; - font-size: 1.2em; - color: #00209f; - margin: 0; - padding: 0; - margin-top: 20px; -} - - -.blog H4{ - font-size: 10px; - font-weight: bold; - color: #999; - margin: 0; - padding: 0; -} - -.blog p{ - font-size: 12px; - line-height: 16px; - padding: 5px 0px 0px 0px; -} - -.blog li { -} - -div.arrowbar { -display: block; -height: 20px; - -} - -#comment_bar{ -border-top: solid 1px #ccc; -margin-top: 10px; -padding: 10px 0 0 0; -width: 420px; -} - -#comment_bar img { - -padding: 1px; -vertical-align: middle; -margin-right: 5px; -} - -#comment_bar a { - -} -#comment_bar ul{ -margin: 0; -padding: 0; -} -#comment_bar li { -margin: 0; -padding: 0; -list-style: none; -display: inline; -padding-right: 10px; -} - -#body { - font-size: 14px; - color: #818284; - padding-top: 15px; - padding-bottom: 15px; -} - -#body p { - /*color: #818284;*/ -} - -#body a { - color: #3fc1f3; -} - -#body ul { - -} - -#body li { - /*color: #818284; */ -} - -#footnote { - margin-top: 50px; - clear: both; - color: #818284; - font-size: 12px; - padding: 0; - text-indent: 0; -} - -#footnote p { - color: #818284; -} - -/*--------------- -footer ----------------*/ - -#footer{ -margin-top: 50px; -clear: both; -border-top: solid 1px #c0c0c0; -color: #666; -font-size: 12px; -} - - -#footer ul { -float: right; -margin: 0; -padding: 0; -text-indent: 0; -} - -#footer ul li{ -display: inline; -margin: 0; -padding: 0; -text-indent: 0; -margin-left: 10px; -} - -#footer a{ -color: #666; -text-decoration: none; -} - -#footer a:hover { -text-decoration: underline; -} - -footer p { -margin: 0; -padding: 0; -text-indent: 0; -} - -#footer_legal{ -float: left; -} - -.right{ - float: right; -} - -.contacts { - margin-top: 20px; -} - -.contacts h3 { -} - -.contacts ul { - padding-bottom: 5px !important; -} - -.linkbox { - margin-top: 0; - margin-left: 15px; - float: right; -} - -.linkbox img { - border: none; -} - -.linkbox h3 { - -} - -.linkbox p { - -} - -.linkbox ul { - font-size: 11px; - font-weight: normal; -} - - -.linkbox ul { - margin: 0; - padding: 0; - padding-left: 2px; - text-indent: 0px; - color: #00209f; - font-weight: normal; -} - -.linkbox li { - padding: 1px 0; - list-style: none; -} - -.linkbox li a { - margin-left: 0px; - text-indent: 0px; - padding-left: 10px; - background: url(/themes/sxip.com/icons/arrow.png) no-repeat 0 3px; -} - - -.linkbox ul ul li a{ - background: url(/themes/sxip.com/icons/arrow2.png) no-repeat 1px 3px !important; -} - -.linkbox li.phone { - - padding-left: 12px !important; - background: url(/themes/sxip.com/icons/phone.png) no-repeat 0px 4px !important; - } - -.linkbox li.email a { - background: url(/themes/sxip.com/icons/mail.png) no-repeat -1px 1px !important; - } - - -.linkbox ul ul li a.current { - background: url(/themes/sxip.com/icons/arrow2fill.png) no-repeat 1px 3px !important; -} - -.linkbox ul ul li a:hover { - background: url(/themes/sxip.com/icons/arrow2fill.png) no-repeat 1px 3px !important; -} - - -.linkbox img { - font-size: 30px; - letter-spacing: -5px; - font-weight: bold; - color: #fff; - text-indent: -10px; - } - -.gw form{ - padding:15px; - padding-top: 20px; - background-color: #eee; - width: 480px; - margin-right: auto; - margin-left: auto; - margin-bottom: 20px; -} - -.gw form h3{ - margin: 0; - padding: 0; -} - -.gw h3 { - margin-top: 25px; -} - -.gw h1 { - color: #f90; - font-size: 14px; -} - -.gw h2{ - margin-top: 25px; - margin-bottom: 10px; - font-size: 16px; - font-weight: 100; -} - -.gw h4{ - margin: 5px 0px 5px 0px;} - -.gw ul{ - margin: 15px; -} - -.gw li{ - color: #ff9900; -} - - -.gw dl{ - padding: 15px; - width: 400px; - margin-left: auto; - margin-right: auto; -} - -.gw dt{ - font-weight: bolder; - margin: 5px; - } - -.gw dd{ - margin-bottom: 10px; - -} - -.gw .notice { - padding: 20px; - width: 500px; - margin-left: auto; - margin-right: auto; - font-weight: bolder; - background-color: #edd; - -} - -.gw p{ - margin-top: 5px; - margin-left: 5px; -} - -.gw strong{ - color: #ff9900; -} - -.xml { - border: 1px solid; - border-color:#FC9 #630 #330 #F96; - padding:0 3px; - font:600 10px lucida,verdana,sans-serif; - color:#FFF !important; - background:#F60; - text-decoration: none !important; - margin:0; -} - - -.orange { - color: #e50f9f; - -} - -/* team page */ - - -#team img { - border: solid 1px #5a5a5a; - margin: 0 15px 5px 0; - float: left; -} - -#team em { - font-style: normal; - font-size: 1.1em; - } - -#team p{ - margin-bottom: 5px; -} - -/* careers page */ - -.jobs { - margin-left: 10px; -} - -.jobs h3 { - font-size: 1.8em; - color: #df008f; - font-weight: normal; - border-top: solid 1px #919191; - padding-top: 10px; -} - - -/* careers page */ - -#relocate { - float: right; - width: 200px; - border: Solid 1px #919191; - background: url(/themes/sxip.com/images/relocate_bgnd.png) #fafafa no-repeat; - padding: 5px; - margin-left: 10px; -} - -#relocate h3 { - margin-top: 50px; - text-align: center; -} - -#relocate p { - line-height: 12px; -} - -#relocate li { - list-style: none; - padding: 2px; - margin: 0; - text-indent: 0; -} - -#relocate li ul li { - margin-left: 4em; -} - - - - - -/* endorsements page */ - -.endorsement { - padding-bottom: 5px; - border-bottom: solid 1px #eee; - margin-bottom: 15px; -} - -.sig { - padding-top: 3px; - padding-left: 10px; -} - -.sig p{ - color: #919191; -} -.sig p a{ - color: #919191; -} - -.copyright { - color: #919191; - font-size: 0.9em; -} -/* glossary page */ - -#glossary h3 { - font-size: 1.8em; - color: #df008f; - font-weight: normal; - border-top: solid 1px #919191; - padding-top: 15px; - padding-left: 5px; -} - - -/* general */ - -/* these are for the breadcrumbs */ -.section-title{ - color: #333; -} - - - -.more a { - color: #df008f; - padding: 0; - margin: 0; - } - - -.more p { - color: #df008f; - padding: 0 !important; - margin: 0 !important; - } - - div.map { - width: 20em; - } - - - pre { font-family: "Verdana", sans, sans-serif; - - } - - -#image-gallery h3{ - width: 600px; - display: block; - border-bottom: solid 2px #cccccc; - padding-bottom: 5px - -} - - - -#image-gallery .section { - - margin-bottom: 15px; -} - - - -#image-gallery a dl { - float: left; - text-align: center; - width: 100px; - height: 100px; - padding: 4px; - margin: 0px 2px; - background-color: #fff; - border: solid 1px #ccc; - } - -#image-gallery a dl:hover{ - border: solid 1px red; -} - -#image-gallery dt { - background-color: #fff; - height: 65px; -} - -#image-gallery .section dd { - background-color: #eee; - border: 0; - padding: 2px; - margin: 0; - vertical-align: bottom; - text-indent: 0; -} - -#image-gallery .section h3 { - padding-top: 15px; - padding-left: 10px; -} - - -#image-gallery .sectiontwo dl { - float: left; - width: 325px; - height: 100px; - padding: 4px; - margin: 5px 5px; - background-color: #fff; - border: solid 1px #ccc; - text-align: left; - } - -#image-gallery .sectiontwo dt { - float: left; - padding-top: 15px; - padding-left: 10px; - height: 70px; -} - -#image-gallery .sectiontwo a dd { - padding: 2px; - margin: 2px 0; - margin-left: 200px; - background-color: #eee; - text-indent: 0; -} - -#image-gallery .sectiontwo a:hover dd { - background-color: #ddd; -} - -#image-gallery .sectiontwo .section h3 { - padding-top: 15px; - padding-left: 10px; -} -#image-gallery .section { - border: 0 ; - width: 550px; - float: left; -} - -#image-gallery .sectiontwo { - border: 0 ; - width: 550px; - float: left; -} - -#callout{ - font-size: 14px; - margin-top: 10px; - background-color: #ACDEF4; - padding: 5px 5px 5px 10px; -} - -#calloutsuccess{ - font-size: 14px; - margin-top: 10px; - color: #ffffff; - background-color: #7AC142; - padding: 5px 5px 5px 10px; -} - -#calloutfailure{ - font-size: 14px; - margin-top: 10px; - color: #ffffff; - background-color: #E73E97; - padding: 5px 5px 5px 10px; -} - -#nymenable a { - color: #7AC142; -} - -#nymdisable a { - color: #E73E97; -} - - -dl.dark { - - background-color: #2a2a2a !important; -} - -dl.dark dt { - background-color: #2a2a2a !important; -} - -dl.dark a dd { - background-color: #e83f98 !important; - color: #fff; - -} - -dl.dark dd { - background-color: #e83f98 !important; - color: #fff; - -} - - -.demo h4{ -padding: 0; -margin: 0; -} - - -.demo ul { - margin: 0; - padding: 0; - padding-left: 2px; - text-indent: 0px; - color: #00209f; - font-weight: normal; -} - -.demo li { - padding: 1px 0; - list-style: none; -} - -.demo li a { -margin-left: 0px; - text-indent: 0px; - padding-left: 10px; - background: url(/themes/sxip.com/icons/arrow.png) no-repeat 0 3px; -} - - -.demo ul ul li a{ - background: url(/themes/sxip.com/icons/arrow2.png) no-repeat 1px 3px !important; -} - -.demo li.phone { - - padding-left: 12px !important; - background: url(/themes/sxip.com/icons/phone.png) no-repeat 0px 4px !important; - } - -.demo li.email a { - background: url(/themes/sxip.com/icons/mail.png) no-repeat -1px 1px !important; - } - - -.demo ul ul li a.current { - background: url(/themes/sxip.com/icons/arrow2fill.png) no-repeat 1px 3px !important; -} - -.demo ul ul li a:hover { - background: url(/themes/sxip.com/icons/arrow2fill.png) no-repeat 1px 3px !important; -} - - - diff --git a/samples/formredirection/formredirection.jsp b/samples/formredirection/formredirection.jsp deleted file mode 100644 index 8631f140..00000000 --- a/samples/formredirection/formredirection.jsp +++ /dev/null @@ -1,20 +0,0 @@ -<%-- - ~ Copyright 2006-2008 Sxip Identity Corporation - --%> - - -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> - - - OpenID HTML FORM Redirection - - -
- - - - -
- - diff --git a/samples/infocardop/INSTALL b/samples/infocardop/INSTALL deleted file mode 100644 index d449fdb8..00000000 --- a/samples/infocardop/INSTALL +++ /dev/null @@ -1,66 +0,0 @@ -... OpenID Infocards / Infocard-OP : INSTALL - -======================================================================== - -INSTALLATION AND CONFIGURATION INSTRUCTIONS - - -Introduction: - -This document describes how to install, configure and use the Infocard -OpenID Provider, a stripped-down version of an OpenID Provider. - -Used together with an STS that can issue RSTRs with OpenID tokens -(as specified by OpenID Infocards 1.0), this OP module only handles -direct OpenID verification requests (openid.mode=check_authentication). - -For general information about the OpenID Infocards package please see the -README document in the package root folder. - - -Configuration: - - 1. SQL/JDBC - - a) A JDBC Connector library installed into your application server: - - MySQL and Tomcat example: - http://dev.mysql.com/downloads/connector/j/ - mysql-connector-java-*.jar installed in CATALINA_HOME/common/lib/ - - b) Database with one table for storing OpenID private associations, - with the following schema: - - CREATE TABLE `private_assoc` ( - `handle` varchar(255) NOT NULL, - `type` varchar(255) NOT NULL, - `mackey` varchar(255) NOT NULL, - `expdate` datetime NOT NULL, - PRIMARY KEY (`handle`) - ) ENGINE=MyISAM DEFAULT CHARSET=latin1 - - This database needs to be shared with the 'higgins-sts' webapp. - - c) Application server configured with a JDBC data source - with the following JNDI name: - - java:comp/env/jdbc/infocardop - - Tomcat example: - infocardop/project/www/META-INF/context.xml - - - - -Build and Installation: - - In the project/ folder, run - - ant - - This will create deployable dist/infocardop.war file. diff --git a/samples/infocardop/InfocardOP.iml b/samples/infocardop/InfocardOP.iml deleted file mode 100644 index 5d3c7555..00000000 --- a/samples/infocardop/InfocardOP.iml +++ /dev/null @@ -1,373 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - jar://$MODULE_DIR$/project/lib/commons-codec-1.3.jar!/ - - - - - jar://$MODULE_DIR$/project/lib/commons-httpclient-3.0.1.jar!/ - - - - - jar://$MODULE_DIR$/project/lib/commons-logging-1.03.jar!/ - - - - - jar://$MODULE_DIR$/project/lib/htmlparser.jar!/ - - - - - jar://$MODULE_DIR$/project/lib/java-openid-sxip.jar!/ - - - - - jar://$MODULE_DIR$/project/lib/jstl.jar!/ - - - - - jar://$MODULE_DIR$/project/lib/log4j-1.2.8.jar!/ - - - - - jar://$MODULE_DIR$/project/lib/openxri-client.jar!/ - - - - - jar://$MODULE_DIR$/project/lib/openxri-syntax.jar!/ - - - - - jar://$MODULE_DIR$/project/lib/spring.jar!/ - - - - - jar://$MODULE_DIR$/project/lib/standard.jar!/ - - - - - jar://$MODULE_DIR$/project/libext/servlet-api.jar!/ - - - - - jar://$MODULE_DIR$/project/libext/svnant.jar!/ - - - - - jar://$MODULE_DIR$/project/libext/svnClientAdapter.jar!/ - - - - - jar://$MODULE_DIR$/project/libext/svnjavahl.jar!/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/infocardop/InfocardOP.ipr b/samples/infocardop/InfocardOP.ipr deleted file mode 100644 index 40801c48..00000000 --- a/samples/infocardop/InfocardOP.ipr +++ /dev/null @@ -1,307 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/infocardop/conf/config.properties-demo b/samples/infocardop/conf/config.properties-demo deleted file mode 100644 index c5c34144..00000000 --- a/samples/infocardop/conf/config.properties-demo +++ /dev/null @@ -1,2 +0,0 @@ -database.jndi=java:comp/env/jdbc/infocardop -private.assoc.table=private_assoc diff --git a/samples/infocardop/conf/config.properties-ivb b/samples/infocardop/conf/config.properties-ivb deleted file mode 100644 index f57a8a2c..00000000 --- a/samples/infocardop/conf/config.properties-ivb +++ /dev/null @@ -1,2 +0,0 @@ -database.jndi=java:comp/env/jdbc/infocardop_local -private.assoc.table=private_assoc diff --git a/samples/infocardop/project/build.xml b/samples/infocardop/project/build.xml deleted file mode 100644 index a81be64a..00000000 --- a/samples/infocardop/project/build.xml +++ /dev/null @@ -1,342 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Last Changed Rev (local): : ${svn.rev.local} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Copyright © 2006-2008 Sxip Identity Corp. All Rights Reserved.]]> - - - - - - - - - - - - - - - - - - Tomcat home directory: ${tomcat.home.dir} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/infocardop/project/lib/jstl.jar b/samples/infocardop/project/lib/jstl.jar deleted file mode 100644 index a02abecc..00000000 Binary files a/samples/infocardop/project/lib/jstl.jar and /dev/null differ diff --git a/samples/infocardop/project/lib/spring-context-2.0.jar b/samples/infocardop/project/lib/spring-context-2.0.jar deleted file mode 100644 index 9a1ca559..00000000 Binary files a/samples/infocardop/project/lib/spring-context-2.0.jar and /dev/null differ diff --git a/samples/infocardop/project/lib/spring-web-2.0.jar b/samples/infocardop/project/lib/spring-web-2.0.jar deleted file mode 100644 index 7cb2e43b..00000000 Binary files a/samples/infocardop/project/lib/spring-web-2.0.jar and /dev/null differ diff --git a/samples/infocardop/project/lib/spring-webmvc-2.0.jar b/samples/infocardop/project/lib/spring-webmvc-2.0.jar deleted file mode 100644 index 24ca4c6d..00000000 Binary files a/samples/infocardop/project/lib/spring-webmvc-2.0.jar and /dev/null differ diff --git a/samples/infocardop/project/lib/standard.jar b/samples/infocardop/project/lib/standard.jar deleted file mode 100644 index bc528acb..00000000 Binary files a/samples/infocardop/project/lib/standard.jar and /dev/null differ diff --git a/samples/infocardop/project/project.properties b/samples/infocardop/project/project.properties deleted file mode 100644 index 078edb41..00000000 --- a/samples/infocardop/project/project.properties +++ /dev/null @@ -1,16 +0,0 @@ -# -# Copyright 2006-2008 Sxip Identity Corporation -# - -component.name=infocardop - -compile.debug=yes -compile.debuglevel=source,lines,vars -compile.optimize=off -compile.deprecation=off -compile.target=1.5 -compile.source=${compile.target} - -openid4java.dir=../../.. -openid4java.lib.dir=${openid4java.dir}/lib - diff --git a/samples/infocardop/project/src/net/sxip/openidcards/infocardop/web/InfocardOPController.java b/samples/infocardop/project/src/net/sxip/openidcards/infocardop/web/InfocardOPController.java deleted file mode 100644 index 0b7b4be8..00000000 --- a/samples/infocardop/project/src/net/sxip/openidcards/infocardop/web/InfocardOPController.java +++ /dev/null @@ -1,141 +0,0 @@ -package net.sxip.openidcards.infocardop.web; - -import org.springframework.web.servlet.mvc.AbstractController; -import org.springframework.web.servlet.ModelAndView; -import org.apache.log4j.Logger; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.ServletOutputStream; - -import java.io.IOException; - -import org.openid4java.server.ServerManager; -import org.openid4java.server.ServerException; -import org.openid4java.message.*; -import org.openid4java.OpenIDException; - -public class InfocardOPController extends AbstractController -{ - private static Logger _log = Logger.getLogger(InfocardOPController.class); - private static final boolean DEBUG = _log.isDebugEnabled(); - - private String _openidErrorView; - - private ServerManager _manager; - - public void setOpenidErrorView(String openidErrorView) - { - this._openidErrorView = openidErrorView; - } - - public void setServerManager(ServerManager manger) - { - this._manager = manger; - } - - public ServerManager getManager() - { - return _manager; - } - - protected ModelAndView handleRequestInternal( - HttpServletRequest httpReq, - HttpServletResponse httpResp) - { - if ("GET".equals(httpReq.getMethod())) - return new ModelAndView(_openidErrorView); - - // extract the parameters from the requestParams - ParameterList requestParams = new ParameterList(httpReq.getParameterMap()); - - String mode = requestParams.getParameterValue("openid.mode"); - boolean compat = ! requestParams.hasParameter("openid.ns"); - - try - { - if ("check_authentication".equals(mode)) - return handleVerifyReq(httpReq, httpResp, requestParams); - - else - return handleUnknownReq(httpReq, httpResp); - } - catch (OpenIDException e) - { - _log.error("Error handling OpenID request: ", e); - - return directError(httpResp, e.getMessage(), compat); - } - } - - - private ModelAndView handleVerifyReq(HttpServletRequest httpReq, - HttpServletResponse httpResp, - ParameterList requestParams) - throws ServerException - { - // --- processing a verification requestParams --- - Message response = _manager.verify(requestParams); - String responseText = response.keyValueFormEncoding(); - - _log.info("Processed direct verification request from: " - + httpReq.getRemoteAddr()); - - return directResponse(httpResp, responseText); - } - - private ModelAndView handleUnknownReq(HttpServletRequest httpReq, - HttpServletResponse httpResp) - throws ServerException - { - // --- error response --- - Message response = DirectError.createDirectError("Unknown requestParams"); - String responseText = response.keyValueFormEncoding(); - - _log.error("Sending direct error response to " - + httpReq.getRemoteAddr()); - - return directResponse(httpResp, responseText); - } - - - private ModelAndView directResponse(HttpServletResponse httpResp, String response) - throws ServerException - { - if (DEBUG) _log.debug("Sending direct response:\n" + response); - - try - { - ServletOutputStream os = httpResp.getOutputStream(); - os.write(response.getBytes()); - os.close(); - } - catch (IOException e) - { - throw new ServerException("Error generating direct verification response", e); - } - - return null; - } - - private ModelAndView directError(HttpServletResponse httpResp, - String response, boolean compat) - { - if (DEBUG) _log.debug("Sending direct response:\n" + response); - - try - { - DirectError err = DirectError.createDirectError(response, compat); - - ServletOutputStream os = httpResp.getOutputStream(); - os.write(err.keyValueFormEncoding().getBytes()); - os.close(); - } - catch (IOException e) - { - _log.error("Error generating direct error response", e); - } - - return null; - } -} diff --git a/samples/infocardop/project/www/META-INF/context.xml b/samples/infocardop/project/www/META-INF/context.xml deleted file mode 100644 index 9ae49447..00000000 --- a/samples/infocardop/project/www/META-INF/context.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - diff --git a/samples/infocardop/project/www/WEB-INF/InfocardOPController-servlet.xml b/samples/infocardop/project/www/WEB-INF/InfocardOPController-servlet.xml deleted file mode 100644 index 96871683..00000000 --- a/samples/infocardop/project/www/WEB-INF/InfocardOPController-servlet.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - classpath:config.defaults.properties - - - - - - - - classpath:config.properties - file:/www/sxweb/server/openidcards/infocardop/conf/config.properties - - - - - - - - - - - /*=InfocardOPController - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/infocardop/project/www/WEB-INF/applicationContext.xml b/samples/infocardop/project/www/WEB-INF/applicationContext.xml deleted file mode 100644 index 86f5a9d9..00000000 --- a/samples/infocardop/project/www/WEB-INF/applicationContext.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - classpath:config.defaults.properties - - - - - - - - classpath:config.properties - file:/www/sxweb/server/openidcards/infocardop/conf/config.properties - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/infocardop/project/www/WEB-INF/classes/config.defaults.properties b/samples/infocardop/project/www/WEB-INF/classes/config.defaults.properties deleted file mode 100644 index 4e9b178a..00000000 --- a/samples/infocardop/project/www/WEB-INF/classes/config.defaults.properties +++ /dev/null @@ -1,8 +0,0 @@ -# -# Copyright 2006-2008 Sxip Identity Corporation -# - -database.jndi=java:comp/env/jdbc/infocardop - -private.assoc.table=private_assoc - diff --git a/samples/infocardop/project/www/WEB-INF/classes/log4j.properties b/samples/infocardop/project/www/WEB-INF/classes/log4j.properties deleted file mode 100644 index 82061ba7..00000000 --- a/samples/infocardop/project/www/WEB-INF/classes/log4j.properties +++ /dev/null @@ -1,102 +0,0 @@ -# -# Copyright 2006-2008 Sxip Identity Corporation -# - -################################################################ -# -# Logging controls -# -################################################################ - -log4j.rootLogger=INFO, A1 -# INFO - log level, possible values: DEBUG, INFO, WARN, ERROR -# If DEBUG is used passwords will be dumped to log files! -# Do not use in production. -# A2 - general daily rolling file appender -# A3 - errors only file appender -# Add A1 to also log to console (and catalina.out) -# Add A4 to also log to syslog - -log4j.logger.org.openid4java=DEBUG, A2, A3 -log4j.logger.net.sxip=DEBUG, A2, A3 - -# A1 is set to be ConsoleAppender sending its output to System.out -log4j.appender.A1=org.apache.log4j.ConsoleAppender - -# A1 uses PatternLayout. -log4j.appender.A1.layout=org.apache.log4j.PatternLayout - -# The conversion pattern consists of date in ISO8601 format, level, -# thread name, logger name truncated to its rightmost two components -# and left justified to 17 characters, location information consisting -# of file name (padded to 13 characters) and line number, nested -# diagnostic context, the and the application supplied message - -log4j.appender.A1.layout.ConversionPattern=%d{yyyy-MM-dd'T'HH:mm:ss'Z'} %-5p %m CLASS:%C{2} %t %x %n - -################################################################ -# -# Send Errors, Warnings and Infos to an audit log -# -################################################################ - -# Appender A2 writes all messages to a file. -# Define the location where the log file will be created. -# Ensure the directory already exists with appropriate -# write permissions. - -log4j.appender.A2=org.apache.log4j.DailyRollingFileAppender -log4j.appender.A2.DatePattern='.'yyyy'-'MM'-'dd -log4j.appender.A2.File=${catalina.home}/logs/openidcards.sxip.com_op_debug_log - - -# Append to the log. -log4j.appender.A2.Append=true - -# Appender A2 uses the PatternLayout. -log4j.appender.A2.layout=org.apache.log4j.PatternLayout -log4j.appender.A2.layout.ConversionPattern=%d{yyyy-MM-dd'T'HH:mm:ss'Z'} %-5p %m CLASS:%C{2} %t %x %n - - -################################################################ -# -# Send Errors to an error log -# -################################################################ - -# Appender A3 writes "error" class messages to a file. -# Define the location where the log file will be created. -# Ensure the directory already exists with appropriate -# write permissions. - -log4j.appender.A3=org.apache.log4j.DailyRollingFileAppender -log4j.appender.A3.DatePattern='.'yyyy'-'MM'-'dd -log4j.appender.A3.File=${catalina.home}/logs/openidcards.sxip.com_op_error_log - -# Append to the log. -log4j.appender.A3.Append=true - -log4j.appender.A3.threshold=ERROR - -# Appender A3 uses the PatternLayout. -log4j.appender.A3.layout=org.apache.log4j.PatternLayout -log4j.appender.A3.layout.ConversionPattern=%d{yyyy-MM-dd'T'HH:mm:ss'Z'} %-5p %m CLASS:%C{2} %t %x %n - - -################################################################ -# -# Send Errors to the SysLog -# -################################################################ - -# Appender A4 writes to the syslog. -log4j.appender.A4=org.apache.log4j.net.SyslogAppender - -log4j.appender.A4.threshold=ERROR -# Specify host name of the syslog service -log4j.appender.A4.SyslogHost=localhost - -# Appender A4 uses the PatternLayout. -log4j.appender.A4.layout=org.apache.log4j.PatternLayout -log4j.appender.A4.layout.ConversionPattern=%m CLASS:%C{2} %n - diff --git a/samples/infocardop/project/www/WEB-INF/jsp/openiderror.jsp b/samples/infocardop/project/www/WEB-INF/jsp/openiderror.jsp deleted file mode 100644 index 3b40dbf8..00000000 --- a/samples/infocardop/project/www/WEB-INF/jsp/openiderror.jsp +++ /dev/null @@ -1,27 +0,0 @@ -<%-- - ~ Copyright 2006-2008 Sxip Identity Corporation - --%> - -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> - - - OpenID Error - - - -
- - -

Whoops!

- -

- An error was encountered while processing the OpenID request: -
- Expected a POST HTTP request but received a HTTP GET. -

- -
- - diff --git a/samples/infocardop/project/www/WEB-INF/web.xml b/samples/infocardop/project/www/WEB-INF/web.xml deleted file mode 100644 index 0f7d41b5..00000000 --- a/samples/infocardop/project/www/WEB-INF/web.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - Infocard OpenID Provider - - - org.springframework.web.context.ContextLoaderListener - - - - InfocardOPController - org.springframework.web.servlet.DispatcherServlet - 2 - - - - - InfocardOPController - /index.jsp - - - - DB Connection - jdbc/infocardop_local - javax.sql.DataSource - Container - - - \ No newline at end of file diff --git a/samples/infocardop/project/www/images/login_openid_bg.gif b/samples/infocardop/project/www/images/login_openid_bg.gif deleted file mode 100644 index cde836c8..00000000 Binary files a/samples/infocardop/project/www/images/login_openid_bg.gif and /dev/null differ diff --git a/samples/infocardop/project/www/images/trans-1.gif b/samples/infocardop/project/www/images/trans-1.gif deleted file mode 100644 index 4d1c7d84..00000000 Binary files a/samples/infocardop/project/www/images/trans-1.gif and /dev/null differ diff --git a/samples/infocardop/project/www/style.css b/samples/infocardop/project/www/style.css deleted file mode 100644 index 278dc8d7..00000000 --- a/samples/infocardop/project/www/style.css +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2006-2008 Sxip Identity Corporation - */ - -body { - margin: 0; - padding: 0; - font-family: Verdana, Arial, "MS Trebuchet", sans-serif; - font-size: 14px; -} - -#wrapper { - width: 750px; - margin-left: auto; - margin-right: auto; -} - -#header { - border-bottom: solid 2px #c0c0c0; - margin-bottom: 20px; - height: 90px; - padding-top: 20px; -} - -#message { - border: solid 1px #fff32a; - padding: 10px; - background: #fff79b; - margin-bottom: 14px; -} - -#body { - margin-left: 150px; - margin-right: 150px; -} - -#footer { - border-top: solid 2px #c0c0c0; - margin-top: 20px; - padding-top: 30px; -} - -#footer p { - text-align: center; - color: #c0c0c0; - -} - -#contents { - margin-bottom: 15px; -} - -.form { - margin-top: 5px; -} - -.form input { - border: solid 1px #ccc; -} - -.left { - float: left; -} - -.right { - float: right; -} - -.footer-center { - clear: both; -} - -#footer a { - text-decoration: none; - color: #555; -} - -input.openid { - background: url( images/login_openid_bg.gif ) no-repeat; - background-color: #fff; - background-position: 0 50%; - color: #000; - padding-left: 18px; -} - diff --git a/samples/pom.xml b/samples/pom.xml index a9c082a7..29bceef1 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -1,41 +1,44 @@ - + 4.0.0 - org.openid4java + com.amarulasolutions openid4java-samples pom - 1.0.0 + 2.0.0 OpenID4Java Samples simple-openid consumer-servlet - - - org.apache.maven.plugins - maven-idea-plugin - - true - true - true - false - - - + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.13.0 + + 17 + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.5.2 + + + org.apache.maven.plugins + maven-war-plugin + 3.4.0 + + + - - - openid4java-snapshots - OpenID4Java Snapshot Repository - https://oss.sonatype.org/content/repositories/openid4java-snapshots/ - - - - org.openid4java + com.amarulasolutions openid4java ${project.version} diff --git a/samples/simple-openid/README.txt b/samples/simple-openid/README.txt index b62f06be..6b7e046d 100644 --- a/samples/simple-openid/README.txt +++ b/samples/simple-openid/README.txt @@ -1,80 +1,82 @@ +OpenID4Java Simple JSP Demo ************ INTRODUCTION ************ -This is a demo consumer and provider using only JSPs. It uses only -in-memory stores for nonces and associations, and the provider does -no user authentication, though it should be obvious in provider.jsp -how to do user authentication using standard web authentication -methods. +This is a demo consumer and provider implemented as JSPs. It uses only +in-memory stores for nonces and associations, and the provider does no +user authentication, though provider.jsp shows where user authentication +would go. -This demo *requires* apache Maven2 to build. +The index.jsp and consumer_*.jsp files comprise the consumer. +The provider_*.jsp files comprise the provider. +The user.jsp produces an XRDS file which points to the provider. -The index.jsp and consumer_*.jsp files comprise the consumer. +There are hardcoded URLs in the JSP files; a comment at the top indicates +what to change to deploy this somewhere other than +http://localhost:8080/simple-openid. -The provider_*.jsp files comprise the provider. +There are no dependencies between the consumer and the provider. -The user.jsp produces a XRDS file which points to the provider. +********** +REQUIREMENTS +********** -There are hardcoded URLs in each of the JSP files - a README at the -top indicates what you need to change to deploy this to other than -http://localhost:8080/simple-openid +JDK 17 or newer and Maven 3.9 or newer. -There are no dependencies between consumer and provider. +The demo uses Jakarta EE 10 (Jakarta Servlet 6.0, Jetty 12). -To install these JSPs in another project/jsp container, you should -make sure to see the pom.xml file which documents dependencies, -and note the xalan files which must go in an endorsed libs -directory (xercesImpl*.jar and xml-apis*.jar) - -The mvn war:war task should create a war file which can be deployed -by copying the war file - but this does not deploy the above mentioned -jars into an endorsed lib directory (such as $CATALINA_HOME/common/endorsed) - **************** RUNNING THE DEMO **************** -To run this as a demo, install the maven2 tool and run the following -command in the simple-openid directory: -mvn jetty:run + +Build and install the library from the repository root first: + + mvn install -DskipTests + +Then run: + + cd samples/simple-openid + mvn jetty:run DEMO CONSUMER ------------- Visit the demo consumer at: http://localhost:8080/simple-openid -You can use an IName, or any HTTP URL which acts as an openid. +You can use an IName, or any HTTP URL which acts as an OpenID. DEMO PROVIDER ------------- To visit the demo provider, visit the consumer at: http://localhost:8080/simple-openid -And login with the following URL: +And log in with the following URL: http://localhost:8080/simple-openid/user.jsp -You'll be prompted to approve the OP request (no authenticatinon) +You will be prompted to approve the OP request (no authentication). ******* LOGGING ******* -You can tweak the incldued log4j.properties file and instruct maven -to run the demo with various levels of logging. Example: -mvn -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger - -Dlog4j.configuration=file:log4j.properties jetty:run +The library logs through Apache Commons Logging. To use the simple logger: + + mvn -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog \ + jetty:run **** TODO **** -Lots. -Error handling is almost nonexistent. +Lots. + +Error handling is almost nonexistent. -Authentication of the user is an excercise left to the reader. +Authentication of the user is an exercise left to the reader. There are probably better ways to manage the ConsumerManager and ServerManager objects. -In general, the JSPs are rather brittle. +In general, the JSPs are rather brittle. diff --git a/samples/simple-openid/log4j.properties b/samples/simple-openid/log4j.properties deleted file mode 100644 index 8e094d52..00000000 --- a/samples/simple-openid/log4j.properties +++ /dev/null @@ -1,8 +0,0 @@ -log4j.rootLogger = INFO, stdout -log4j.logger.org.openid4java=DEBUG - -log4j.appender.stdout = org.apache.log4j.ConsoleAppender -log4j.appender.stdout.Threshold = DEBUG -log4j.appender.stdout.Target = System.out -log4j.appender.stdout.layout = org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern = [%-5p] %d{ABSOLUTE} [%C : %F : %L] : %m%n diff --git a/samples/simple-openid/pom.xml b/samples/simple-openid/pom.xml index 49bc430f..219bff42 100644 --- a/samples/simple-openid/pom.xml +++ b/samples/simple-openid/pom.xml @@ -1,64 +1,52 @@ - org.openid4java + com.amarulasolutions openid4java-samples - 1.0.0 + 2.0.0 ../pom.xml 4.0.0 simple-openid war Simple Openid4Java Consumer and Provider - http://maven.apache.org + https://github.com/amarula/openid4java - javax.servlet - jstl - 1.1.2 + com.amarulasolutions + openid4java - junit - junit - 3.8.1 - test + jakarta.servlet + jakarta.servlet-api + 6.0.0 + provided - commons-httpclient - commons-httpclient - 3.0.1 - - - junit - junit - - + jakarta.servlet.jsp + jakarta.servlet.jsp-api + 3.1.1 + provided - org.openid4java - openid4java + junit + junit + 4.13.2 + test simple-openid - org.mortbay.jetty - maven-jetty-plugin - 6.0.2 - - 10 - - - java.endorsed.dirs - ${basedir}/target/simple-openid/WEB-INF/lib/ - - - org.apache.commons.logging.Log - org.apache.commons.logging.impl.SimpleLog - - - + org.eclipse.jetty.ee10 + jetty-ee10-maven-plugin + 12.1.15 + + + /simple-openid + + diff --git a/samples/simple-openid/src/main/webapp/WEB-INF/web.xml b/samples/simple-openid/src/main/webapp/WEB-INF/web.xml index 9f88c1f9..b7952743 100644 --- a/samples/simple-openid/src/main/webapp/WEB-INF/web.xml +++ b/samples/simple-openid/src/main/webapp/WEB-INF/web.xml @@ -1,7 +1,7 @@ - - - - Archetype Created Web Application + + + Simple OpenID Consumer and Provider diff --git a/samples/simple-openid/src/main/webapp/consumer_redirect.jsp b/samples/simple-openid/src/main/webapp/consumer_redirect.jsp index 10775975..808f042c 100644 --- a/samples/simple-openid/src/main/webapp/consumer_redirect.jsp +++ b/samples/simple-openid/src/main/webapp/consumer_redirect.jsp @@ -1,5 +1,5 @@ <%@ page session="true" %> -<%@ page import="java.util.Map,java.util.Iterator,org.openid4java.discovery.Identifier, org.openid4java.discovery.DiscoveryInformation, org.openid4java.message.ax.FetchRequest, org.openid4java.message.ax.FetchResponse, org.openid4java.message.ax.AxMessage, org.openid4java.message.*, org.openid4java.OpenIDException, java.util.List, java.io.IOException, javax.servlet.http.HttpSession, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.openid4java.consumer.ConsumerManager, org.openid4java.consumer.InMemoryConsumerAssociationStore, org.openid4java.consumer.InMemoryNonceVerifier" %> +<%@ page import="java.util.Map,java.util.Iterator,org.openid4java.discovery.Identifier, org.openid4java.discovery.DiscoveryInformation, org.openid4java.message.ax.FetchRequest, org.openid4java.message.ax.FetchResponse, org.openid4java.message.ax.AxMessage, org.openid4java.message.*, org.openid4java.OpenIDException, java.util.List, java.io.IOException, jakarta.servlet.http.HttpSession, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, org.openid4java.consumer.ConsumerManager, org.openid4java.consumer.InMemoryConsumerAssociationStore, org.openid4java.consumer.InMemoryNonceVerifier" %> <% // README: diff --git a/samples/simple-openid/src/main/webapp/consumer_returnurl.jsp b/samples/simple-openid/src/main/webapp/consumer_returnurl.jsp index 56a43807..45b9d5df 100644 --- a/samples/simple-openid/src/main/webapp/consumer_returnurl.jsp +++ b/samples/simple-openid/src/main/webapp/consumer_returnurl.jsp @@ -1,5 +1,5 @@ <%@ page session="true" %> -<%@ page import="org.openid4java.discovery.Identifier, org.openid4java.discovery.DiscoveryInformation, org.openid4java.message.ax.FetchRequest, org.openid4java.message.ax.FetchResponse, org.openid4java.message.ax.AxMessage, org.openid4java.message.*, org.openid4java.OpenIDException, java.util.List, java.io.IOException, javax.servlet.http.HttpSession, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.openid4java.consumer.ConsumerManager, org.openid4java.consumer.InMemoryConsumerAssociationStore, org.openid4java.consumer.VerificationResult" %> +<%@ page import="org.openid4java.discovery.Identifier, org.openid4java.discovery.DiscoveryInformation, org.openid4java.message.ax.FetchRequest, org.openid4java.message.ax.FetchResponse, org.openid4java.message.ax.AxMessage, org.openid4java.message.*, org.openid4java.OpenIDException, java.util.List, java.io.IOException, jakarta.servlet.http.HttpSession, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, org.openid4java.consumer.ConsumerManager, org.openid4java.consumer.InMemoryConsumerAssociationStore, org.openid4java.consumer.VerificationResult" %> <% diff --git a/samples/simple-openid/src/main/webapp/provider.jsp b/samples/simple-openid/src/main/webapp/provider.jsp index 0e1b0c24..a2d5acca 100644 --- a/samples/simple-openid/src/main/webapp/provider.jsp +++ b/samples/simple-openid/src/main/webapp/provider.jsp @@ -1,4 +1,4 @@ -<%@ page session="true" %><%@ page import="java.util.List, org.openid4java.message.AuthSuccess, org.openid4java.server.InMemoryServerAssociationStore, org.openid4java.message.DirectError,org.openid4java.message.Message,org.openid4java.message.ParameterList, org.openid4java.discovery.Identifier, org.openid4java.discovery.DiscoveryInformation, org.openid4java.message.ax.FetchRequest, org.openid4java.message.ax.FetchResponse, org.openid4java.message.ax.AxMessage, org.openid4java.message.*, org.openid4java.OpenIDException, java.util.List, java.io.IOException, javax.servlet.http.HttpSession, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.openid4java.server.ServerManager, org.openid4java.consumer.InMemoryConsumerAssociationStore, org.openid4java.consumer.VerificationResult" %><% +<%@ page session="true" %><%@ page import="java.util.List, org.openid4java.message.AuthSuccess, org.openid4java.server.InMemoryServerAssociationStore, org.openid4java.message.DirectError,org.openid4java.message.Message,org.openid4java.message.ParameterList, org.openid4java.discovery.Identifier, org.openid4java.discovery.DiscoveryInformation, org.openid4java.message.ax.FetchRequest, org.openid4java.message.ax.FetchResponse, org.openid4java.message.ax.AxMessage, org.openid4java.message.*, org.openid4java.OpenIDException, java.util.List, java.io.IOException, jakarta.servlet.http.HttpSession, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, org.openid4java.server.ServerManager, org.openid4java.consumer.InMemoryConsumerAssociationStore, org.openid4java.consumer.VerificationResult" %><% // There must be NO newlines allowed at beginning or ending of this JSP // because the output of this jsp is passed directly // (during associate response) to client ParameterList object which barfs on diff --git a/samples/simple-openid/src/main/webapp/provider_authorization.jsp b/samples/simple-openid/src/main/webapp/provider_authorization.jsp index 57ccef32..55dbdd8a 100644 --- a/samples/simple-openid/src/main/webapp/provider_authorization.jsp +++ b/samples/simple-openid/src/main/webapp/provider_authorization.jsp @@ -1,5 +1,5 @@ <%@ page session="true" %> -<%@ page import="java.util.List, org.openid4java.message.AuthSuccess, org.openid4java.server.InMemoryServerAssociationStore, org.openid4java.message.DirectError,org.openid4java.message.Message,org.openid4java.message.ParameterList, org.openid4java.discovery.Identifier, org.openid4java.discovery.DiscoveryInformation, org.openid4java.message.ax.FetchRequest, org.openid4java.message.ax.FetchResponse, org.openid4java.message.ax.AxMessage, org.openid4java.message.*, org.openid4java.OpenIDException, java.util.List, java.io.IOException, javax.servlet.http.HttpSession, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.openid4java.server.ServerManager, org.openid4java.consumer.InMemoryConsumerAssociationStore, org.openid4java.consumer.VerificationResult" %> +<%@ page import="java.util.List, org.openid4java.message.AuthSuccess, org.openid4java.server.InMemoryServerAssociationStore, org.openid4java.message.DirectError,org.openid4java.message.Message,org.openid4java.message.ParameterList, org.openid4java.discovery.Identifier, org.openid4java.discovery.DiscoveryInformation, org.openid4java.message.ax.FetchRequest, org.openid4java.message.ax.FetchResponse, org.openid4java.message.ax.AxMessage, org.openid4java.message.*, org.openid4java.OpenIDException, java.util.List, java.io.IOException, jakarta.servlet.http.HttpSession, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, org.openid4java.server.ServerManager, org.openid4java.consumer.InMemoryConsumerAssociationStore, org.openid4java.consumer.VerificationResult" %> <% // HOWTO: diff --git a/src/org/openid4java/consumer/ConsumerManager.java b/src/org/openid4java/consumer/ConsumerManager.java index 31482550..0d1d0b5a 100644 --- a/src/org/openid4java/consumer/ConsumerManager.java +++ b/src/org/openid4java/consumer/ConsumerManager.java @@ -7,7 +7,7 @@ import com.google.inject.Inject; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpStatus; +import org.apache.hc.core5.http.HttpStatus; import org.openid4java.OpenIDException; import org.openid4java.association.Association; import org.openid4java.association.AssociationException; @@ -321,6 +321,7 @@ public int getMaxAssocAttempts() * @deprecated * @see #setAllowStateless(boolean) */ + @Deprecated public void allowStateless(boolean allowStateless) { setAllowStateless(allowStateless); @@ -350,6 +351,7 @@ public void setAllowStateless(boolean allowStateless) * @deprecated * @see #isAllowStateless() */ + @Deprecated public boolean statelessAllowed() { return _allowStateless; diff --git a/src/org/openid4java/consumer/EhcacheNonceVerifier.java b/src/org/openid4java/consumer/EhcacheNonceVerifier.java index 239a24c4..0eb78510 100644 --- a/src/org/openid4java/consumer/EhcacheNonceVerifier.java +++ b/src/org/openid4java/consumer/EhcacheNonceVerifier.java @@ -4,13 +4,13 @@ package org.openid4java.consumer; -import net.sf.ehcache.Cache; -import net.sf.ehcache.Element; - -import java.util.Date; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.ehcache.Cache; +import org.ehcache.expiry.ExpiryPolicy; + +import java.time.Duration; +import java.util.Date; /** * @author Marius Scurtescu, Johnny Bufu @@ -20,32 +20,48 @@ public class EhcacheNonceVerifier extends AbstractNonceVerifier private static Log _log = LogFactory.getLog(EhcacheNonceVerifier.class); private static final boolean DEBUG = _log.isDebugEnabled(); - private Cache _cache; + private Cache _cache; public EhcacheNonceVerifier(int maxAge) { super(maxAge); } - public void setCache(Cache cache) + public void setCache(Cache cache) { - if (cache.getTimeToLiveSeconds() != _maxAgeSeconds) + @SuppressWarnings("unchecked") + ExpiryPolicy expiryPolicy = + (ExpiryPolicy) cache.getRuntimeConfiguration().getExpiryPolicy(); + + long timeToLive = getSeconds(expiryPolicy.getExpiryForCreation("key", "value")); + long timeToIdle = getSeconds(expiryPolicy.getExpiryForAccess("key", () -> "value")); + + if (timeToLive != _maxAgeSeconds) { - throw new IllegalArgumentException("Max Age: " + _maxAgeSeconds + ", same expected for cache, but found: " + cache.getTimeToLiveSeconds()); + throw new IllegalArgumentException("Max Age: " + _maxAgeSeconds + ", same expected for cache, but found: " + timeToLive); } - if (cache.getTimeToLiveSeconds() != cache.getTimeToIdleSeconds()) + if (timeToLive != timeToIdle) { - throw new IllegalArgumentException("Cache must have same timeToLive (" + cache.getTimeToLiveSeconds() + ") as timeToIdle (" + cache.getTimeToIdleSeconds() + ")"); + throw new IllegalArgumentException("Cache must have same timeToLive (" + timeToLive + ") as timeToIdle (" + timeToIdle + ")"); } _cache = cache; } + private static long getSeconds(Duration duration) + { + if (duration == null) + { + throw new IllegalArgumentException("Cache expiry policy must define a duration"); + } + + return duration.getSeconds(); + } + protected int seen(Date now, String opUrl, String nonce) { String pair = opUrl + '#' + nonce; - Element element = new Element(pair, pair); if (_cache.get(pair) != null) { @@ -53,7 +69,7 @@ protected int seen(Date now, String opUrl, String nonce) return SEEN; } - _cache.put(element); + _cache.put(pair, pair); if (DEBUG) _log.debug("Nonce verified: " + nonce); diff --git a/src/org/openid4java/discovery/Discovery.java b/src/org/openid4java/discovery/Discovery.java index 548e1aca..dfefa975 100644 --- a/src/org/openid4java/discovery/Discovery.java +++ b/src/org/openid4java/discovery/Discovery.java @@ -41,7 +41,7 @@ public static XriResolver getXriResolver() String className = OpenID4JavaUtils.getProperty(XRI_RESOLVER_CLASS_NAME_KEY); if (DEBUG) _log.debug(XRI_RESOLVER_CLASS_NAME_KEY + ":" + className); try { - return (XriResolver) Class.forName(className).newInstance(); + return (XriResolver) Class.forName(className).getDeclaredConstructor().newInstance(); } catch (Exception e) { throw new RuntimeException("Error initializing XRI resolver.", e); } diff --git a/src/org/openid4java/discovery/UrlIdentifier.java b/src/org/openid4java/discovery/UrlIdentifier.java index 530d789d..5057b506 100644 --- a/src/org/openid4java/discovery/UrlIdentifier.java +++ b/src/org/openid4java/discovery/UrlIdentifier.java @@ -25,18 +25,18 @@ public class UrlIdentifier implements Identifier static { for (char c = 'a'; c <= 'z'; c++) - UNRESERVED_CHARACTERS.add(new Character(c)); + UNRESERVED_CHARACTERS.add(Character.valueOf(c)); for (char c = 'A'; c <= 'Z'; c++) - UNRESERVED_CHARACTERS.add(new Character(c)); + UNRESERVED_CHARACTERS.add(Character.valueOf(c)); for (char c = '0'; c <= '9'; c++) - UNRESERVED_CHARACTERS.add(new Character(c)); + UNRESERVED_CHARACTERS.add(Character.valueOf(c)); - UNRESERVED_CHARACTERS.add(new Character('-')); - UNRESERVED_CHARACTERS.add(new Character('.')); - UNRESERVED_CHARACTERS.add(new Character('_')); - UNRESERVED_CHARACTERS.add(new Character('~')); + UNRESERVED_CHARACTERS.add(Character.valueOf('-')); + UNRESERVED_CHARACTERS.add(Character.valueOf('.')); + UNRESERVED_CHARACTERS.add(Character.valueOf('_')); + UNRESERVED_CHARACTERS.add(Character.valueOf('~')); } private final URL _urlIdentifier; @@ -197,7 +197,7 @@ private static String normalizeUrlEncoding(String text) String str = URLDecoder.decode(percentCode, "ISO-8859-1"); char chr = str.charAt(0); - if (UNRESERVED_CHARACTERS.contains(new Character(chr))) + if (UNRESERVED_CHARACTERS.contains(Character.valueOf(chr))) normalized.append(chr); else normalized.append(percentCode); diff --git a/src/org/openid4java/discovery/html/HtmlResolver.java b/src/org/openid4java/discovery/html/HtmlResolver.java index 7b93d96b..cd8fdf58 100644 --- a/src/org/openid4java/discovery/html/HtmlResolver.java +++ b/src/org/openid4java/discovery/html/HtmlResolver.java @@ -5,7 +5,7 @@ package org.openid4java.discovery.html; import com.google.inject.Inject; -import org.apache.http.HttpStatus; +import org.apache.hc.core5.http.HttpStatus; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -42,7 +42,7 @@ public class HtmlResolver if (DEBUG) _log.debug(HTML_PARSER_CLASS_NAME_KEY + ":" + className); try { - HTML_PARSER = (HtmlParser) Class.forName(className).newInstance(); + HTML_PARSER = (HtmlParser) Class.forName(className).getDeclaredConstructor().newInstance(); } catch (Exception e) { diff --git a/src/org/openid4java/discovery/html/CyberNekoDOMHtmlParser.java b/src/org/openid4java/discovery/html/JsoupHtmlParser.java similarity index 65% rename from src/org/openid4java/discovery/html/CyberNekoDOMHtmlParser.java rename to src/org/openid4java/discovery/html/JsoupHtmlParser.java index a11757f8..2fb17122 100644 --- a/src/org/openid4java/discovery/html/CyberNekoDOMHtmlParser.java +++ b/src/org/openid4java/discovery/html/JsoupHtmlParser.java @@ -6,90 +6,64 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.html.dom.HTMLDocumentImpl; +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; +import org.jsoup.select.Elements; import org.openid4java.OpenIDException; import org.openid4java.discovery.DiscoveryException; -import org.openid4java.util.OpenID4JavaDOMParser; -import org.w3c.dom.NodeList; -import org.w3c.dom.html.HTMLHeadElement; -import org.w3c.dom.html.HTMLLinkElement; import java.util.Arrays; import java.util.List; /** - * A {@link HtmlParser} implementation using the DOMParser of CyberNeko HTML. - * + * A {@link HtmlParser} implementation using jsoup. + * * @author Sutra Zhou * @since 0.9.4 - * @see org.openid4java.util.OpenID4JavaDOMParser */ -public class CyberNekoDOMHtmlParser implements HtmlParser +public class JsoupHtmlParser implements HtmlParser { - private static final Log _log = LogFactory.getLog(CyberNekoDOMHtmlParser.class); + private static final Log _log = LogFactory.getLog(JsoupHtmlParser.class); private static final boolean DEBUG = _log.isDebugEnabled(); - /* - * (non-Javadoc) - * - * @see org.openid4java.discovery.html.HtmlParser#parse(java.lang.String, - * org.openid4java.discovery.html.HtmlResult) - */ public void parseHtml(String htmlData, HtmlResult result) throws DiscoveryException { if (DEBUG) _log.debug("Parsing HTML data:\n" + htmlData); - HTMLDocumentImpl doc = this.parseDocument(htmlData); - - NodeList heads = doc.getElementsByTagName("head"); - if (heads.getLength() != 1) - throw new DiscoveryException( - "HTML response must have exactly one HEAD element, " - + "found " + heads.getLength() + " : " - + heads.toString(), - OpenIDException.DISCOVERY_HTML_PARSE_ERROR); - - HTMLHeadElement head = (HTMLHeadElement) doc.getHead(); - NodeList linkElements = head.getElementsByTagName("LINK"); - for (int i = 0, len = linkElements.getLength(); i < len; i++) - { - HTMLLinkElement linkElement = (HTMLLinkElement) linkElements.item(i); - setResult(linkElement.getRel(), linkElement.getHref(), result); - } - - if (DEBUG) - _log.debug("HTML discovery result:\n" + result); - } - - private HTMLDocumentImpl parseDocument(String htmlData) throws DiscoveryException - { - OpenID4JavaDOMParser parser = new OpenID4JavaDOMParser(); + Document doc; try { - parser.parse(OpenID4JavaDOMParser.createInputSource(htmlData)); + doc = Jsoup.parse(htmlData == null ? "" : htmlData); } catch (Exception e) { throw new DiscoveryException("Error parsing HTML message", - OpenIDException.DISCOVERY_HTML_PARSE_ERROR, e); + OpenIDException.DISCOVERY_HTML_PARSE_ERROR, e); } - if (parser.isIgnoredHeadStartElement()) - { + Element head = doc.head(); + if (head == null) throw new DiscoveryException( "HTML response must have exactly one HEAD element.", OpenIDException.DISCOVERY_HTML_PARSE_ERROR); + + Elements linkElements = head.select("link"); + for (Element linkElement : linkElements) + { + setResult(linkElement.attr("rel"), linkElement.attr("href"), result); } - return (HTMLDocumentImpl) parser.getDocument(); + if (DEBUG) + _log.debug("HTML discovery result:\n" + result); } /** * Set the result from rel and href that * parsed from node link. - * + * * @param rel * the rel * @param href diff --git a/src/org/openid4java/discovery/xri/LocalXriResolver.java b/src/org/openid4java/discovery/xri/LocalXriResolver.java deleted file mode 100644 index 86a4fa46..00000000 --- a/src/org/openid4java/discovery/xri/LocalXriResolver.java +++ /dev/null @@ -1,270 +0,0 @@ -package org.openid4java.discovery.xri; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.openid4java.discovery.DiscoveryException; -import org.openid4java.discovery.DiscoveryInformation; -import org.openid4java.discovery.Identifier; -import org.openid4java.discovery.XriIdentifier; -import org.openxri.XRI; -import org.openxri.resolve.Resolver; -import org.openxri.resolve.ResolverFlags; -import org.openxri.resolve.ResolverState; -import org.openxri.resolve.exception.PartialResolutionException; -import org.openxri.xml.CanonicalID; -import org.openxri.xml.SEPUri; -import org.openxri.xml.Service; -import org.openxri.xml.Status; -import org.openxri.xml.XRD; -import org.openxri.xml.XRDS; - -public class LocalXriResolver implements XriResolver -{ - private static Log _log = LogFactory.getLog(LocalXriResolver.class); - private static final boolean DEBUG = _log.isDebugEnabled(); - - private Resolver _openXriResolver; - - - public LocalXriResolver() - { - if (DEBUG) _log.debug("Initializing local XRI resolver..."); - - try { - - _openXriResolver = new Resolver(null); - } catch (Exception e) { - - throw new RuntimeException("Cannot initialize OpenXRI Resolver: " + e.getMessage(), e); - } - } - - public Resolver getResolver() { - - return _openXriResolver; - } - - public List discover(XriIdentifier xri) throws DiscoveryException - { - try - { - ResolverFlags flags = new ResolverFlags(); - flags.setCid(true); - flags.setRefs(true); - ResolverState state = new ResolverState(); - XRDS xrds = _openXriResolver.resolveAuthToXRDS( - new XRI(xri.getIdentifier()), flags, state); - - if (DEBUG) _log.debug("Retrieved XRDS:\n" + xrds.dump()); - - XRD xrd = xrds.getFinalXRD(); - - if (! xrd.getStatus().getCID().equals(Status.CID_VERIFIED)) - { - _log.error("Unverified CanonicalID: " + xrd.getCanonicalID() + " of: " + xri.getIdentifier()); - throw new RuntimeException("Unverified CanonicalID: " + xrd.getCanonicalID() + " of: " + xri.getIdentifier()); - } - - CanonicalID canonical = xrd.getCanonicalID(); - if (canonical == null) throw new RuntimeException("Missing CanonicalID of: " + xri.getIdentifier()); - - _log.info("XRI resolution succeeded on " + xri.toString()); - - return extractDiscoveryInformation(xrds, xri, _openXriResolver); - - } - catch (Exception e) - { - throw new DiscoveryException( - "Cannot resolve XRI: " + xri, e); - } - } - - public XriIdentifier parseIdentifier(String identifier) throws DiscoveryException { - - XRI xri = new XRI(identifier); - return new XriIdentifier(identifier, xri.toIRINormalForm(), xri.toURINormalForm()); - } - - // --- XRI discovery patch from William Tan --- - - /** - * Extracts OpenID discovery endpoints from a XRDS discovery result - * for XRI identifiers. - * - * @param xrds The discovered XRDS document. - * @param identifier The identifier on which discovery was performed. - * @param xriResolver The XRI resolver to use for extraction of OpenID - * service endpoints. - * @return A list of DiscoveryInformation endpoints. - * @throws DiscoveryException when invalid information is discovered. - */ - protected List extractDiscoveryInformation(XRDS xrds, - XriIdentifier identifier, - Resolver xriResolver) - throws DiscoveryException - { - ArrayList endpoints = new ArrayList(); - - XRD xrd = xrds.getFinalXRD(); - - // try OP Identifier - extractDiscoveryInformationOpenID( - xriResolver, - endpoints, - xrd, - identifier, - DiscoveryInformation.OPENID2_OP, - false // no CID - ); - - // OpenID 2 signon - extractDiscoveryInformationOpenID( - xriResolver, - endpoints, - xrd, - identifier, - DiscoveryInformation.OPENID2, // sepType - true // want CID - ); - - // OpenID 1.x - extractDiscoveryInformationOpenID( - xriResolver, - endpoints, - xrd, - identifier, - DiscoveryInformation.OPENID11, - true // wantCID - ); - - extractDiscoveryInformationOpenID( - xriResolver, - endpoints, - xrd, - identifier, - DiscoveryInformation.OPENID10, - true // wantCID - ); - - if (endpoints.size() == 0) - _log.info("No OpenID service types found in the XRDS."); - - return endpoints; - } - - protected boolean extractDiscoveryInformationOpenID( - Resolver xriResolver, ArrayList out, XRD baseXRD, - XriIdentifier identifier, String srvType, boolean wantCID) - { - try - { - ResolverFlags flags = new ResolverFlags(); - flags.setCid(true); - flags.setRefs(true); - flags.setNoDefaultT(srvType != null); // we don't want default SEPs, only ones that really have the service type we are looking for - ResolverState state = new ResolverState(); - - List services = xriResolver.selectServiceFromXRD( - new XRDS(), - baseXRD, - new XRI(identifier.getIdentifier()), - srvType, - null, // sepMediaType - flags, - state - ); - - Identifier claimedIdentifier = null; - URL opEndpointUrl; - CanonicalID canonID; - - if (! baseXRD.getStatus().getCID().equals(Status.CID_VERIFIED)) { - _log.error("Unverified CanonicalID: " + baseXRD.getCanonicalID() + " of:" + identifier.getIdentifier()); - return false; - } - - if (wantCID) - { - canonID = baseXRD.getCanonicalID(); - - if (canonID == null) { - _log.error("No CanonicalID found for " + srvType + - " after XRI resolution of: " - + identifier.getIdentifier()); - return false; - } - - claimedIdentifier = parseIdentifier(canonID.getValue()); - _log.info("Using canonicalID as claimedID: " + - claimedIdentifier.getIdentifier() + - " for " + srvType); - } - - Iterator it = services.iterator(); - while (it.hasNext()) - { - Service srv = (Service)it.next(); - Iterator itURI = srv.getPrioritizedURIs().iterator(); - SEPUri sepURI; - while (itURI.hasNext()) - { - sepURI = (SEPUri) itURI.next(); - try - { - String urlString = xriResolver.constructURI( - sepURI.getURI(), - sepURI.getAppend(), - new XRI(identifier.toString())); - - opEndpointUrl = new URL(urlString); - - DiscoveryInformation extracted = - new DiscoveryInformation( - opEndpointUrl, - wantCID ? claimedIdentifier : null, - null, - srvType); - - _log.info("Added " + srvType + - " endpoint: " + opEndpointUrl); - - out.add(extracted); - } - catch (MalformedURLException mue) - { - _log.warn("Ignoring malformed OP endpoint URL in XRDS file: " - + sepURI.toString(), mue); - } - catch (IllegalArgumentException ee) - { - _log.warn("Ignoring invalid OP endpoint URL in XRDS file: " - + sepURI.toString(), ee); - } - - } - } - - return true; - } - catch (PartialResolutionException e) - { - _log.error("XRI resolution failed for " + srvType, e); - } - catch (DiscoveryException de) - { - _log.error("XRDS discovery failed for " + srvType, de); - } - - return false; - } - - // --- end XRI discovery patch from William Tan --- - -} diff --git a/src/org/openid4java/discovery/xri/XriDotNetProxyResolver.java b/src/org/openid4java/discovery/xri/XriDotNetProxyResolver.java index 24667f0d..d77d88e6 100644 --- a/src/org/openid4java/discovery/xri/XriDotNetProxyResolver.java +++ b/src/org/openid4java/discovery/xri/XriDotNetProxyResolver.java @@ -4,7 +4,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpStatus; +import org.apache.hc.core5.http.HttpStatus; import org.openid4java.discovery.DiscoveryException; import org.openid4java.discovery.DiscoveryInformation; import org.openid4java.discovery.XriIdentifier; @@ -45,7 +45,7 @@ public class XriDotNetProxyResolver implements XriResolver if (DEBUG) _log.debug(XRDS_PARSER_CLASS_NAME_KEY + ":" + className); try { - XRDS_PARSER = (XrdsParser) Class.forName(className).newInstance(); + XRDS_PARSER = (XrdsParser) Class.forName(className).getDeclaredConstructor().newInstance(); } catch (Exception e) { @@ -119,7 +119,7 @@ public List discover(XriIdentifier xri) throws DiscoveryException public XriIdentifier parseIdentifier(String identifier) throws DiscoveryException { - // todo: http://code.google.com/p/openid4java/issues/detail?id=63 + // todo: see the upstream issue tracker (issue 63) _log.warn("Creating XRI identifier with the friendly XRI identifier as the IRI/URI normal forms."); return new XriIdentifier(identifier, identifier, identifier); } diff --git a/src/org/openid4java/discovery/yadis/CyberNekoDOMYadisHtmlParser.java b/src/org/openid4java/discovery/yadis/CyberNekoDOMYadisHtmlParser.java deleted file mode 100644 index eb3a7101..00000000 --- a/src/org/openid4java/discovery/yadis/CyberNekoDOMYadisHtmlParser.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright 2006-2008 Sxip Identity Corporation - */ - -package org.openid4java.discovery.yadis; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.html.dom.HTMLDocumentImpl; -import org.openid4java.OpenIDException; -import org.openid4java.util.OpenID4JavaDOMParser; -import org.w3c.dom.NodeList; -import org.w3c.dom.html.HTMLHeadElement; -import org.w3c.dom.html.HTMLMetaElement; - -import javax.xml.transform.TransformerException; - -/** - * A {@link org.openid4java.discovery.yadis.YadisHtmlParser} implementation using the DOMParser of CyberNeko HTML. - * - * @author Sutra Zhou - * @since 0.9.4 - * @see org.openid4java.util.OpenID4JavaDOMParser - */ -public class CyberNekoDOMYadisHtmlParser implements YadisHtmlParser -{ - private static final Log _log = LogFactory.getLog(CyberNekoDOMYadisHtmlParser.class); - private static final boolean DEBUG = _log.isDebugEnabled(); - - /* - * (non-Javadoc) - * - * @see org.openid4java.discovery.yadis.YadisParser#getHtmlMeta(java.lang.String) - */ - public String getHtmlMeta(String input) throws YadisException - { - String xrdsLocation = null; - - HTMLDocumentImpl doc = this.parseDocument(input); - if (DEBUG) - { - try - { - _log.debug("document:\n" + OpenID4JavaDOMParser.toXmlString(doc)); - } catch (TransformerException e) - { - _log.debug("An exception occurs while transforming the document to string in debugging.", e); - } - } - - NodeList heads = doc.getElementsByTagName("head"); - if (heads.getLength() != 1) - throw new YadisException( - "HTML response must have exactly one HEAD element, " - + "found " + heads.getLength() + " : " - + heads.toString(), - OpenIDException.YADIS_HTMLMETA_INVALID_RESPONSE); - - HTMLHeadElement head = (HTMLHeadElement) doc.getHead(); - NodeList metaElements = head.getElementsByTagName("META"); - if (metaElements == null || metaElements.getLength() == 0) - { - if (DEBUG) - _log.debug("No element found under . " + - "See Yadis specification, section 6.2.5/1."); - } - else - { - for (int i = 0, len = metaElements.getLength(); i < len; i++) - { - HTMLMetaElement metaElement = (HTMLMetaElement) metaElements.item(i); - - String httpEquiv = metaElement.getHttpEquiv(); - if (YadisResolver.YADIS_XRDS_LOCATION.equalsIgnoreCase(httpEquiv)) - { - if (xrdsLocation != null) - throw new YadisException( - "More than one " - + YadisResolver.YADIS_XRDS_LOCATION - + "META tags found in HEAD: " - + head.toString(), - OpenIDException.YADIS_HTMLMETA_INVALID_RESPONSE); - - xrdsLocation = metaElement.getContent(); - if (DEBUG) - _log.debug("Found " + YadisResolver.YADIS_XRDS_LOCATION - + " META tags."); - } - } - } - return xrdsLocation; - } - - private HTMLDocumentImpl parseDocument(String htmlData) throws YadisException - { - OpenID4JavaDOMParser parser = new OpenID4JavaDOMParser(); - try - { - parser.parse(OpenID4JavaDOMParser.createInputSource(htmlData)); - } - catch (Exception e) - { - throw new YadisException("Error parsing HTML message", - OpenIDException.YADIS_HTMLMETA_INVALID_RESPONSE, e); - } - - if (parser.isIgnoredHeadStartElement()) - { - throw new YadisException("HTML response must have exactly one HEAD element.", - OpenIDException.YADIS_HTMLMETA_INVALID_RESPONSE); - } - - return (HTMLDocumentImpl) parser.getDocument(); - } -} diff --git a/src/org/openid4java/discovery/yadis/JsoupYadisHtmlParser.java b/src/org/openid4java/discovery/yadis/JsoupYadisHtmlParser.java new file mode 100644 index 00000000..a1ccd256 --- /dev/null +++ b/src/org/openid4java/discovery/yadis/JsoupYadisHtmlParser.java @@ -0,0 +1,82 @@ +/* + * Copyright 2006-2008 Sxip Identity Corporation + */ + +package org.openid4java.discovery.yadis; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; +import org.jsoup.select.Elements; +import org.openid4java.OpenIDException; +import org.openid4java.util.HtmlUtils; + +/** + * A {@link YadisHtmlParser} implementation using jsoup. + * + * @author Sutra Zhou + * @since 0.9.4 + */ +public class JsoupYadisHtmlParser implements YadisHtmlParser +{ + private static final Log _log = LogFactory.getLog(JsoupYadisHtmlParser.class); + private static final boolean DEBUG = _log.isDebugEnabled(); + + public String getHtmlMeta(String input) throws YadisException + { + if (DEBUG) + _log.debug("Parsing HTML data:\n" + input); + + int headCount = HtmlUtils.countTopLevelHeads(input); + if (headCount != 1) + throw new YadisException( + "HTML response must have exactly one HEAD element, " + + "found " + headCount, + OpenIDException.YADIS_HTMLMETA_INVALID_RESPONSE); + + Document doc; + try + { + doc = Jsoup.parse(input == null ? "" : input); + } + catch (Exception e) + { + throw new YadisException("Error parsing HTML message", + OpenIDException.YADIS_HTMLMETA_INVALID_RESPONSE, e); + } + + Element head = doc.head(); + if (head == null) + throw new YadisException( + "HTML response must have exactly one HEAD element.", + OpenIDException.YADIS_HTMLMETA_INVALID_RESPONSE); + + String xrdsLocation = null; + Elements metaElements = head.select("meta"); + + for (Element metaElement : metaElements) + { + String httpEquiv = metaElement.attr("http-equiv"); + if (YadisResolver.YADIS_XRDS_LOCATION.equalsIgnoreCase(httpEquiv)) + { + if (xrdsLocation != null) + throw new YadisException( + "More than one " + + YadisResolver.YADIS_XRDS_LOCATION + + " META tags found in HEAD: " + + head, + OpenIDException.YADIS_HTMLMETA_INVALID_RESPONSE); + + xrdsLocation = metaElement.hasAttr("content") + ? metaElement.attr("content") : null; + if (DEBUG) + _log.debug("Found " + YadisResolver.YADIS_XRDS_LOCATION + + " META tags."); + } + } + + return xrdsLocation; + } +} diff --git a/src/org/openid4java/discovery/yadis/YadisResolver.java b/src/org/openid4java/discovery/yadis/YadisResolver.java index e5d51868..ae36cf28 100644 --- a/src/org/openid4java/discovery/yadis/YadisResolver.java +++ b/src/org/openid4java/discovery/yadis/YadisResolver.java @@ -6,12 +6,11 @@ import com.google.inject.Inject; -import org.apache.http.HttpException; -import org.apache.http.HttpStatus; -import org.apache.http.Header; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.client.ClientProtocolException; +import org.apache.hc.client5.http.ClientProtocolException; +import org.apache.hc.core5.http.Header; +import org.apache.hc.core5.http.HttpStatus; import java.io.IOException; import java.util.Set; @@ -76,7 +75,7 @@ public class YadisResolver if (DEBUG) _log.debug(YADIS_HTML_PARSER_CLASS_NAME_KEY + ":" + className); try { - YADIS_HTML_PARSER = (YadisHtmlParser) Class.forName(className).newInstance(); + YADIS_HTML_PARSER = (YadisHtmlParser) Class.forName(className).getDeclaredConstructor().newInstance(); } catch (Exception e) { @@ -86,7 +85,7 @@ public class YadisResolver if (DEBUG) _log.debug(XRDS_PARSER_CLASS_NAME_KEY + ":" + className); try { - XRDS_PARSER = (XrdsParser) Class.forName(className).newInstance(); + XRDS_PARSER = (XrdsParser) Class.forName(className).getDeclaredConstructor().newInstance(); } catch (Exception e) { diff --git a/src/org/openid4java/infocard/InfocardException.java b/src/org/openid4java/infocard/InfocardException.java deleted file mode 100644 index 2e3f80e4..00000000 --- a/src/org/openid4java/infocard/InfocardException.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2006-2008 Sxip Identity Corporation - */ - -package org.openid4java.infocard; - -import org.openid4java.OpenIDException; - -/** - * @author Johnny Bufu - */ -public class InfocardException extends OpenIDException -{ - public InfocardException(String message) - { - super(message, INFOCARD_ERROR); - } - - public InfocardException(String message, int code) - { - super(message, code); - } - - public InfocardException(String message, Throwable cause) - { - super(message, INFOCARD_ERROR, cause); - } - - public InfocardException(Throwable cause) - { - super(INFOCARD_ERROR, cause); - } -} diff --git a/src/org/openid4java/infocard/OpenIDToken.java b/src/org/openid4java/infocard/OpenIDToken.java deleted file mode 100644 index 1ecd3653..00000000 --- a/src/org/openid4java/infocard/OpenIDToken.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright 2006-2008 Sxip Identity Corporation - */ - -package org.openid4java.infocard; - -import org.openid4java.message.Message; -import org.openid4java.message.ParameterList; -import org.openid4java.OpenIDException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.w3c.dom.Document; -import org.xml.sax.SAXException; - -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.ParserConfigurationException; -import java.io.ByteArrayInputStream; -import java.io.IOException; - -/** - * Models the OpenID Infocard token used to transport OpenID messages. - * An OpenID token encapsulates an OpenID message in key-value form into - * an element. - *

- * Provides functionality for OPs / Servers to create OpenID tokens from - * OpenID messages, and for RPs / Consumers to parse received tokens into - * OpenID messages. - */ -public class OpenIDToken -{ - private static Log _log = LogFactory.getLog(OpenIDToken.class); - private static final boolean DEBUG = _log.isDebugEnabled(); - - /** - * Token type data structure. - */ - private OpenIDTokenType _tokenType; - - /** - * The encapsulated OpenID Message. - */ - private Message _openidMessage; - - /** - * Constructs an OpenID token encapsulating the provided OpenID Message. - * Should be used on the OP/STS side to generate a RSTR. - * - * @param openidMessage The OpenID message obtained from - * ServerManager.authResponse(). - */ - public OpenIDToken(Message openidMessage) - { - setOpenIDMessage(openidMessage); - - if (DEBUG) - _log.debug("Created " + _tokenType +" token"); - } - - /** - * Parses the data posted by the selector into an OpenID token. - * Should be used on the RP side. - * - * @param xmlToken The "xmlToken" parameter posted by the selector. - * @return An OpenIDToken encapsulating the OpenID AuthResponse. - */ - public static OpenIDToken createFromXmlToken(String xmlToken) - throws InfocardException - { - if (xmlToken == null) - throw new InfocardException("Error processing xmlToken: null value"); - - if (DEBUG) - _log.debug("Processing xmlToken: " + xmlToken); - - try - { - DocumentBuilderFactory documentBuilderFactory = - DocumentBuilderFactory.newInstance(); - documentBuilderFactory.setNamespaceAware(true); - - DocumentBuilder documentBuilder = - documentBuilderFactory.newDocumentBuilder(); - - Document document = documentBuilder.parse( - new ByteArrayInputStream(xmlToken.getBytes("utf-8"))); - - String keyValueForm; - try - { - keyValueForm = document.getElementsByTagNameNS( - Message.OPENID2_NS, "OpenIDToken") - .item(0).getFirstChild().getNodeValue(); - } - catch (Exception e) - { - throw new InfocardException( - "Error extracting OpenID message from the xmlToken", e); - } - - Message message = Message.createMessage( - ParameterList.createFromKeyValueForm(keyValueForm)); - - return new OpenIDToken(message); - - // DOM exceptions : - } - catch (ParserConfigurationException e) - { - throw new InfocardException("Parser configuration error", e); - } - catch (SAXException e) - { - throw new InfocardException("Error parsing XML token document", e); - } - catch (IOException e) - { - throw new InfocardException("Error reading xmlToken document", e); - } - catch (OpenIDException e) - { - throw new InfocardException("Error building OpenID message from xmlToken", e); - } - } - - /** - * Gets the OpenID message contained in the OpenID token. - */ - public Message getOpenIDMessage() - { - return _openidMessage; - } - - /** - * Gets the OpenID message as a ParameterList. - * @return ParameterList containing the OpenID message. - */ - public ParameterList getOpenIDParams() - { - return new ParameterList(_openidMessage.getParameterMap()); - } - - /** - * Sets the OpenID Message to encapsulate into the token. - */ - public void setOpenIDMessage(Message openidMessage) - { - this._openidMessage = openidMessage; - - if (OpenIDTokenType.OPENID20_TOKEN.toString().equals( - openidMessage.getParameterValue("openid.ns"))) - _tokenType = OpenIDTokenType.OPENID20_TOKEN; - - else - _tokenType = OpenIDTokenType.OPENID11_TOKEN; - } - - /** - * Gets the OpenID token type. - * - * @see org.openid4java.infocard.OpenIDTokenType - */ - public OpenIDTokenType getTokenType() - { - return _tokenType; - } - - /** - * Generates the XML string representation of the OpenID token. - */ - public String getToken() - { - StringBuffer token = new StringBuffer(); - - token.append(""); - - token.append(_openidMessage.keyValueFormEncoding()); - - token.append(""); - - return token.toString(); - } -} diff --git a/src/org/openid4java/infocard/OpenIDTokenType.java b/src/org/openid4java/infocard/OpenIDTokenType.java deleted file mode 100644 index 7adb229e..00000000 --- a/src/org/openid4java/infocard/OpenIDTokenType.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2006-2008 Sxip Identity Corporation - */ - -package org.openid4java.infocard; - -/** - * Enumeration class with the defined OpenID token types. - */ -public class OpenIDTokenType -{ - /** - * OpenID 1.1 token type. - */ - public static final OpenIDTokenType OPENID11_TOKEN = - new OpenIDTokenType("http://specs.openid.net/auth/1.1"); - - /** - * OpenID 2.0 token type. - */ - public static final OpenIDTokenType OPENID20_TOKEN = - new OpenIDTokenType("http://specs.openid.net/auth/2.0"); - - /** - * The OpenID Identifier claim type. - */ - public static final String OPENID_CLAIM = - "http://schema.openid.net/2007/05/claims/identifier"; - - /** - * Token URI value. - */ - private final String _tokenTypeUri; - - /** - * Constructs a token type for the given URI value. - */ - private OpenIDTokenType(String uriValue) - { - _tokenTypeUri = uriValue; - } - - /** - * Gets the URI string value for the token type. - * @return String representation of the token URI type. - */ - public String toString() - { - return _tokenTypeUri; - } -} diff --git a/src/org/openid4java/infocard/package.html b/src/org/openid4java/infocard/package.html deleted file mode 100644 index 8c9beeb1..00000000 --- a/src/org/openid4java/infocard/package.html +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - -Provides support for - -OpenID-InforCards. - - -

- RP support: -

    -
  • - Generate <OBJECT;> element of type - "application/x-informationCard" for RPs to request login - with an OpenID InfoCard. -
  • -
  • - Extract the OpenID Authentication Response from the - XML token posted by an Identity Selctor -
  • -
-

- -

- OP support: -

    -
  • - OpenID Token Generator plugin/extension for the - Higgins STS. - -
  • -
-

- -

- See also: -

    -
  • - Demonstrative deployment at - openidcards.sxip.com. -
  • -
  • - Sample InfoCard-enabled OpenID DemoRP (samples/demorp) and - Infocard OP (samples/infocardop). -
  • -
-

- - - - diff --git a/src/org/openid4java/infocard/rp/InfocardInvocation.java b/src/org/openid4java/infocard/rp/InfocardInvocation.java deleted file mode 100644 index 3ad4febd..00000000 --- a/src/org/openid4java/infocard/rp/InfocardInvocation.java +++ /dev/null @@ -1,329 +0,0 @@ -/* - * Copyright 2006-2008 Sxip Identity Corporation - */ - -package org.openid4java.infocard.rp; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.openid4java.message.ax.FetchRequest; -import org.openid4java.infocard.OpenIDTokenType; - -import java.util.List; -import java.util.ArrayList; -import java.util.Iterator; - -/** - * Utility class to generate HTML or XHTLM snippets that express - * Relying Parties' requirements and invoke Infocard Selectors, - * requesting login with an OpenID Infocard. - *

- * Attribute Exchange Fetch Requests can be mapped to Infocard claim URIs. - * - * @author Johnny Bufu - */ -public class InfocardInvocation -{ - private static Log _log = LogFactory.getLog(InfocardInvocation.class); - private static final boolean DEBUG = _log.isDebugEnabled(); - - /** - * The requested token type (OpenID 1.1 or 2.0) - */ - private OpenIDTokenType _tokenType; - - /** - * List of required claim URIs. The OpenID Identifier claim - * is always part of the list. - */ - private List _requiredClaims = new ArrayList(); - - /** - * List of optional claim URIs. - */ - private List _optionalClaims = new ArrayList(); - - /** - * The issuer's URL for the accepted claims. - */ - private String _issuer; - - /** - * The issuer's WS-SecurityPolicy URL, if different than "/mex". - */ - private String _issuerPolicy; - - /** - * Relying Party's privacy URL. - */ - private String _privacyUrl; - - /** - * Relying Party's privacy document version. When selectors notice - * a change in this value, users are prompted with the privacy policy - * document retrieved from the privacyUrl. - */ - private int _privacyVersion; - - // todo: enforce data types? - - /** - * Creates a new InfocardInvocation object, describing Relying Party's - * requirements. - * - * @param tokenType The required token type. - */ - public InfocardInvocation(OpenIDTokenType tokenType) - { - _requiredClaims.add(OpenIDTokenType.OPENID_CLAIM); - _tokenType = tokenType; - - if (DEBUG) - _log.debug("Created " + _tokenType + " token type InfocardInvocation"); - } - - /** - * Creates an InfocardInvocation object from an Attribute Exchange - * Fetch Request. - *

- * Attriute type URIs are mapped to Infocard claim URIs. - * Attribute value count and update_url features are cannot be - * expressed in InfocardInvocation data structures. - * - * @param fetch The Fetch Request. - */ - public InfocardInvocation(FetchRequest fetch) - { - _requiredClaims.add(OpenIDTokenType.OPENID_CLAIM); - _tokenType = OpenIDTokenType.OPENID20_TOKEN; - - _requiredClaims.addAll(fetch.getAttributes(true).values()); - _optionalClaims.addAll(fetch.getAttributes(false).values()); - - if (DEBUG) - _log.debug("Created " + _tokenType + - " token type InfocardInvocation from a FetchRequest."); - } - - /** - * Gets the token type. - */ - public OpenIDTokenType getTokenType() - { - return _tokenType; - } - - /** - * Sets the token type. - * @param tokenType - */ - public void setTokenType(OpenIDTokenType tokenType) - { - this._tokenType = tokenType; - } - - /** - * Gets required or optional claim URIs. - *

- * The OpenID Identifier claim is always part of the required claims list. - * - * @param required If true, the required claims are returned; optional - * claims are returned otherwise. - * @return The list of configured required/optional claims. - */ - public List getClaims(boolean required) - { - return required ? _requiredClaims : _optionalClaims; - } - - /** - * Adds a claim URI to the required or optional claim list. - * - * @param claim The claim URI to be added. - * @param required If true, the clai is added to the required - * claims list, otherwise it is added to the - * optional claims list. - */ - public void addClaim(String claim, boolean required) - { - if (required && ! _requiredClaims.contains(claim)) - _requiredClaims.add(claim); - - else if (! _optionalClaims.contains(claim)) - _optionalClaims.add(claim); - } - - /** - * Sets the list of required or optional claim URIs. - *

- * If the required claim list is set, and the OpenID Identifier claim - * is not part of the provided list, it is added transparently to the list. - * - * @param claims List of claim URIs. - * @param required If true, the required claims list is set, - * otherwise the optional claims list is set. - */ - public void setClaims(List claims, boolean required) - { - if (required) - { - _requiredClaims = claims; - if (! _requiredClaims.contains(OpenIDTokenType.OPENID_CLAIM)) - _requiredClaims.add(OpenIDTokenType.OPENID_CLAIM); - } - else - _optionalClaims = claims; - - } - - /** - * Gets the issuer URL. - */ - public String getIssuer() - { - return _issuer; - } - - /** - * Sets the issuer URL. - * @param issuer - */ - public void setIssuer(String issuer) - { - this._issuer = issuer; - } - - /** - * Gets the issuer policy URL, if different than "/mex". - */ - public String getIssuerPolicy() - { - return _issuerPolicy; - } - - /** - * Sets the issuer policy URL, if different than "/mex". - */ - public void setIssuerPolicy(String issuerPolicy) - { - this._issuerPolicy = issuerPolicy; - } - - /** - * Gets the Relyin Party's privacy policy URL. - */ - public String getPrivacyUrl() - { - return _privacyUrl; - } - - /** - * Gets the Relying Party's privacy document's version. - */ - public int getPrivacyVersion() - { - return _privacyVersion; - } - - /** - * Sets the Relyin Party's privacy policy URL and version. - *

- * When selectors notice a change in this value, users are prompted - * with the privacy policy document retrieved from the privacyUrl. - */ - public void setPrivacyData(String url, int version) - { - _privacyUrl = url; - _privacyVersion = version; - } - - /** - * Generates the HTML element used to describe - * the Relying Party's requirements and invoke the infocard selectors. - */ - public String getHtmlObject() - { - StringBuffer object = new StringBuffer(); - - object.append(""); - - object.append(getObjectParam("tokenType", _tokenType.toString())); - - // claims - object.append(getObjectParam("requiredClaims", arrayToString(_requiredClaims))); - - if (_optionalClaims.size() > 0) - object.append(getObjectParam("optionslClaims", arrayToString(_optionalClaims))); - - // issuer - if (_issuer != null && _issuer.length() > 0) - object.append(getObjectParam("issuer", _issuer)); - - if (_issuerPolicy != null && _issuerPolicy.length() > 0) - object.append(getObjectParam("issuerPolicy", _issuerPolicy)); - - // privacy - if (_privacyUrl != null && _privacyUrl.length() > 0) - { - object.append(getObjectParam("privacyUrl", _privacyUrl)); - object.append(getObjectParam("privacyVersion", Integer.toString(_privacyVersion))); - } - - if (DEBUG) - _log.debug("Generated element: " + object); - - return object.toString(); - } - - - /** - * Generates the XHTML snippet element used to describe - * the Relying Party's requirements and invoke the infocard selectors. - */ - public String getXhtml() - { - StringBuffer xhtml = new StringBuffer(); - - if (DEBUG) - _log.debug("Generated XHTML invocation snippet: " + xhtml); - - // todo: xhtml - throw new UnsupportedOperationException("XHTML invocation not implemented"); - } - - /** - * Generates an HTML snippet for an parameter - * from a name-value pair. - */ - public String getObjectParam(String paramName, String paramValue) - { - StringBuffer param = new StringBuffer(); - - param.append(" 0) - { - Iterator iter = list.iterator(); - while (iter.hasNext()) - { - result.append(iter.next()); - result.append(" "); - } - - result.deleteCharAt(result.length() - 1); - } - - return result.toString(); - } -} diff --git a/src/org/openid4java/infocard/sts/OpenIDTokenGeneratorHandler.java b/src/org/openid4java/infocard/sts/OpenIDTokenGeneratorHandler.java deleted file mode 100644 index 315eabd7..00000000 --- a/src/org/openid4java/infocard/sts/OpenIDTokenGeneratorHandler.java +++ /dev/null @@ -1,485 +0,0 @@ -/* - * Copyright 2006-2008 Sxip Identity Corporation - */ - -package org.openid4java.infocard.sts; - -import java.util.Map; -import java.util.HashMap; -import java.util.Iterator; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.io.UnsupportedEncodingException; - -import org.eclipse.higgins.sts.api.*; -import org.eclipse.higgins.sts.common.Fault; -import org.eclipse.higgins.sts.utilities.XMLHelper; -import org.openid4java.message.AuthSuccess; -import org.openid4java.message.ax.FetchResponse; -import org.openid4java.server.ServerAssociationStore; -import org.openid4java.server.JdbcServerAssociationStore; -import org.openid4java.server.NonceGenerator; -import org.openid4java.server.IncrementalNonceGenerator; -import org.openid4java.association.AssociationException; -import org.openid4java.association.Association; -import org.openid4java.OpenIDException; -import org.openid4java.infocard.OpenIDTokenType; -import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.OMNamespace; -import org.apache.axiom.om.OMFactory; -import org.apache.axiom.om.OMAbstractFactory; -import org.apache.axiom.om.util.Base64; - -import javax.sql.DataSource; -import javax.naming.InitialContext; -import javax.naming.NamingException; - -/** - * Handle RSTs and generate RSTRs containing OpenID Tokens. - * - * @author Johnny Bufu - */ -public class OpenIDTokenGeneratorHandler - extends org.eclipse.higgins.sts.server.token.handler.TokenHandler -{ - private final org.eclipse.higgins.sts.utilities.LogHelper log = - new org.eclipse.higgins.sts.utilities.LogHelper - (OpenIDTokenGeneratorHandler.class.getName()); - - javax.xml.namespace.QName qnameIdentityClaimType = - new javax.xml.namespace.QName(null, "ClaimType"); - - javax.xml.namespace.QName qnameIdentityClaimURI = - new javax.xml.namespace.QName(null, "Uri"); - - private boolean bConfigured = false; - - // nonce generator not actually used: - // verification will remove private assoc on first use - private NonceGenerator _nonceGenerator = new IncrementalNonceGenerator(); - - private ServerAssociationStore _privateAssociations; - - private String _opEndpoint; - - private Integer _expireIn; - - /** - * Protected constructor, must use TokenGeneratorHandlerFactory - */ - protected OpenIDTokenGeneratorHandler() - { - this.log.trace("TokenGeneratorHandler::TokenGeneratorHandler"); - } - - /* (non-Javadoc) - * @see org.eclipse.higgins.sts.IExtension#configure(java.util.Hashtable) - */ - public void configure - (final Map mapGlobalSettings, - final String strComponentName, - final Map mapComponentSettings) - { - this.log.trace("TokenGeneratorHandler::initialize"); - - String tableName = (String) mapComponentSettings.get("AssocTableName"); - JdbcServerAssociationStore privateAssociations = - new JdbcServerAssociationStore(tableName); - - boolean status = true; - try - { - InitialContext cxt = new InitialContext(); - String dataSourceJndi = (String) mapComponentSettings.get("AssocDataSource"); - DataSource ds = (DataSource) cxt.lookup(dataSourceJndi); - privateAssociations.setDataSource(ds); - } - catch (NamingException e) - { - log.error("Unable to load JNDI data source from context."); - status = false; - } - - _privateAssociations = privateAssociations; - - java.net.URI opEndpointUri = - (java.net.URI) mapComponentSettings.get("OPEndpoint"); - _opEndpoint = opEndpointUri != null ? opEndpointUri.toString() : null; - - _expireIn = (Integer) mapComponentSettings.get("AssocExpiry"); - - this.bConfigured = status; - } - - /* (non-Javadoc) - * @see org.eclipse.higgins.sts.IExtension#invoke - */ - public void invoke - (final java.util.Map mapGlobalSettings, - final String strComponentName, - final java.util.Map mapComponentSettings, - final java.util.Map mapInvocationSettings, - final IConstants constants, - final ISTSRequest request, - final ISTSResponse response) - { - this.log.trace("TokenGeneratorHandler::invoke: " + strComponentName); - - if (!this.bConfigured) - { - setWstFault(constants, response, "The specified request failed", - "Issue handler not configured"); - return; - } - - // --- load component configuration --- - - final java.net.URI uriDefaultKeyType = - (java.net.URI)mapComponentSettings.get("DefaultKeyType"); - this.log.trace("DefaultKeyType: " + - uriDefaultKeyType != null ? uriDefaultKeyType.toString() : null); - - final java.lang.Boolean bIncludeBearerSubjectName = - (java.lang.Boolean)mapComponentSettings.get("IncludeBearerSubjectName"); - this.log.trace("IncludeBearerSubjectName: " + - bIncludeBearerSubjectName != null ? - bIncludeBearerSubjectName.toString() : null); - - final java.net.URI uriTokenIssuer = - (java.net.URI)mapComponentSettings.get("TokenIssuer"); - this.log.trace("TokenIssuer: " + uriTokenIssuer != null ? - uriTokenIssuer.toString() : null); - - if (null == uriTokenIssuer) - { - setWstFault(constants, response, "The specified request failed", - "TokenIssuer not set."); - return; - } - - final java.net.URI uriSubjectNameIdentifier = - (java.net.URI)mapComponentSettings.get("SubjectNameIdentifierAttribute"); - if (null != uriSubjectNameIdentifier) - this.log.trace("SubjectNameIdentifier: " + - uriSubjectNameIdentifier != null ? - uriSubjectNameIdentifier.toString() : null); - - final java.net.URI uriSubjectNameIdentifierFormat = - (java.net.URI)mapComponentSettings.get("SubjectNameIdentifierFormat"); - if (null != uriSubjectNameIdentifierFormat) - this.log.trace("SubjectNameIdentifierFormat: " + - uriSubjectNameIdentifierFormat != null ? - uriSubjectNameIdentifierFormat.toString() : null); - - final java.lang.Boolean bEncryptToken = - (java.lang.Boolean)mapComponentSettings.get("EncryptToken"); - this.log.trace("EncryptToken: " + - bEncryptToken != null ? bEncryptToken.toString() : null); - - - - // --- extract needed data from the RST --- - - final java.util.List listRST = request.getRequestSecurityTokenCollection(); - final IRequestSecurityToken RST = (IRequestSecurityToken)listRST.get(0); - - final org.eclipse.higgins.sts.api.ILifetime ltLifetime = RST.getLifetime(); - - final java.net.URI uriTokenType = RST.getTokenType(); - if (uriTokenType == null || - (! OpenIDTokenType.OPENID20_TOKEN.toString().equals(uriTokenType.toString()) && - ! OpenIDTokenType.OPENID11_TOKEN.toString().equals(uriTokenType.toString()) ) ) - { - setWstFault(constants, response, "Invalid token type", - "Cannot handle tokens of type: " + uriTokenType); - return; - } - boolean compat = OpenIDTokenType.OPENID11_TOKEN.equals(uriTokenType.toString()); - - // appliesTo = OpenID return_to URL - final org.eclipse.higgins.sts.api.IAppliesTo appliesToRequest = RST.getAppliesTo(); - java.net.URI uriAppliesTo = null; - this.log.trace("Checking for AppliesTo"); - if (appliesToRequest != null) - { - this.log.trace("Found AppliesTo"); - final org.eclipse.higgins.sts.api.IEndpointReference eprAppliesTo = - appliesToRequest.getEndpointReference(); - uriAppliesTo = eprAppliesTo.getAddress(); - } - - if (uriAppliesTo == null) - { - setWstFault(constants, response, "The specified request failed", - "AppliesTo / return_url not found; required for OpenID Tokens."); - return; - } - - final org.eclipse.higgins.sts.api.IDigitalIdentity digitalIdentity = - RST.getDigitalIdentity(); - if (null == digitalIdentity) - { - setWstFault(constants, response, "The specified request failed", - "Digital Subject was not found"); - return; - } - - // --- build response --- - - final OMFactory omFactory = OMAbstractFactory.getOMFactory(); - - final OMNamespace omIdentityNamespace = omFactory.createOMNamespace( - constants.getIdentityNamespace().toString(),"ic"); - - final OMNamespace omWSTrustNamespace = omFactory.createOMNamespace( - constants.getWSTrustNamespace().toString(),"wst"); - - final OMElement omRequestedDisplayToken = omFactory.createOMElement( - "RequestedDisplayToken", omIdentityNamespace); - - final OMElement omDisplayToken = omFactory.createOMElement( - "DisplayToken", omIdentityNamespace, omRequestedDisplayToken); - - OMElement omRequestedSecurityToken = omFactory.createOMElement( - "RequestedSecurityToken", omWSTrustNamespace); - - final org.apache.axiom.om.OMElement omRequestedAttachedReference = - omFactory.createOMElement("RequestedAttachedReference", omWSTrustNamespace); - final org.apache.axiom.om.OMElement omRequestedUnattachedReference = - omFactory.createOMElement("RequestedUnattachedReference", omWSTrustNamespace); - - final org.apache.axiom.om.OMNamespace omWSSNamespace = - omFactory.createOMNamespace(constants.getWSSecurityNamespace().toString(), "wsse"); - final org.apache.axiom.om.OMElement omSecurityTokenReference1 = - omFactory.createOMElement("SecurityTokenReference", - omWSSNamespace, omRequestedAttachedReference); - final org.apache.axiom.om.OMElement omSecurityTokenReference2 = - omFactory.createOMElement("SecurityTokenReference", - omWSSNamespace, omRequestedUnattachedReference); - final org.apache.axiom.om.OMElement omKeyIdentifier1 = - omFactory.createOMElement("KeyIdentifier", - omWSSNamespace, omSecurityTokenReference1); - final org.apache.axiom.om.OMElement omKeyIdentifier2 = - omFactory.createOMElement("KeyIdentifier", - omWSSNamespace, omSecurityTokenReference2); - - String keyIdentifierValueType = - "http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1"; - omKeyIdentifier1.addAttribute("ValueType", keyIdentifierValueType, null); - omKeyIdentifier2.addAttribute("ValueType", keyIdentifierValueType, null); - - - // --- process the claims / attribute request --- - - String claimedID = null; - Map attrs = new HashMap(); - - final java.util.List listClaims = digitalIdentity.getClaims(); - final java.util.Map mapAttributeClaim = - (java.util.Map)mapGlobalSettings.get("AttributeClaimMap"); - - String claimTypeUri; - String value; - String displayTag; - Iterator claimsIter = listClaims.iterator(); - while (claimsIter.hasNext()) - { - final IClaim claim = (IClaim) claimsIter.next(); - - value = claim.getValues().hasNext() ? - (String) claim.getValues().next() : null; - if (value == null) continue; - - claimTypeUri = claim.getType().getName().toString(); - displayTag = (String) ((Map)mapAttributeClaim.get(claimTypeUri)).get("DisplayName"); - - if (OpenIDTokenType.OPENID_CLAIM.equals(claimTypeUri)) - { - claimedID = value; - addDisplayClaim(claimTypeUri, claimedID, displayTag, - omDisplayToken, omIdentityNamespace, omFactory); - if (compat) break; - } - else if (! compat) - { - attrs.put(claimTypeUri, value); - addDisplayClaim(claimTypeUri, value, displayTag, - omDisplayToken, omIdentityNamespace, omFactory); - } - } - - if (claimedID == null) - { - setWstFault(constants, response, - "Cannot process OpenID-token RST", - "No claimed identifier found."); - return; - } - - Association assoc; - try - { - assoc = _privateAssociations.generate( - org.openid4java.association.Association.TYPE_HMAC_SHA1, _expireIn.intValue()); - } - catch (AssociationException e) - { - setWstFault(constants, response, - "Cannot instantiate private association store", - e.getMessage()); - return; - } - - if (! compat && _opEndpoint == null) - { - setWstFault(constants, response, - "Cannot process OpenID-token RST", - "OP-Endpoint not configured; required for OpenID 2 messages."); - return; - } - - // nonces not used: OP invalidates private assoc handle on first use - String nonce = _nonceGenerator.next(); - - AuthSuccess openidResp; - try - { - openidResp = AuthSuccess.createAuthSuccess( - _opEndpoint, claimedID, claimedID, - compat, uriAppliesTo.toString(), nonce, - null, assoc, false); - - if (! compat) - { - FetchResponse fetchResp = FetchResponse.createFetchResponse(); - fetchResp.addAttributes(attrs); - openidResp.addExtension(fetchResp); - } - - // sign the message - openidResp.setSignature(assoc.sign(openidResp.getSignedText())); - } - catch (OpenIDException e) - { - setWstFault(constants, response, - "Cannot generate OpenID assertion", - e.getMessage()); - return; - } - - // set the attached / unattached token reference hash - MessageDigest md; - try - { - md = MessageDigest.getInstance("SHA-1"); - } - catch (NoSuchAlgorithmException e) - { - setWstFault(constants, response, - "Cannot create SHA-1 hash for Requested(Un)AttachedReference", - e.getMessage()); - return; - } - - String sha1base64 = null; - try - { - sha1base64 = Base64.encode( - md.digest(openidResp.keyValueFormEncoding().getBytes("utf-8"))); - } - catch (UnsupportedEncodingException e) - { - setWstFault(constants, response, - "Unsupported encoding for the OpenID message", - e.getMessage()); - return; - } - - omKeyIdentifier1.setText(sha1base64); - omKeyIdentifier2.setText(sha1base64); - - //todo: move this to OMElement OpenIDToken.getToken()? - //OpenIDToken openidToken = new OpenIDToken(openidResp); - final OMNamespace omOpenIDNamespace = omFactory.createOMNamespace( - org.openid4java.message.Message.OPENID2_NS, "openid"); - OMElement omOpenIDToken = omFactory.createOMElement( - "OpenIDToken", omOpenIDNamespace, omRequestedSecurityToken); - - omOpenIDToken.setText(openidResp.keyValueFormEncoding()); - - - final java.util.List listRSTR = - response.getRequestSecurityTokenResponseCollection(); - if (0 == listRSTR.size()) - { - listRSTR.add(new org.eclipse.higgins.sts.common.RequestSecurityTokenResponse()); - } - - final org.eclipse.higgins.sts.api.IRequestSecurityTokenResponse RSTR = - (org.eclipse.higgins.sts.common.RequestSecurityTokenResponse)listRSTR.get(0); - - try - { - RSTR.setTokenType(uriTokenType); - - RSTR.setLifetime(ltLifetime); - - RSTR.setRequestedSecurityToken( - XMLHelper.toElement(omRequestedSecurityToken)); - - RSTR.setRequestedDisplayToken( - XMLHelper.toElement(omRequestedDisplayToken)); - - RSTR.setRequestedAttachedReference - (org.eclipse.higgins.sts.utilities.XMLHelper.toElement(omRequestedAttachedReference)); - RSTR.setRequestedUnattachedReference - (org.eclipse.higgins.sts.utilities.XMLHelper.toElement(omRequestedUnattachedReference)); - - } - catch (final Exception e) - { - org.eclipse.higgins.sts.utilities.ExceptionHelper.Log(this.log,e); - - setWstFault(constants, response, "The specified request failed", - "Failed to set RequestSecurityToken elements."); - } - } - - private void setWstFault(IConstants constants, ISTSResponse response, - String reason, String detail) - { - final Fault fault = new Fault( - constants.getWSTrustNamespace(), - "wst", constants.getRequestFailedFaultCode(), - reason, detail); - - response.setFault(fault); - } - - - public void addDisplayClaim(String uri, String value, String displayTag, - OMElement omParent, OMNamespace omNs, OMFactory omFactory) - { - final OMElement elemDisplayClaim = omFactory.createOMElement( - "DisplayClaim", omNs, omParent); - - elemDisplayClaim.addAttribute("Uri", uri, null); - - // build and set the display tag as the part after the last "/" - final OMElement elemDisplayTag = omFactory.createOMElement( - "DisplayTag", omNs, elemDisplayClaim); - if (displayTag == null || displayTag.length() == 0) - { - int lastIndex = uri.lastIndexOf("/"); - displayTag = ""; - if (lastIndex > -1 && uri.length() > lastIndex) - displayTag = uri.substring(lastIndex + 1); - } - elemDisplayTag.setText(displayTag); - - // set the display value - final OMElement elemDisplayValue = omFactory.createOMElement( - "DisplayValue", omNs, elemDisplayClaim); - elemDisplayValue.setText(value); - } -} \ No newline at end of file diff --git a/src/org/openid4java/infocard/sts/OpenIDTokenGeneratorHandlerFactory.java b/src/org/openid4java/infocard/sts/OpenIDTokenGeneratorHandlerFactory.java deleted file mode 100644 index 6a3a3dac..00000000 --- a/src/org/openid4java/infocard/sts/OpenIDTokenGeneratorHandlerFactory.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2006-2008 Sxip Identity Corporation - */ - -package org.openid4java.infocard.sts; - -/** - * Implements the IConfigurableComponentFactory that creates the IssueHandler implementation. - * - * @author Johnny Bufu - */ -public class OpenIDTokenGeneratorHandlerFactory - implements org.eclipse.higgins.configuration.api.IConfigurableComponentFactory -{ - /** - * Provides access to the singleton instance - * - * @return the singleton instance - */ - public org.eclipse.higgins.configuration.api.IConfigurableComponent getSingletonInstance() - { - return null; - } - - /** - * Provides access to the new instance - * - * @return the new instance - */ - public org.eclipse.higgins.configuration.api.IConfigurableComponent getNewInstance() - { - return new org.openid4java.infocard.sts.OpenIDTokenGeneratorHandler(); - } -} diff --git a/src/org/openid4java/message/AssociationResponse.java b/src/org/openid4java/message/AssociationResponse.java index d6ebe6af..3c7b1712 100644 --- a/src/org/openid4java/message/AssociationResponse.java +++ b/src/org/openid4java/message/AssociationResponse.java @@ -64,7 +64,7 @@ protected AssociationResponse(AssociationRequest assocReq, Association assoc) setAssocHandle(assoc.getHandle()); - Long expiryIn = new Long( ( assoc.getExpiry().getTime() - + Long expiryIn = Long.valueOf( ( assoc.getExpiry().getTime() - System.currentTimeMillis() ) / 1000 ); setExpire(expiryIn); diff --git a/src/org/openid4java/message/Message.java b/src/org/openid4java/message/Message.java index 1d95de81..daf16d19 100644 --- a/src/org/openid4java/message/Message.java +++ b/src/org/openid4java/message/Message.java @@ -276,7 +276,7 @@ public static void addExtensionFactory(Class clazz) throws MessageException try { MessageExtensionFactory extensionFactory = - (MessageExtensionFactory) clazz.newInstance(); + (MessageExtensionFactory) clazz.getDeclaredConstructor().newInstance(); if (DEBUG) _log.debug("Adding extension factory for " + extensionFactory.getTypeUri()); @@ -319,7 +319,7 @@ public static MessageExtensionFactory getExtensionFactory(String typeUri) try { Class extensionClass = (Class) _extensionFactories.get(typeUri); - extensionFactory = (MessageExtensionFactory) extensionClass.newInstance(); + extensionFactory = (MessageExtensionFactory) extensionClass.getDeclaredConstructor().newInstance(); } catch (Exception e) { diff --git a/src/org/openid4java/openid4java-default.properties b/src/org/openid4java/openid4java-default.properties index 22105300..b01cc034 100644 --- a/src/org/openid4java/openid4java-default.properties +++ b/src/org/openid4java/openid4java-default.properties @@ -1,8 +1,7 @@ -# HTML Parser for HtmlResolver of discovery - Must implement org.openid4java.discovery.html.HtmlPaser -discovery.html.parser=org.openid4java.discovery.html.CyberNekoDOMHtmlParser +# HTML Parser for HtmlResolver of discovery - Must implement org.openid4java.discovery.html.HtmlParser +discovery.html.parser=org.openid4java.discovery.html.JsoupHtmlParser # HTML Parser for YadisResolver of discovery - Must implement org.openid4java.discovery.yadis.YadisHtmlParser -discovery.yadis.html.parser=org.openid4java.discovery.yadis.CyberNekoDOMYadisHtmlParser +discovery.yadis.html.parser=org.openid4java.discovery.yadis.JsoupYadisHtmlParser # XRDS Parser for YadisResolver of discovery - Must implement org.openid4java.discovery.yadis.YadisXrdsParser discovery.xrds.parser=org.openid4java.discovery.xrds.XrdsParserImpl -discovery.xri.resolver=org.openid4java.discovery.xri.XriDotNetProxyResolver -#discovery.xri.resolver=org.openid4java.discovery.xri.LocalXriResolver \ No newline at end of file +discovery.xri.resolver=org.openid4java.discovery.xri.XriDotNetProxyResolver \ No newline at end of file diff --git a/src/org/openid4java/util/HtmlUtils.java b/src/org/openid4java/util/HtmlUtils.java new file mode 100644 index 00000000..3fe46ed2 --- /dev/null +++ b/src/org/openid4java/util/HtmlUtils.java @@ -0,0 +1,66 @@ +/* + * Copyright 2006-2008 Sxip Identity Corporation + */ + +package org.openid4java.util; + +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Small HTML helpers shared by the HTML discovery parsers. + */ +public final class HtmlUtils +{ + private static final Pattern NON_MARKUP = Pattern.compile( + "|]*>.*?|]*>.*?", + Pattern.CASE_INSENSITIVE | Pattern.DOTALL); + + private static final Pattern HEAD_BODY_TAG = Pattern.compile( + "<\\s*(/?)\\s*(head|body)\\b[^>]*>", + Pattern.CASE_INSENSITIVE); + + private HtmlUtils() + { + } + + /** + * Counts HEAD start tags that are not inside a BODY element. + * + * HTML parsers normalize malformed documents, so the original markup is + * checked to preserve the "exactly one HEAD" requirement. + * + * @param html the HTML source + * @return the number of top-level HEAD start tags + */ + public static int countTopLevelHeads(String html) + { + if (html == null || html.length() == 0) + { + return 0; + } + + String markup = NON_MARKUP.matcher(html).replaceAll(""); + Matcher matcher = HEAD_BODY_TAG.matcher(markup); + boolean inBody = false; + int heads = 0; + + while (matcher.find()) + { + boolean closing = matcher.group(1).length() > 0; + String tag = matcher.group(2).toLowerCase(Locale.ROOT); + + if ("body".equals(tag)) + { + inBody = !closing; + } + else if (!closing && !inBody) + { + heads++; + } + } + + return heads; + } +} diff --git a/src/org/openid4java/util/HttpCache.java b/src/org/openid4java/util/HttpCache.java index 5782f04f..3ce3c309 100644 --- a/src/org/openid4java/util/HttpCache.java +++ b/src/org/openid4java/util/HttpCache.java @@ -6,20 +6,19 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.Header; -import org.apache.http.HttpEntity; -import org.apache.http.NameValuePair; -import org.apache.http.client.HttpClient; -import org.apache.http.client.entity.UrlEncodedFormEntity; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpHead; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.params.AllClientPNames; -import org.apache.http.conn.ssl.X509HostnameVerifier; -import org.apache.http.message.BasicNameValuePair; +import org.apache.hc.client5.http.classic.methods.HttpGet; +import org.apache.hc.client5.http.classic.methods.HttpHead; +import org.apache.hc.client5.http.classic.methods.HttpPost; +import org.apache.hc.client5.http.entity.UrlEncodedFormEntity; +import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; +import org.apache.hc.core5.http.Header; +import org.apache.hc.core5.http.HttpEntity; +import org.apache.hc.core5.http.NameValuePair; +import org.apache.hc.core5.http.message.BasicNameValuePair; import java.io.IOException; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -28,6 +27,7 @@ import java.util.Map.Entry; import java.util.Date; +import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLContext; /** @@ -45,7 +45,7 @@ public class HttpCache extends AbstractHttpFetcher /** * HttpClient used to place the HTTP requests. */ - private HttpClient _client; + private CloseableHttpClient _client; /** * Cache for GET requests. Map of URL -> HttpResponse. @@ -75,7 +75,7 @@ public HttpCache(SSLContext sslContext) * * @see HttpRequestOptions */ - public HttpCache(SSLContext sslContext, X509HostnameVerifier hostnameVerifier) + public HttpCache(SSLContext sslContext, HostnameVerifier hostnameVerifier) { super(); _client = HttpClientFactory.getInstance( @@ -124,35 +124,24 @@ public HttpResponse get(String url, HttpRequestOptions requestOptions) } HttpGet get = new HttpGet(url); + HttpUtils.setRequestOptions(get, requestOptions); - org.apache.http.HttpResponse httpResponse = null; - HttpEntity responseEntity = null; + resp = _client.execute(get, httpResponse -> { + int statusCode = httpResponse.getCode(); + String statusLine = httpResponse.getReasonPhrase(); - try - { - get.getParams().setParameter(AllClientPNames.HANDLE_REDIRECTS, Boolean.TRUE); - HttpUtils.setRequestOptions(get, requestOptions); - - httpResponse = _client.execute(get); - responseEntity = httpResponse.getEntity(); - int statusCode = httpResponse.getStatusLine().getStatusCode(); - String statusLine = httpResponse.getStatusLine().getReasonPhrase(); - - ResponseBody body = getResponseBody(responseEntity, + ResponseBody body = getResponseBody(httpResponse.getEntity(), requestOptions.getMaxBodySize()); - resp = new DefaultHttpResponse(statusCode, statusLine, - requestOptions.getMaxRedirects(), get.getURI().toString(), - httpResponse.getAllHeaders(), body.getBody()); - resp.setBodySizeExceeded(body.isBodyTruncated()); + DefaultHttpResponse response = new DefaultHttpResponse(statusCode, statusLine, + requestOptions.getMaxRedirects(), url, + httpResponse.getHeaders(), body.getBody()); + response.setBodySizeExceeded(body.isBodyTruncated()); + return response; + }); - // save result in cache - _getCache.put(url, resp); - } - finally - { - HttpUtils.dispose(responseEntity); - } + // save result in cache + _getCache.put(url, resp); return resp; } @@ -174,35 +163,24 @@ public HttpResponse post(String url, Map parameters, // build the post message with the parameters from the request HttpPost post = new HttpPost(url); + HttpUtils.setRequestOptions(post, requestOptions, false); + post.setEntity(new UrlEncodedFormEntity(toList(parameters), StandardCharsets.UTF_8)); - DefaultHttpResponse resp; - org.apache.http.HttpResponse httpResponse = null; - try - { - // can't follow redirects on a POST (w/o user intervention) - post.getParams().setBooleanParameter(AllClientPNames.HANDLE_REDIRECTS, false); - HttpUtils.setRequestOptions(post, requestOptions); - - post.setEntity(new UrlEncodedFormEntity(toList(parameters), "UTF-8")); - - // place the http call to the OP - if (DEBUG) _log.debug("Performing HTTP POST on " + url); - httpResponse = _client.execute(post); - int statusCode = httpResponse.getStatusLine().getStatusCode(); - String statusLine = httpResponse.getStatusLine().getReasonPhrase(); + // place the http call to the OP + if (DEBUG) _log.debug("Performing HTTP POST on " + url); + DefaultHttpResponse resp = _client.execute(post, httpResponse -> { + int statusCode = httpResponse.getCode(); + String statusLine = httpResponse.getReasonPhrase(); ResponseBody body = getResponseBody(httpResponse.getEntity(), requestOptions.getMaxBodySize()); - resp = new DefaultHttpResponse(statusCode, statusLine, - requestOptions.getMaxRedirects(), post.getURI().toString(), - httpResponse.getAllHeaders(), body.getBody()); - resp.setBodySizeExceeded(body.isBodyTruncated()); - } - finally - { - HttpUtils.dispose(httpResponse); - } + DefaultHttpResponse response = new DefaultHttpResponse(statusCode, statusLine, + requestOptions.getMaxRedirects(), url, + httpResponse.getHeaders(), body.getBody()); + response.setBodySizeExceeded(body.isBodyTruncated()); + return response; + }); return resp; } @@ -323,32 +301,19 @@ public HttpResponse head(String url, HttpRequestOptions requestOptions) } HttpHead head = new HttpHead(url); + HttpUtils.setRequestOptions(head, requestOptions); - org.apache.http.HttpResponse httpResponse = null; - HttpEntity responseEntity = null; - - try - { - head.getParams().setParameter(AllClientPNames.HANDLE_REDIRECTS, Boolean.TRUE); - HttpUtils.setRequestOptions(head, requestOptions); - - httpResponse = _client.execute(head); - responseEntity = httpResponse.getEntity(); + resp = _client.execute(head, httpResponse -> { + int statusCode = httpResponse.getCode(); + String statusLine = httpResponse.getReasonPhrase(); - int statusCode = httpResponse.getStatusLine().getStatusCode(); - String statusLine = httpResponse.getStatusLine().getReasonPhrase(); + return new DefaultHttpResponse(statusCode, statusLine, + requestOptions.getMaxRedirects(), url, + httpResponse.getHeaders(), null); + }); - resp = new DefaultHttpResponse(statusCode, statusLine, - requestOptions.getMaxRedirects(), head.getURI().toString(), - httpResponse.getAllHeaders(), null); - - // save result in cache - _headCache.put(url, resp); - } - finally - { - HttpUtils.dispose(responseEntity); - } + // save result in cache + _headCache.put(url, resp); return resp; } diff --git a/src/org/openid4java/util/HttpClientFactory.java b/src/org/openid4java/util/HttpClientFactory.java index 5f6a907e..6375a9f6 100644 --- a/src/org/openid4java/util/HttpClientFactory.java +++ b/src/org/openid4java/util/HttpClientFactory.java @@ -7,24 +7,21 @@ */ package org.openid4java.util; -import org.apache.http.HttpHost; -import org.apache.http.auth.AuthScope; -import org.apache.http.auth.Credentials; -import org.apache.http.client.HttpClient; -import org.apache.http.client.params.AllClientPNames; -import org.apache.http.conn.ClientConnectionManager; -import org.apache.http.conn.params.ConnRoutePNames; -import org.apache.http.conn.scheme.PlainSocketFactory; -import org.apache.http.conn.scheme.Scheme; -import org.apache.http.conn.scheme.SchemeRegistry; -import org.apache.http.conn.ssl.SSLSocketFactory; -import org.apache.http.conn.ssl.X509HostnameVerifier; -import org.apache.http.impl.client.DefaultHttpClient; -import org.apache.http.impl.conn.SingleClientConnManager; -import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager; -import org.apache.http.params.BasicHttpParams; -import org.apache.http.params.HttpParams; - +import org.apache.hc.client5.http.auth.AuthScope; +import org.apache.hc.client5.http.config.ConnectionConfig; +import org.apache.hc.client5.http.config.RequestConfig; +import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider; +import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; +import org.apache.hc.client5.http.impl.classic.HttpClientBuilder; +import org.apache.hc.client5.http.impl.classic.HttpClients; +import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder; +import org.apache.hc.client5.http.io.HttpClientConnectionManager; +import org.apache.hc.client5.http.ssl.ClientTlsStrategyBuilder; +import org.apache.hc.client5.http.ssl.TlsSocketStrategy; +import org.apache.hc.core5.http.HttpHost; +import org.apache.hc.core5.util.Timeout; + +import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLContext; /** @@ -61,92 +58,93 @@ public static boolean isMultiThreadedHttpClient() { /** * Configures the type of HttpClient's constructed by the factory. * - * @param multiThreadedHttpClient if true, MultiThreadedHttpConnectionManager's are constructed; - * if false - SimpleHttpConnectionManager's. - * + * @param multiThreadedHttpClient if true, a pooling connection manager is + * constructed; otherwise a connection pool + * limited to a single connection is used. */ public static void setMultiThreadedHttpClient(boolean multiThreadedHttpClient) { HttpClientFactory.multiThreadedHttpClient = multiThreadedHttpClient; } - public static HttpClient getInstance(int maxRedirects, + public static CloseableHttpClient getInstance(int maxRedirects, Boolean allowCircularRedirects, int connTimeout, int socketTimeout, String cookiePolicy) { - return getInstance(maxRedirects, allowCircularRedirects, connTimeout, socketTimeout, cookiePolicy, null, null); + return getInstance(maxRedirects, allowCircularRedirects, connTimeout, + socketTimeout, cookiePolicy, null, null); } - - public static HttpClient getInstance(int maxRedirects, + + public static CloseableHttpClient getInstance(int maxRedirects, Boolean allowCircularRedirects, int connTimeout, int socketTimeout, String cookiePolicy, SSLContext sslContext, - X509HostnameVerifier hostnameVerifier) + HostnameVerifier hostnameVerifier) { - HttpParams httpParams = new BasicHttpParams(); - - SchemeRegistry registry = new SchemeRegistry(); - - registry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); - SSLSocketFactory sslSocketFactory; - if (null == sslContext) + ClientTlsStrategyBuilder tlsStrategyBuilder = ClientTlsStrategyBuilder.create(); + if (sslContext != null) { - sslSocketFactory = SSLSocketFactory.getSocketFactory(); + tlsStrategyBuilder.setSslContext(sslContext); } - else + if (hostnameVerifier != null) { - sslSocketFactory = new SSLSocketFactory(sslContext); + tlsStrategyBuilder.setHostnameVerifier(hostnameVerifier); } - if (null != hostnameVerifier) + TlsSocketStrategy tlsStrategy = tlsStrategyBuilder.buildClassic(); + + ConnectionConfig connectionConfig = ConnectionConfig.custom() + .setConnectTimeout(Timeout.ofMilliseconds(connTimeout)) + .build(); + + PoolingHttpClientConnectionManagerBuilder connManagerBuilder = + PoolingHttpClientConnectionManagerBuilder.create() + .setTlsSocketStrategy(tlsStrategy) + .setDefaultConnectionConfig(connectionConfig); + + if (!multiThreadedHttpClient) { - sslSocketFactory.setHostnameVerifier(hostnameVerifier); + connManagerBuilder.setMaxConnTotal(1); + connManagerBuilder.setMaxConnPerRoute(1); } - registry.register(new Scheme("https", 443, sslSocketFactory)); - - ClientConnectionManager connManager; - if (multiThreadedHttpClient) - connManager = new ThreadSafeClientConnManager(registry); - else - connManager = new SingleClientConnManager(registry); - - DefaultHttpClient client = new DefaultHttpClient(connManager, httpParams); - - client.getParams().setParameter(AllClientPNames.MAX_REDIRECTS, - new Integer(maxRedirects)); - client.getParams().setParameter(AllClientPNames.ALLOW_CIRCULAR_REDIRECTS, - allowCircularRedirects); - client.getParams().setParameter(AllClientPNames.SO_TIMEOUT, - new Integer(socketTimeout)); - client.getParams().setParameter(AllClientPNames.CONNECTION_TIMEOUT, - new Integer(connTimeout)); - if (cookiePolicy == null) + HttpClientConnectionManager connManager = connManagerBuilder.build(); + + RequestConfig.Builder requestConfigBuilder = RequestConfig.custom() + .setMaxRedirects(maxRedirects) + .setCircularRedirectsAllowed(Boolean.TRUE.equals(allowCircularRedirects)) + .setResponseTimeout(Timeout.ofMilliseconds(socketTimeout)); + + if (cookiePolicy != null) { - client.setCookieStore(null); + requestConfigBuilder.setCookieSpec(cookiePolicy); } - else + + HttpClientBuilder clientBuilder = HttpClients.custom() + .setConnectionManager(connManager) + .setDefaultRequestConfig(requestConfigBuilder.build()); + + if (cookiePolicy == null) { - client.getParams().setParameter(AllClientPNames.COOKIE_POLICY, - cookiePolicy); + clientBuilder.disableCookieManagement(); } - if (proxyProperties != null) { HttpHost proxy = new HttpHost( - proxyProperties.getProxyHostName(), - proxyProperties.getProxyPort()); - - client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); - - //now set headers for auth - AuthScope authScope = new AuthScope(AuthScope.ANY_HOST, - AuthScope.ANY_PORT, AuthScope.ANY_REALM, AuthScope.ANY_SCHEME); - Credentials credentials = proxyProperties.getCredentials(); - client.getCredentialsProvider().setCredentials(authScope, credentials); + proxyProperties.getProxyHostName(), + proxyProperties.getProxyPort()); + + clientBuilder.setProxy(proxy); + + BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider(); + AuthScope authScope = new AuthScope( + proxyProperties.getProxyHostName(), + proxyProperties.getProxyPort()); + credentialsProvider.setCredentials(authScope, + proxyProperties.getCredentials()); + clientBuilder.setDefaultCredentialsProvider(credentialsProvider); } - return client; + return clientBuilder.build(); } } - diff --git a/src/org/openid4java/util/HttpFetcherFactory.java b/src/org/openid4java/util/HttpFetcherFactory.java index ee7dad2c..40b33861 100644 --- a/src/org/openid4java/util/HttpFetcherFactory.java +++ b/src/org/openid4java/util/HttpFetcherFactory.java @@ -16,10 +16,9 @@ */ package org.openid4java.util; +import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLContext; -import org.apache.http.conn.ssl.X509HostnameVerifier; - import com.google.inject.Inject; import com.google.inject.Provider; @@ -47,7 +46,7 @@ public HttpFetcherFactory(SSLContext sslContext) this(new HttpCacheProvider(sslContext)); } - public HttpFetcherFactory(SSLContext sslContext, X509HostnameVerifier hostnameVerifier) + public HttpFetcherFactory(SSLContext sslContext, HostnameVerifier hostnameVerifier) { this(new HttpCacheProvider(sslContext, hostnameVerifier)); } @@ -63,9 +62,9 @@ private static class HttpCacheProvider implements Provider { private final SSLContext sslContext; - private final X509HostnameVerifier hostnameVerifier; + private final HostnameVerifier hostnameVerifier; - public HttpCacheProvider(SSLContext sslContext, X509HostnameVerifier hostnameVerifier) + public HttpCacheProvider(SSLContext sslContext, HostnameVerifier hostnameVerifier) { this.sslContext = sslContext; this.hostnameVerifier = hostnameVerifier; diff --git a/src/org/openid4java/util/HttpResponse.java b/src/org/openid4java/util/HttpResponse.java index 9e542dac..63a04ed0 100644 --- a/src/org/openid4java/util/HttpResponse.java +++ b/src/org/openid4java/util/HttpResponse.java @@ -3,7 +3,7 @@ */ package org.openid4java.util; -import org.apache.http.Header; +import org.apache.hc.core5.http.Header; /** * Container class for HTTP responses. diff --git a/src/org/openid4java/util/HttpUtils.java b/src/org/openid4java/util/HttpUtils.java index f9aaac98..07a9b7f6 100644 --- a/src/org/openid4java/util/HttpUtils.java +++ b/src/org/openid4java/util/HttpUtils.java @@ -4,9 +4,12 @@ package org.openid4java.util; -import org.apache.http.HttpEntity; -import org.apache.http.client.methods.HttpRequestBase; -import org.apache.http.client.params.AllClientPNames; +import org.apache.hc.client5.http.classic.methods.HttpUriRequestBase; +import org.apache.hc.client5.http.config.RequestConfig; +import org.apache.hc.core5.http.ClassicHttpResponse; +import org.apache.hc.core5.http.HttpEntity; +import org.apache.hc.core5.http.io.entity.EntityUtils; +import org.apache.hc.core5.util.Timeout; import java.util.Iterator; import java.util.Map; @@ -18,15 +21,11 @@ private HttpUtils() // empty } - public static void dispose(final org.apache.http.HttpResponse response) + public static void dispose(final ClassicHttpResponse response) { if (response != null) { - HttpEntity e = response.getEntity(); - if (e != null) - { - dispose(e); - } + dispose(response.getEntity()); } } @@ -34,27 +33,27 @@ public static void dispose(final HttpEntity entity) { if (entity != null) { - try - { - entity.consumeContent(); - } - catch (Exception ignored) - { - // ignored - } + EntityUtils.consumeQuietly(entity); } } - public static void setRequestOptions(HttpRequestBase request, HttpRequestOptions requestOptions) + public static void setRequestOptions(HttpUriRequestBase request, + HttpRequestOptions requestOptions) + { + setRequestOptions(request, requestOptions, true); + } + + public static void setRequestOptions(HttpUriRequestBase request, + HttpRequestOptions requestOptions, + boolean redirectsEnabled) { - request.getParams().setParameter(AllClientPNames.MAX_REDIRECTS, - new Integer(requestOptions.getMaxRedirects())); - request.getParams().setParameter(AllClientPNames.SO_TIMEOUT, - new Integer(requestOptions.getSocketTimeout())); - request.getParams().setParameter(AllClientPNames.CONNECTION_TIMEOUT, - new Integer(requestOptions.getConnTimeout())); - request.getParams().setParameter(AllClientPNames.ALLOW_CIRCULAR_REDIRECTS, - Boolean.valueOf(requestOptions.getAllowCircularRedirects())); + RequestConfig config = RequestConfig.custom() + .setMaxRedirects(requestOptions.getMaxRedirects()) + .setCircularRedirectsAllowed(requestOptions.getAllowCircularRedirects()) + .setResponseTimeout(Timeout.ofMilliseconds(requestOptions.getSocketTimeout())) + .setRedirectsEnabled(redirectsEnabled) + .build(); + request.setConfig(config); Map requestHeaders = requestOptions.getRequestHeaders(); if (requestHeaders != null) diff --git a/src/org/openid4java/util/OpenID4JavaDOMParser.java b/src/org/openid4java/util/OpenID4JavaDOMParser.java deleted file mode 100644 index 07be2ec7..00000000 --- a/src/org/openid4java/util/OpenID4JavaDOMParser.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright 2006-2008 Sxip Identity Corporation - */ - -package org.openid4java.util; - -import org.apache.xerces.xni.Augmentations; -import org.apache.xerces.xni.QName; -import org.apache.xerces.xni.XMLAttributes; -import org.cyberneko.html.HTMLTagBalancingListener; -import org.cyberneko.html.parsers.DOMParser; -import org.openid4java.discovery.RuntimeDiscoveryException; -import org.w3c.dom.Document; -import org.w3c.dom.html.HTMLHtmlElement; -import org.xml.sax.*; - -import javax.xml.transform.*; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; -import java.io.*; - -/** - * A DOMParser extends from Cyberneko HTML. - *

- * This extended parser marks that a(or more) HTML element head is - * ignored while parsing. - *

- * - * @author Sutra Zhou - * @see NekoHTML - * @since 0.9.4 - */ -public class OpenID4JavaDOMParser extends DOMParser implements HTMLTagBalancingListener -{ - /** - * Create an InputSource form a String. - * - * @param s - * the String - * @return an InputSource - * @throws NullPointerException - * if s is null. - */ - public static InputSource createInputSource(String s) - { - try - { - return new InputSource( - new ByteArrayInputStream(s.getBytes("UTF-8"))); - } - catch (UnsupportedEncodingException e) - { - throw new RuntimeException(e); - } - } - - /** - * Transform the document to string. - * - * @param doc the document - * @return a string - * @throws TransformerException If an unrecoverable error occurs - * during the course of the transformation. - */ - public static String toXmlString(Document doc) throws TransformerException - { - TransformerFactory factory = TransformerFactory.newInstance(); - Transformer transformer; - try - { - transformer = factory.newTransformer(); - } - catch (TransformerConfigurationException e) - { - throw new RuntimeException(e); - } - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - transformer.setOutputProperty(OutputKeys.STANDALONE, "yes"); - transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); - - DOMSource source = new DOMSource(doc); - StringWriter xmlString = new StringWriter(); - StreamResult streamResult = new StreamResult(xmlString); - transformer.transform(source, streamResult); - return xmlString.toString(); - } - - private boolean ignoredHeadStartElement; - - /** - * @see NekoHTML | Parser Settings - */ - public OpenID4JavaDOMParser() { - try - { - this.setFeature("http://xml.org/sax/features/namespaces", false); - this.setFeature("http://xml.org/sax/features/validation", false); - this.setFeature("http://xml.org/sax/features/external-general-entities", false); - this.setFeature("http://xml.org/sax/features/external-parameter-entities", false); - this.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false); - this.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); - this.setEntityResolver(new EntityResolver() { - public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { - throw new RuntimeDiscoveryException("External entity found in input data" ); - } - }); - } - catch (SAXNotRecognizedException e) - { - // Do nothing as this exception will not happen. - } - catch (SAXNotSupportedException e) - { - // Do nothing as this exception will not happen. - } - } - - public boolean isIgnoredHeadStartElement() - { - return ignoredHeadStartElement; - } - - public void ignoredEndElement(QName element, Augmentations augs) - { - // Do nothing. - } - - public void ignoredStartElement(QName element, XMLAttributes attrs, Augmentations augs) - { - if (element.rawname.equals("HEAD") - && this.fCurrentNode instanceof HTMLHtmlElement) - { - this.ignoredHeadStartElement = true; - } - } -} \ No newline at end of file diff --git a/src/org/openid4java/util/OpenID4JavaUtils.java b/src/org/openid4java/util/OpenID4JavaUtils.java index 8039dda3..467590c9 100644 --- a/src/org/openid4java/util/OpenID4JavaUtils.java +++ b/src/org/openid4java/util/OpenID4JavaUtils.java @@ -31,7 +31,11 @@ public class OpenID4JavaUtils // Load default properties first, then use custom properties to replace // the default. _appProperties = new Properties(); - _appProperties.putAll(loadProperties("openid4java-default.properties")); + Properties defaults = loadProperties("openid4java-default.properties"); + if (defaults != null) + { + _appProperties.putAll(defaults); + } Properties custom = loadProperties("/openid4java.properties"); if (custom != null) { diff --git a/src/org/openid4java/util/ProxyProperties.java b/src/org/openid4java/util/ProxyProperties.java index a7e80388..a34d48bc 100644 --- a/src/org/openid4java/util/ProxyProperties.java +++ b/src/org/openid4java/util/ProxyProperties.java @@ -4,9 +4,9 @@ package org.openid4java.util; -import org.apache.http.auth.Credentials; -import org.apache.http.auth.NTCredentials; -import org.apache.http.auth.UsernamePasswordCredentials; +import org.apache.hc.client5.http.auth.Credentials; +import org.apache.hc.client5.http.auth.NTCredentials; +import org.apache.hc.client5.http.auth.UsernamePasswordCredentials; /** * Utility bean for setting transport properties in runtime. @@ -102,19 +102,20 @@ public void setUserName(String userName) * * @return the proxy credentials */ + @SuppressWarnings("deprecation") public Credentials getCredentials() { Credentials credentials = null; if (this.getDomain().equals(ANONYMOUS)) { credentials = new UsernamePasswordCredentials( this.getUserName(), - this.getPassword()); + this.getPassword().toCharArray()); } else { credentials = new NTCredentials( this.getUserName(), - this.getPassword(), + this.getPassword().toCharArray(), this.getProxyHostName(), this.getDomain()); } diff --git a/src/overview.html b/src/overview.html index 3bae2e4b..f5267285 100644 --- a/src/overview.html +++ b/src/overview.html @@ -19,8 +19,8 @@

Consumer Site / Relying Party:

Relying Party (Consumer) and the library are the {@link org.openid4java.consumer.ConsumerManager ConsumerManager} and {@link org.openid4java.discovery.Discovery Discovery} classes. -A reference {@link org.openid4java.consumer.SampleConsumer SampleConsumer} -implementation is provided in the consumer package. +A reference SampleConsumer implementation is provided in the test +sources under org.openid4java.consumer. See the general usage pattern below.

@@ -29,8 +29,8 @@

OpenID Provider / Server:

The main interaction point between a web application acting as a OpenID Provider (Server) and the library is the {@link org.openid4java.server.ServerManager ServerManager} class. -A reference {@link org.openid4java.server.SampleServer SampleServer} -implementation is provided in the server package. +A reference SampleServer implementation is provided in the test +sources under org.openid4java.server. See the general usage pattern below.

@@ -84,7 +84,7 @@

Relying Party / Consumer Usage Pattern:

// Allows payloads > 255 bytes // <FORM action="OpenID Provider's service endpoint"> - // see samples/formredirection.jsp for a JSP example + // build the HTML form from authReq.getParameterMap() authReq.getOPEndpoint(); // build a HTML FORM with the message parameters diff --git a/test/src/log4j.properties b/test/src/log4j.properties deleted file mode 100644 index 3be91629..00000000 --- a/test/src/log4j.properties +++ /dev/null @@ -1,20 +0,0 @@ -# -# Copyright 2006-2008 Sxip Identity Corporation -# - -log4j.rootLogger=INFO, File, Console -log4j.logger.org.openid4java=DEBUG -#log4j.logger.org.openid4java=WARN -log4j.logger.org.openid4java.samples=DEBUG - -log4j.appender.File=org.apache.log4j.FileAppender -log4j.appender.File.File=build/test/testLog.txt -log4j.appender.File.layout=org.apache.log4j.PatternLayout -log4j.appender.File.layout.ConversionPattern=[%-5p] %d{ABSOLUTE} [%-40F:%4L] %-20x : %m%n -log4j.appender.File.append=false - -log4j.appender.Console=org.apache.log4j.ConsoleAppender -log4j.appender.Console.Threshold=DEBUG -#log4j.appender.Console.Target=System.out -log4j.appender.Console.layout=org.apache.log4j.PatternLayout -log4j.appender.Console.layout.ConversionPattern=[%-5p] %d{ABSOLUTE} [%-40F:%4L] %-20x : %m%n diff --git a/test/src/org/openid4java/consumer/EhcacheNonceVerifierTest.java b/test/src/org/openid4java/consumer/EhcacheNonceVerifierTest.java index acff3f63..d4b72c92 100644 --- a/test/src/org/openid4java/consumer/EhcacheNonceVerifierTest.java +++ b/test/src/org/openid4java/consumer/EhcacheNonceVerifierTest.java @@ -6,8 +6,16 @@ import junit.framework.Test; import junit.framework.TestSuite; -import net.sf.ehcache.CacheManager; -import net.sf.ehcache.Cache; +import org.ehcache.Cache; +import org.ehcache.CacheManager; +import org.ehcache.config.CacheConfiguration; +import org.ehcache.config.builders.CacheConfigurationBuilder; +import org.ehcache.config.builders.CacheManagerBuilder; +import org.ehcache.config.builders.ResourcePoolsBuilder; +import org.ehcache.expiry.ExpiryPolicy; + +import java.time.Duration; +import java.util.function.Supplier; /** * @author Marius Scurtescu, Johnny Bufu @@ -15,6 +23,7 @@ public class EhcacheNonceVerifierTest extends AbstractNonceVerifierTest { private CacheManager _cacheManager; + private int _cacheCount; public EhcacheNonceVerifierTest(String name) { @@ -23,7 +32,7 @@ public EhcacheNonceVerifierTest(String name) public void setUp() throws Exception { - _cacheManager = new CacheManager(); + _cacheManager = CacheManagerBuilder.newCacheManagerBuilder().build(true); super.setUp(); } @@ -32,16 +41,44 @@ public void tearDown() throws Exception { super.tearDown(); + if (_cacheManager != null) + { + _cacheManager.close(); + } _cacheManager = null; } public NonceVerifier createVerifier(int maxAge) { - _cacheManager.removalAll(); - _cacheManager.addCache(new Cache("testCache", 100, false, false, maxAge, maxAge)); + ExpiryPolicy expiryPolicy = new ExpiryPolicy() + { + public Duration getExpiryForCreation(String key, String value) + { + return Duration.ofSeconds(maxAge); + } + + public Duration getExpiryForAccess(String key, Supplier valueSupplier) + { + return Duration.ofSeconds(maxAge); + } + + public Duration getExpiryForUpdate(String key, Supplier oldValueSupplier, String newValue) + { + return Duration.ofSeconds(maxAge); + } + }; + + CacheConfiguration configuration = CacheConfigurationBuilder + .newCacheConfigurationBuilder(String.class, String.class, + ResourcePoolsBuilder.heap(100)) + .withExpiry(expiryPolicy) + .build(); + + Cache cache = _cacheManager.createCache( + "testCache" + _cacheCount++, configuration); EhcacheNonceVerifier nonceVerifier = new EhcacheNonceVerifier(maxAge); - nonceVerifier.setCache(_cacheManager.getCache("testCache")); + nonceVerifier.setCache(cache); return nonceVerifier; } diff --git a/test/src/org/openid4java/consumer/InjectionTest.java b/test/src/org/openid4java/consumer/InjectionTest.java index 8d68f248..2cbc28c6 100644 --- a/test/src/org/openid4java/consumer/InjectionTest.java +++ b/test/src/org/openid4java/consumer/InjectionTest.java @@ -22,7 +22,7 @@ import junit.framework.TestCase; -import org.apache.http.Header; +import org.apache.hc.core5.http.Header; import org.openid4java.discovery.yadis.YadisResolver; import org.openid4java.util.AbstractHttpFetcher; import org.openid4java.util.HttpCache; diff --git a/test/src/org/openid4java/consumer/JdbcNonceVerifierTest.java b/test/src/org/openid4java/consumer/JdbcNonceVerifierTest.java index b99065ee..7614813e 100644 --- a/test/src/org/openid4java/consumer/JdbcNonceVerifierTest.java +++ b/test/src/org/openid4java/consumer/JdbcNonceVerifierTest.java @@ -2,7 +2,7 @@ import junit.framework.Test; import junit.framework.TestSuite; -import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.datasource.SingleConnectionDataSource; import javax.sql.DataSource; @@ -16,14 +16,11 @@ public JdbcNonceVerifierTest(String name) { @Override public NonceVerifier createVerifier(int maxAge) { DataSource dataSource = new SingleConnectionDataSource( - "org.hsqldb.jdbcDriver", "jdbc:hsqldb:mem:saasstore_security_client", "sa", "", true); - SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource); - jdbcTemplate.getJdbcOperations().execute( + JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); + jdbcTemplate.execute( "DROP TABLE IF EXISTS openid_nonce;"); - jdbcTemplate - .getJdbcOperations() - .execute( + jdbcTemplate.execute( "CREATE TABLE openid_nonce ( " + "opurl varchar(255) NOT NULL, nonce varchar(25) NOT NULL, " + "date datetime DEFAULT NULL, PRIMARY KEY (opurl,nonce))"); diff --git a/src/org/openid4java/consumer/SampleConsumer.java b/test/src/org/openid4java/consumer/SampleConsumer.java similarity index 100% rename from src/org/openid4java/consumer/SampleConsumer.java rename to test/src/org/openid4java/consumer/SampleConsumer.java diff --git a/test/src/org/openid4java/discovery/html/CyberNekoDOMHtmlParserTest.java b/test/src/org/openid4java/discovery/html/CyberNekoDOMHtmlParserTest.java deleted file mode 100644 index f702b3c4..00000000 --- a/test/src/org/openid4java/discovery/html/CyberNekoDOMHtmlParserTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2006-2008 Sxip Identity Corporation - */ - -package org.openid4java.discovery.html; - -import junit.framework.TestCase; -import org.apache.commons.io.IOUtils; -import org.openid4java.discovery.DiscoveryException; - -import java.io.IOException; - -/** - * @author Sutra Zhou - * - */ -public class CyberNekoDOMHtmlParserTest extends TestCase -{ - private CyberNekoDOMHtmlParser parser; - - /* - * (non-Javadoc) - * - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception - { - super.setUp(); - parser = new CyberNekoDOMHtmlParser(); - } - - /** - * Test method for - * {@link org.openid4java.discovery.html.CyberNekoDOMHtmlParser#parseHtml(java.lang.String, org.openid4java.discovery.html.HtmlResult)} - * . - * - * @throws IOException - * @throws DiscoveryException - */ - public void testParseHtml() throws IOException, DiscoveryException - { - String htmlData = IOUtils.toString(this.getClass().getResourceAsStream( - "identityPage.html")); - HtmlResult result = new HtmlResult(); - parser.parseHtml(htmlData, result); - assertEquals("http://www.example.com:8080/openidserver/users/myusername", result - .getDelegate1()); - System.out.println(result.getOP1Endpoint()); - assertEquals("http://www.example.com:8080/openidserver/openid.server", result - .getOP1Endpoint().toExternalForm()); - } - - /** - * Test method for - * {@link org.openid4java.discovery.html.CyberNekoDOMHtmlParser#parseHtml(java.lang.String, org.openid4java.discovery.html.HtmlResult)} - * . - * - * @throws IOException - * @throws DiscoveryException - */ - public void testParseHtmlWithXmlNamespace() throws IOException, - DiscoveryException - { - String htmlData = IOUtils.toString(this.getClass().getResourceAsStream( - "identityPage-with-xml-namespace.html")); - HtmlResult result = new HtmlResult(); - parser.parseHtml(htmlData, result); - assertEquals("http://www.example.com:8080/openidserver/users/myusername", result - .getDelegate1()); - assertEquals("http://www.example.com:8080/openidserver/openid.server", result - .getOP1Endpoint().toExternalForm()); - } - - public void testParseHtmlXXE() throws Exception - { - String htmlData = IOUtils.toString(this.getClass().getResourceAsStream( - "identityPageWithExternalEntityReference.html")); - parser.parseHtml(htmlData, new HtmlResult()); - // don't fail trying to read "/path/to/some/file" from the input data - } - -} diff --git a/test/src/org/openid4java/discovery/html/JsoupHtmlParserTest.java b/test/src/org/openid4java/discovery/html/JsoupHtmlParserTest.java new file mode 100644 index 00000000..e353b5df --- /dev/null +++ b/test/src/org/openid4java/discovery/html/JsoupHtmlParserTest.java @@ -0,0 +1,65 @@ +/* + * Copyright 2006-2008 Sxip Identity Corporation + */ + +package org.openid4java.discovery.html; + +import junit.framework.TestCase; +import org.apache.commons.io.IOUtils; +import org.openid4java.discovery.DiscoveryException; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; + +/** + * @author Sutra Zhou + */ +public class JsoupHtmlParserTest extends TestCase +{ + private JsoupHtmlParser parser; + + protected void setUp() throws Exception + { + super.setUp(); + parser = new JsoupHtmlParser(); + } + + public void testParseHtml() throws IOException, DiscoveryException + { + String htmlData = readResource("identityPage.html"); + HtmlResult result = new HtmlResult(); + parser.parseHtml(htmlData, result); + assertEquals("http://www.example.com:8080/openidserver/users/myusername", + result.getDelegate1()); + assertEquals("http://www.example.com:8080/openidserver/openid.server", + result.getOP1Endpoint().toExternalForm()); + } + + public void testParseHtmlWithXmlNamespace() throws IOException, + DiscoveryException + { + String htmlData = readResource("identityPage-with-xml-namespace.html"); + HtmlResult result = new HtmlResult(); + parser.parseHtml(htmlData, result); + assertEquals("http://www.example.com:8080/openidserver/users/myusername", + result.getDelegate1()); + assertEquals("http://www.example.com:8080/openidserver/openid.server", + result.getOP1Endpoint().toExternalForm()); + } + + public void testParseHtmlXXE() throws Exception + { + String htmlData = readResource("identityPageWithExternalEntityReference.html"); + parser.parseHtml(htmlData, new HtmlResult()); + // don't fail trying to read "/path/to/some/file" from the input data + } + + private static String readResource(String name) throws IOException + { + try (InputStream input = JsoupHtmlParserTest.class.getResourceAsStream(name)) + { + return IOUtils.toString(input, StandardCharsets.UTF_8); + } + } +} diff --git a/test/src/org/openid4java/discovery/yadis/CyberNekoDOMYadisHtmlParserTest.java b/test/src/org/openid4java/discovery/yadis/CyberNekoDOMYadisHtmlParserTest.java deleted file mode 100644 index 0dd23453..00000000 --- a/test/src/org/openid4java/discovery/yadis/CyberNekoDOMYadisHtmlParserTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2006-2008 Sxip Identity Corporation - */ - -package org.openid4java.discovery.yadis; - -import junit.framework.TestCase; -import org.apache.commons.io.IOUtils; -import org.openid4java.discovery.html.CyberNekoDOMHtmlParserTest; - -import java.io.IOException; -import java.io.InputStream; - -/** - * @author Sutra Zhou - * - */ -public class CyberNekoDOMYadisHtmlParserTest extends TestCase -{ - private CyberNekoDOMYadisHtmlParser parser; - - /** - * {@inheritDoc} - */ - protected void setUp() throws Exception - { - super.setUp(); - parser = new CyberNekoDOMYadisHtmlParser(); - } - - /** - * Test method for - * {@link org.openid4java.discovery.yadis.CyberNekoDOMYadisHtmlParser#getHtmlMeta(java.lang.String)} - * . - * - * @throws IOException - * @throws YadisException - */ - public final void testGetHtmlMetaIssue83() throws IOException, YadisException - { - String htmlData = getResourceAsString("issue83.html"); - String s = parser.getHtmlMeta(htmlData); - assertEquals("http://edevil.livejournal.com/data/yadis", s); - } - - public void testParseHtmlMetaXXE() throws Exception { - parser.getHtmlMeta(IOUtils.toString(CyberNekoDOMHtmlParserTest.class.getResourceAsStream( - "identityPageWithExternalEntityReference.html"))); - // don't fail trying to read "/path/to/some/file" from the input data - } - - /** - * Read the resource as string. - * - * @param name - * the resource name - * @return a string - * @throws IOException - * if an I/O error occurs - */ - private String getResourceAsString(String name) throws IOException - { - InputStream inputStream = CyberNekoDOMYadisHtmlParserTest.class.getResourceAsStream(name); - try - { - return IOUtils.toString(inputStream); - } finally - { - inputStream.close(); - } - } -} diff --git a/test/src/org/openid4java/discovery/yadis/JsoupYadisHtmlParserTest.java b/test/src/org/openid4java/discovery/yadis/JsoupYadisHtmlParserTest.java new file mode 100644 index 00000000..88146279 --- /dev/null +++ b/test/src/org/openid4java/discovery/yadis/JsoupYadisHtmlParserTest.java @@ -0,0 +1,52 @@ +/* + * Copyright 2006-2008 Sxip Identity Corporation + */ + +package org.openid4java.discovery.yadis; + +import junit.framework.TestCase; +import org.apache.commons.io.IOUtils; +import org.openid4java.discovery.html.JsoupHtmlParserTest; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; + +/** + * @author Sutra Zhou + */ +public class JsoupYadisHtmlParserTest extends TestCase +{ + private JsoupYadisHtmlParser parser; + + protected void setUp() throws Exception + { + super.setUp(); + parser = new JsoupYadisHtmlParser(); + } + + public final void testGetHtmlMetaIssue83() throws IOException, YadisException + { + String htmlData = readResource("issue83.html"); + String s = parser.getHtmlMeta(htmlData); + assertEquals("http://edevil.livejournal.com/data/yadis", s); + } + + public void testParseHtmlMetaXXE() throws Exception + { + try (InputStream input = JsoupHtmlParserTest.class.getResourceAsStream( + "identityPageWithExternalEntityReference.html")) + { + parser.getHtmlMeta(IOUtils.toString(input, StandardCharsets.UTF_8)); + } + // don't fail trying to read "/path/to/some/file" from the input data + } + + private static String readResource(String name) throws IOException + { + try (InputStream input = JsoupYadisHtmlParserTest.class.getResourceAsStream(name)) + { + return IOUtils.toString(input, StandardCharsets.UTF_8); + } + } +} diff --git a/test/src/org/openid4java/infocard/OpenIDTokenTest.java b/test/src/org/openid4java/infocard/OpenIDTokenTest.java deleted file mode 100644 index eccaef73..00000000 --- a/test/src/org/openid4java/infocard/OpenIDTokenTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2006-2008 Sxip Identity Corporation - */ - -package org.openid4java.infocard; - -import junit.framework.TestCase; - -public class OpenIDTokenTest extends TestCase -{ - - public OpenIDTokenTest(String name) - { - super(name); - } - - public void setUp() throws Exception - { - } - - public void testCreateFromXmlToken() throws Exception - { - String xmlToken ="" + - "openid.ns:http://specs.openid.net/auth/2.0\n" + - "\n" + - "openid.mode:id_res\n" + - "\n" + - "openid.op_endpoint:https://example-op.com/openid-server/\n" + - "\n" + - "openid.claimed_id:https://example-op.com/johndoe/\n" + - "\n" + - "openid.identity:https://example-op.com/johndoe/\n" + - "\n" + - "openid.return_to:https://example-rp.com/openid-infocard-endpoint/\n" + - "\n" + - "openid.response_nonce:2007-06-28T22:16:58Z0\n" + - "\n" + - "openid.assoc_handle:d38f38e8166443cb\n" + - "\n" + - "openid.signed:op_endpoint,claimed_id,identity,return_to,response_nonce,assoc_handle\n" + - "\n" + - "openid.sig:PZNucb3/5KnEHsOXEMFkg1FJAnGD+UbGR1LqsscVvEc=\n" + - "\n" + - "openid.ns.ext1:http://openid.net/srv/ax/1.0\n" + - "\n" + - "openid.ext1.mode:fetch_response\n" + - "\n" + - "openid.ext1.type.FirstName:http://axschema.org/namePerson/first\n" + - "\n" + - "openid.ext1.value.FirstName:John\n" + - "\n" + - "openid.ext1.type.LastName:http://axschema.org/namePerson/last\n" + - "\n" + - "openid.ext1.value.LastName:Doe\n" + - "\n" + - "openid.ext1.type.email:http://axschema.org/contact/email\n" + - "\n" + - "openid.ext1.value.email:johndoe@example.com" + - ""; - - OpenIDToken token = OpenIDToken.createFromXmlToken(xmlToken); - - assertNotNull(token); - - } -} diff --git a/test/src/org/openid4java/samples/HttpServletSupport.java b/test/src/org/openid4java/samples/HttpServletSupport.java index cbca3566..279b0d7e 100644 --- a/test/src/org/openid4java/samples/HttpServletSupport.java +++ b/test/src/org/openid4java/samples/HttpServletSupport.java @@ -11,8 +11,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.log4j.Logger; -import org.apache.log4j.NDC; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; public abstract class HttpServletSupport extends HttpServlet { @@ -20,21 +20,21 @@ public abstract class HttpServletSupport extends HttpServlet protected static Exception lastException; protected static int count_; - protected Logger logger_; + protected Log logger_; public HttpServletSupport() { - logger_ = Logger.getLogger(getClass()); + logger_ = LogFactory.getLog(getClass()); } protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { count_++; - String ndcName = getClass().getName(); - ndcName = ndcName.substring(ndcName.lastIndexOf('.')+1); - NDC.push(ndcName); - NDC.push("call-" + count_); - logger_.info("begin onService"); + String name = getClass().getName(); + name = name.substring(name.lastIndexOf('.') + 1); + String context = name + " call-" + count_ + " : "; + + logger_.info(context + "begin onService"); try { onService(req, resp); @@ -46,9 +46,7 @@ protected void service(HttpServletRequest req, HttpServletResponse resp) throws } finally { - logger_.info("end onService"); - NDC.pop(); - NDC.pop(); + logger_.info(context + "end onService"); } } diff --git a/test/src/org/openid4java/server/RealmVerifierTest.java b/test/src/org/openid4java/server/RealmVerifierTest.java index 5bb275ad..b0ee2a6d 100644 --- a/test/src/org/openid4java/server/RealmVerifierTest.java +++ b/test/src/org/openid4java/server/RealmVerifierTest.java @@ -8,10 +8,10 @@ import junit.framework.TestCase; import junit.framework.TestSuite; -import org.jdom.Document; -import org.jdom.Element; -import org.jdom.JDOMException; -import org.jdom.input.SAXBuilder; +import org.jdom2.Document; +import org.jdom2.Element; +import org.jdom2.JDOMException; +import org.jdom2.input.SAXBuilder; import org.openid4java.discovery.yadis.YadisResolver; import org.openid4java.util.HttpFetcherFactory; @@ -37,15 +37,15 @@ public class RealmVerifierTest extends TestCase static { - _resultCodes.put("OK", new Integer(RealmVerifier.OK)); - _resultCodes.put("DENIED_REALM", new Integer(RealmVerifier.DENIED_REALM)); - _resultCodes.put("MALFORMED_REALM", new Integer(RealmVerifier.MALFORMED_REALM)); - _resultCodes.put("MALFORMED_RETURN_TO_URL", new Integer(RealmVerifier.MALFORMED_RETURN_TO_URL)); - _resultCodes.put("FRAGMENT_NOT_ALLOWED", new Integer(RealmVerifier.FRAGMENT_NOT_ALLOWED)); - _resultCodes.put("PROTOCOL_MISMATCH", new Integer(RealmVerifier.PROTOCOL_MISMATCH)); - _resultCodes.put("PORT_MISMATCH", new Integer(RealmVerifier.PORT_MISMATCH)); - _resultCodes.put("PATH_MISMATCH", new Integer(RealmVerifier.PATH_MISMATCH)); - _resultCodes.put("DOMAIN_MISMATCH", new Integer(RealmVerifier.DOMAIN_MISMATCH)); + _resultCodes.put("OK", Integer.valueOf(RealmVerifier.OK)); + _resultCodes.put("DENIED_REALM", Integer.valueOf(RealmVerifier.DENIED_REALM)); + _resultCodes.put("MALFORMED_REALM", Integer.valueOf(RealmVerifier.MALFORMED_REALM)); + _resultCodes.put("MALFORMED_RETURN_TO_URL", Integer.valueOf(RealmVerifier.MALFORMED_RETURN_TO_URL)); + _resultCodes.put("FRAGMENT_NOT_ALLOWED", Integer.valueOf(RealmVerifier.FRAGMENT_NOT_ALLOWED)); + _resultCodes.put("PROTOCOL_MISMATCH", Integer.valueOf(RealmVerifier.PROTOCOL_MISMATCH)); + _resultCodes.put("PORT_MISMATCH", Integer.valueOf(RealmVerifier.PORT_MISMATCH)); + _resultCodes.put("PATH_MISMATCH", Integer.valueOf(RealmVerifier.PATH_MISMATCH)); + _resultCodes.put("DOMAIN_MISMATCH", Integer.valueOf(RealmVerifier.DOMAIN_MISMATCH)); } private RealmVerifier _realmVerifier; diff --git a/src/org/openid4java/server/SampleServer.java b/test/src/org/openid4java/server/SampleServer.java similarity index 100% rename from src/org/openid4java/server/SampleServer.java rename to test/src/org/openid4java/server/SampleServer.java