diff --git a/openid-connect-client/pom.xml b/openid-connect-client/pom.xml
index 649f00297a..0df0ec1e41 100644
--- a/openid-connect-client/pom.xml
+++ b/openid-connect-client/pom.xml
@@ -22,7 +22,7 @@
openid-connect-parent
org.mitre
- 1.3.7.cnaf-20250915
+ 1.4.0.cnaf-20251012
..
openid-connect-client
diff --git a/openid-connect-client/src/test/java/org/mitre/openid/connect/client/service/impl/TestHybridClientConfigurationService.java b/openid-connect-client/src/test/java/org/mitre/openid/connect/client/service/impl/TestHybridClientConfigurationService.java
index f7455981d9..542352b28d 100644
--- a/openid-connect-client/src/test/java/org/mitre/openid/connect/client/service/impl/TestHybridClientConfigurationService.java
+++ b/openid-connect-client/src/test/java/org/mitre/openid/connect/client/service/impl/TestHybridClientConfigurationService.java
@@ -17,22 +17,24 @@
*******************************************************************************/
package org.mitre.openid.connect.client.service.impl;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.lenient;
+import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.verify;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mitre.oauth2.model.RegisteredClient;
import org.mitre.openid.connect.config.ServerConfiguration;
import org.mockito.InjectMocks;
-import org.mockito.Matchers;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.runners.MockitoJUnitRunner;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.nullValue;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
+import org.mockito.junit.MockitoJUnitRunner;
/**
* @author wkim
@@ -41,77 +43,80 @@
@RunWith(MockitoJUnitRunner.class)
public class TestHybridClientConfigurationService {
- @Mock
- private StaticClientConfigurationService mockStaticService;
+ @Mock
+ private StaticClientConfigurationService mockStaticService;
- @Mock
- private DynamicRegistrationClientConfigurationService mockDynamicService;
+ @Mock
+ private DynamicRegistrationClientConfigurationService mockDynamicService;
- @InjectMocks
- private HybridClientConfigurationService hybridService;
+ @InjectMocks
+ private HybridClientConfigurationService hybridService;
- // test fixture
+ // test fixture
- @Mock
- private RegisteredClient mockClient;
+ @Mock
+ private RegisteredClient mockClient;
- @Mock
- private ServerConfiguration mockServerConfig;
+ @Mock
+ private ServerConfiguration mockServerConfig;
- private String issuer = "https://www.example.com/";
+ private String issuer = "https://www.example.com/";
- @Before
- public void prepare() {
+ @Before
+ public void prepare() {
- Mockito.reset(mockDynamicService, mockStaticService);
+ reset(mockDynamicService, mockStaticService);
- Mockito.when(mockServerConfig.getIssuer()).thenReturn(issuer);
+ lenient().when(mockServerConfig.getIssuer()).thenReturn(issuer);
- }
+ }
- @Test
- public void getClientConfiguration_useStatic() {
+ @Test
+ public void getClientConfiguration_useStatic() {
- Mockito.when(mockStaticService.getClientConfiguration(mockServerConfig)).thenReturn(mockClient);
+ lenient().when(mockStaticService.getClientConfiguration(mockServerConfig)).thenReturn(mockClient);
- RegisteredClient result = hybridService.getClientConfiguration(mockServerConfig);
+ RegisteredClient result = hybridService.getClientConfiguration(mockServerConfig);
- Mockito.verify(mockStaticService).getClientConfiguration(mockServerConfig);
- Mockito.verify(mockDynamicService, Mockito.never()).getClientConfiguration(Matchers.any(ServerConfiguration.class));
- assertEquals(mockClient, result);
- }
+ verify(mockStaticService).getClientConfiguration(mockServerConfig);
+ verify(mockDynamicService, Mockito.never())
+ .getClientConfiguration(any(ServerConfiguration.class));
+ assertEquals(mockClient, result);
+ }
- @Test
- public void getClientConfiguration_useDynamic() {
+ @Test
+ public void getClientConfiguration_useDynamic() {
- Mockito.when(mockStaticService.getClientConfiguration(mockServerConfig)).thenReturn(null);
- Mockito.when(mockDynamicService.getClientConfiguration(mockServerConfig)).thenReturn(mockClient);
+ lenient().when(mockStaticService.getClientConfiguration(mockServerConfig)).thenReturn(null);
+ lenient().when(mockDynamicService.getClientConfiguration(mockServerConfig))
+ .thenReturn(mockClient);
- RegisteredClient result = hybridService.getClientConfiguration(mockServerConfig);
+ RegisteredClient result = hybridService.getClientConfiguration(mockServerConfig);
- Mockito.verify(mockStaticService).getClientConfiguration(mockServerConfig);
- Mockito.verify(mockDynamicService).getClientConfiguration(mockServerConfig);
- assertEquals(mockClient, result);
- }
+ verify(mockStaticService).getClientConfiguration(mockServerConfig);
+ verify(mockDynamicService).getClientConfiguration(mockServerConfig);
+ assertEquals(mockClient, result);
+ }
- /**
- * Checks the behavior when the issuer is not known.
- */
- @Test
- public void getClientConfiguration_noIssuer() {
+ /**
+ * Checks the behavior when the issuer is not known.
+ */
+ @Test
+ public void getClientConfiguration_noIssuer() {
- // The mockServerConfig is known to both services
- Mockito.when(mockStaticService.getClientConfiguration(mockServerConfig)).thenReturn(mockClient);
- Mockito.when(mockDynamicService.getClientConfiguration(mockServerConfig)).thenReturn(mockClient);
+ // The mockServerConfig is known to both services
+ lenient().when(mockStaticService.getClientConfiguration(mockServerConfig)).thenReturn(mockClient);
+ lenient().when(mockDynamicService.getClientConfiguration(mockServerConfig))
+ .thenReturn(mockClient);
- // But oh noes! We're going to ask it to find us some other issuer
- ServerConfiguration badIssuer = Mockito.mock(ServerConfiguration.class);
- Mockito.when(badIssuer.getIssuer()).thenReturn("www.badexample.com");
+ // But oh noes! We're going to ask it to find us some other issuer
+ ServerConfiguration badIssuer = Mockito.mock(ServerConfiguration.class);
+ lenient().when(badIssuer.getIssuer()).thenReturn("www.badexample.com");
- RegisteredClient result = hybridService.getClientConfiguration(badIssuer);
+ RegisteredClient result = hybridService.getClientConfiguration(badIssuer);
- Mockito.verify(mockStaticService).getClientConfiguration(badIssuer);
- Mockito.verify(mockDynamicService).getClientConfiguration(badIssuer);
- assertThat(result, is(nullValue()));
- }
+ verify(mockStaticService).getClientConfiguration(badIssuer);
+ verify(mockDynamicService).getClientConfiguration(badIssuer);
+ assertThat(result, is(nullValue()));
+ }
}
diff --git a/openid-connect-client/src/test/java/org/mitre/openid/connect/client/service/impl/TestHybridServerConfigurationService.java b/openid-connect-client/src/test/java/org/mitre/openid/connect/client/service/impl/TestHybridServerConfigurationService.java
index c14e756f14..652f6e9334 100644
--- a/openid-connect-client/src/test/java/org/mitre/openid/connect/client/service/impl/TestHybridServerConfigurationService.java
+++ b/openid-connect-client/src/test/java/org/mitre/openid/connect/client/service/impl/TestHybridServerConfigurationService.java
@@ -18,21 +18,23 @@
package org.mitre.openid.connect.client.service.impl;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.lenient;
+import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.verify;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mitre.openid.connect.config.ServerConfiguration;
import org.mockito.InjectMocks;
-import org.mockito.Matchers;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.runners.MockitoJUnitRunner;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.nullValue;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
+import org.mockito.junit.MockitoJUnitRunner;
/**
* @author wkim
@@ -41,68 +43,68 @@
@RunWith(MockitoJUnitRunner.class)
public class TestHybridServerConfigurationService {
- @Mock
- private StaticServerConfigurationService mockStaticService;
+ @Mock
+ private StaticServerConfigurationService mockStaticService;
- @Mock
- private DynamicServerConfigurationService mockDynamicService;
+ @Mock
+ private DynamicServerConfigurationService mockDynamicService;
- @InjectMocks
- private HybridServerConfigurationService hybridService;
+ @InjectMocks
+ private HybridServerConfigurationService hybridService;
- @Mock
- private ServerConfiguration mockServerConfig;
+ @Mock
+ private ServerConfiguration mockServerConfig;
- private String issuer = "https://www.example.com/";
+ private String issuer = "https://www.example.com/";
- @Before
- public void prepare() {
+ @Before
+ public void prepare() {
- Mockito.reset(mockDynamicService, mockStaticService);
+ reset(mockDynamicService, mockStaticService);
- }
+ }
- @Test
- public void getServerConfiguration_useStatic() {
+ @Test
+ public void getServerConfiguration_useStatic() {
- Mockito.when(mockStaticService.getServerConfiguration(issuer)).thenReturn(mockServerConfig);
+ lenient().when(mockStaticService.getServerConfiguration(issuer)).thenReturn(mockServerConfig);
- ServerConfiguration result = hybridService.getServerConfiguration(issuer);
+ ServerConfiguration result = hybridService.getServerConfiguration(issuer);
- Mockito.verify(mockStaticService).getServerConfiguration(issuer);
- Mockito.verify(mockDynamicService, Mockito.never()).getServerConfiguration(Matchers.anyString());
- assertEquals(mockServerConfig, result);
- }
+ verify(mockStaticService).getServerConfiguration(issuer);
+ verify(mockDynamicService, Mockito.never()).getServerConfiguration(any(String.class));
+ assertEquals(mockServerConfig, result);
+ }
- @Test
- public void getServerConfiguration_useDynamic() {
+ @Test
+ public void getServerConfiguration_useDynamic() {
- Mockito.when(mockStaticService.getServerConfiguration(issuer)).thenReturn(null);
- Mockito.when(mockDynamicService.getServerConfiguration(issuer)).thenReturn(mockServerConfig);
+ lenient().when(mockStaticService.getServerConfiguration(issuer)).thenReturn(null);
+ lenient().when(mockDynamicService.getServerConfiguration(issuer)).thenReturn(mockServerConfig);
- ServerConfiguration result = hybridService.getServerConfiguration(issuer);
+ ServerConfiguration result = hybridService.getServerConfiguration(issuer);
- Mockito.verify(mockStaticService).getServerConfiguration(issuer);
- Mockito.verify(mockDynamicService).getServerConfiguration(issuer);
- assertEquals(mockServerConfig, result);
- }
+ verify(mockStaticService).getServerConfiguration(issuer);
+ verify(mockDynamicService).getServerConfiguration(issuer);
+ assertEquals(mockServerConfig, result);
+ }
- /**
- * Checks the behavior when the issuer is not known.
- */
- @Test
- public void getServerConfiguration_noIssuer() {
+ /**
+ * Checks the behavior when the issuer is not known.
+ */
+ @Test
+ public void getServerConfiguration_noIssuer() {
- Mockito.when(mockStaticService.getServerConfiguration(issuer)).thenReturn(mockServerConfig);
- Mockito.when(mockDynamicService.getServerConfiguration(issuer)).thenReturn(mockServerConfig);
+ lenient().when(mockStaticService.getServerConfiguration(issuer)).thenReturn(mockServerConfig);
+ lenient().when(mockDynamicService.getServerConfiguration(issuer)).thenReturn(mockServerConfig);
- String badIssuer = "www.badexample.com";
+ String badIssuer = "www.badexample.com";
- ServerConfiguration result = hybridService.getServerConfiguration(badIssuer);
+ ServerConfiguration result = hybridService.getServerConfiguration(badIssuer);
- Mockito.verify(mockStaticService).getServerConfiguration(badIssuer);
- Mockito.verify(mockDynamicService).getServerConfiguration(badIssuer);
- assertThat(result, is(nullValue()));
- }
+ verify(mockStaticService).getServerConfiguration(badIssuer);
+ verify(mockDynamicService).getServerConfiguration(badIssuer);
+ assertThat(result, is(nullValue()));
+ }
}
diff --git a/openid-connect-client/src/test/java/org/mitre/openid/connect/client/service/impl/TestStaticClientConfigurationService.java b/openid-connect-client/src/test/java/org/mitre/openid/connect/client/service/impl/TestStaticClientConfigurationService.java
index 4f251a4e3c..e530c12690 100644
--- a/openid-connect-client/src/test/java/org/mitre/openid/connect/client/service/impl/TestStaticClientConfigurationService.java
+++ b/openid-connect-client/src/test/java/org/mitre/openid/connect/client/service/impl/TestStaticClientConfigurationService.java
@@ -17,6 +17,12 @@
*******************************************************************************/
package org.mitre.openid.connect.client.service.impl;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+
import java.util.HashMap;
import java.util.Map;
@@ -27,14 +33,7 @@
import org.mitre.openid.connect.config.ServerConfiguration;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.runners.MockitoJUnitRunner;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.CoreMatchers.nullValue;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
+import org.mockito.junit.MockitoJUnitRunner;
/**
* @author wkim
diff --git a/openid-connect-client/src/test/java/org/mitre/openid/connect/client/service/impl/TestStaticServerConfigurationService.java b/openid-connect-client/src/test/java/org/mitre/openid/connect/client/service/impl/TestStaticServerConfigurationService.java
index 9f86bd3469..4d9c51197d 100644
--- a/openid-connect-client/src/test/java/org/mitre/openid/connect/client/service/impl/TestStaticServerConfigurationService.java
+++ b/openid-connect-client/src/test/java/org/mitre/openid/connect/client/service/impl/TestStaticServerConfigurationService.java
@@ -17,6 +17,12 @@
*******************************************************************************/
package org.mitre.openid.connect.client.service.impl;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+
import java.util.HashMap;
import java.util.Map;
@@ -25,14 +31,7 @@
import org.junit.runner.RunWith;
import org.mitre.openid.connect.config.ServerConfiguration;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.CoreMatchers.nullValue;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
+import org.mockito.junit.MockitoJUnitRunner;
/**
* @author wkim
diff --git a/openid-connect-common/pom.xml b/openid-connect-common/pom.xml
index 30cc0d65c6..8a7c657169 100644
--- a/openid-connect-common/pom.xml
+++ b/openid-connect-common/pom.xml
@@ -22,7 +22,7 @@
openid-connect-parent
org.mitre
- 1.3.7.cnaf-20250915
+ 1.4.0.cnaf-20251012
..
openid-connect-common
diff --git a/openid-connect-common/src/main/java/org/mitre/oauth2/model/ClientLastUsedEntity.java b/openid-connect-common/src/main/java/org/mitre/oauth2/model/ClientLastUsedEntity.java
index e632ac7ae2..5ed9b6042a 100644
--- a/openid-connect-common/src/main/java/org/mitre/oauth2/model/ClientLastUsedEntity.java
+++ b/openid-connect-common/src/main/java/org/mitre/oauth2/model/ClientLastUsedEntity.java
@@ -30,48 +30,48 @@
@Table(name = "client_last_used")
public class ClientLastUsedEntity {
- @Id
- @Column(name = "client_details_id")
- private Long id;
+ @Id
+ @Column(name = "client_details_id")
+ private Long id;
- @OneToOne(cascade = CascadeType.ALL)
- @MapsId
- @JoinColumn(name = "client_details_id")
- private ClientDetailsEntity client;
+ @OneToOne(cascade = CascadeType.ALL)
+ @MapsId
+ @JoinColumn(name = "client_details_id")
+ private ClientDetailsEntity client;
- @Column(name = "last_used", nullable = false)
- private LocalDate lastUsed;
+ @Column(name = "last_used", nullable = false)
+ private LocalDate lastUsed;
- public ClientLastUsedEntity() {
- // empty constructor
- }
+ public ClientLastUsedEntity() {
+ // empty constructor
+ }
- public ClientLastUsedEntity(ClientDetailsEntity client, LocalDate lastUsed) {
- this.client = client;
- this.lastUsed = lastUsed;
- }
+ public ClientLastUsedEntity(ClientDetailsEntity client, LocalDate lastUsed) {
+ this.client = client;
+ this.lastUsed = lastUsed;
+ }
- public Long getId() {
- return id;
- }
+ public Long getId() {
+ return id;
+ }
- public void setId(Long id) {
- this.id = id;
- }
+ public void setId(Long id) {
+ this.id = id;
+ }
- public ClientDetailsEntity getClient() {
- return client;
- }
+ public ClientDetailsEntity getClient() {
+ return client;
+ }
- public void setClient(ClientDetailsEntity client) {
- this.client = client;
- }
+ public void setClient(ClientDetailsEntity client) {
+ this.client = client;
+ }
- public LocalDate getLastUsed() {
- return lastUsed;
- }
+ public LocalDate getLastUsed() {
+ return lastUsed;
+ }
- public void setLastUsed(LocalDate lastUsed) {
- this.lastUsed = lastUsed;
- }
+ public void setLastUsed(LocalDate lastUsed) {
+ this.lastUsed = lastUsed;
+ }
}
diff --git a/openid-connect-common/src/main/java/org/mitre/oauth2/model/OAuth2AccessTokenEntity.java b/openid-connect-common/src/main/java/org/mitre/oauth2/model/OAuth2AccessTokenEntity.java
index 2695c18a2e..062ef6a950 100644
--- a/openid-connect-common/src/main/java/org/mitre/oauth2/model/OAuth2AccessTokenEntity.java
+++ b/openid-connect-common/src/main/java/org/mitre/oauth2/model/OAuth2AccessTokenEntity.java
@@ -62,296 +62,307 @@
* @author jricher
*
*/
+@SuppressWarnings("deprecation")
@Entity
@Table(name = "access_token")
@NamedQueries({
- @NamedQuery(name = OAuth2AccessTokenEntity.QUERY_ALL, query = "select a from OAuth2AccessTokenEntity a"),
- @NamedQuery(name = OAuth2AccessTokenEntity.QUERY_EXPIRED_BY_DATE, query = "select a from OAuth2AccessTokenEntity a where a.expiration <= :" + OAuth2AccessTokenEntity.PARAM_DATE),
- @NamedQuery(name = OAuth2AccessTokenEntity.QUERY_BY_REFRESH_TOKEN, query = "select a from OAuth2AccessTokenEntity a where a.refreshToken = :" + OAuth2AccessTokenEntity.PARAM_REFRESH_TOKEN),
- @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_HASH, query = "select a from OAuth2AccessTokenEntity a where a.tokenValueHash = :" + OAuth2AccessTokenEntity.PARAM_TOKEN_VALUE_HASH),
- @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_NAME, query = "select r from OAuth2AccessTokenEntity r where r.authenticationHolder.userAuth.name = :" + OAuth2AccessTokenEntity.PARAM_NAME),
- @NamedQuery(name = OAuth2AccessTokenEntity.DELETE_BY_REFRESH_TOKEN, query = "delete from OAuth2AccessTokenEntity a where a.refreshToken = :" + OAuth2AccessTokenEntity.PARAM_REFRESH_TOKEN)
-})
-@com.fasterxml.jackson.databind.annotation.JsonSerialize(using = OAuth2AccessTokenJackson2Serializer.class)
-@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = OAuth2AccessTokenJackson2Deserializer.class)
+ @NamedQuery(name = OAuth2AccessTokenEntity.QUERY_ALL,
+ query = "select a from OAuth2AccessTokenEntity a"),
+ @NamedQuery(name = OAuth2AccessTokenEntity.QUERY_EXPIRED_BY_DATE,
+ query = "select a from OAuth2AccessTokenEntity a where a.expiration <= :"
+ + OAuth2AccessTokenEntity.PARAM_DATE),
+ @NamedQuery(name = OAuth2AccessTokenEntity.QUERY_BY_REFRESH_TOKEN,
+ query = "select a from OAuth2AccessTokenEntity a where a.refreshToken = :"
+ + OAuth2AccessTokenEntity.PARAM_REFRESH_TOKEN),
+ @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_HASH,
+ query = "select a from OAuth2AccessTokenEntity a where a.tokenValueHash = :"
+ + OAuth2AccessTokenEntity.PARAM_TOKEN_VALUE_HASH),
+ @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_NAME,
+ query = "select r from OAuth2AccessTokenEntity r where r.authenticationHolder.userAuth.name = :"
+ + OAuth2AccessTokenEntity.PARAM_NAME),
+ @NamedQuery(name = OAuth2AccessTokenEntity.DELETE_BY_REFRESH_TOKEN,
+ query = "delete from OAuth2AccessTokenEntity a where a.refreshToken = :"
+ + OAuth2AccessTokenEntity.PARAM_REFRESH_TOKEN)})
+@com.fasterxml.jackson.databind.annotation.JsonSerialize(
+ using = OAuth2AccessTokenJackson2Serializer.class)
+@com.fasterxml.jackson.databind.annotation.JsonDeserialize(
+ using = OAuth2AccessTokenJackson2Deserializer.class)
public class OAuth2AccessTokenEntity implements OAuth2AccessToken {
- public static final String QUERY_BY_APPROVED_SITE = "OAuth2AccessTokenEntity.getByApprovedSite";
- public static final String QUERY_BY_TOKEN_VALUE_HASH = "OAuth2AccessTokenEntity.getByTokenValue";
- public static final String QUERY_BY_CLIENT = "OAuth2AccessTokenEntity.getByClient";
- public static final String QUERY_BY_REFRESH_TOKEN = "OAuth2AccessTokenEntity.getByRefreshToken";
- public static final String QUERY_EXPIRED_BY_DATE = "OAuth2AccessTokenEntity.getAllExpiredByDate";
- public static final String QUERY_ALL = "OAuth2AccessTokenEntity.getAll";
- public static final String QUERY_BY_RESOURCE_SET = "OAuth2AccessTokenEntity.getByResourceSet";
- public static final String QUERY_BY_NAME = "OAuth2AccessTokenEntity.getByName";
- public static final String DELETE_BY_REFRESH_TOKEN = "OAuth2AccessTokenEntity.deleteByRefreshToken";
-
- public static final String PARAM_TOKEN_VALUE_HASH = "tokenValueHash";
- public static final String PARAM_CLIENT = "client";
- public static final String PARAM_REFRESH_TOKEN = "refreshToken";
- public static final String PARAM_DATE = "date";
- public static final String PARAM_RESOURCE_SET_ID = "rsid";
- 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";
-
- private Long id;
-
- private ClientDetailsEntity client;
-
- private AuthenticationHolderEntity authenticationHolder; // the authentication that made this access
-
- private JWT jwtValue; // JWT-encoded access token value
-
- private String tokenValueHash; // hash of access token value
-
- private Date expiration;
-
- private String tokenType = OAuth2AccessToken.BEARER_TYPE;
-
- private OAuth2RefreshTokenEntity refreshToken;
-
- private Set scope;
-
- private Set permissions;
-
- private ApprovedSite approvedSite;
-
- private Map additionalInformation = new HashMap<>(); // ephemeral map of items to be added to the OAuth token response
-
- /**
- * Create a new, blank access token
- */
- public OAuth2AccessTokenEntity() {
-
- }
-
- /**
- * @return the id
- */
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- @Column(name = "id")
- public Long getId() {
- return id;
- }
-
- /**
- * @param id the id to set
- */
- public void setId(Long id) {
- this.id = id;
- }
-
- /**
- * Get all additional information to be sent to the serializer as part of the token response.
- * This map is not persisted to the database.
- */
- @Override
- @Transient
- public Map getAdditionalInformation() {
- return additionalInformation;
- }
-
- /**
- * The authentication in place when this token was created.
- * @return the authentication
- */
- @ManyToOne
- @JoinColumn(name = "auth_holder_id")
- public AuthenticationHolderEntity getAuthenticationHolder() {
- return authenticationHolder;
- }
-
- /**
- * @param authentication the authentication to set
- */
- public void setAuthenticationHolder(AuthenticationHolderEntity authenticationHolder) {
- this.authenticationHolder = authenticationHolder;
- }
-
- /**
- * @return the client
- */
- @ManyToOne
- @JoinColumn(name = "client_id")
- public ClientDetailsEntity getClient() {
- return client;
- }
-
- /**
- * @param client the client to set
- */
- public void setClient(ClientDetailsEntity client) {
- this.client = client;
- }
-
- /**
- * Get the string-encoded value of this access token.
- */
- @Override
- @Transient
- public String getValue() {
- return jwtValue.serialize();
- }
-
- @Override
- @Basic
- @Temporal(javax.persistence.TemporalType.TIMESTAMP)
- @Column(name = "expiration")
- public Date getExpiration() {
- return expiration;
- }
-
- public void setExpiration(Date expiration) {
- this.expiration = expiration;
- }
-
- @Override
- @Basic
- @Column(name="token_type")
- public String getTokenType() {
- return tokenType;
- }
-
- public void setTokenType(String tokenType) {
- this.tokenType = tokenType;
- }
-
- @Override
- @ManyToOne
- @JoinColumn(name="refresh_token_id")
- public OAuth2RefreshTokenEntity getRefreshToken() {
- return refreshToken;
- }
-
- public void setRefreshToken(OAuth2RefreshTokenEntity refreshToken) {
- this.refreshToken = refreshToken;
- }
-
- public void setRefreshToken(OAuth2RefreshToken refreshToken) {
- if (!(refreshToken instanceof OAuth2RefreshTokenEntity)) {
- throw new IllegalArgumentException("Not a storable refresh token entity!");
- }
- // force a pass through to the entity version
- setRefreshToken((OAuth2RefreshTokenEntity)refreshToken);
- }
-
- @Override
- @ElementCollection(fetch=FetchType.EAGER)
- @CollectionTable(
- joinColumns=@JoinColumn(name="owner_id"),
- name="token_scope"
- )
- public Set getScope() {
- return scope;
- }
-
- public void setScope(Set scope) {
- this.scope = scope;
- }
-
- @Override
- @Transient
- public boolean isExpired() {
- return getExpiration() == null ? false : System.currentTimeMillis() > getExpiration().getTime();
- }
-
- /**
- * @return the jwtValue
- */
- @Basic
- @Column(name="token_value")
- @Convert(converter = JWTStringConverter.class)
- public JWT getJwt() {
- return jwtValue;
- }
-
- /**
- * @param jwtValue the jwtValue to set
- */
- public void setJwt(JWT jwt) {
- this.jwtValue = jwt;
- }
-
- /**
- * @return the tokenValueHash
- */
- @Basic
- @Column(name = "token_value_hash", length = 64)
- public String getTokenValueHash() {
- return tokenValueHash;
- }
-
- public void setTokenValueHash(String hash) {
- this.tokenValueHash = hash;
- }
-
- @Override
- @Transient
- public int getExpiresIn() {
-
- if (getExpiration() == null) {
- return -1; // no expiration time
- } else {
- int secondsRemaining = (int) ((getExpiration().getTime() - System.currentTimeMillis()) / 1000);
- if (isExpired()) {
- return 0; // has an expiration time and expired
- } else { // has an expiration time and not expired
- return secondsRemaining;
- }
- }
- }
-
- /**
- * @return the permissions
- */
- @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
- @JoinTable(
- name = "access_token_permissions",
- joinColumns = @JoinColumn(name = "access_token_id"),
- inverseJoinColumns = @JoinColumn(name = "permission_id")
- )
- public Set getPermissions() {
- return permissions;
- }
-
- /**
- * @param permissions the permissions to set
- */
- public void setPermissions(Set permissions) {
- this.permissions = permissions;
- }
-
- @ManyToOne
- @JoinColumn(name="approved_site_id")
- public ApprovedSite getApprovedSite() {
- return approvedSite;
- }
-
- public void setApprovedSite(ApprovedSite approvedSite) {
- this.approvedSite = approvedSite;
- }
-
- /**
- * Add the ID Token to the additionalInformation map for a token response.
- * @param idToken
- */
- @Transient
- public void setIdToken(JWT idToken) {
- if (idToken != null) {
- additionalInformation.put(ID_TOKEN_FIELD_NAME, idToken.serialize());
- }
- }
+ public static final String QUERY_BY_APPROVED_SITE = "OAuth2AccessTokenEntity.getByApprovedSite";
+ public static final String QUERY_BY_TOKEN_VALUE_HASH = "OAuth2AccessTokenEntity.getByTokenValue";
+ public static final String QUERY_BY_CLIENT = "OAuth2AccessTokenEntity.getByClient";
+ public static final String QUERY_BY_REFRESH_TOKEN = "OAuth2AccessTokenEntity.getByRefreshToken";
+ public static final String QUERY_EXPIRED_BY_DATE = "OAuth2AccessTokenEntity.getAllExpiredByDate";
+ public static final String QUERY_ALL = "OAuth2AccessTokenEntity.getAll";
+ public static final String QUERY_BY_NAME = "OAuth2AccessTokenEntity.getByName";
+ public static final String DELETE_BY_REFRESH_TOKEN =
+ "OAuth2AccessTokenEntity.deleteByRefreshToken";
+
+ public static final String PARAM_TOKEN_VALUE_HASH = "tokenValueHash";
+ public static final String PARAM_CLIENT = "client";
+ public static final String PARAM_REFRESH_TOKEN = "refreshToken";
+ public static final String PARAM_DATE = "date";
+ public static final String PARAM_RESOURCE_SET_ID = "rsid";
+ 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";
+
+ private Long id;
+
+ private ClientDetailsEntity client;
+
+ private AuthenticationHolderEntity authenticationHolder;
+
+ private JWT jwtValue; // JWT-encoded access token value
+
+ private String tokenValueHash; // hash of access token value
+
+ private Date expiration;
+
+ private String tokenType = OAuth2AccessToken.BEARER_TYPE;
+
+ private OAuth2RefreshTokenEntity refreshToken;
+
+ private Set scope;
+
+ private ApprovedSite approvedSite;
+
+ private Map additionalInformation = new HashMap<>();
+
+ /**
+ * Create a new, blank access token
+ */
+ public OAuth2AccessTokenEntity() {
+
+ }
+
+ public OAuth2AccessTokenEntity(OAuth2AccessToken token, ClientDetailsEntity client) {
+ this.setExpiration(token.getExpiration());
+ this.setScope(token.getScope());
+ this.setTokenType(token.getTokenType());
+ this.setRefreshToken(token.getRefreshToken());
+ this.additionalInformation.clear();
+ this.additionalInformation.putAll(token.getAdditionalInformation());
+ this.tokenValueHash = sha256(token.getValue());
+ this.client = client;
+ }
+
+ /**
+ * @return the id
+ */
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "id")
+ public Long getId() {
+ return id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ /**
+ * Get all additional information to be sent to the serializer as part of the token response. This
+ * map is not persisted to the database.
+ */
+ @Override
+ @Transient
+ public Map getAdditionalInformation() {
+ return additionalInformation;
+ }
+
+ /**
+ * The authentication in place when this token was created.
+ *
+ * @return the authentication
+ */
+ @ManyToOne(cascade = CascadeType.PERSIST)
+ @JoinColumn(name = "auth_holder_id")
+ public AuthenticationHolderEntity getAuthenticationHolder() {
+ return authenticationHolder;
+ }
+
+ /**
+ * @param authentication the authentication to set
+ */
+ public void setAuthenticationHolder(AuthenticationHolderEntity authenticationHolder) {
+ this.authenticationHolder = authenticationHolder;
+ }
+
+ /**
+ * @return the client
+ */
+ @ManyToOne
+ @JoinColumn(name = "client_id")
+ public ClientDetailsEntity getClient() {
+ return client;
+ }
+
+ /**
+ * @param client the client to set
+ */
+ public void setClient(ClientDetailsEntity client) {
+ this.client = client;
+ }
+
+ /**
+ * Get the string-encoded value of this access token.
+ */
+ @Override
+ @Transient
+ public String getValue() {
+ return jwtValue.serialize();
+ }
+
+ @Override
+ @Basic
+ @Temporal(javax.persistence.TemporalType.TIMESTAMP)
+ @Column(name = "expiration")
+ public Date getExpiration() {
+ return expiration;
+ }
+
+ public void setExpiration(Date expiration) {
+ this.expiration = expiration;
+ }
+
+ @Override
+ @Basic
+ @Column(name = "token_type")
+ public String getTokenType() {
+ return tokenType;
+ }
+
+ public void setTokenType(String tokenType) {
+ this.tokenType = tokenType;
+ }
+
+ @Override
+ @ManyToOne
+ @JoinColumn(name = "refresh_token_id")
+ public OAuth2RefreshTokenEntity getRefreshToken() {
+ return refreshToken;
+ }
+
+ public void setRefreshToken(OAuth2RefreshTokenEntity refreshToken) {
+ this.refreshToken = refreshToken;
+ }
+
+ public void setRefreshToken(OAuth2RefreshToken refreshToken) {
+ if (refreshToken == null) {
+ return;
+ }
+ if (!(refreshToken instanceof OAuth2RefreshTokenEntity)) {
+ throw new IllegalArgumentException("Not a storable refresh token entity!");
+ }
+ // force a pass through to the entity version
+ setRefreshToken((OAuth2RefreshTokenEntity) refreshToken);
+ }
+
+ @Override
+ @ElementCollection(fetch = FetchType.EAGER)
+ @CollectionTable(joinColumns = @JoinColumn(name = "owner_id"), name = "token_scope")
+ public Set getScope() {
+ return scope;
+ }
+
+ public void setScope(Set scope) {
+ this.scope = scope;
+ }
+
+ @Override
+ @Transient
+ public boolean isExpired() {
+ return getExpiration() == null ? false : System.currentTimeMillis() > getExpiration().getTime();
+ }
+
+ /**
+ * @return the jwtValue
+ */
+ @Basic
+ @Column(name = "token_value")
+ @Convert(converter = JWTStringConverter.class)
+ public JWT getJwt() {
+ return jwtValue;
+ }
+
+ /**
+ * @param jwtValue the jwtValue to set
+ */
+ public void setJwt(JWT jwt) {
+ this.jwtValue = jwt;
+ }
+
+ /**
+ * @return the tokenValueHash
+ */
+ @Basic
+ @Column(name = "token_value_hash", length = 64)
+ public String getTokenValueHash() {
+ return tokenValueHash;
+ }
+
+ public void setTokenValueHash(String hash) {
+ this.tokenValueHash = hash;
+ }
+
+ @Override
+ @Transient
+ public int getExpiresIn() {
+
+ if (getExpiration() == null) {
+ return -1; // no expiration time
+ } else {
+ int secondsRemaining =
+ (int) ((getExpiration().getTime() - System.currentTimeMillis()) / 1000);
+ if (isExpired()) {
+ return 0; // has an expiration time and expired
+ } else { // has an expiration time and not expired
+ return secondsRemaining;
+ }
+ }
+ }
+
+ @ManyToOne
+ @JoinColumn(name = "approved_site_id")
+ public ApprovedSite getApprovedSite() {
+ return approvedSite;
+ }
+
+ public void setApprovedSite(ApprovedSite approvedSite) {
+ this.approvedSite = approvedSite;
+ }
+
+ /**
+ * Add the ID Token to the additionalInformation map for a token response.
+ *
+ * @param idToken
+ */
+ @Transient
+ public void setIdToken(JWT idToken) {
+ if (idToken != null) {
+ additionalInformation.put(ID_TOKEN_FIELD_NAME, idToken.serialize());
+ }
+ }
public void hashMe() {
if (jwtValue != null) {
- this.tokenValueHash =
- Hashing.sha256().hashString(jwtValue.serialize(), StandardCharsets.UTF_8).toString();
+ this.tokenValueHash = sha256(jwtValue.serialize());
}
}
+
+ public static String sha256(String tokenString) {
+ return Hashing.sha256().hashString(tokenString, StandardCharsets.UTF_8).toString();
+ }
}
diff --git a/openid-connect-common/src/main/java/org/mitre/oauth2/repository/AuthenticationHolderRepository.java b/openid-connect-common/src/main/java/org/mitre/oauth2/repository/AuthenticationHolderRepository.java
index 1b217de3e2..87481b0ae7 100644
--- a/openid-connect-common/src/main/java/org/mitre/oauth2/repository/AuthenticationHolderRepository.java
+++ b/openid-connect-common/src/main/java/org/mitre/oauth2/repository/AuthenticationHolderRepository.java
@@ -23,15 +23,17 @@
import org.mitre.oauth2.model.AuthenticationHolderEntity;
public interface AuthenticationHolderRepository {
- public List getAll();
- public AuthenticationHolderEntity getById(Long id);
+ public List getAll();
- public void remove(AuthenticationHolderEntity a);
+ public AuthenticationHolderEntity getById(Long id);
- public AuthenticationHolderEntity save(AuthenticationHolderEntity a);
+ public void remove(AuthenticationHolderEntity a);
- public List getOrphanedAuthenticationHolders();
+ public AuthenticationHolderEntity save(AuthenticationHolderEntity a);
- public List getOrphanedAuthenticationHolders(PageCriteria pageCriteria);
+ public List getOrphanedAuthenticationHolders();
+
+ public List getOrphanedAuthenticationHolders(
+ PageCriteria pageCriteria);
}
diff --git a/openid-connect-common/src/main/java/org/mitre/oauth2/service/OAuth2TokenEntityService.java b/openid-connect-common/src/main/java/org/mitre/oauth2/service/OAuth2TokenEntityService.java
index cf0e5169f0..0cc8d43157 100644
--- a/openid-connect-common/src/main/java/org/mitre/oauth2/service/OAuth2TokenEntityService.java
+++ b/openid-connect-common/src/main/java/org/mitre/oauth2/service/OAuth2TokenEntityService.java
@@ -28,41 +28,45 @@
import org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices;
import org.springframework.security.oauth2.provider.token.ResourceServerTokenServices;
+import com.nimbusds.jwt.SignedJWT;
+
@SuppressWarnings("deprecation")
-public interface OAuth2TokenEntityService extends AuthorizationServerTokenServices, ResourceServerTokenServices {
+public interface OAuth2TokenEntityService
+ extends AuthorizationServerTokenServices, ResourceServerTokenServices {
- @Override
- public OAuth2AccessTokenEntity readAccessToken(String accessTokenValue);
+ @Override
+ public OAuth2AccessTokenEntity readAccessToken(String accessTokenValue);
- public OAuth2RefreshTokenEntity getRefreshToken(String refreshTokenValue);
+ @Override
+ public OAuth2AccessTokenEntity getAccessToken(OAuth2Authentication authentication);
- public void revokeRefreshToken(OAuth2RefreshTokenEntity refreshToken);
+ public OAuth2RefreshTokenEntity getRefreshToken(String refreshTokenValue);
- public void revokeAccessToken(OAuth2AccessTokenEntity accessToken);
+ public void revokeRefreshToken(OAuth2RefreshTokenEntity refreshToken);
- public List getAccessTokensForClient(ClientDetailsEntity client);
+ public void revokeAccessToken(OAuth2AccessTokenEntity accessToken);
- public List getRefreshTokensForClient(ClientDetailsEntity client);
+ public List getAccessTokensForClient(ClientDetailsEntity client);
- public void clearExpiredTokens();
+ public List getRefreshTokensForClient(ClientDetailsEntity client);
- public OAuth2AccessTokenEntity saveAccessToken(OAuth2AccessTokenEntity accessToken);
+ public void clearExpiredTokens();
- public OAuth2RefreshTokenEntity saveRefreshToken(OAuth2RefreshTokenEntity refreshToken);
+ public OAuth2AccessTokenEntity saveAccessToken(OAuth2AccessTokenEntity accessToken);
- @Override
- public OAuth2AccessTokenEntity getAccessToken(OAuth2Authentication authentication);
+ public OAuth2RefreshTokenEntity saveRefreshToken(OAuth2RefreshTokenEntity refreshToken);
- public OAuth2AccessTokenEntity getAccessTokenById(Long id);
+ public OAuth2AccessTokenEntity getAccessTokenById(Long id);
- public OAuth2RefreshTokenEntity getRefreshTokenById(Long id);
+ public OAuth2RefreshTokenEntity getRefreshTokenById(Long id);
- public Set getAllAccessTokensForUser(String name);
+ public Set getAllAccessTokensForUser(String name);
- public Set getAllRefreshTokensForUser(String name);
+ public Set getAllRefreshTokensForUser(String name);
- public OAuth2AccessTokenEntity getRegistrationAccessTokenForClient(ClientDetailsEntity client);
+ public OAuth2AccessTokenEntity getRegistrationAccessTokenForClient(ClientDetailsEntity client);
- public OAuth2RefreshTokenEntity createRefreshToken(ClientDetailsEntity client, AuthenticationHolderEntity authHolder);
+ public OAuth2RefreshTokenEntity createRefreshToken(ClientDetailsEntity client,
+ AuthenticationHolderEntity authHolder);
}
diff --git a/openid-connect-server/pom.xml b/openid-connect-server/pom.xml
index f02bfacaa3..2bdf0f637e 100644
--- a/openid-connect-server/pom.xml
+++ b/openid-connect-server/pom.xml
@@ -23,7 +23,7 @@
org.mitre
openid-connect-parent
- 1.3.7.cnaf-20250915
+ 1.4.0.cnaf-20251012
..
@@ -74,7 +74,7 @@
- org.apache.commons
+ commons-io
commons-io
diff --git a/openid-connect-server/src/main/java/org/mitre/oauth2/repository/impl/JpaOAuth2TokenRepository.java b/openid-connect-server/src/main/java/org/mitre/oauth2/repository/impl/JpaOAuth2TokenRepository.java
index becb26710c..61abc0249b 100644
--- a/openid-connect-server/src/main/java/org/mitre/oauth2/repository/impl/JpaOAuth2TokenRepository.java
+++ b/openid-connect-server/src/main/java/org/mitre/oauth2/repository/impl/JpaOAuth2TokenRepository.java
@@ -267,14 +267,8 @@ public Set getAllExpiredRefreshTokens(
}
@Override
- public Set getAccessTokensForResourceSet(
- ResourceSet rs) {
- TypedQuery query = manager.createNamedQuery(
- OAuth2AccessTokenEntity.QUERY_BY_RESOURCE_SET,
- OAuth2AccessTokenEntity.class);
- query.setParameter(OAuth2AccessTokenEntity.PARAM_RESOURCE_SET_ID,
- rs.getId());
- return new LinkedHashSet<>(query.getResultList());
+ public Set getAccessTokensForResourceSet(ResourceSet rs) {
+ return Set.of();
}
@Override
diff --git a/openid-connect-server/src/main/java/org/mitre/oauth2/service/impl/DefaultIntrospectionResultAssembler.java b/openid-connect-server/src/main/java/org/mitre/oauth2/service/impl/DefaultIntrospectionResultAssembler.java
index ea36949fb6..20477b29ec 100644
--- a/openid-connect-server/src/main/java/org/mitre/oauth2/service/impl/DefaultIntrospectionResultAssembler.java
+++ b/openid-connect-server/src/main/java/org/mitre/oauth2/service/impl/DefaultIntrospectionResultAssembler.java
@@ -25,7 +25,6 @@
import org.mitre.oauth2.model.OAuth2RefreshTokenEntity;
import org.mitre.oauth2.service.IntrospectionResultAssembler;
import org.mitre.openid.connect.model.UserInfo;
-import org.mitre.uma.model.Permission;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
@@ -53,26 +52,9 @@ public Map assembleFrom(OAuth2AccessTokenEntity accessToken, Use
result.put(ACTIVE, true);
- if (accessToken.getPermissions() != null && !accessToken.getPermissions().isEmpty()) {
+ Set scopes = Sets.intersection(authScopes, accessToken.getScope());
- Set