Compare commits

...

126 Commits

Author SHA1 Message Date
Justin Richer d074573de0
Merge pull request #1570 from shrexster42/master
Upgrade to Java 11 and Spring 5
2022-04-19 14:17:46 -04:00
shrexster42 5e87fa7650
Update .travis.yml to use oraclejdk11 2022-04-18 17:20:36 +01:00
shrexster42 7e85d2575e
Merge branch 'mitreid-connect:master' into master 2022-04-17 18:16:56 +01:00
Chen Zhang 05fd73e643 Improve Travis CI build Performance 2022-03-29 11:29:46 -04:00
faidh 2c41e6a267 Add SNAPSHOT back to pom files 2022-03-29 11:29:22 -04:00
faidh 8a58d12600 Merge latest MitreID with updated 3pps back to GitHub fork 2022-03-29 11:29:22 -04:00
Justin Richer f5df762153 [maven-release-plugin] prepare for next development iteration 2021-12-20 13:09:11 -05:00
Justin Richer a0bd2c70ac [maven-release-plugin] prepare release mitreid-connect-1.3.4 2021-12-20 13:09:08 -05:00
shrexster42 6906f616e2 Upgrade to Java 11 and Spring 5 2021-12-18 22:30:43 +00:00
Michael Stepankin 7eba3c12fe Fix Spring Autobinding vulnerability
1. Make authorizationRequest no longer affected by http request parameters due to @ModelAttribute. See http://agrrrdog.blogspot.com/2017/03/autobinding-vulns-and-spring-mvc.html
2021-02-18 16:13:36 -05:00
Justin Richer 0d4ef2cb4f
Update README.md 2019-08-01 16:41:55 -04:00
ruslan cc6bd4b590 upgrade eclipselink to v. 2.7.4 2019-04-29 16:13:21 -04:00
Justin Richer 621e86e62d [maven-release-plugin] prepare for next development iteration 2019-04-19 16:04:45 -04:00
Justin Richer 73459f0348 [maven-release-plugin] prepare release mitreid-connect-1.3.3 2019-04-19 16:04:40 -04:00
Justin Richer 5aa8b2a0a7 updated changelog for release 2019-04-19 16:00:06 -04:00
Martin Kuba ae7debba2f added refresh_token into grant_types_supported 2019-03-07 12:14:30 -05:00
Martin Kuba ad64aef0c5 updated dependencies patchlevels 2019-03-07 12:12:27 -05:00
Justin Richer 703c341308
Merge pull request #1436 from blm126/upgrade-guava
#1435: Update guava dependency to latest version.
2018-12-10 14:26:20 -05:00
Stephen Moore 8430b42ab3 Both approve pages were using pagecontext rather than the configured
issuer
2018-12-10 12:35:03 -05:00
Brady Mulhollem 4979f9f50e #1435: Update guava dependency to latest version. 2018-11-27 16:06:38 -05:00
Justin Richer a2e8cb1a67
Merge pull request #1410 from hausenism/master
fix bug #1397 Attempting to execute an operation on a closed EntityMa…
2018-06-21 15:50:12 -04:00
鄭脈龍 676451c73d fix bug #1397 Attempting to execute an operation on a closed EntityManager. 2018-06-21 10:05:49 +08:00
Justin Richer 04f439ec58
Merge pull request #1405 from angelok1/db_script_fixes
Corrected Oracle create script
2018-06-11 16:23:28 -04:00
Justin Richer aa2dc78148
Merge pull request #1406 from angelok1/db_script_schema_fixes
Fixed broken scripts from schema change on system_scope
2018-06-11 16:21:41 -04:00
Angelo Kastroulis f56918982a Fixed broken scripts from schema change on system_scope 2018-06-11 16:13:30 -04:00
Angelo Kastroulis 69afba59cc Corrected create script 2018-06-11 15:52:17 -04:00
Justin Richer 802e40ebc9 Updated changelog 2018-05-03 14:52:49 -04:00
Justin Richer ea6960e66a
Merge pull request #1259 from sbke/patch-1
Adjustment to generate longer codes
2018-05-03 14:48:52 -04:00
Justin Richer 9d6f42b141
Merge pull request #1320 from bverhoeven/rfc7662-sub
Client: Parse 'sub' key to identify resource owner in introspection response (RFC7662)
2018-05-03 14:46:49 -04:00
Justin Richer dd922b4cf7
Merge pull request #1378 from ketola/fetch-tokens-by-sub
Fetch tokens by user name
2018-05-03 14:44:51 -04:00
Justin Richer 938d7e00c2 Merge branch 'ondrejvelisek/verification-uri-complete'
Closes #1386
2018-05-03 14:39:23 -04:00
Justin Richer a596cc1fd4 Made full URLs for device flow switchable server-wide instead of per-client 2018-05-03 14:37:50 -04:00
Justin Richer 7ad29ae9c6 Revert "Add possibility to disable verification_uri_complete per client"
This reverts commit dae674af67.
2018-05-03 13:59:38 -04:00
Justin Richer e3cfb80c33
Merge pull request #1390 from mobilcom-debitel/master
Update admin.js
2018-05-03 11:40:26 -04:00
jansinger fd938e11e9
Update admin.js
Allow scope names longer than 30 characters to be checked in the client scope list.
2018-05-03 14:48:01 +02:00
ondrejvelisek dae674af67 Add possibility to disable verification_uri_complete per client 2018-05-01 13:46:23 +02:00
ondrejvelisek 67c87d56a6 Add support for verification_uri_complete 2018-05-01 10:45:49 +02:00
Justin Richer 4a818c7b4b
Merge pull request #1385 from elennick/master
"Unable to load locale" log should not be ERROR level
2018-04-23 15:38:46 -04:00
Evan Lennick fe000d91cb undid autoformatting again 2018-04-23 14:30:43 -04:00
Evan Lennick 011bf8adb8 addressed review feedback 2018-04-23 14:29:38 -04:00
Evan Lennick 0ee4ee2f58 undid some autoformatting changes 2018-04-21 13:22:17 -04:00
Evan Lennick 0b531a0fd3 fixed an issue where missing locales would generate a lot of ERROR level log messages 2018-04-21 13:19:44 -04:00
Sauli Ketola e6a8e0c17d Integration tests for new repository methods 2018-04-11 13:16:28 +03:00
Sauli Ketola a070f61edf Clean up code in modified classes, remove line breaks, add static imports 2018-04-06 09:12:47 +03:00
Sauli Ketola 51b580aa18 Use 'userName' instead of 'sub' in naming 2018-04-06 08:55:06 +03:00
Sauli Ketola 3f277047e3 Use query by user sub to get all tokens for user 2018-04-06 08:47:37 +03:00
Sauli Ketola 417a6b7c74 Removed some line breaks and auto generated comments for consistency 2018-04-05 19:29:54 +03:00
Sauli Ketola bf8149605a Create queries for getting access and refresh tokens by user sub 2018-04-05 19:25:23 +03:00
Justin Richer 64fbee7935
Merge pull request #1377 from ketola/master
Add an index for refresh_token.token_value
2018-04-04 10:12:53 -04:00
Sauli Ketola bca388d740 Add an index for refresh_token.token_value 2018-04-04 15:49:13 +03:00
Justin Richer e2d94f422a new year 2018 2018-02-12 10:39:04 -05:00
Justin Richer a5a16f27c7
Merge pull request #1353 from col-panic/master
Minor typo in en/messages.json (Registrered -> Registered)
2018-02-08 16:49:44 -05:00
Justin Richer 4dd907ea16
Merge pull request #1357 from praseodym/spring-security-4.2.4
Upgrade to Spring Security 4.2.4
2018-02-08 15:34:30 -05:00
Mark Janssen d119559d4d Upgrade to Spring Security 4.2.4
https://spring.io/blog/2018/01/30/cve-2018-1199-spring-security-5-0-1-4-2-4-4-1-5-released
2018-02-08 21:03:31 +01:00
Justin Richer b804f22bc8 [maven-release-plugin] prepare for next development iteration 2018-02-07 09:14:16 -05:00
Justin Richer f72e6b3e08 [maven-release-plugin] prepare release mitreid-connect-1.3.2 2018-02-07 09:14:10 -05:00
Justin Richer 1feb0958bd prepare for release 2018-02-07 09:09:07 -05:00
Justin Richer 6497af40e8 removed erroneous not yet implemented tag from client page 2018-02-07 09:05:43 -05:00
Justin Richer 7dc309c5af
Update CHANGELOG.md 2018-02-07 09:03:09 -05:00
Justin Richer 7f956a5854
Merge pull request #1355 from ocadotechnology/jwt_fix
Throwing exception on all other JWT types than SignedJWT
2018-02-07 08:52:59 -05:00
Tomasz Borowiec 37fba622b9 Throwing exception on all other JWT types than SignedJWT 2018-02-07 11:00:28 +01:00
Tomasz Borowiec c38b9d7a42 added PlainJWT and EncryptedJWT support + tests 2018-02-07 11:00:15 +01:00
Marco Descher 36ec1b82e6
Minor type (Registrered -> Registered) 2018-02-06 08:41:14 +01:00
Justin Richer fcb119ff6a
Merge pull request #1270 from bodewig/custom_claim_friendly_token_enhancer
add hook for custom JWT claims to ConnectTokenEnhancer
2018-02-05 16:01:09 -05:00
Justin Richer 8fb9adefc1
Merge pull request #1342 from bodewig/custom_claims_in_id_token
add hook for custom JWT claims to DefaultOIDCTokenService
2018-02-05 15:43:22 -05:00
Justin Richer 0ce55d079a
Merge pull request #1352 from blm126/upgrade-nimbus
Upgrade nimbus-jose-jwt to 5.4.
2018-02-05 15:26:50 -05:00
Brady Mulhollem f7da25fbe8 Upgrade nimbus-jose-jwt to 5.4. 2018-02-05 13:28:48 -05:00
Justin Richer 1c7b9d5b44
Merge pull request #1346 from praseodym/fix-admin-interface-without-trailing-slash
Fix interface for issuer URI without trailing slash
2018-01-22 05:54:25 -05:00
Mark Janssen a1a45aa36a Fix interface for issuer URI without trailing slash 2018-01-21 12:01:25 +01:00
Stefan Bodewig 01eb1401a3 add hook for custom JWT claims to DefaultOIDCTokenService 2018-01-12 15:22:37 +01:00
Justin Richer e6130872a9
Merge pull request #1324 from patfrat/master
Add French messages
2017-11-22 13:23:56 -05:00
Patrick Fratczak ca3642b6c3 Add French messages 2017-11-22 14:27:15 +01:00
Bas Verhoeven 85246d2d3e
Parse 'sub' to identify resource owner
As per https://tools.ietf.org/html/rfc7662#section-2.2 the `sub` key should
identify the resource owner in oauth2 introspection responses. 

This change adds support for the `sub` key and will allow the introspection 
response of RFC-compliant servers to be parsed.

Will still try `user_id` first as to not break backward compatibility.
2017-11-13 16:46:52 +01:00
Justin Richer ce9bf3507f
Merge pull request #1312 from kules/master
Correct minor typo error for confirmation message displayed when logging out from IDP
2017-11-01 13:56:24 -04:00
still fetalvero 9bff58085d Fix typo error for log out to IDP confirmation message 2017-10-30 22:56:07 +08:00
Stefan Bodewig 514dcc3851 add hook for custom JWT claims to ConnectTokenEnhancer 2017-07-18 16:10:58 +02:00
sbke 8b4e461748 Adjustment to generate longer codes
RandomValueStringGenerator default constructor creates a code of length six only. The RFC 6819 (OAuth 2.0 Threat Model and Security Considerations) suggests (5.1.4.2.2.  Use High Entropy for Secrets) that secrets that aren't used by humans (e.g. client secrets or token handles) have a reasonable level of enthropy. They propose a token lengths of at least 128 bits. Since the RandomValueStringGenerator only uses case sensitive alpha numeric symbols, 22 symbols are needed to achieve an enthropy >=128 bits.
2017-06-28 14:20:11 +02:00
Justin Richer ef01d3032e Merge pull request #1228 from leonard84/fix-psql-scripts
Fix psql_database script, replace SERIAL with BIGSERIAL and fix ...
2017-06-15 09:45:13 -04:00
Justin Richer bba18fd118 Merge pull request #1240 from Connz/patch-2
Corrected typo
2017-06-15 09:44:46 -04:00
Justin Richer 28ad78e9f3 Merge pull request #1233 from Connz/patch-1
Removed double 'sure'
2017-06-15 09:44:33 -04:00
Justin Richer 059e140164 removed old document PDFs from repo 2017-05-27 06:49:34 -04:00
Justin Richer 0b1f9000db check for missing refresh token value on refresh, closes #1242 2017-05-26 20:30:09 -04:00
Justin Richer 705ac9879c removed unused field from UI config bean 2017-05-26 20:20:11 -04:00
Justin Richer 4dc31cdfbd fixed client readme file 2017-05-26 20:17:29 -04:00
Justin Richer 661c242a9f Updated copyrights 2017-05-26 20:17:17 -04:00
Connz 0859a5d122 Corrected typo 2017-05-16 12:09:54 +02:00
Justin Richer c11e47a75b fixed unit test for new default redirect behavior 2017-05-11 11:27:41 -04:00
Justin Richer 2f31ceddf8 set redirect URI matching to strict by default 2017-05-10 17:39:59 -04:00
Justin Richer 7e6864ff38 escaped output values on approval page, closes #1111 2017-05-10 17:39:48 -04:00
Justin Richer a316306f33 added changelog file 2017-05-09 14:54:47 -04:00
Justin Richer 7b06d91700 [maven-release-plugin] prepare for next development iteration 2017-05-09 14:29:53 -04:00
Justin Richer 8301f35e17 [maven-release-plugin] prepare release mitreid-connect-1.3.1 2017-05-09 14:29:49 -04:00
Justin Richer f17a44e9b4 downgrade mysql dependency to GA version 2017-05-09 14:25:03 -04:00
Connz 90c3c396ee Removed double 'sure' 2017-05-04 15:35:34 +02:00
Justin Richer 713e872b8a fixed discovery endpoint, closes #1230 2017-04-29 15:01:15 -04:00
Justin Richer 9baacc0eaf Completed end session endpoint
Addresses #1129, addresses #972, addresses #891, addresses #1223
2017-04-29 14:58:37 -04:00
Justin Richer 2aa12fc0e3 end session endpoint 2017-04-28 19:05:30 -04:00
Justin Richer 0c46e7cb7a skeleton of end session endpoint, maybe need a change to user info lookup 2017-04-27 14:29:05 -04:00
Leonard Brünings e6679b6e4b Fix psql_database script, replace SERIAL with BIGSERIAL and fix ...
BIGINT AUTO_INCREMENT to BIGSERIAL

Change-Id: I19b4433d3bae29b0879be7d9dd9405eabe490482
2017-04-19 14:24:11 +02:00
Justin Richer 0efa77b580 [maven-release-plugin] prepare for next development iteration 2017-04-15 13:20:13 -04:00
Justin Richer b9b7bf53c3 [maven-release-plugin] prepare release mitreid-connect-1.3.0 2017-04-15 13:20:05 -04:00
Justin Richer 0aedfc8e22 minor cleanup 2017-04-14 17:21:50 -04:00
Justin Richer 0d564d9714 made token service transactional, closes #1222 2017-04-14 15:27:16 -04:00
Justin Richer 11f3cccab9 fix JWKS parsing in software statements, closes #1220 2017-04-14 14:42:49 -04:00
Justin Richer 702a775881 handle creation time stamp in clients, closes #1210 2017-04-13 11:50:57 -04:00
Justin Richer 45ea899de8 made user codes case insensitive 2017-04-12 16:00:23 -04:00
Justin Richer d317cf5024 added exception handling to device code creation step 2017-04-12 15:59:17 -04:00
Justin Richer cc0622edd0 internalized random string generation for device codes 2017-04-12 14:59:18 -04:00
Justin Richer 52829d4adb mapped user info and server config interceptors to only interactive portions of the site, closes #1206 2017-04-07 17:02:50 -04:00
Mark Janssen 903168a949 Decrease log level of trailing slash warning
Having an issuer without trailing slash configured is just fine, so
there is no reason to log a warning for this every time the discovery
endpoint is called.
2017-04-07 14:59:58 -04:00
Justin Richer 6216659cd6 manage reporting plugin versions, added jacoco coverage to reporting 2017-04-07 14:58:11 -04:00
Leonard Brünings 9d1a50d17e Add codecov badge
Change-Id: I04f56036af6bd2ac663843c2c10e8c0cebfb05d3
2017-04-07 13:38:25 -04:00
Leonard Brünings 2aecedfb3d Replace cobertura with jacoco to generate code-coverage for codecov.io
Change-Id: I031144c375d73aaa39d0a6111d37223ad6e4d655
2017-04-07 13:38:25 -04:00
Justin Richer f43ff53683 Extracted database indexes to separate files 2017-04-06 14:12:27 -04:00
Justin Richer bf49cd193d removed incompatible constraints on mysql files 2017-04-06 14:07:39 -04:00
Justin Richer 835a326627 allow polling of device codes, fixed UI for device code input 2017-03-27 14:39:40 -05:00
Justin Richer 1d7fba5d6e added cascade to address object, closes #1209 2017-03-24 12:44:49 -04:00
Justin Richer 2ea5f8fd28 sync’d databases with HSQL schema, closes #1212 2017-03-24 12:41:14 -04:00
Justin Richer 050662dd5c updated dependencies 2017-03-24 12:12:06 -04:00
Justin Richer 7767c7a831 add “if not exists” to all indexes in HSQL 2017-03-22 17:30:08 -04:00
Justin Richer 7a225e56c4 don’t pack wro4j into .war file
We use it only during compilation, not runtime
2017-03-22 17:29:37 -04:00
Justin Richer 78b9b6ced4 auto format and cleanup javascript 2017-03-21 15:04:18 -04:00
Justin Richer bd72b4138d added missing copyright declarations 2017-03-21 14:11:40 -04:00
Justin Richer 32ce21b5cd automated code formatting and cleanup 2017-03-21 14:07:20 -04:00
Justin Richer b6cf8fe22b cleanup 2017-03-20 13:45:55 -04:00
Justin Richer dd0f69ba6d [maven-release-plugin] prepare for next development iteration 2017-03-20 11:58:58 -04:00
394 changed files with 41198 additions and 28824 deletions

3
.gitignore vendored
View File

@ -1,4 +1,3 @@
local-values.conf
target target
*~ *~
bin bin
@ -11,5 +10,3 @@ bin
/target /target
.springBeans .springBeans
nb-configuration.xml nb-configuration.xml
openid-connect-server-webapp/src/main/webapp/resources/bootstrap2/css/bootstrap-responsive.css
openid-connect-server-webapp/src/main/webapp/resources/bootstrap2/css/bootstrap.css

View File

@ -1,7 +1,11 @@
language: java language: java
jdk: jdk:
- oraclejdk8 - oraclejdk11
sudo: false sudo: false
after_success: after_success:
- bash <(curl -s https://codecov.io/bash) - bash <(curl -s https://codecov.io/bash)
cache:
directories:
- $HOME/.m2

43
CHANGELOG.md Normal file
View File

@ -0,0 +1,43 @@
Unreleased:
*1.3.3*:
- Authorization codes are now longer
- Client/RS can parse the "sub" and "user_id" claims in introspection response
- Database-direct queries for fetching tokens by user (optimization)
- Device flow supports verification_uri_complete (must be turned on)
- Long scopes display properly and are still checkable
- Language system remebers when it can't find a file and stops throwing so many errors
- Index added for refresh tokens
- Updated to Spring Security 4.2.11
- Updated Spring to 4.3.22
- Change approve pages to use issuer instead of page context
- Updated oracle database scripts
*1.3.2*:
- Added changelog
- Set default redirect URI resolver strict matching to true
- Fixed XSS vulnerability on redirect URI display on approval page
- Removed MITRE from copyright
- Disallow unsigned JWTs on client authentication
- Upgraded Nimbus revision
- Added French translation
- Added hooks for custom JWT claims
- Removed "Not Yet Implemented" tag from post-logout redirect URI
*1.3.1*:
- Added End Session endpoint
- Fixed discovery endpoint
- Downgrade MySQL connector dependency version from developer preview to GA release
*1.3.0*:
- Added device flow support
- Added PKCE support
- Modularized UI to allow better overlay and extensions
- Modularized data import/export API
- Added software statements to dynamic client registration
- Added assertion processing framework
- Removed ID tokens from storage
- Removed structured scopes
*1.2.6*:
- Added strict HEART compliance mode

View File

@ -1,8 +1,9 @@
Copyright 2016 The MITRE Corporation Copyright 2018 The MIT Internet Trust Consortium
and the MIT Internet Trust Consortium
Portions copyright 2011-2013 The MITRE Corporation
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this project except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0

View File

@ -1,7 +1,7 @@
# MITREid Connect # MITREid Connect
--- ---
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.mitre/openid-connect-parent/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.mitre/openid-connect-parent) [![Travis CI](https://travis-ci.org/mitreid-connect/OpenID-Connect-Java-Spring-Server.svg?branch=master)](https://travis-ci.org/mitreid-connect/OpenID-Connect-Java-Spring-Server) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.mitre/openid-connect-parent/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.mitre/openid-connect-parent) [![Travis CI](https://travis-ci.org/mitreid-connect/OpenID-Connect-Java-Spring-Server.svg?branch=master)](https://travis-ci.org/mitreid-connect/OpenID-Connect-Java-Spring-Server) [![Codecov](https://codecov.io/github/mitreid-connect/OpenID-Connect-Java-Spring-Server/coverage.svg?branch=master)](https://codecov.io/github/mitreid-connect/OpenID-Connect-Java-Spring-Server)
This project contains a certified OpenID Connect reference implementation in Java on the Spring platform, including a functioning [server library](openid-connect-server), [deployable server package](openid-connect-server-webapp), [client (RP) library](openid-connect-client), and general [utility libraries](openid-connect-common). The server can be used as an OpenID Connect Identity Provider as well as a general-purpose OAuth 2.0 Authorization Server. This project contains a certified OpenID Connect reference implementation in Java on the Spring platform, including a functioning [server library](openid-connect-server), [deployable server package](openid-connect-server-webapp), [client (RP) library](openid-connect-client), and general [utility libraries](openid-connect-common). The server can be used as an OpenID Connect Identity Provider as well as a general-purpose OAuth 2.0 Authorization Server.
@ -28,5 +28,4 @@ The authors and key contributors of the project include:
* [Mark Janssen](https://github.com/praseodym) * [Mark Janssen](https://github.com/praseodym)
Copyright &copy;2017, [The MITRE Corporation](http://www.mitre.org/) Licensed under the Apache 2.0 license, for details see `LICENSE.txt`.
and the [MIT Internet Trust Consortium](http://www.trust.mit.edu/). Licensed under the Apache 2.0 license, for details see `LICENSE.txt`.

View File

@ -35,5 +35,4 @@
版权所有 &copy;2016, [ MITRE公司 ](http://www.mitre.org/) 版权所有 &copy;2018 [MIT因特网信任联盟](http://www.mit-trust.org/). 采用Apache 2.0许可证, 详见 `LICENSE.txt`.
以及 [MIT因特网信任联盟](http://www.mit-trust.org/). 采用Apache 2.0许可证, 详见 `LICENSE.txt`.

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
Copyright 2017 The MITRE Corporation Copyright 2018 The MIT Internet Trust Consortium
and the MIT Internet Trust Consortium
Portions copyright 2011-2013 The MITRE Corporation
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

Binary file not shown.

Binary file not shown.

View File

@ -2,7 +2,7 @@
## Overview ## ## Overview ##
This project contains an OpenID Connect Client implemented as a Spring Security AuthenticationFilter. The client facilitates a user's authentication into the secured application to an OpenID Connect Java Spring Server following the OpenID Connect Standard protocol. This project contains an OpenID Connect Client implemented as a Spring Security AuthenticationFilter. The client facilitates a user's authentication into the secured application to an OpenID Connect Server following the OpenID Connect standard protocol.
## Configuring ## ## Configuring ##

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
Copyright 2017 The MITRE Corporation Copyright 2018 The MIT Internet Trust Consortium
and the MIT Internet Trust Consortium
Portions copyright 2011-2013 The MITRE Corporation
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -21,7 +22,7 @@
<parent> <parent>
<artifactId>openid-connect-parent</artifactId> <artifactId>openid-connect-parent</artifactId>
<groupId>org.mitre</groupId> <groupId>org.mitre</groupId>
<version>1.3.0-RC2</version> <version>1.3.5-SNAPSHOT</version>
<relativePath>..</relativePath> <relativePath>..</relativePath>
</parent> </parent>
<artifactId>openid-connect-client</artifactId> <artifactId>openid-connect-client</artifactId>

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,6 +17,8 @@
*******************************************************************************/ *******************************************************************************/
package org.mitre.oauth2.introspectingfilter; package org.mitre.oauth2.introspectingfilter;
import static org.mitre.oauth2.model.ClientDetailsEntity.AuthMethod.SECRET_BASIC;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.util.Calendar; import java.util.Calendar;
@ -54,8 +57,6 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import com.nimbusds.jose.util.Base64; import com.nimbusds.jose.util.Base64;
import static org.mitre.oauth2.model.ClientDetailsEntity.AuthMethod.SECRET_BASIC;
/** /**
* This ResourceServerTokenServices implementation introspects incoming tokens at a * This ResourceServerTokenServices implementation introspects incoming tokens at a
* server's introspection endpoint URL and passes an Authentication object along * server's introspection endpoint URL and passes an Authentication object along
@ -243,7 +244,10 @@ public class IntrospectingTokenService implements ResourceServerTokenServices {
private Authentication createUserAuthentication(JsonObject token) { private Authentication createUserAuthentication(JsonObject token) {
JsonElement userId = token.get("user_id"); JsonElement userId = token.get("user_id");
if(userId == null) { if(userId == null) {
return null; userId = token.get("sub");
if (userId == null) {
return null;
}
} }
return new PreAuthenticatedAuthenticationToken(userId.getAsString(), token, introspectionAuthorityGranter.getAuthorities(token)); return new PreAuthenticatedAuthenticationToken(userId.getAsString(), token, introspectionAuthorityGranter.getAuthorities(token));

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.oauth2.introspectingfilter.service; package org.mitre.oauth2.introspectingfilter.service;

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.oauth2.introspectingfilter.service; package org.mitre.oauth2.introspectingfilter.service;

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.oauth2.introspectingfilter.service.impl; package org.mitre.oauth2.introspectingfilter.service.impl;
@ -32,11 +33,11 @@ import com.nimbusds.jwt.JWT;
import com.nimbusds.jwt.JWTParser; import com.nimbusds.jwt.JWTParser;
/** /**
* *
* Parses the incoming accesstoken as a JWT and determines the issuer based on * Parses the incoming accesstoken as a JWT and determines the issuer based on
* the "iss" field inside the JWT. Uses the ServerConfigurationService to determine * the "iss" field inside the JWT. Uses the ServerConfigurationService to determine
* the introspection URL for that issuer. * the introspection URL for that issuer.
* *
* @author jricher * @author jricher
* *
*/ */

View File

@ -1,6 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -34,7 +33,7 @@ import com.google.gson.JsonObject;
* *
*/ */
public class ScopeBasedIntrospectionAuthoritiesGranter implements IntrospectionAuthorityGranter { public class ScopeBasedIntrospectionAuthoritiesGranter implements IntrospectionAuthorityGranter {
private List<GrantedAuthority> authorities = AuthorityUtils.createAuthorityList("ROLE_API"); private List<GrantedAuthority> authorities = AuthorityUtils.createAuthorityList("ROLE_API");
/* (non-Javadoc) /* (non-Javadoc)
@ -43,7 +42,7 @@ public class ScopeBasedIntrospectionAuthoritiesGranter implements IntrospectionA
@Override @Override
public List<GrantedAuthority> getAuthorities(JsonObject introspectionResponse) { public List<GrantedAuthority> getAuthorities(JsonObject introspectionResponse) {
List<GrantedAuthority> auth = new ArrayList<>(getAuthorities()); List<GrantedAuthority> auth = new ArrayList<>(getAuthorities());
if (introspectionResponse.has("scope") && introspectionResponse.get("scope").isJsonPrimitive()) { if (introspectionResponse.has("scope") && introspectionResponse.get("scope").isJsonPrimitive()) {
String scopeString = introspectionResponse.get("scope").getAsString(); String scopeString = introspectionResponse.get("scope").getAsString();
Set<String> scopes = OAuth2Utils.parseParameterList(scopeString); Set<String> scopes = OAuth2Utils.parseParameterList(scopeString);
@ -51,7 +50,7 @@ public class ScopeBasedIntrospectionAuthoritiesGranter implements IntrospectionA
auth.add(new SimpleGrantedAuthority("OAUTH_SCOPE_" + scope)); auth.add(new SimpleGrantedAuthority("OAUTH_SCOPE_" + scope));
} }
} }
return auth; return auth;
} }

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.oauth2.introspectingfilter.service.impl; package org.mitre.oauth2.introspectingfilter.service.impl;
@ -28,9 +29,9 @@ import org.springframework.security.core.authority.AuthorityUtils;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
/** /**
* *
* Grants the same set of authorities no matter what's passed in. * Grants the same set of authorities no matter what's passed in.
* *
* @author jricher * @author jricher
* *
*/ */

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.oauth2.introspectingfilter.service.impl; package org.mitre.oauth2.introspectingfilter.service.impl;
@ -23,10 +24,10 @@ import org.mitre.oauth2.introspectingfilter.service.IntrospectionConfigurationSe
import org.mitre.oauth2.model.RegisteredClient; import org.mitre.oauth2.model.RegisteredClient;
/** /**
* *
* Always provides the (configured) IntrospectionURL and RegisteredClient regardless * Always provides the (configured) IntrospectionURL and RegisteredClient regardless
* of token. Useful for talking to a single, trusted authorization server. * of token. Useful for talking to a single, trusted authorization server.
* *
* @author jricher * @author jricher
* *
*/ */

View File

@ -1,3 +1,18 @@
/*******************************************************************************
* Copyright 2018 The MIT Internet Trust Consortium
*
* 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.mitre.openid.connect.client; package org.mitre.openid.connect.client;
import org.springframework.security.authentication.AuthenticationServiceException; import org.springframework.security.authentication.AuthenticationServiceException;
@ -7,9 +22,9 @@ public class AuthorizationEndpointException extends AuthenticationServiceExcepti
private static final long serialVersionUID = 6953119789654778380L; private static final long serialVersionUID = 6953119789654778380L;
private String error; private String error;
private String errorDescription; private String errorDescription;
private String errorURI; private String errorURI;
public AuthorizationEndpointException(String error, String errorDescription, String errorURI) { public AuthorizationEndpointException(String error, String errorDescription, String errorURI) {

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.openid.connect.client; package org.mitre.openid.connect.client;
@ -34,13 +35,13 @@ import com.nimbusds.jwt.JWT;
import com.nimbusds.jwt.JWTClaimsSet; import com.nimbusds.jwt.JWTClaimsSet;
/** /**
* *
* Simple mapper that adds ROLE_USER to the authorities map for all queries, * Simple mapper that adds ROLE_USER to the authorities map for all queries,
* plus adds ROLE_ADMIN if the subject and issuer pair are found in the * plus adds ROLE_ADMIN if the subject and issuer pair are found in the
* configurable "admins" set. * configurable "admins" set.
* *
* @author jricher * @author jricher
* *
*/ */
public class NamedAdminAuthoritiesMapper implements OIDCAuthoritiesMapper { public class NamedAdminAuthoritiesMapper implements OIDCAuthoritiesMapper {

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -88,9 +89,9 @@ import com.nimbusds.jwt.SignedJWT;
/** /**
* OpenID Connect Authentication Filter class * OpenID Connect Authentication Filter class
* *
* @author nemonik, jricher * @author nemonik, jricher
* *
*/ */
public class OIDCAuthenticationFilter extends AbstractAuthenticationProcessingFilter { public class OIDCAuthenticationFilter extends AbstractAuthenticationProcessingFilter {
@ -169,9 +170,9 @@ public class OIDCAuthenticationFilter extends AbstractAuthenticationProcessingFi
/* /*
* This is the main entry point for the filter. * This is the main entry point for the filter.
* *
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.springframework.security.web.authentication. * @see org.springframework.security.web.authentication.
* AbstractAuthenticationProcessingFilter * AbstractAuthenticationProcessingFilter
* #attemptAuthentication(javax.servlet.http.HttpServletRequest, * #attemptAuthentication(javax.servlet.http.HttpServletRequest,
@ -204,7 +205,7 @@ public class OIDCAuthenticationFilter extends AbstractAuthenticationProcessingFi
/** /**
* Initiate an Authorization request * Initiate an Authorization request
* *
* @param request * @param request
* The request from which to extract parameters and perform the * The request from which to extract parameters and perform the
* authentication * authentication
@ -270,7 +271,7 @@ public class OIDCAuthenticationFilter extends AbstractAuthenticationProcessingFi
String state = createState(session); String state = createState(session);
Map<String, String> options = authOptions.getOptions(serverConfig, clientConfig, request); Map<String, String> options = authOptions.getOptions(serverConfig, clientConfig, request);
// if we're using PKCE, handle the challenge here // if we're using PKCE, handle the challenge here
if (clientConfig.getCodeChallengeMethod() != null) { if (clientConfig.getCodeChallengeMethod() != null) {
String codeVerifier = createCodeVerifier(session); String codeVerifier = createCodeVerifier(session);
@ -287,7 +288,7 @@ public class OIDCAuthenticationFilter extends AbstractAuthenticationProcessingFi
e.printStackTrace(); e.printStackTrace();
} }
} }
} }
@ -330,7 +331,7 @@ public class OIDCAuthenticationFilter extends AbstractAuthenticationProcessingFi
form.add("grant_type", "authorization_code"); form.add("grant_type", "authorization_code");
form.add("code", authorizationCode); form.add("code", authorizationCode);
form.setAll(authOptions.getTokenOptions(serverConfig, clientConfig, request)); form.setAll(authOptions.getTokenOptions(serverConfig, clientConfig, request));
String codeVerifier = getStoredCodeVerifier(session); String codeVerifier = getStoredCodeVerifier(session);
if (codeVerifier != null) { if (codeVerifier != null) {
form.add("code_verifier", codeVerifier); form.add("code_verifier", codeVerifier);
@ -345,11 +346,11 @@ public class OIDCAuthenticationFilter extends AbstractAuthenticationProcessingFi
if(httpClient == null) { if(httpClient == null) {
httpClient = HttpClientBuilder.create() httpClient = HttpClientBuilder.create()
.useSystemProperties() .useSystemProperties()
.setDefaultRequestConfig(RequestConfig.custom() .setDefaultRequestConfig(RequestConfig.custom()
.setSocketTimeout(httpSocketTimeout) .setSocketTimeout(httpSocketTimeout)
.build()) .build())
.build(); .build();
} }
HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(httpClient); HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(httpClient);
@ -634,7 +635,7 @@ public class OIDCAuthenticationFilter extends AbstractAuthenticationProcessingFi
/** /**
* Handle Authorization Endpoint error * Handle Authorization Endpoint error
* *
* @param request * @param request
* The request from which to extract parameters and handle the * The request from which to extract parameters and handle the
* error * error
@ -708,7 +709,7 @@ public class OIDCAuthenticationFilter extends AbstractAuthenticationProcessingFi
protected static String getStoredState(HttpSession session) { protected static String getStoredState(HttpSession session) {
return getStoredSessionString(session, STATE_SESSION_VARIABLE); return getStoredSessionString(session, STATE_SESSION_VARIABLE);
} }
/** /**
* Create a random code challenge and store it in the session * Create a random code challenge and store it in the session
* @param session * @param session
@ -719,7 +720,7 @@ public class OIDCAuthenticationFilter extends AbstractAuthenticationProcessingFi
session.setAttribute(CODE_VERIFIER_SESSION_VARIABLE, challenge); session.setAttribute(CODE_VERIFIER_SESSION_VARIABLE, challenge);
return challenge; return challenge;
} }
/** /**
* Retrieve the stored challenge from our session * Retrieve the stored challenge from our session
* @param session * @param session

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -34,7 +35,7 @@ import com.nimbusds.jwt.JWT;
/** /**
* @author nemonik, Justin Richer * @author nemonik, Justin Richer
* *
*/ */
public class OIDCAuthenticationProvider implements AuthenticationProvider { public class OIDCAuthenticationProvider implements AuthenticationProvider {
@ -46,7 +47,7 @@ public class OIDCAuthenticationProvider implements AuthenticationProvider {
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.springframework.security.authentication.AuthenticationProvider# * @see org.springframework.security.authentication.AuthenticationProvider#
* authenticate(org.springframework.security.core.Authentication) * authenticate(org.springframework.security.core.Authentication)
*/ */
@ -86,7 +87,7 @@ public class OIDCAuthenticationProvider implements AuthenticationProvider {
/** /**
* Override this function to return a different kind of Authentication, processes the authorities differently, * Override this function to return a different kind of Authentication, processes the authorities differently,
* or do post-processing based on the UserInfo object. * or do post-processing based on the UserInfo object.
* *
* @param token * @param token
* @param authorities * @param authorities
* @param userInfo * @param userInfo
@ -115,7 +116,7 @@ public class OIDCAuthenticationProvider implements AuthenticationProvider {
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see * @see
* org.springframework.security.authentication.AuthenticationProvider#supports * org.springframework.security.authentication.AuthenticationProvider#supports
* (java.lang.Class) * (java.lang.Class)

View File

@ -1,6 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,6 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,7 +18,7 @@ package org.mitre.openid.connect.client;
/** /**
* Simple target URI checker, checks whether the string in question starts * Simple target URI checker, checks whether the string in question starts
* with a configured prefix. Returns "/" if the match fails. * with a configured prefix. Returns "/" if the match fails.
* *
* @author jricher * @author jricher
* *
*/ */

View File

@ -1,6 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +14,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.openid.connect.client; package org.mitre.openid.connect.client;
@ -24,9 +23,9 @@ import org.springframework.security.core.GrantedAuthority;
import com.google.common.base.Strings; import com.google.common.base.Strings;
/** /**
* *
* Simple authority representing a user at an issuer. * Simple authority representing a user at an issuer.
* *
* @author jricher * @author jricher
* *
*/ */
@ -51,9 +50,9 @@ public class SubjectIssuerGrantedAuthority implements GrantedAuthority {
/** /**
* Returns a string formed by concatenating the subject with the issuer, separated by _ and prepended with OIDC_ * Returns a string formed by concatenating the subject with the issuer, separated by _ and prepended with OIDC_
* *
* For example, the user "bob" from issuer "http://id.example.com/" would return the authority string of: * For example, the user "bob" from issuer "http://id.example.com/" would return the authority string of:
* *
* OIDC_bob_http://id.example.com/ * OIDC_bob_http://id.example.com/
*/ */
@Override @Override

View File

@ -1,6 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -20,7 +19,7 @@ public interface TargetLinkURIChecker {
/** /**
* Check the parameter to make sure that it's a valid deep-link into this application. * Check the parameter to make sure that it's a valid deep-link into this application.
* *
* @param target * @param target
* @return * @return
*/ */

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -60,7 +61,7 @@ public class UserInfoFetcher {
private static final Logger logger = LoggerFactory.getLogger(UserInfoFetcher.class); private static final Logger logger = LoggerFactory.getLogger(UserInfoFetcher.class);
private LoadingCache<PendingOIDCAuthenticationToken, UserInfo> cache; private LoadingCache<PendingOIDCAuthenticationToken, UserInfo> cache;
public UserInfoFetcher() { public UserInfoFetcher() {
this(HttpClientBuilder.create().useSystemProperties().build()); this(HttpClientBuilder.create().useSystemProperties().build());
} }
@ -71,7 +72,7 @@ public class UserInfoFetcher {
.maximumSize(100) .maximumSize(100)
.build(new UserInfoLoader(httpClient)); .build(new UserInfoLoader(httpClient));
} }
public UserInfo loadUserInfo(final PendingOIDCAuthenticationToken token) { public UserInfo loadUserInfo(final PendingOIDCAuthenticationToken token) {
try { try {
return cache.get(token); return cache.get(token);
@ -81,8 +82,8 @@ public class UserInfoFetcher {
} }
} }
private class UserInfoLoader extends CacheLoader<PendingOIDCAuthenticationToken, UserInfo> { private class UserInfoLoader extends CacheLoader<PendingOIDCAuthenticationToken, UserInfo> {
private HttpComponentsClientHttpRequestFactory factory; private HttpComponentsClientHttpRequestFactory factory;
@ -90,22 +91,23 @@ public class UserInfoFetcher {
this.factory = new HttpComponentsClientHttpRequestFactory(httpClient); this.factory = new HttpComponentsClientHttpRequestFactory(httpClient);
} }
@Override
public UserInfo load(final PendingOIDCAuthenticationToken token) throws URISyntaxException { public UserInfo load(final PendingOIDCAuthenticationToken token) throws URISyntaxException {
ServerConfiguration serverConfiguration = token.getServerConfiguration(); ServerConfiguration serverConfiguration = token.getServerConfiguration();
if (serverConfiguration == null) { if (serverConfiguration == null) {
logger.warn("No server configuration found."); logger.warn("No server configuration found.");
return null; return null;
} }
if (Strings.isNullOrEmpty(serverConfiguration.getUserInfoUri())) { if (Strings.isNullOrEmpty(serverConfiguration.getUserInfoUri())) {
logger.warn("No userinfo endpoint, not fetching."); logger.warn("No userinfo endpoint, not fetching.");
return null; return null;
} }
String userInfoString = null; String userInfoString = null;
if (serverConfiguration.getUserInfoTokenMethod() == null || serverConfiguration.getUserInfoTokenMethod().equals(UserInfoTokenMethod.HEADER)) { if (serverConfiguration.getUserInfoTokenMethod() == null || serverConfiguration.getUserInfoTokenMethod().equals(UserInfoTokenMethod.HEADER)) {
RestTemplate restTemplate = new RestTemplate(factory) { RestTemplate restTemplate = new RestTemplate(factory) {
@ -145,7 +147,7 @@ public class UserInfoFetcher {
// didn't get anything throw exception // didn't get anything throw exception
throw new IllegalArgumentException("Unable to load user info"); throw new IllegalArgumentException("Unable to load user info");
} }
} }
} }

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.openid.connect.client.keypublisher; package org.mitre.openid.connect.client.keypublisher;

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.openid.connect.client.keypublisher; package org.mitre.openid.connect.client.keypublisher;
@ -26,9 +27,9 @@ import org.springframework.web.servlet.View;
import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.ViewResolver;
/** /**
* *
* Simple view resolver to map JWK view names to appropriate beans * Simple view resolver to map JWK view names to appropriate beans
* *
* @author jricher * @author jricher
* *
*/ */

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,14 +16,14 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.openid.connect.client.model; package org.mitre.openid.connect.client.model;
/** /**
* *
* Data container to facilitate returns from the IssuerService API. * Data container to facilitate returns from the IssuerService API.
* *
* @author jricher * @author jricher
* *
*/ */

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.openid.connect.client.service; package org.mitre.openid.connect.client.service;
@ -27,11 +28,11 @@ import org.mitre.oauth2.model.RegisteredClient;
import org.mitre.openid.connect.config.ServerConfiguration; import org.mitre.openid.connect.config.ServerConfiguration;
/** /**
* *
* This service provides any extra options that need to be passed to the authentication request, * This service provides any extra options that need to be passed to the authentication request,
* either through the authorization endpoint (getOptions) or the token endpoint (getTokenOptions). * either through the authorization endpoint (getOptions) or the token endpoint (getTokenOptions).
* These options may depend on the server configuration, client configuration, or HTTP request. * These options may depend on the server configuration, client configuration, or HTTP request.
* *
* @author jricher * @author jricher
* *
*/ */
@ -39,7 +40,7 @@ public interface AuthRequestOptionsService {
/** /**
* The set of options needed at the authorization endpoint. * The set of options needed at the authorization endpoint.
* *
* @param server * @param server
* @param client * @param client
* @param request * @param request
@ -49,7 +50,7 @@ public interface AuthRequestOptionsService {
/** /**
* The set of options needed at the token endpoint. * The set of options needed at the token endpoint.
* *
* @param server * @param server
* @param client * @param client
* @param request * @param request

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.openid.connect.client.service; package org.mitre.openid.connect.client.service;
@ -26,7 +27,7 @@ import org.mitre.openid.connect.config.ServerConfiguration;
/** /**
* Builds a URL string to the IdP's authorization endpoint. * Builds a URL string to the IdP's authorization endpoint.
* *
* @author jricher * @author jricher
* *
*/ */

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.openid.connect.client.service; package org.mitre.openid.connect.client.service;

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.openid.connect.client.service; package org.mitre.openid.connect.client.service;
@ -24,9 +25,9 @@ import javax.servlet.http.HttpServletRequest;
import org.mitre.openid.connect.client.model.IssuerServiceResponse; import org.mitre.openid.connect.client.model.IssuerServiceResponse;
/** /**
* *
* Gets an issuer for the given request. Might do dynamic discovery, or might be statically configured. * Gets an issuer for the given request. Might do dynamic discovery, or might be statically configured.
* *
* @author jricher * @author jricher
* *
*/ */

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,12 +16,10 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.openid.connect.client.service; package org.mitre.openid.connect.client.service;
import java.util.List;
import org.mitre.oauth2.model.RegisteredClient; import org.mitre.oauth2.model.RegisteredClient;
/** /**

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.openid.connect.client.service; package org.mitre.openid.connect.client.service;

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.openid.connect.client.service.impl; package org.mitre.openid.connect.client.service.impl;
@ -164,10 +165,10 @@ public class DynamicRegistrationClientConfigurationService implements ClientConf
/** /**
* Loader class that fetches the client information. * Loader class that fetches the client information.
* *
* If a client has been registered (ie, it's known to the RegisteredClientService), then this * If a client has been registered (ie, it's known to the RegisteredClientService), then this
* will fetch the client's configuration from the server. * will fetch the client's configuration from the server.
* *
* @author jricher * @author jricher
* *
*/ */
@ -203,12 +204,12 @@ public class DynamicRegistrationClientConfigurationService implements ClientConf
try { try {
String registered = restTemplate.postForObject(serverConfig.getRegistrationEndpointUri(), entity, String.class); String registered = restTemplate.postForObject(serverConfig.getRegistrationEndpointUri(), entity, String.class);
RegisteredClient client = ClientDetailsEntityJsonProcessor.parseRegistered(registered); RegisteredClient client = ClientDetailsEntityJsonProcessor.parseRegistered(registered);
// save this client for later // save this client for later
registeredClientService.save(serverConfig.getIssuer(), client); registeredClientService.save(serverConfig.getIssuer(), client);
return client; return client;
} catch (RestClientException rce) { } catch (RestClientException rce) {
throw new InvalidClientException("Error registering client with server"); throw new InvalidClientException("Error registering client with server");
@ -227,9 +228,9 @@ public class DynamicRegistrationClientConfigurationService implements ClientConf
try { try {
String registered = restTemplate.exchange(knownClient.getRegistrationClientUri(), HttpMethod.GET, entity, String.class).getBody(); String registered = restTemplate.exchange(knownClient.getRegistrationClientUri(), HttpMethod.GET, entity, String.class).getBody();
// TODO: handle HTTP errors // TODO: handle HTTP errors
RegisteredClient client = ClientDetailsEntityJsonProcessor.parseRegistered(registered); RegisteredClient client = ClientDetailsEntityJsonProcessor.parseRegistered(registered);
return client; return client;
} catch (RestClientException rce) { } catch (RestClientException rce) {
throw new InvalidClientException("Error loading previously registered client information from server"); throw new InvalidClientException("Error loading previously registered client information from server");

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,10 +16,17 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.openid.connect.client.service.impl; package org.mitre.openid.connect.client.service.impl;
import static org.mitre.util.JsonUtils.getAsBoolean;
import static org.mitre.util.JsonUtils.getAsEncryptionMethodList;
import static org.mitre.util.JsonUtils.getAsJweAlgorithmList;
import static org.mitre.util.JsonUtils.getAsJwsAlgorithmList;
import static org.mitre.util.JsonUtils.getAsString;
import static org.mitre.util.JsonUtils.getAsStringList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
@ -41,17 +49,10 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import static org.mitre.util.JsonUtils.getAsBoolean;
import static org.mitre.util.JsonUtils.getAsEncryptionMethodList;
import static org.mitre.util.JsonUtils.getAsJweAlgorithmList;
import static org.mitre.util.JsonUtils.getAsJwsAlgorithmList;
import static org.mitre.util.JsonUtils.getAsString;
import static org.mitre.util.JsonUtils.getAsStringList;
/** /**
* *
* Dynamically fetches OpenID Connect server configurations based on the issuer. Caches the server configurations. * Dynamically fetches OpenID Connect server configurations based on the issuer. Caches the server configurations.
* *
* @author jricher * @author jricher
* *
*/ */
@ -133,9 +134,9 @@ public class DynamicServerConfigurationService implements ServerConfigurationSer
private HttpComponentsClientHttpRequestFactory httpFactory; private HttpComponentsClientHttpRequestFactory httpFactory;
private JsonParser parser = new JsonParser(); private JsonParser parser = new JsonParser();
OpenIDConnectServiceConfigurationFetcher(HttpClient httpClient) { OpenIDConnectServiceConfigurationFetcher(HttpClient httpClient) {
this.httpFactory = new HttpComponentsClientHttpRequestFactory(httpClient); this.httpFactory = new HttpComponentsClientHttpRequestFactory(httpClient);
} }
@Override @Override
public ServerConfiguration load(String issuer) throws Exception { public ServerConfiguration load(String issuer) throws Exception {

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.openid.connect.client.service.impl; package org.mitre.openid.connect.client.service.impl;

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.openid.connect.client.service.impl; package org.mitre.openid.connect.client.service.impl;
@ -31,12 +32,12 @@ import org.mitre.openid.connect.config.ServerConfiguration;
* Houses both a static client configuration and a dynamic client configuration * Houses both a static client configuration and a dynamic client configuration
* service in one object. Checks the static service first, then falls through to * service in one object. Checks the static service first, then falls through to
* the dynamic service. * the dynamic service.
* *
* Provides configuration passthrough for the template, registered client service, whitelist, * Provides configuration passthrough for the template, registered client service, whitelist,
* and blacklist for the dynamic service, and to the static service's client map. * and blacklist for the dynamic service, and to the static service's client map.
* *
* @author jricher * @author jricher
* *
*/ */
public class HybridClientConfigurationService implements ClientConfigurationService { public class HybridClientConfigurationService implements ClientConfigurationService {

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -26,11 +27,11 @@ import org.mitre.openid.connect.client.service.IssuerService;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
/** /**
* *
* Issuer service that tries to parse input from the inputs from a third-party * Issuer service that tries to parse input from the inputs from a third-party
* account chooser service (if possible), but falls back to webfinger discovery * account chooser service (if possible), but falls back to webfinger discovery
* if not. * if not.
* *
* @author jricher * @author jricher
* *
*/ */

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.openid.connect.client.service.impl; package org.mitre.openid.connect.client.service.impl;
@ -29,11 +30,11 @@ import org.mitre.openid.connect.config.ServerConfiguration;
* Houses both a static server configuration and a dynamic server configuration * Houses both a static server configuration and a dynamic server configuration
* service in one object. Checks the static service first, then falls through to * service in one object. Checks the static service first, then falls through to
* the dynamic service. * the dynamic service.
* *
* Provides configuration passthrough to the dynamic service's whitelist and blacklist, * Provides configuration passthrough to the dynamic service's whitelist and blacklist,
* and to the static service's server map. * and to the static service's server map.
* *
* *
* @author jricher * @author jricher
* *
*/ */

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.openid.connect.client.service.impl; package org.mitre.openid.connect.client.service.impl;

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.openid.connect.client.service.impl; package org.mitre.openid.connect.client.service.impl;
@ -55,20 +56,20 @@ public class JsonFileRegisteredClientService implements RegisteredClientService
private static final Logger logger = LoggerFactory.getLogger(JsonFileRegisteredClientService.class); private static final Logger logger = LoggerFactory.getLogger(JsonFileRegisteredClientService.class);
private Gson gson = new GsonBuilder() private Gson gson = new GsonBuilder()
.registerTypeAdapter(RegisteredClient.class, new JsonSerializer<RegisteredClient>() { .registerTypeAdapter(RegisteredClient.class, new JsonSerializer<RegisteredClient>() {
@Override @Override
public JsonElement serialize(RegisteredClient src, Type typeOfSrc, JsonSerializationContext context) { public JsonElement serialize(RegisteredClient src, Type typeOfSrc, JsonSerializationContext context) {
return ClientDetailsEntityJsonProcessor.serialize(src); return ClientDetailsEntityJsonProcessor.serialize(src);
} }
}) })
.registerTypeAdapter(RegisteredClient.class, new JsonDeserializer<RegisteredClient>() { .registerTypeAdapter(RegisteredClient.class, new JsonDeserializer<RegisteredClient>() {
@Override @Override
public RegisteredClient deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { public RegisteredClient deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
return ClientDetailsEntityJsonProcessor.parseRegistered(json); return ClientDetailsEntityJsonProcessor.parseRegistered(json);
} }
}) })
.setPrettyPrinting() .setPrettyPrinting()
.create(); .create();
private File file; private File file;

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.openid.connect.client.service.impl; package org.mitre.openid.connect.client.service.impl;
@ -33,9 +34,9 @@ import com.google.common.base.Joiner;
import com.google.common.base.Strings; import com.google.common.base.Strings;
/** /**
* *
* Builds an auth request redirect URI with normal query parameters. * Builds an auth request redirect URI with normal query parameters.
* *
* @author jricher * @author jricher
* *
*/ */

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.openid.connect.client.service.impl; package org.mitre.openid.connect.client.service.impl;

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.openid.connect.client.service.impl; package org.mitre.openid.connect.client.service.impl;
@ -29,9 +30,9 @@ import org.mitre.openid.connect.client.service.AuthRequestOptionsService;
import org.mitre.openid.connect.config.ServerConfiguration; import org.mitre.openid.connect.config.ServerConfiguration;
/** /**
* *
* Always returns the same set of options. * Always returns the same set of options.
* *
* @author jricher * @author jricher
* *
*/ */

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.openid.connect.client.service.impl; package org.mitre.openid.connect.client.service.impl;
@ -29,9 +30,9 @@ import org.mitre.openid.connect.config.ServerConfiguration;
/** /**
* Client configuration service that holds a static map from issuer URL to a ClientDetails object to use at that issuer. * Client configuration service that holds a static map from issuer URL to a ClientDetails object to use at that issuer.
* *
* Designed to be configured as a bean. * Designed to be configured as a bean.
* *
* @author jricher * @author jricher
* *
*/ */
@ -56,7 +57,7 @@ public class StaticClientConfigurationService implements ClientConfigurationServ
/** /**
* Get the client configured for this issuer * Get the client configured for this issuer
* *
* @see org.mitre.openid.connect.client.service.ClientConfigurationService#getClientConfiguration(java.lang.String) * @see org.mitre.openid.connect.client.service.ClientConfigurationService#getClientConfiguration(java.lang.String)
*/ */
@Override @Override

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.openid.connect.client.service.impl; package org.mitre.openid.connect.client.service.impl;
@ -28,7 +29,7 @@ import org.mitre.openid.connect.config.ServerConfiguration;
/** /**
* Statically configured server configuration service that maps issuer URLs to server configurations to use at that issuer. * Statically configured server configuration service that maps issuer URLs to server configurations to use at that issuer.
* *
* @author jricher * @author jricher
* *
*/ */

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.openid.connect.client.service.impl; package org.mitre.openid.connect.client.service.impl;
@ -51,7 +52,7 @@ public class StaticSingleIssuerService implements IssuerService {
/** /**
* Always returns the configured issuer URL * Always returns the configured issuer URL
* *
* @see org.mitre.openid.connect.client.service.IssuerService#getIssuer(javax.servlet.http.HttpServletRequest) * @see org.mitre.openid.connect.client.service.IssuerService#getIssuer(javax.servlet.http.HttpServletRequest)
*/ */
@Override @Override

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.openid.connect.client.service.impl; package org.mitre.openid.connect.client.service.impl;
@ -34,9 +35,9 @@ import org.springframework.security.authentication.AuthenticationServiceExceptio
import com.google.common.base.Strings; import com.google.common.base.Strings;
/** /**
* *
* Determines the issuer using an account chooser or other third-party-initiated login * Determines the issuer using an account chooser or other third-party-initiated login
* *
* @author jricher * @author jricher
* *
*/ */

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.openid.connect.client.service.impl; package org.mitre.openid.connect.client.service.impl;
@ -74,7 +75,7 @@ public class WebfingerIssuerService implements IssuerService {
this.issuer = issuer; this.issuer = issuer;
} }
} }
private Set<String> whitelist = new HashSet<>(); private Set<String> whitelist = new HashSet<>();
private Set<String> blacklist = new HashSet<>(); private Set<String> blacklist = new HashSet<>();
@ -118,7 +119,7 @@ public class WebfingerIssuerService implements IssuerService {
if (blacklist.contains(lr.issuer)) { if (blacklist.contains(lr.issuer)) {
throw new AuthenticationServiceException("Issuer was in blacklist: " + lr.issuer); throw new AuthenticationServiceException("Issuer was in blacklist: " + lr.issuer);
} }
return new IssuerServiceResponse(lr.issuer, lr.loginHint, request.getParameter("target_link_uri")); return new IssuerServiceResponse(lr.issuer, lr.loginHint, request.getParameter("target_link_uri"));
} catch (UncheckedExecutionException | ExecutionException e) { } catch (UncheckedExecutionException | ExecutionException e) {
logger.warn("Issue fetching issuer for user input: " + identifier + ": " + e.getMessage()); logger.warn("Issue fetching issuer for user input: " + identifier + ": " + e.getMessage());
@ -218,7 +219,7 @@ public class WebfingerIssuerService implements IssuerService {
public LoadingResult load(String identifier) throws Exception { public LoadingResult load(String identifier) throws Exception {
UriComponents key = WebfingerURLNormalizer.normalizeResource(identifier); UriComponents key = WebfingerURLNormalizer.normalizeResource(identifier);
RestTemplate restTemplate = new RestTemplate(httpFactory); RestTemplate restTemplate = new RestTemplate(httpFactory);
// construct the URL to go to // construct the URL to go to
@ -268,7 +269,7 @@ public class WebfingerIssuerService implements IssuerService {
// we found the issuer, return it // we found the issuer, return it
String href = linkObj.get("href").getAsString(); String href = linkObj.get("href").getAsString();
if (identifier.equals(href) if (identifier.equals(href)
|| identifier.startsWith("http")) { || identifier.startsWith("http")) {
// try to avoid sending a URL as the login hint // try to avoid sending a URL as the login hint

View File

@ -1,6 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,6 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -38,7 +37,7 @@ public class TestScopeBasedIntrospectionAuthoritiesGranter {
private JsonObject introspectionResponse; private JsonObject introspectionResponse;
private ScopeBasedIntrospectionAuthoritiesGranter granter = new ScopeBasedIntrospectionAuthoritiesGranter(); private ScopeBasedIntrospectionAuthoritiesGranter granter = new ScopeBasedIntrospectionAuthoritiesGranter();
/** /**
* @throws java.lang.Exception * @throws java.lang.Exception
*/ */
@ -53,16 +52,16 @@ public class TestScopeBasedIntrospectionAuthoritiesGranter {
@Test @Test
public void testGetAuthoritiesJsonObject_withScopes() { public void testGetAuthoritiesJsonObject_withScopes() {
introspectionResponse.addProperty("scope", "foo bar baz batman"); introspectionResponse.addProperty("scope", "foo bar baz batman");
List<GrantedAuthority> expected = new ArrayList<>(); List<GrantedAuthority> expected = new ArrayList<>();
expected.add(new SimpleGrantedAuthority("ROLE_API")); expected.add(new SimpleGrantedAuthority("ROLE_API"));
expected.add(new SimpleGrantedAuthority("OAUTH_SCOPE_foo")); expected.add(new SimpleGrantedAuthority("OAUTH_SCOPE_foo"));
expected.add(new SimpleGrantedAuthority("OAUTH_SCOPE_bar")); expected.add(new SimpleGrantedAuthority("OAUTH_SCOPE_bar"));
expected.add(new SimpleGrantedAuthority("OAUTH_SCOPE_baz")); expected.add(new SimpleGrantedAuthority("OAUTH_SCOPE_baz"));
expected.add(new SimpleGrantedAuthority("OAUTH_SCOPE_batman")); expected.add(new SimpleGrantedAuthority("OAUTH_SCOPE_batman"));
List<GrantedAuthority> authorities = granter.getAuthorities(introspectionResponse); List<GrantedAuthority> authorities = granter.getAuthorities(introspectionResponse);
assertTrue(authorities.containsAll(expected)); assertTrue(authorities.containsAll(expected));
assertTrue(expected.containsAll(authorities)); assertTrue(expected.containsAll(authorities));
} }
@ -72,12 +71,12 @@ public class TestScopeBasedIntrospectionAuthoritiesGranter {
*/ */
@Test @Test
public void testGetAuthoritiesJsonObject_withoutScopes() { public void testGetAuthoritiesJsonObject_withoutScopes() {
List<GrantedAuthority> expected = new ArrayList<>(); List<GrantedAuthority> expected = new ArrayList<>();
expected.add(new SimpleGrantedAuthority("ROLE_API")); expected.add(new SimpleGrantedAuthority("ROLE_API"));
List<GrantedAuthority> authorities = granter.getAuthorities(introspectionResponse); List<GrantedAuthority> authorities = granter.getAuthorities(introspectionResponse);
assertTrue(authorities.containsAll(expected)); assertTrue(authorities.containsAll(expected));
assertTrue(expected.containsAll(authorities)); assertTrue(expected.containsAll(authorities));
} }

View File

@ -1,11 +1,20 @@
/*******************************************************************************
* Copyright 2018 The MIT Internet Trust Consortium
*
* 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.mitre.openid.connect.client; package org.mitre.openid.connect.client;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -13,13 +22,21 @@ import org.junit.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.springframework.security.authentication.AuthenticationServiceException; import org.springframework.security.authentication.AuthenticationServiceException;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.mockito.Mockito.mock;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
public class TestOIDCAuthenticationFilter { public class TestOIDCAuthenticationFilter {
private OIDCAuthenticationFilter filter = new OIDCAuthenticationFilter(); private OIDCAuthenticationFilter filter = new OIDCAuthenticationFilter();
@Test @Test
public void attemptAuthentication_error() throws Exception { public void attemptAuthentication_error() throws Exception {
HttpServletRequest request = Mockito.mock(HttpServletRequest.class); HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
Mockito.when(request.getParameter("error")).thenReturn("Error"); Mockito.when(request.getParameter("error")).thenReturn("Error");
Mockito.when(request.getParameter("error_description")).thenReturn("Description"); Mockito.when(request.getParameter("error_description")).thenReturn("Description");
@ -27,13 +44,13 @@ public class TestOIDCAuthenticationFilter {
try { try {
filter.attemptAuthentication(request, mock(HttpServletResponse.class)); filter.attemptAuthentication(request, mock(HttpServletResponse.class));
fail("AuthorizationEndpointException expected."); fail("AuthorizationEndpointException expected.");
} }
catch (AuthorizationEndpointException exception) { catch (AuthorizationEndpointException exception) {
assertThat(exception.getMessage(), assertThat(exception.getMessage(),
is("Error from Authorization Endpoint: Error Description http://example.com")); is("Error from Authorization Endpoint: Error Description http://example.com"));
assertThat(exception.getError(), is("Error")); assertThat(exception.getError(), is("Error"));
assertThat(exception.getErrorDescription(), is("Description")); assertThat(exception.getErrorDescription(), is("Description"));
assertThat(exception.getErrorURI(), is("http://example.com")); assertThat(exception.getErrorURI(), is("http://example.com"));

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -52,7 +53,7 @@ import static org.junit.Assert.fail;
/** /**
* @author wkim * @author wkim
* *
*/ */
public class TestSignedAuthRequestUrlBuilder { public class TestSignedAuthRequestUrlBuilder {
@ -91,7 +92,7 @@ public class TestSignedAuthRequestUrlBuilder {
@Before @Before
public void prepare() throws NoSuchAlgorithmException, InvalidKeySpecException { public void prepare() throws NoSuchAlgorithmException, InvalidKeySpecException {
RSAKey key = new RSAKey(new Base64URL(n), new Base64URL(e), new Base64URL(d), KeyUse.SIGNATURE, null, new Algorithm(alg), kid, null, null, null); RSAKey key = new RSAKey(new Base64URL(n), new Base64URL(e), new Base64URL(d), KeyUse.SIGNATURE, null, new Algorithm(alg), kid, null, null, null, null, null);
Map<String, JWK> keys = Maps.newHashMap(); Map<String, JWK> keys = Maps.newHashMap();
keys.put("client", key); keys.put("client", key);

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
Copyright 2017 The MITRE Corporation Copyright 2018 The MIT Internet Trust Consortium
and the MIT Internet Trust Consortium
Portions copyright 2011-2013 The MITRE Corporation
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
Copyright 2017 The MITRE Corporation Copyright 2018 The MIT Internet Trust Consortium
and the MIT Internet Trust Consortium
Portions copyright 2011-2013 The MITRE Corporation
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -21,7 +22,7 @@
<parent> <parent>
<artifactId>openid-connect-parent</artifactId> <artifactId>openid-connect-parent</artifactId>
<groupId>org.mitre</groupId> <groupId>org.mitre</groupId>
<version>1.3.0-RC2</version> <version>1.3.5-SNAPSHOT</version>
<relativePath>..</relativePath> <relativePath>..</relativePath>
</parent> </parent>
<artifactId>openid-connect-common</artifactId> <artifactId>openid-connect-common</artifactId>
@ -86,6 +87,26 @@
<groupId>org.bouncycastle</groupId> <groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId> <artifactId>bcprov-jdk15on</artifactId>
</dependency> </dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</dependency>
</dependencies> </dependencies>
<packaging>jar</packaging> <packaging>jar</packaging>

View File

@ -1,12 +1,27 @@
/*******************************************************************************
* Copyright 2018 The MIT Internet Trust Consortium
*
* 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.mitre.data; package org.mitre.data;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Abstract class for performing an operation on a potentially large * Abstract class for performing an operation on a potentially large
* number of items by paging through the items in discreet chunks. * number of items by paging through the items in discreet chunks.
@ -16,162 +31,162 @@ import java.util.Set;
*/ */
public abstract class AbstractPageOperationTemplate<T> { public abstract class AbstractPageOperationTemplate<T> {
private static final Logger logger = LoggerFactory.getLogger(AbstractPageOperationTemplate.class); private static final Logger logger = LoggerFactory.getLogger(AbstractPageOperationTemplate.class);
private static int DEFAULT_MAX_PAGES = 1000; private static int DEFAULT_MAX_PAGES = 1000;
private static long DEFAULT_MAX_TIME_MILLIS = 600000L; //10 Minutes private static long DEFAULT_MAX_TIME_MILLIS = 600000L; //10 Minutes
/** /**
* int specifying the maximum number of * int specifying the maximum number of
* pages which should be fetched before * pages which should be fetched before
* execution should terminate * execution should terminate
*/ */
private int maxPages; private int maxPages;
/** /**
* long specifying the maximum execution time * long specifying the maximum execution time
* in milliseconds * in milliseconds
*/ */
private long maxTime; private long maxTime;
/** /**
* boolean specifying whether or not Exceptions * boolean specifying whether or not Exceptions
* incurred performing the operation should be * incurred performing the operation should be
* swallowed during execution default true. * swallowed during execution default true.
*/ */
private boolean swallowExceptions = true; private boolean swallowExceptions = true;
/** /**
* String that is used for logging in final tallies. * String that is used for logging in final tallies.
*/ */
private String operationName = ""; private String operationName = "";
/** /**
* default constructor which sets the value of * default constructor which sets the value of
* maxPages and maxTime to DEFAULT_MAX_PAGES and * maxPages and maxTime to DEFAULT_MAX_PAGES and
* DEFAULT_MAX_TIME_MILLIS respectively * DEFAULT_MAX_TIME_MILLIS respectively
*/ */
public AbstractPageOperationTemplate(String operationName){ public AbstractPageOperationTemplate(String operationName){
this(DEFAULT_MAX_PAGES, DEFAULT_MAX_TIME_MILLIS, operationName); this(DEFAULT_MAX_PAGES, DEFAULT_MAX_TIME_MILLIS, operationName);
} }
/** /**
* Instantiates a new AbstractPageOperationTemplate with the * Instantiates a new AbstractPageOperationTemplate with the
* given maxPages and maxTime * given maxPages and maxTime
* *
* @param maxPages the maximum number of pages to fetch. * @param maxPages the maximum number of pages to fetch.
* @param maxTime the maximum execution time. * @param maxTime the maximum execution time.
*/ */
public AbstractPageOperationTemplate(int maxPages, long maxTime, String operationName){ public AbstractPageOperationTemplate(int maxPages, long maxTime, String operationName){
this.maxPages = maxPages; this.maxPages = maxPages;
this.maxTime = maxTime; this.maxTime = maxTime;
this.operationName = operationName; this.operationName = operationName;
} }
/** /**
* Execute the operation on each member of a page of results * Execute the operation on each member of a page of results
* retrieved through the fetch method. the method will execute * retrieved through the fetch method. the method will execute
* until either the maxPages or maxTime limit is reached or until * until either the maxPages or maxTime limit is reached or until
* the fetch method returns no more results. Exceptions thrown * the fetch method returns no more results. Exceptions thrown
* performing the operation on the item will be swallowed if the * performing the operation on the item will be swallowed if the
* swallowException (default true) field is set true. * swallowException (default true) field is set true.
*/ */
public void execute(){ public void execute(){
logger.debug("[" + getOperationName() + "] Starting execution of paged operation. maximum time: " + maxTime + ", maximum pages: " + maxPages); logger.debug("[" + getOperationName() + "] Starting execution of paged operation. maximum time: " + maxTime + ", maximum pages: " + maxPages);
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
long executionTime = 0; long executionTime = 0;
int i = 0; int i = 0;
int exceptionsSwallowedCount = 0; int exceptionsSwallowedCount = 0;
int operationsCompleted = 0; int operationsCompleted = 0;
Set<String> exceptionsSwallowedClasses = new HashSet<String>(); Set<String> exceptionsSwallowedClasses = new HashSet<String>();
while (i< maxPages && executionTime < maxTime){ while (i< maxPages && executionTime < maxTime){
Collection<T> page = fetchPage(); Collection<T> page = fetchPage();
if(page == null || page.size() == 0){ if(page == null || page.size() == 0){
break; break;
} }
for (T item : page) { for (T item : page) {
try { try {
doOperation(item); doOperation(item);
operationsCompleted++; operationsCompleted++;
} catch (Exception e){ } catch (Exception e){
if(swallowExceptions){ if(swallowExceptions){
exceptionsSwallowedCount++; exceptionsSwallowedCount++;
exceptionsSwallowedClasses.add(e.getClass().getName()); exceptionsSwallowedClasses.add(e.getClass().getName());
logger.debug("Swallowing exception " + e.getMessage(), e); logger.debug("Swallowing exception " + e.getMessage(), e);
} else { } else {
logger.debug("Rethrowing exception " + e.getMessage()); logger.debug("Rethrowing exception " + e.getMessage());
throw e; throw e;
} }
} }
} }
i++; i++;
executionTime = System.currentTimeMillis() - startTime; executionTime = System.currentTimeMillis() - startTime;
} }
finalReport(operationsCompleted, exceptionsSwallowedCount, exceptionsSwallowedClasses); finalReport(operationsCompleted, exceptionsSwallowedCount, exceptionsSwallowedClasses);
} }
/** /**
* method responsible for fetching * method responsible for fetching
* a page of items. * a page of items.
* *
* @return the collection of items * @return the collection of items
*/ */
public abstract Collection<T> fetchPage(); public abstract Collection<T> fetchPage();
/** /**
* method responsible for performing desired * method responsible for performing desired
* operation on a fetched page item. * operation on a fetched page item.
* *
* @param item the item * @param item the item
*/ */
protected abstract void doOperation(T item); protected abstract void doOperation(T item);
/**
* Method responsible for final report of progress.
* @return
*/
protected void finalReport(int operationsCompleted, int exceptionsSwallowedCount, Set<String> exceptionsSwallowedClasses) {
if (operationsCompleted > 0 || exceptionsSwallowedCount > 0) {
logger.info("[" + getOperationName() + "] Paged operation run: completed " + operationsCompleted + "; swallowed " + exceptionsSwallowedCount + " exceptions");
}
for(String className: exceptionsSwallowedClasses) {
logger.warn("[" + getOperationName() + "] Paged operation swallowed at least one exception of type " + className);
}
}
public int getMaxPages() { /**
return maxPages; * Method responsible for final report of progress.
} * @return
*/
protected void finalReport(int operationsCompleted, int exceptionsSwallowedCount, Set<String> exceptionsSwallowedClasses) {
if (operationsCompleted > 0 || exceptionsSwallowedCount > 0) {
logger.info("[" + getOperationName() + "] Paged operation run: completed " + operationsCompleted + "; swallowed " + exceptionsSwallowedCount + " exceptions");
}
for(String className: exceptionsSwallowedClasses) {
logger.warn("[" + getOperationName() + "] Paged operation swallowed at least one exception of type " + className);
}
}
public void setMaxPages(int maxPages) { public int getMaxPages() {
this.maxPages = maxPages; return maxPages;
} }
public long getMaxTime() { public void setMaxPages(int maxPages) {
return maxTime; this.maxPages = maxPages;
} }
public void setMaxTime(long maxTime) { public long getMaxTime() {
this.maxTime = maxTime; return maxTime;
} }
public boolean isSwallowExceptions() { public void setMaxTime(long maxTime) {
return swallowExceptions; this.maxTime = maxTime;
} }
public void setSwallowExceptions(boolean swallowExceptions) { public boolean isSwallowExceptions() {
this.swallowExceptions = swallowExceptions; return swallowExceptions;
} }
public void setSwallowExceptions(boolean swallowExceptions) {
this.swallowExceptions = swallowExceptions;
}
/** /**

View File

@ -1,3 +1,18 @@
/*******************************************************************************
* Copyright 2018 The MIT Internet Trust Consortium
*
* 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.mitre.data; package org.mitre.data;
/** /**
@ -8,28 +23,28 @@ package org.mitre.data;
*/ */
public class DefaultPageCriteria implements PageCriteria { public class DefaultPageCriteria implements PageCriteria {
private static final int DEFAULT_PAGE_NUMBER = 0; private static final int DEFAULT_PAGE_NUMBER = 0;
private static final int DEFAULT_PAGE_SIZE = 100; private static final int DEFAULT_PAGE_SIZE = 100;
private int pageNumber; private int pageNumber;
private int pageSize; private int pageSize;
public DefaultPageCriteria(){ public DefaultPageCriteria(){
this(DEFAULT_PAGE_NUMBER, DEFAULT_PAGE_SIZE); this(DEFAULT_PAGE_NUMBER, DEFAULT_PAGE_SIZE);
} }
public DefaultPageCriteria(int pageNumber, int pageSize) { public DefaultPageCriteria(int pageNumber, int pageSize) {
this.pageNumber = pageNumber; this.pageNumber = pageNumber;
this.pageSize = pageSize; this.pageSize = pageSize;
} }
@Override @Override
public int getPageNumber() { public int getPageNumber() {
return pageNumber; return pageNumber;
} }
@Override @Override
public int getPageSize() { public int getPageSize() {
return pageSize; return pageSize;
} }
} }

View File

@ -1,3 +1,18 @@
/*******************************************************************************
* Copyright 2018 The MIT Internet Trust Consortium
*
* 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.mitre.data; package org.mitre.data;
/** /**
@ -8,6 +23,6 @@ package org.mitre.data;
*/ */
public interface PageCriteria { public interface PageCriteria {
public int getPageNumber(); public int getPageNumber();
public int getPageSize(); public int getPageSize();
} }

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -29,7 +30,7 @@ import com.google.common.base.Strings;
/** /**
* Provides utility methods for normalizing and parsing URIs for use with Webfinger Discovery. * Provides utility methods for normalizing and parsing URIs for use with Webfinger Discovery.
* *
* @author wkim * @author wkim
* *
*/ */

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.jose.keystore; package org.mitre.jose.keystore;

View File

@ -1,6 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -26,5 +25,5 @@ import com.nimbusds.jwt.JWT;
public interface AssertionValidator { public interface AssertionValidator {
public boolean isValid(JWT assertion); public boolean isValid(JWT assertion);
} }

View File

@ -1,6 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,7 +22,7 @@ import com.nimbusds.jwt.JWT;
/** /**
* Reject all assertions passed in. * Reject all assertions passed in.
* *
* @author jricher * @author jricher
* *
*/ */

View File

@ -1,6 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -25,6 +24,7 @@ import org.mitre.openid.connect.config.ConfigurationPropertiesBean;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.nimbusds.jwt.JWT; import com.nimbusds.jwt.JWT;
@ -33,27 +33,28 @@ import com.nimbusds.jwt.SignedJWT;
/** /**
* Validates all assertions generated by this server * Validates all assertions generated by this server
* *
* @author jricher * @author jricher
* *
*/ */
@Component("selfAssertionValidator")
public class SelfAssertionValidator implements AssertionValidator { public class SelfAssertionValidator implements AssertionValidator {
private static Logger logger = LoggerFactory.getLogger(SelfAssertionValidator.class); private static Logger logger = LoggerFactory.getLogger(SelfAssertionValidator.class);
@Autowired @Autowired
private ConfigurationPropertiesBean config; private ConfigurationPropertiesBean config;
@Autowired @Autowired
private JWTSigningAndValidationService jwtService; private JWTSigningAndValidationService jwtService;
@Override @Override
public boolean isValid(JWT assertion) { public boolean isValid(JWT assertion) {
if (!(assertion instanceof SignedJWT)) { if (!(assertion instanceof SignedJWT)) {
// unsigned assertion // unsigned assertion
return false; return false;
} }
JWTClaimsSet claims; JWTClaimsSet claims;
try { try {
claims = assertion.getJWTClaimsSet(); claims = assertion.getJWTClaimsSet();
@ -61,17 +62,20 @@ public class SelfAssertionValidator implements AssertionValidator {
logger.debug("Invalid assertion claims"); logger.debug("Invalid assertion claims");
return false; return false;
} }
// make sure the issuer exists
if (Strings.isNullOrEmpty(claims.getIssuer())) { if (Strings.isNullOrEmpty(claims.getIssuer())) {
logger.debug("No issuer for assertion, rejecting"); logger.debug("No issuer for assertion, rejecting");
return false; return false;
} }
if (claims.getIssuer().equals(config.getIssuer())) { // make sure the issuer is us
if (!claims.getIssuer().equals(config.getIssuer())) {
logger.debug("Issuer is not the same as this server, rejecting"); logger.debug("Issuer is not the same as this server, rejecting");
return false; return false;
} }
// validate the signature based on our public key
if (jwtService.validateSignature((SignedJWT) assertion)) { if (jwtService.validateSignature((SignedJWT) assertion)) {
return true; return true;
} else { } else {

View File

@ -1,6 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -41,12 +40,12 @@ import com.nimbusds.jwt.SignedJWT;
public class WhitelistedIssuerAssertionValidator implements AssertionValidator { public class WhitelistedIssuerAssertionValidator implements AssertionValidator {
private static Logger logger = LoggerFactory.getLogger(WhitelistedIssuerAssertionValidator.class); private static Logger logger = LoggerFactory.getLogger(WhitelistedIssuerAssertionValidator.class);
/** /**
* Map of issuer -> JWKSetUri * Map of issuer -> JWKSetUri
*/ */
private Map<String, String> whitelist = new HashMap<>(); private Map<String, String> whitelist = new HashMap<>();
/** /**
* @return the whitelist * @return the whitelist
*/ */
@ -63,15 +62,15 @@ public class WhitelistedIssuerAssertionValidator implements AssertionValidator {
@Autowired @Autowired
private JWKSetCacheService jwkCache; private JWKSetCacheService jwkCache;
@Override @Override
public boolean isValid(JWT assertion) { public boolean isValid(JWT assertion) {
if (!(assertion instanceof SignedJWT)) { if (!(assertion instanceof SignedJWT)) {
// unsigned assertion // unsigned assertion
return false; return false;
} }
JWTClaimsSet claims; JWTClaimsSet claims;
try { try {
claims = assertion.getJWTClaimsSet(); claims = assertion.getJWTClaimsSet();
@ -79,21 +78,21 @@ public class WhitelistedIssuerAssertionValidator implements AssertionValidator {
logger.debug("Invalid assertion claims"); logger.debug("Invalid assertion claims");
return false; return false;
} }
if (Strings.isNullOrEmpty(claims.getIssuer())) { if (Strings.isNullOrEmpty(claims.getIssuer())) {
logger.debug("No issuer for assertion, rejecting"); logger.debug("No issuer for assertion, rejecting");
return false; return false;
} }
if (!whitelist.containsKey(claims.getIssuer())) { if (!whitelist.containsKey(claims.getIssuer())) {
logger.debug("Issuer is not in whitelist, rejecting"); logger.debug("Issuer is not in whitelist, rejecting");
return false; return false;
} }
String jwksUri = whitelist.get(claims.getIssuer()); String jwksUri = whitelist.get(claims.getIssuer());
JWTSigningAndValidationService validator = jwkCache.getValidator(jwksUri); JWTSigningAndValidationService validator = jwkCache.getValidator(jwksUri);
if (validator.validateSignature((SignedJWT) assertion)) { if (validator.validateSignature((SignedJWT) assertion)) {
return true; return true;
} else { } else {

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -45,7 +46,6 @@ import com.nimbusds.jose.crypto.ECDHEncrypter;
import com.nimbusds.jose.crypto.RSADecrypter; import com.nimbusds.jose.crypto.RSADecrypter;
import com.nimbusds.jose.crypto.RSAEncrypter; import com.nimbusds.jose.crypto.RSAEncrypter;
import com.nimbusds.jose.crypto.bc.BouncyCastleProviderSingleton; import com.nimbusds.jose.crypto.bc.BouncyCastleProviderSingleton;
import com.nimbusds.jose.jca.JCAContext;
import com.nimbusds.jose.jwk.ECKey; import com.nimbusds.jose.jwk.ECKey;
import com.nimbusds.jose.jwk.JWK; import com.nimbusds.jose.jwk.JWK;
import com.nimbusds.jose.jwk.OctetSequenceKey; import com.nimbusds.jose.jwk.OctetSequenceKey;
@ -80,7 +80,7 @@ public class DefaultJWTEncryptionAndDecryptionService implements JWTEncryptionAn
/** /**
* Build this service based on the keys given. All public keys will be used to make encrypters, * Build this service based on the keys given. All public keys will be used to make encrypters,
* all private keys will be used to make decrypters. * all private keys will be used to make decrypters.
* *
* @param keys * @param keys
* @throws NoSuchAlgorithmException * @throws NoSuchAlgorithmException
* @throws InvalidKeySpecException * @throws InvalidKeySpecException
@ -94,7 +94,7 @@ public class DefaultJWTEncryptionAndDecryptionService implements JWTEncryptionAn
/** /**
* Build this service based on the given keystore. All keys must have a key * Build this service based on the given keystore. All keys must have a key
* id ({@code kid}) field in order to be used. * id ({@code kid}) field in order to be used.
* *
* @param keyStore * @param keyStore
* @throws NoSuchAlgorithmException * @throws NoSuchAlgorithmException
* @throws InvalidKeySpecException * @throws InvalidKeySpecException
@ -240,13 +240,13 @@ public class DefaultJWTEncryptionAndDecryptionService implements JWTEncryptionAn
logger.warn("No private key for key #" + jwk.getKeyID()); logger.warn("No private key for key #" + jwk.getKeyID());
} }
} else if (jwk instanceof ECKey) { } else if (jwk instanceof ECKey) {
// build EC Encrypters and decrypters // build EC Encrypters and decrypters
ECDHEncrypter encrypter = new ECDHEncrypter((ECKey) jwk); ECDHEncrypter encrypter = new ECDHEncrypter((ECKey) jwk);
encrypter.getJCAContext().setProvider(BouncyCastleProviderSingleton.getInstance()); encrypter.getJCAContext().setProvider(BouncyCastleProviderSingleton.getInstance());
encrypters.put(id, encrypter); encrypters.put(id, encrypter);
if (jwk.isPrivate()) { // we can decrypt too if (jwk.isPrivate()) { // we can decrypt too
ECDHDecrypter decrypter = new ECDHDecrypter((ECKey) jwk); ECDHDecrypter decrypter = new ECDHDecrypter((ECKey) jwk);
decrypter.getJCAContext().setProvider(BouncyCastleProviderSingleton.getInstance()); decrypter.getJCAContext().setProvider(BouncyCastleProviderSingleton.getInstance());

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -34,7 +35,7 @@ public interface JWTSigningAndValidationService {
/** /**
* Checks the signature of the given JWT against all configured signers, * Checks the signature of the given JWT against all configured signers,
* returns true if at least one of the signers validates it. * returns true if at least one of the signers validates it.
* *
* @param jwtString * @param jwtString
* the string representation of the JWT as sent on the wire * the string representation of the JWT as sent on the wire
* @return true if the signature is valid, false if not * @return true if the signature is valid, false if not
@ -45,7 +46,7 @@ public interface JWTSigningAndValidationService {
/** /**
* Called to sign a jwt in place for a client that hasn't registered a preferred signing algorithm. * Called to sign a jwt in place for a client that hasn't registered a preferred signing algorithm.
* Use the default algorithm to sign. * Use the default algorithm to sign.
* *
* @param jwt the jwt to sign * @param jwt the jwt to sign
* @return the signed jwt * @return the signed jwt
* @throws NoSuchAlgorithmException * @throws NoSuchAlgorithmException
@ -67,7 +68,7 @@ public interface JWTSigningAndValidationService {
/** /**
* Sign a jwt using the selected algorithm. The algorithm is selected using the String parameter values specified * Sign a jwt using the selected algorithm. The algorithm is selected using the String parameter values specified
* in the JWT spec, section 6. I.E., "HS256" means HMAC with SHA-256 and corresponds to our HmacSigner class. * in the JWT spec, section 6. I.E., "HS256" means HMAC with SHA-256 and corresponds to our HmacSigner class.
* *
* @param jwt the jwt to sign * @param jwt the jwt to sign
* @param alg the name of the algorithm to use, as specified in JWS s.6 * @param alg the name of the algorithm to use, as specified in JWS s.6
* @return the signed jwt * @return the signed jwt

View File

@ -1,6 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -39,10 +38,10 @@ import com.nimbusds.jose.JWSAlgorithm;
import com.nimbusds.jose.jwk.JWKSet; import com.nimbusds.jose.jwk.JWKSet;
/** /**
* *
* Takes in a client and returns the appropriate validator or encrypter for * Takes in a client and returns the appropriate validator or encrypter for
* that client's registered key types. * that client's registered key types.
* *
* @author jricher * @author jricher
* *
*/ */

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,8 +18,6 @@
package org.mitre.jwt.signer.service.impl; package org.mitre.jwt.signer.service.impl;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.security.interfaces.ECPrivateKey;
import java.security.interfaces.ECPublicKey;
import java.security.spec.InvalidKeySpecException; import java.security.spec.InvalidKeySpecException;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
@ -72,10 +71,10 @@ public class DefaultJWTSigningAndValidationService implements JWTSigningAndValid
/** /**
* Build this service based on the keys given. All public keys will be used * Build this service based on the keys given. All public keys will be used
* to make verifiers, all private keys will be used to make signers. * to make verifiers, all private keys will be used to make signers.
* *
* @param keys * @param keys
* A map of key identifier to key * A map of key identifier to key
* *
* @throws InvalidKeySpecException * @throws InvalidKeySpecException
* If the keys in the JWKs are not valid * If the keys in the JWKs are not valid
* @throws NoSuchAlgorithmException * @throws NoSuchAlgorithmException
@ -89,10 +88,10 @@ public class DefaultJWTSigningAndValidationService implements JWTSigningAndValid
/** /**
* Build this service based on the given keystore. All keys must have a key * Build this service based on the given keystore. All keys must have a key
* id ({@code kid}) field in order to be used. * id ({@code kid}) field in order to be used.
* *
* @param keyStore * @param keyStore
* the keystore to load all keys from * the keystore to load all keys from
* *
* @throws InvalidKeySpecException * @throws InvalidKeySpecException
* If the keys in the JWKs are not valid * If the keys in the JWKs are not valid
* @throws NoSuchAlgorithmException * @throws NoSuchAlgorithmException
@ -165,37 +164,37 @@ public class DefaultJWTSigningAndValidationService implements JWTSigningAndValid
try { try {
if (jwk instanceof RSAKey) { if (jwk instanceof RSAKey) {
// build RSA signers & verifiers // build RSA signers & verifiers
if (jwk.isPrivate()) { // only add the signer if there's a private key if (jwk.isPrivate()) { // only add the signer if there's a private key
RSASSASigner signer = new RSASSASigner((RSAKey) jwk); RSASSASigner signer = new RSASSASigner((RSAKey) jwk);
signers.put(id, signer); signers.put(id, signer);
} }
RSASSAVerifier verifier = new RSASSAVerifier((RSAKey) jwk); RSASSAVerifier verifier = new RSASSAVerifier((RSAKey) jwk);
verifiers.put(id, verifier); verifiers.put(id, verifier);
} else if (jwk instanceof ECKey) { } else if (jwk instanceof ECKey) {
// build EC signers & verifiers // build EC signers & verifiers
if (jwk.isPrivate()) { if (jwk.isPrivate()) {
ECDSASigner signer = new ECDSASigner((ECKey) jwk); ECDSASigner signer = new ECDSASigner((ECKey) jwk);
signers.put(id, signer); signers.put(id, signer);
} }
ECDSAVerifier verifier = new ECDSAVerifier((ECKey) jwk); ECDSAVerifier verifier = new ECDSAVerifier((ECKey) jwk);
verifiers.put(id, verifier); verifiers.put(id, verifier);
} else if (jwk instanceof OctetSequenceKey) { } else if (jwk instanceof OctetSequenceKey) {
// build HMAC signers & verifiers // build HMAC signers & verifiers
if (jwk.isPrivate()) { // technically redundant check because all HMAC keys are private if (jwk.isPrivate()) { // technically redundant check because all HMAC keys are private
MACSigner signer = new MACSigner((OctetSequenceKey) jwk); MACSigner signer = new MACSigner((OctetSequenceKey) jwk);
signers.put(id, signer); signers.put(id, signer);
} }
MACVerifier verifier = new MACVerifier((OctetSequenceKey) jwk); MACVerifier verifier = new MACVerifier((OctetSequenceKey) jwk);
verifiers.put(id, verifier); verifiers.put(id, verifier);
} else { } else {
logger.warn("Unknown key type: " + jwk); logger.warn("Unknown key type: " + jwk);
} }

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.jwt.signer.service.impl; package org.mitre.jwt.signer.service.impl;
@ -43,12 +44,12 @@ import com.google.gson.JsonParseException;
import com.nimbusds.jose.jwk.JWKSet; import com.nimbusds.jose.jwk.JWKSet;
/** /**
* *
* Creates a caching map of JOSE signers/validators and encrypters/decryptors * Creates a caching map of JOSE signers/validators and encrypters/decryptors
* keyed on the JWK Set URI. Dynamically loads JWK Sets to create the services. * keyed on the JWK Set URI. Dynamically loads JWK Sets to create the services.
* *
* @author jricher * @author jricher
* *
*/ */
@Service @Service
public class JWKSetCacheService { public class JWKSetCacheService {
@ -150,11 +151,11 @@ public class JWKSetCacheService {
try { try {
String jsonString = restTemplate.getForObject(key, String.class); String jsonString = restTemplate.getForObject(key, String.class);
JWKSet jwkSet = JWKSet.parse(jsonString); JWKSet jwkSet = JWKSet.parse(jsonString);
JWKSetKeyStore keyStore = new JWKSetKeyStore(jwkSet); JWKSetKeyStore keyStore = new JWKSetKeyStore(jwkSet);
JWTEncryptionAndDecryptionService service = new DefaultJWTEncryptionAndDecryptionService(keyStore); JWTEncryptionAndDecryptionService service = new DefaultJWTEncryptionAndDecryptionService(keyStore);
return service; return service;
} catch (JsonParseException | RestClientException e) { } catch (JsonParseException | RestClientException e) {
throw new IllegalArgumentException("Unable to load JWK Set"); throw new IllegalArgumentException("Unable to load JWK Set");

View File

@ -1,6 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -41,7 +40,7 @@ import com.nimbusds.jose.util.Base64URL;
/** /**
* Creates and caches symmetrical validators for clients based on client secrets. * Creates and caches symmetrical validators for clients based on client secrets.
* *
* @author jricher * @author jricher
* *
*/ */
@ -66,7 +65,7 @@ public class SymmetricKeyJWTValidatorCacheService {
/** /**
* Create a symmetric signing and validation service for the given client * Create a symmetric signing and validation service for the given client
* *
* @param client * @param client
* @return * @return
*/ */
@ -100,8 +99,10 @@ public class SymmetricKeyJWTValidatorCacheService {
try { try {
String id = "SYMMETRIC-KEY"; String id = "SYMMETRIC-KEY";
JWK jwk = new OctetSequenceKey.Builder(Base64URL.encode(key))
JWK jwk = new OctetSequenceKey(Base64URL.encode(key), KeyUse.SIGNATURE, null, null, id, null, null, null); .keyUse(KeyUse.SIGNATURE)
.keyID(id)
.build();
Map<String, JWK> keys = ImmutableMap.of(id, jwk); Map<String, JWK> keys = ImmutableMap.of(id, jwk);
JWTSigningAndValidationService service = new DefaultJWTSigningAndValidationService(keys); JWTSigningAndValidationService service = new DefaultJWTSigningAndValidationService(keys);

View File

@ -0,0 +1,50 @@
/*******************************************************************************
* Copyright 2018 The MIT Internet Trust Consortium
*
* 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.mitre.oauth2.exception;
/**
* @author jricher
*
*/
public class DeviceCodeCreationException extends Exception {
private static final long serialVersionUID = 8078568710169208466L;
private String error;
public DeviceCodeCreationException(String error, String message) {
super(message);
this.error = error;
}
/**
* @return the error
*/
public String getError() {
return error;
}
/**
* @param error the error to set
*/
public void setError(String error) {
this.error = error;
}
}

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -33,7 +34,7 @@ import javax.persistence.Temporal;
/** /**
* Entity class for authorization codes * Entity class for authorization codes
* *
* @author aanganes * @author aanganes
* *
*/ */
@ -67,7 +68,7 @@ public class AuthorizationCodeEntity {
/** /**
* Create a new AuthorizationCodeEntity with the given code and AuthorizationRequestHolder. * Create a new AuthorizationCodeEntity with the given code and AuthorizationRequestHolder.
* *
* @param code the authorization code * @param code the authorization code
* @param authRequest the AuthoriztionRequestHolder associated with the original code request * @param authRequest the AuthoriztionRequestHolder associated with the original code request
*/ */

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.oauth2.model; package org.mitre.oauth2.model;
@ -57,7 +58,6 @@ import org.mitre.oauth2.model.convert.SimpleGrantedAuthorityStringConverter;
import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.oauth2.provider.ClientDetails; import org.springframework.security.oauth2.provider.ClientDetails;
import com.nimbusds.jose.Algorithm;
import com.nimbusds.jose.EncryptionMethod; import com.nimbusds.jose.EncryptionMethod;
import com.nimbusds.jose.JWEAlgorithm; import com.nimbusds.jose.JWEAlgorithm;
import com.nimbusds.jose.JWSAlgorithm; import com.nimbusds.jose.JWSAlgorithm;
@ -66,7 +66,7 @@ import com.nimbusds.jwt.JWT;
/** /**
* @author jricher * @author jricher
* *
*/ */
@Entity @Entity
@Table(name = "client_details") @Table(name = "client_details")
@ -151,10 +151,10 @@ public class ClientDetailsEntity implements ClientDetails {
/** fields for UMA */ /** fields for UMA */
private Set<String> claimsRedirectUris; private Set<String> claimsRedirectUris;
/** Software statement **/ /** Software statement **/
private JWT softwareStatement; private JWT softwareStatement;
/** PKCE **/ /** PKCE **/
private PKCEAlgorithm codeChallengeMethod; private PKCEAlgorithm codeChallengeMethod;
@ -239,7 +239,7 @@ public class ClientDetailsEntity implements ClientDetails {
return lookup.get(value); return lookup.get(value);
} }
} }
/** /**
* Create a blank ClientDetailsEntity * Create a blank ClientDetailsEntity
*/ */
@ -267,7 +267,7 @@ public class ClientDetailsEntity implements ClientDetails {
} }
/** /**
* *
* @param id the id to set * @param id the id to set
*/ */
public void setId(Long id) { public void setId(Long id) {
@ -314,7 +314,7 @@ public class ClientDetailsEntity implements ClientDetails {
/** /**
* Number of seconds ID token is valid for. MUST be a positive integer, can not be null. * Number of seconds ID token is valid for. MUST be a positive integer, can not be null.
* *
* @return the idTokenValiditySeconds * @return the idTokenValiditySeconds
*/ */
@Basic @Basic
@ -367,7 +367,7 @@ public class ClientDetailsEntity implements ClientDetails {
} }
/** /**
* *
*/ */
@Override @Override
@Transient @Transient
@ -580,9 +580,9 @@ public class ClientDetailsEntity implements ClientDetails {
/** /**
* This library does not make use of this field, so it is not * This library does not make use of this field, so it is not
* stored using our persistence layer. * stored using our persistence layer.
* *
* However, it's somehow required by SECOUATH. * However, it's somehow required by SECOUATH.
* *
* @return an empty map * @return an empty map
*/ */
@Override @Override

View File

@ -1,6 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -54,11 +53,11 @@ public class DeviceCode {
public static final String QUERY_BY_USER_CODE = "DeviceCode.queryByUserCode"; public static final String QUERY_BY_USER_CODE = "DeviceCode.queryByUserCode";
public static final String QUERY_BY_DEVICE_CODE = "DeviceCode.queryByDeviceCode"; public static final String QUERY_BY_DEVICE_CODE = "DeviceCode.queryByDeviceCode";
public static final String QUERY_EXPIRED_BY_DATE = "DeviceCode.queryExpiredByDate"; public static final String QUERY_EXPIRED_BY_DATE = "DeviceCode.queryExpiredByDate";
public static final String PARAM_USER_CODE = "userCode"; public static final String PARAM_USER_CODE = "userCode";
public static final String PARAM_DEVICE_CODE = "deviceCode"; public static final String PARAM_DEVICE_CODE = "deviceCode";
public static final String PARAM_DATE = "date"; public static final String PARAM_DATE = "date";
private Long id; private Long id;
private String deviceCode; private String deviceCode;
private String userCode; private String userCode;
@ -68,11 +67,11 @@ public class DeviceCode {
private Map<String, String> requestParameters; private Map<String, String> requestParameters;
private boolean approved; private boolean approved;
private AuthenticationHolderEntity authenticationHolder; private AuthenticationHolderEntity authenticationHolder;
public DeviceCode() { public DeviceCode() {
} }
public DeviceCode(String deviceCode, String userCode, Set<String> scope, String clientId, Map<String, String> params) { public DeviceCode(String deviceCode, String userCode, Set<String> scope, String clientId, Map<String, String> params) {
this.deviceCode = deviceCode; this.deviceCode = deviceCode;
this.userCode = userCode; this.userCode = userCode;
@ -213,7 +212,7 @@ public class DeviceCode {
public void setApproved(boolean approved) { public void setApproved(boolean approved) {
this.approved = approved; this.approved = approved;
} }
/** /**
* The authentication in place when this token was created. * The authentication in place when this token was created.
* @return the authentication * @return the authentication
@ -231,5 +230,5 @@ public class DeviceCode {
this.authenticationHolder = authenticationHolder; this.authenticationHolder = authenticationHolder;
} }
} }

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.oauth2.model; package org.mitre.oauth2.model;
@ -41,7 +42,6 @@ import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery; import javax.persistence.NamedQuery;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal; import javax.persistence.Temporal;
import javax.persistence.Transient; import javax.persistence.Transient;
@ -71,7 +71,8 @@ import com.nimbusds.jwt.JWT;
@NamedQuery(name = OAuth2AccessTokenEntity.QUERY_BY_CLIENT, query = "select a from OAuth2AccessTokenEntity a where a.client = :" + OAuth2AccessTokenEntity.PARAM_CLIENT), @NamedQuery(name = OAuth2AccessTokenEntity.QUERY_BY_CLIENT, query = "select a from OAuth2AccessTokenEntity a where a.client = :" + OAuth2AccessTokenEntity.PARAM_CLIENT),
@NamedQuery(name = OAuth2AccessTokenEntity.QUERY_BY_TOKEN_VALUE, query = "select a from OAuth2AccessTokenEntity a where a.jwt = :" + OAuth2AccessTokenEntity.PARAM_TOKEN_VALUE), @NamedQuery(name = OAuth2AccessTokenEntity.QUERY_BY_TOKEN_VALUE, query = "select a from OAuth2AccessTokenEntity a where a.jwt = :" + OAuth2AccessTokenEntity.PARAM_TOKEN_VALUE),
@NamedQuery(name = OAuth2AccessTokenEntity.QUERY_BY_APPROVED_SITE, query = "select a from OAuth2AccessTokenEntity a where a.approvedSite = :" + OAuth2AccessTokenEntity.PARAM_APPROVED_SITE), @NamedQuery(name = OAuth2AccessTokenEntity.QUERY_BY_APPROVED_SITE, query = "select a from OAuth2AccessTokenEntity a where a.approvedSite = :" + OAuth2AccessTokenEntity.PARAM_APPROVED_SITE),
@NamedQuery(name = OAuth2AccessTokenEntity.QUERY_BY_RESOURCE_SET, query = "select a from OAuth2AccessTokenEntity a join a.permissions p where p.resourceSet.id = :" + OAuth2AccessTokenEntity.PARAM_RESOURCE_SET_ID) @NamedQuery(name = OAuth2AccessTokenEntity.QUERY_BY_RESOURCE_SET, query = "select a from OAuth2AccessTokenEntity a join a.permissions p where p.resourceSet.id = :" + OAuth2AccessTokenEntity.PARAM_RESOURCE_SET_ID),
@NamedQuery(name = OAuth2AccessTokenEntity.QUERY_BY_NAME, query = "select r from OAuth2AccessTokenEntity r where r.authenticationHolder.userAuth.name = :" + OAuth2AccessTokenEntity.PARAM_NAME)
}) })
@org.codehaus.jackson.map.annotate.JsonSerialize(using = OAuth2AccessTokenJackson1Serializer.class) @org.codehaus.jackson.map.annotate.JsonSerialize(using = OAuth2AccessTokenJackson1Serializer.class)
@org.codehaus.jackson.map.annotate.JsonDeserialize(using = OAuth2AccessTokenJackson1Deserializer.class) @org.codehaus.jackson.map.annotate.JsonDeserialize(using = OAuth2AccessTokenJackson1Deserializer.class)
@ -86,6 +87,7 @@ public class OAuth2AccessTokenEntity implements OAuth2AccessToken {
public static final String QUERY_EXPIRED_BY_DATE = "OAuth2AccessTokenEntity.getAllExpiredByDate"; public static final String QUERY_EXPIRED_BY_DATE = "OAuth2AccessTokenEntity.getAllExpiredByDate";
public static final String QUERY_ALL = "OAuth2AccessTokenEntity.getAll"; public static final String QUERY_ALL = "OAuth2AccessTokenEntity.getAll";
public static final String QUERY_BY_RESOURCE_SET = "OAuth2AccessTokenEntity.getByResourceSet"; public static final String QUERY_BY_RESOURCE_SET = "OAuth2AccessTokenEntity.getByResourceSet";
public static final String QUERY_BY_NAME = "OAuth2AccessTokenEntity.getByName";
public static final String PARAM_TOKEN_VALUE = "tokenValue"; public static final String PARAM_TOKEN_VALUE = "tokenValue";
public static final String PARAM_CLIENT = "client"; public static final String PARAM_CLIENT = "client";
@ -93,6 +95,7 @@ public class OAuth2AccessTokenEntity implements OAuth2AccessToken {
public static final String PARAM_DATE = "date"; public static final String PARAM_DATE = "date";
public static final String PARAM_RESOURCE_SET_ID = "rsid"; public static final String PARAM_RESOURCE_SET_ID = "rsid";
public static final String PARAM_APPROVED_SITE = "approvedSite"; public static final String PARAM_APPROVED_SITE = "approvedSite";
public static final String PARAM_NAME = "name";
public static final String ID_TOKEN_FIELD_NAME = "id_token"; public static final String ID_TOKEN_FIELD_NAME = "id_token";
@ -113,9 +116,9 @@ public class OAuth2AccessTokenEntity implements OAuth2AccessToken {
private Set<String> scope; private Set<String> scope;
private Set<Permission> permissions; private Set<Permission> permissions;
private ApprovedSite approvedSite; private ApprovedSite approvedSite;
private Map<String, Object> additionalInformation = new HashMap<>(); // ephemeral map of items to be added to the OAuth token response private Map<String, Object> additionalInformation = new HashMap<>(); // ephemeral map of items to be added to the OAuth token response
/** /**
@ -297,7 +300,7 @@ public class OAuth2AccessTokenEntity implements OAuth2AccessToken {
name = "access_token_permissions", name = "access_token_permissions",
joinColumns = @JoinColumn(name = "access_token_id"), joinColumns = @JoinColumn(name = "access_token_id"),
inverseJoinColumns = @JoinColumn(name = "permission_id") inverseJoinColumns = @JoinColumn(name = "permission_id")
) )
public Set<Permission> getPermissions() { public Set<Permission> getPermissions() {
return permissions; return permissions;
} }

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.oauth2.model; package org.mitre.oauth2.model;
@ -52,7 +53,8 @@ import com.nimbusds.jwt.JWT;
@NamedQuery(name = OAuth2RefreshTokenEntity.QUERY_ALL, query = "select r from OAuth2RefreshTokenEntity r"), @NamedQuery(name = OAuth2RefreshTokenEntity.QUERY_ALL, query = "select r from OAuth2RefreshTokenEntity r"),
@NamedQuery(name = OAuth2RefreshTokenEntity.QUERY_EXPIRED_BY_DATE, query = "select r from OAuth2RefreshTokenEntity r where r.expiration <= :" + OAuth2RefreshTokenEntity.PARAM_DATE), @NamedQuery(name = OAuth2RefreshTokenEntity.QUERY_EXPIRED_BY_DATE, query = "select r from OAuth2RefreshTokenEntity r where r.expiration <= :" + OAuth2RefreshTokenEntity.PARAM_DATE),
@NamedQuery(name = OAuth2RefreshTokenEntity.QUERY_BY_CLIENT, query = "select r from OAuth2RefreshTokenEntity r where r.client = :" + OAuth2RefreshTokenEntity.PARAM_CLIENT), @NamedQuery(name = OAuth2RefreshTokenEntity.QUERY_BY_CLIENT, query = "select r from OAuth2RefreshTokenEntity r where r.client = :" + OAuth2RefreshTokenEntity.PARAM_CLIENT),
@NamedQuery(name = OAuth2RefreshTokenEntity.QUERY_BY_TOKEN_VALUE, query = "select r from OAuth2RefreshTokenEntity r where r.jwt = :" + OAuth2RefreshTokenEntity.PARAM_TOKEN_VALUE) @NamedQuery(name = OAuth2RefreshTokenEntity.QUERY_BY_TOKEN_VALUE, query = "select r from OAuth2RefreshTokenEntity r where r.jwt = :" + OAuth2RefreshTokenEntity.PARAM_TOKEN_VALUE),
@NamedQuery(name = OAuth2RefreshTokenEntity.QUERY_BY_NAME, query = "select r from OAuth2RefreshTokenEntity r where r.authenticationHolder.userAuth.name = :" + OAuth2RefreshTokenEntity.PARAM_NAME)
}) })
public class OAuth2RefreshTokenEntity implements OAuth2RefreshToken { public class OAuth2RefreshTokenEntity implements OAuth2RefreshToken {
@ -60,10 +62,12 @@ public class OAuth2RefreshTokenEntity implements OAuth2RefreshToken {
public static final String QUERY_BY_CLIENT = "OAuth2RefreshTokenEntity.getByClient"; public static final String QUERY_BY_CLIENT = "OAuth2RefreshTokenEntity.getByClient";
public static final String QUERY_EXPIRED_BY_DATE = "OAuth2RefreshTokenEntity.getAllExpiredByDate"; public static final String QUERY_EXPIRED_BY_DATE = "OAuth2RefreshTokenEntity.getAllExpiredByDate";
public static final String QUERY_ALL = "OAuth2RefreshTokenEntity.getAll"; public static final String QUERY_ALL = "OAuth2RefreshTokenEntity.getAll";
public static final String QUERY_BY_NAME = "OAuth2RefreshTokenEntity.getByName";
public static final String PARAM_TOKEN_VALUE = "tokenValue"; public static final String PARAM_TOKEN_VALUE = "tokenValue";
public static final String PARAM_CLIENT = "client"; public static final String PARAM_CLIENT = "client";
public static final String PARAM_DATE = "date"; public static final String PARAM_DATE = "date";
public static final String PARAM_NAME = "name";
private Long id; private Long id;
@ -78,7 +82,7 @@ public class OAuth2RefreshTokenEntity implements OAuth2RefreshToken {
private Date expiration; private Date expiration;
/** /**
* *
*/ */
public OAuth2RefreshTokenEntity() { public OAuth2RefreshTokenEntity() {
@ -104,7 +108,7 @@ public class OAuth2RefreshTokenEntity implements OAuth2RefreshToken {
/** /**
* The authentication in place when the original access token was * The authentication in place when the original access token was
* created * created
* *
* @return the authentication * @return the authentication
*/ */
@ManyToOne @ManyToOne

View File

@ -1,6 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -26,8 +25,13 @@ import com.nimbusds.jose.Requirement;
*/ */
public final class PKCEAlgorithm extends Algorithm { public final class PKCEAlgorithm extends Algorithm {
/**
*
*/
private static final long serialVersionUID = 7752852583210088925L;
public static final PKCEAlgorithm plain = new PKCEAlgorithm("plain", Requirement.REQUIRED); public static final PKCEAlgorithm plain = new PKCEAlgorithm("plain", Requirement.REQUIRED);
public static final PKCEAlgorithm S256 = new PKCEAlgorithm("S256", Requirement.OPTIONAL); public static final PKCEAlgorithm S256 = new PKCEAlgorithm("S256", Requirement.OPTIONAL);
public PKCEAlgorithm(String name, Requirement req) { public PKCEAlgorithm(String name, Requirement req) {
@ -37,7 +41,7 @@ public final class PKCEAlgorithm extends Algorithm {
public PKCEAlgorithm(String name) { public PKCEAlgorithm(String name) {
super(name, null); super(name, null);
} }
public static PKCEAlgorithm parse(final String s) { public static PKCEAlgorithm parse(final String s) {
if (s.equals(plain.getName())) { if (s.equals(plain.getName())) {
return plain; return plain;
@ -47,7 +51,7 @@ public final class PKCEAlgorithm extends Algorithm {
return new PKCEAlgorithm(s); return new PKCEAlgorithm(s);
} }
} }
} }

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.oauth2.model; package org.mitre.oauth2.model;
@ -50,7 +51,7 @@ public class RegisteredClient {
private JsonObject src; private JsonObject src;
/** /**
* *
*/ */
public RegisteredClient() { public RegisteredClient() {
this.client = new ClientDetailsEntity(); this.client = new ClientDetailsEntity();
@ -815,7 +816,7 @@ public class RegisteredClient {
public void setSoftwareStatement(JWT softwareStatement) { public void setSoftwareStatement(JWT softwareStatement) {
client.setSoftwareStatement(softwareStatement); client.setSoftwareStatement(softwareStatement);
} }
/** /**
* @return * @return
* @see org.mitre.oauth2.model.ClientDetailsEntity#getCodeChallengeMethod() * @see org.mitre.oauth2.model.ClientDetailsEntity#getCodeChallengeMethod()

View File

@ -1,6 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,6 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -40,7 +39,7 @@ import org.springframework.security.core.GrantedAuthority;
/** /**
* This class stands in for an original Authentication object. * This class stands in for an original Authentication object.
* *
* @author jricher * @author jricher
* *
*/ */

View File

@ -1,6 +1,7 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium *
* Portions copyright 2011-2013 The MITRE Corporation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +16,7 @@
* limitations under the License. * limitations under the License.
*******************************************************************************/ *******************************************************************************/
/** /**
* *
*/ */
package org.mitre.oauth2.model; package org.mitre.oauth2.model;
@ -28,7 +29,6 @@ import javax.persistence.Id;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery; import javax.persistence.NamedQuery;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Transient;
/** /**
* @author jricher * @author jricher

View File

@ -1,6 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,6 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,6 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,6 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,6 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,6 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2017 The MITRE Corporation * Copyright 2018 The MIT Internet Trust Consortium
* and the MIT Internet Trust Consortium
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

Some files were not shown because too many files have changed in this diff Show More