registeredRedirectUris = client.getRegisteredRedirectUri();
+ if (registeredRedirectUris == null || registeredRedirectUris.isEmpty()) {
+ throw new InvalidRequestException("At least one redirect_uri must be registered with the client.");
+ }
+
+ String redirect = obtainMatchingRedirect(registeredRedirectUris, requestedRedirect);
+
+ if (blacklistService.isBlacklisted(redirect)) {
+ // don't let it go through
+ throw new InvalidRequestException("The supplied redirect_uri is not allowed on this server.");
+ } else {
+ // not blacklisted, passed the parent test, we're fine
+ return redirect;
+ }
+ }
+
+ /**
+ * Whether the requested redirect URI "matches" the specified redirect URI. For a URL, this implementation tests if
+ * the user requested redirect starts with the registered redirect, so it would have the same host and root path if
+ * it is an HTTP URL. The port, userinfo, query params also matched. Request redirect uri path can include
+ * additional parameters which are ignored for the match
+ *
+ * For other (non-URL) cases, such as for some implicit clients, the redirect_uri must be an exact match.
+ *
+ * @param requestedRedirect The requested redirect URI.
+ * @param redirectUri The registered redirect URI.
+ * @return Whether the requested redirect URI "matches" the specified redirect URI.
+ */
+ protected boolean redirectMatches(String requestedRedirect, String redirectUri) {
+ UriComponents requestedRedirectUri = UriComponentsBuilder.fromUriString(requestedRedirect).build();
+ UriComponents registeredRedirectUri = UriComponentsBuilder.fromUriString(redirectUri).build();
+
+ boolean schemeMatch = isEqual(registeredRedirectUri.getScheme(), requestedRedirectUri.getScheme());
+ boolean userInfoMatch = isEqual(registeredRedirectUri.getUserInfo(), requestedRedirectUri.getUserInfo());
+ boolean hostMatch = hostMatches(registeredRedirectUri.getHost(), requestedRedirectUri.getHost());
+ boolean portMatch = !matchPorts || registeredRedirectUri.getPort() == requestedRedirectUri.getPort();
+ boolean pathMatch = true;
+ boolean queryParamMatch = true;
+ if (strictMatch) {
+ pathMatch = isEqual(registeredRedirectUri.getPath(),
+ StringUtils.cleanPath(requestedRedirectUri.getPath()));
+ queryParamMatch = matchQueryParams(registeredRedirectUri.getQueryParams(),
+ requestedRedirectUri.getQueryParams());
+ }
+
+ return schemeMatch && userInfoMatch && hostMatch && portMatch && pathMatch && queryParamMatch;
+ }
+
+ /**
+ * @param grantTypes some grant types
+ * @return true if the supplied grant types includes one or more of the redirect types
+ */
+ private boolean containsRedirectGrantType(Set grantTypes) {
+ for (String type : grantTypes) {
+ if (redirectGrantTypes.contains(type)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Attempt to match one of the registered URIs to the that of the requested one.
+ *
+ * @param redirectUris the set of the registered URIs to try and find a match. This cannot be null or empty.
+ * @param requestedRedirect the URI used as part of the request
+ * @return redirect uri
+ * @throws RedirectMismatchException if no match was found
+ */
+ private String obtainMatchingRedirect(Set redirectUris, String requestedRedirect) {
+ Assert.notEmpty(redirectUris, "Redirect URIs cannot be empty");
+
+ if (redirectUris.size() == 1 && requestedRedirect == null) {
+ return redirectUris.iterator().next();
+ }
+
+ for (String redirectUri : redirectUris) {
+ if (requestedRedirect != null && redirectMatches(requestedRedirect, redirectUri)) {
+ // Initialize with the registered redirect-uri
+ UriComponentsBuilder redirectUriBuilder = UriComponentsBuilder.fromUriString(redirectUri);
+ UriComponents requestedRedirectUri = UriComponentsBuilder.fromUriString(requestedRedirect).build();
+
+ if (this.matchSubdomains) {
+ redirectUriBuilder.host(requestedRedirectUri.getHost());
+ }
+ if (!this.matchPorts) {
+ redirectUriBuilder.port(requestedRedirectUri.getPort());
+ }
+ if (!this.strictMatch) {
+ redirectUriBuilder.path(requestedRedirectUri.getPath());
+ }
+ redirectUriBuilder.replaceQuery(requestedRedirectUri.getQuery()); // retain additional params (if any)
+ redirectUriBuilder.fragment(null);
+ return redirectUriBuilder.build().toUriString();
+ }
+ }
+
+ throw new RedirectMismatchException("Invalid redirect: " + requestedRedirect
+ + " does not match one of the registered values.");
+ }
+
+ /**
+ * Compares two strings but treats empty string or null equal
+ *
+ * @param str1
+ * @param str2
+ * @return true if strings are equal, false otherwise
+ */
+ private boolean isEqual(String str1, String str2) {
+ if (StringUtils.isEmpty(str1)) {
+ return StringUtils.isEmpty(str2);
+ } else {
+ return str1.equals(str2);
+ }
+ }
+
+ /**
+ * Check if host matches the registered value.
+ *
+ * @param registered the registered host. Can be null.
+ * @param requested the requested host. Can be null.
+ * @return true if they match
+ */
+ protected boolean hostMatches(String registered, String requested) {
+ if (matchSubdomains) {
+ return isEqual(registered, requested) || (requested != null && requested.endsWith("." + registered));
+ }
+ return isEqual(registered, requested);
+ }
+
+ /**
+ * Checks whether the registered redirect uri query params key and values contains match the requested set
+ *
+ * The requested redirect uri query params are allowed to contain additional params which will be retained
+ *
+ * @param registeredRedirectUriQueryParams
+ * @param requestedRedirectUriQueryParams
+ * @return whether the params match
+ */
+ private boolean matchQueryParams(MultiValueMap registeredRedirectUriQueryParams,
+ MultiValueMap requestedRedirectUriQueryParams)
+ {
+ for (String key : registeredRedirectUriQueryParams.keySet()) {
+ List registeredRedirectUriQueryParamsValues = registeredRedirectUriQueryParams.get(key);
+ List requestedRedirectUriQueryParamsValues = requestedRedirectUriQueryParams.get(key);
+
+ if (!registeredRedirectUriQueryParamsValues.equals(requestedRedirectUriQueryParamsValues)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
}
diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/service/impl/DefaultOIDCTokenService.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/service/impl/DefaultOIDCTokenService.java
index 00863745a..2b6fb1ec7 100644
--- a/openid-connect-server/src/main/java/org/mitre/openid/connect/service/impl/DefaultOIDCTokenService.java
+++ b/openid-connect-server/src/main/java/org/mitre/openid/connect/service/impl/DefaultOIDCTokenService.java
@@ -188,7 +188,7 @@ public class DefaultOIDCTokenService implements OIDCTokenService {
null, null);
idToken = new SignedJWT(header, idClaims.build());
- JWTSigningAndValidationService signer = symmetricCacheService.getSymmetricValidtor(client);
+ JWTSigningAndValidationService signer = symmetricCacheService.getSymmetricValidator(client);
// sign it with the client's secret
signer.signJwt((SignedJWT) idToken);
diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/view/UserInfoJWTView.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/view/UserInfoJWTView.java
index e452b352b..1ce83dff0 100644
--- a/openid-connect-server/src/main/java/org/mitre/openid/connect/view/UserInfoJWTView.java
+++ b/openid-connect-server/src/main/java/org/mitre/openid/connect/view/UserInfoJWTView.java
@@ -142,7 +142,7 @@ public class UserInfoJWTView extends UserInfoView {
|| signingAlg.equals(JWSAlgorithm.HS512)) {
// sign it with the client's secret
- JWTSigningAndValidationService signer = symmetricCacheService.getSymmetricValidtor(client);
+ JWTSigningAndValidationService signer = symmetricCacheService.getSymmetricValidator(client);
signer.signJwt(signed);
} else {
diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/web/UserInfoInterceptor.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/web/UserInfoInterceptor.java
index eff165d06..e58a1cda2 100644
--- a/openid-connect-server/src/main/java/org/mitre/openid/connect/web/UserInfoInterceptor.java
+++ b/openid-connect-server/src/main/java/org/mitre/openid/connect/web/UserInfoInterceptor.java
@@ -20,11 +20,6 @@
*/
package org.mitre.openid.connect.web;
-import java.lang.reflect.Type;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
import org.mitre.openid.connect.model.UserInfo;
import org.mitre.openid.connect.service.UserInfoService;
@@ -38,11 +33,12 @@ import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
-import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
-import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
/**
* Injects the UserInfo object for the current user into the current model's context, if both exist. Allows JSPs and the like to call "userInfo.name" and other fields.
*
diff --git a/openid-connect-server/src/main/java/org/mitre/uma/model/Claim.java b/openid-connect-server/src/main/java/org/mitre/uma/model/Claim.java
index d6d30b64d..aaa88eb56 100644
--- a/openid-connect-server/src/main/java/org/mitre/uma/model/Claim.java
+++ b/openid-connect-server/src/main/java/org/mitre/uma/model/Claim.java
@@ -16,6 +16,9 @@
package org.mitre.uma.model;
+import com.google.gson.JsonElement;
+import org.mitre.oauth2.model.convert.JsonElementStringConverter;
+
import java.util.Set;
import javax.persistence.Basic;
@@ -31,10 +34,6 @@ import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Table;
-import org.mitre.oauth2.model.convert.JsonElementStringConverter;
-
-import com.google.gson.JsonElement;
-
/**
* @author jricher
*/
diff --git a/openid-connect-server/src/test/java/org/mitre/oauth2/service/impl/TestBlacklistAwareRedirectResolver.java b/openid-connect-server/src/test/java/org/mitre/oauth2/service/impl/TestBlacklistAwareRedirectResolver.java
index 3698ec9e0..ae0b525a7 100644
--- a/openid-connect-server/src/test/java/org/mitre/oauth2/service/impl/TestBlacklistAwareRedirectResolver.java
+++ b/openid-connect-server/src/test/java/org/mitre/oauth2/service/impl/TestBlacklistAwareRedirectResolver.java
@@ -74,8 +74,6 @@ public class TestBlacklistAwareRedirectResolver {
when(client.getAuthorizedGrantTypes()).thenReturn(ImmutableSet.of("authorization_code"));
when(client.getRegisteredRedirectUri()).thenReturn(ImmutableSet.of(goodUri, blacklistedUri));
-
- when(config.isHeartMode()).thenReturn(false);
}
@Test
@@ -141,8 +139,6 @@ public class TestBlacklistAwareRedirectResolver {
@Test
public void testHeartMode() {
- when(config.isHeartMode()).thenReturn(true);
-
// this is not an exact match
boolean res1 = resolver.redirectMatches(pathUri, goodUri);
diff --git a/openid-connect-server/src/test/java/org/mitre/oauth2/service/impl/TestDefaultOAuth2ClientDetailsEntityService.java b/openid-connect-server/src/test/java/org/mitre/oauth2/service/impl/TestDefaultOAuth2ClientDetailsEntityService.java
index 6ec31ca80..23f5993c8 100644
--- a/openid-connect-server/src/test/java/org/mitre/oauth2/service/impl/TestDefaultOAuth2ClientDetailsEntityService.java
+++ b/openid-connect-server/src/test/java/org/mitre/oauth2/service/impl/TestDefaultOAuth2ClientDetailsEntityService.java
@@ -17,15 +17,11 @@
*******************************************************************************/
package org.mitre.oauth2.service.impl;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
+import com.google.common.collect.Sets;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mitre.oauth2.model.ClientDetailsEntity;
-import org.mitre.oauth2.model.ClientDetailsEntity.AuthMethod;
import org.mitre.oauth2.model.SystemScope;
import org.mitre.oauth2.repository.OAuth2ClientRepository;
import org.mitre.oauth2.repository.OAuth2TokenRepository;
@@ -40,22 +36,23 @@ import org.mitre.uma.model.ResourceSet;
import org.mitre.uma.service.ResourceSetService;
import org.mockito.AdditionalAnswers;
import org.mockito.InjectMocks;
-import org.mockito.Matchers;
+import org.mockito.ArgumentMatchers;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
import org.springframework.security.oauth2.common.exceptions.InvalidClientException;
-import com.google.common.collect.Sets;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.Set;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.CoreMatchers.nullValue;
-
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.hamcrest.core.IsNull.nullValue;
import static org.junit.Assert.fail;
/**
@@ -99,7 +96,7 @@ public class TestDefaultOAuth2ClientDetailsEntityService {
public void prepare() {
Mockito.reset(clientRepository, tokenRepository, approvedSiteService, whitelistedSiteService, blacklistedSiteService, scopeService, statsService);
- Mockito.when(clientRepository.saveClient(Matchers.any(ClientDetailsEntity.class))).thenAnswer(new Answer() {
+ Mockito.when(clientRepository.saveClient(ArgumentMatchers.any(ClientDetailsEntity.class))).thenAnswer(new Answer() {
@Override
public ClientDetailsEntity answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
@@ -107,15 +104,10 @@ public class TestDefaultOAuth2ClientDetailsEntityService {
}
});
- Mockito.when(clientRepository.updateClient(Matchers.anyLong(), Matchers.any(ClientDetailsEntity.class))).thenAnswer(new Answer() {
- @Override
- public ClientDetailsEntity answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- return (ClientDetailsEntity) args[1];
- }
- });
+ Mockito.when(clientRepository.updateClient(ArgumentMatchers.nullable(Long.class), ArgumentMatchers.any(ClientDetailsEntity.class)))
+ .then(a -> a.getArgument(1));
- Mockito.when(scopeService.fromStrings(Matchers.anySet())).thenAnswer(new Answer>() {
+ Mockito.when(scopeService.fromStrings(ArgumentMatchers.anySet())).thenAnswer(new Answer>() {
@Override
public Set answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
@@ -128,7 +120,7 @@ public class TestDefaultOAuth2ClientDetailsEntityService {
}
});
- Mockito.when(scopeService.toStrings(Matchers.anySet())).thenAnswer(new Answer>() {
+ Mockito.when(scopeService.toStrings(ArgumentMatchers.anySet())).thenAnswer(new Answer>() {
@Override
public Set answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
@@ -142,7 +134,7 @@ public class TestDefaultOAuth2ClientDetailsEntityService {
});
// we're not testing reserved scopes here, just pass through when it's called
- Mockito.when(scopeService.removeReservedScopes(Matchers.anySet())).then(AdditionalAnswers.returnsFirstArg());
+ Mockito.when(scopeService.removeReservedScopes(ArgumentMatchers.anySet())).then(AdditionalAnswers.returnsFirstArg());
Mockito.when(config.isHeartMode()).thenReturn(false);
@@ -187,7 +179,7 @@ public class TestDefaultOAuth2ClientDetailsEntityService {
service.saveNewClient(client);
- Mockito.verify(client).setClientId(Matchers.anyString());
+ Mockito.verify(client).setClientId(ArgumentMatchers.anyString());
}
/**
@@ -217,7 +209,7 @@ public class TestDefaultOAuth2ClientDetailsEntityService {
client = service.saveNewClient(client);
- Mockito.verify(scopeService, Mockito.atLeastOnce()).removeReservedScopes(Matchers.anySet());
+ Mockito.verify(scopeService, Mockito.atLeastOnce()).removeReservedScopes(ArgumentMatchers.anySet());
assertThat(client.getScope().contains(SystemScopeService.OFFLINE_ACCESS), is(equalTo(false)));
}
@@ -343,7 +335,7 @@ public class TestDefaultOAuth2ClientDetailsEntityService {
client = service.updateClient(oldClient, client);
- Mockito.verify(scopeService, Mockito.atLeastOnce()).removeReservedScopes(Matchers.anySet());
+ Mockito.verify(scopeService, Mockito.atLeastOnce()).removeReservedScopes(ArgumentMatchers.anySet());
assertThat(client.getScope().contains(SystemScopeService.OFFLINE_ACCESS), is(equalTo(true)));
}
@@ -359,7 +351,7 @@ public class TestDefaultOAuth2ClientDetailsEntityService {
client = service.updateClient(oldClient, client);
- Mockito.verify(scopeService, Mockito.atLeastOnce()).removeReservedScopes(Matchers.anySet());
+ Mockito.verify(scopeService, Mockito.atLeastOnce()).removeReservedScopes(ArgumentMatchers.anySet());
assertThat(client.getScope().contains(SystemScopeService.OFFLINE_ACCESS), is(equalTo(false)));
}
@@ -375,7 +367,7 @@ public class TestDefaultOAuth2ClientDetailsEntityService {
grantTypes.add("client_credentials");
client.setGrantTypes(grantTypes);
- client.setTokenEndpointAuthMethod(AuthMethod.PRIVATE_KEY);
+ client.setTokenEndpointAuthMethod(ClientDetailsEntity.AuthMethod.PRIVATE_KEY);
client.setRedirectUris(Sets.newHashSet("https://foo.bar/"));
@@ -396,7 +388,7 @@ public class TestDefaultOAuth2ClientDetailsEntityService {
grantTypes.add("client_credentials");
client.setGrantTypes(grantTypes);
- client.setTokenEndpointAuthMethod(AuthMethod.NONE);
+ client.setTokenEndpointAuthMethod(ClientDetailsEntity.AuthMethod.NONE);
client.setRedirectUris(Sets.newHashSet("https://foo.bar/"));
@@ -417,7 +409,7 @@ public class TestDefaultOAuth2ClientDetailsEntityService {
grantTypes.add("implicit");
client.setGrantTypes(grantTypes);
- client.setTokenEndpointAuthMethod(AuthMethod.PRIVATE_KEY);
+ client.setTokenEndpointAuthMethod(ClientDetailsEntity.AuthMethod.PRIVATE_KEY);
client.setJwksUri("https://foo.bar/jwks");
@@ -434,7 +426,7 @@ public class TestDefaultOAuth2ClientDetailsEntityService {
grantTypes.add("authorization_code");
client.setGrantTypes(grantTypes);
- client.setTokenEndpointAuthMethod(AuthMethod.SECRET_POST);
+ client.setTokenEndpointAuthMethod(ClientDetailsEntity.AuthMethod.SECRET_POST);
client.setRedirectUris(Sets.newHashSet("https://foo.bar/"));
@@ -453,7 +445,7 @@ public class TestDefaultOAuth2ClientDetailsEntityService {
grantTypes.add("implicit");
client.setGrantTypes(grantTypes);
- client.setTokenEndpointAuthMethod(AuthMethod.PRIVATE_KEY);
+ client.setTokenEndpointAuthMethod(ClientDetailsEntity.AuthMethod.PRIVATE_KEY);
client.setRedirectUris(Sets.newHashSet("https://foo.bar/"));
@@ -472,7 +464,7 @@ public class TestDefaultOAuth2ClientDetailsEntityService {
grantTypes.add("client_credentials");
client.setGrantTypes(grantTypes);
- client.setTokenEndpointAuthMethod(AuthMethod.SECRET_BASIC);
+ client.setTokenEndpointAuthMethod(ClientDetailsEntity.AuthMethod.SECRET_BASIC);
client.setRedirectUris(Sets.newHashSet("https://foo.bar/"));
@@ -491,7 +483,7 @@ public class TestDefaultOAuth2ClientDetailsEntityService {
grantTypes.add("authorization_code");
client.setGrantTypes(grantTypes);
- client.setTokenEndpointAuthMethod(AuthMethod.PRIVATE_KEY);
+ client.setTokenEndpointAuthMethod(ClientDetailsEntity.AuthMethod.PRIVATE_KEY);
service.saveNewClient(client);
@@ -506,7 +498,7 @@ public class TestDefaultOAuth2ClientDetailsEntityService {
grantTypes.add("implicit");
client.setGrantTypes(grantTypes);
- client.setTokenEndpointAuthMethod(AuthMethod.NONE);
+ client.setTokenEndpointAuthMethod(ClientDetailsEntity.AuthMethod.NONE);
service.saveNewClient(client);
@@ -521,7 +513,7 @@ public class TestDefaultOAuth2ClientDetailsEntityService {
grantTypes.add("client_credentials");
client.setGrantTypes(grantTypes);
- client.setTokenEndpointAuthMethod(AuthMethod.PRIVATE_KEY);
+ client.setTokenEndpointAuthMethod(ClientDetailsEntity.AuthMethod.PRIVATE_KEY);
client.setRedirectUris(Sets.newHashSet("http://foo.bar/"));
@@ -538,7 +530,7 @@ public class TestDefaultOAuth2ClientDetailsEntityService {
grantTypes.add("authorization_code");
client.setGrantTypes(grantTypes);
- client.setTokenEndpointAuthMethod(AuthMethod.PRIVATE_KEY);
+ client.setTokenEndpointAuthMethod(ClientDetailsEntity.AuthMethod.PRIVATE_KEY);
client.setRedirectUris(Sets.newHashSet("http://foo.bar/"));
@@ -557,7 +549,7 @@ public class TestDefaultOAuth2ClientDetailsEntityService {
grantTypes.add("authorization_code");
client.setGrantTypes(grantTypes);
- client.setTokenEndpointAuthMethod(AuthMethod.PRIVATE_KEY);
+ client.setTokenEndpointAuthMethod(ClientDetailsEntity.AuthMethod.PRIVATE_KEY);
client.setRedirectUris(Sets.newHashSet("https://foo.bar/"));
@@ -578,7 +570,7 @@ public class TestDefaultOAuth2ClientDetailsEntityService {
grantTypes.add("refresh_token");
client.setGrantTypes(grantTypes);
- client.setTokenEndpointAuthMethod(AuthMethod.PRIVATE_KEY);
+ client.setTokenEndpointAuthMethod(ClientDetailsEntity.AuthMethod.PRIVATE_KEY);
client.setRedirectUris(Sets.newHashSet("https://foo.bar/"));
@@ -600,7 +592,7 @@ public class TestDefaultOAuth2ClientDetailsEntityService {
grantTypes.add("refresh_token");
client.setGrantTypes(grantTypes);
- client.setTokenEndpointAuthMethod(AuthMethod.PRIVATE_KEY);
+ client.setTokenEndpointAuthMethod(ClientDetailsEntity.AuthMethod.PRIVATE_KEY);
client.setRedirectUris(Sets.newHashSet("http://foo.bar/"));
@@ -620,7 +612,7 @@ public class TestDefaultOAuth2ClientDetailsEntityService {
grantTypes.add("refresh_token");
client.setGrantTypes(grantTypes);
- client.setTokenEndpointAuthMethod(AuthMethod.PRIVATE_KEY);
+ client.setTokenEndpointAuthMethod(ClientDetailsEntity.AuthMethod.PRIVATE_KEY);
client.setRedirectUris(Sets.newHashSet("http://localhost/", "https://foo.bar", "foo://bar"));
diff --git a/openid-connect-server/src/test/java/org/mitre/oauth2/service/impl/TestDefaultOAuth2ProviderTokenService.java b/openid-connect-server/src/test/java/org/mitre/oauth2/service/impl/TestDefaultOAuth2ProviderTokenService.java
index afdb9dd6b..a409d15af 100644
--- a/openid-connect-server/src/test/java/org/mitre/oauth2/service/impl/TestDefaultOAuth2ProviderTokenService.java
+++ b/openid-connect-server/src/test/java/org/mitre/oauth2/service/impl/TestDefaultOAuth2ProviderTokenService.java
@@ -191,8 +191,6 @@ public class TestDefaultOAuth2ProviderTokenService {
// we're not testing restricted or reserved scopes here, just pass through
when(scopeService.removeReservedScopes(anySet())).then(returnsFirstArg());
- when(scopeService.removeRestrictedAndReservedScopes(anySet())).then(returnsFirstArg());
-
when(tokenEnhancer.enhance(any(OAuth2AccessTokenEntity.class), any(OAuth2Authentication.class)))
.thenAnswer(new Answer(){
@Override
diff --git a/openid-connect-server/src/test/java/org/mitre/openid/connect/service/impl/TestDefaultApprovedSiteService.java b/openid-connect-server/src/test/java/org/mitre/openid/connect/service/impl/TestDefaultApprovedSiteService.java
index 8524145f0..149694449 100644
--- a/openid-connect-server/src/test/java/org/mitre/openid/connect/service/impl/TestDefaultApprovedSiteService.java
+++ b/openid-connect-server/src/test/java/org/mitre/openid/connect/service/impl/TestDefaultApprovedSiteService.java
@@ -123,7 +123,6 @@ public class TestDefaultApprovedSiteService {
String otherId = "a different id";
client.setClientId(otherId);
service.clearApprovedSitesForClient(client);
- Mockito.when(repository.getByClientId(otherId)).thenReturn(new HashSet());
Mockito.verify(repository, never()).remove(any(ApprovedSite.class));
}
diff --git a/openid-connect-server/src/test/java/org/mitre/openid/connect/service/impl/TestDefaultStatsService.java b/openid-connect-server/src/test/java/org/mitre/openid/connect/service/impl/TestDefaultStatsService.java
index b5c1ae6b3..db4a78a9c 100644
--- a/openid-connect-server/src/test/java/org/mitre/openid/connect/service/impl/TestDefaultStatsService.java
+++ b/openid-connect-server/src/test/java/org/mitre/openid/connect/service/impl/TestDefaultStatsService.java
@@ -63,11 +63,6 @@ public class TestDefaultStatsService {
private ApprovedSite ap5 = Mockito.mock(ApprovedSite.class);
private ApprovedSite ap6 = Mockito.mock(ApprovedSite.class);
- private ClientDetailsEntity client1 = Mockito.mock(ClientDetailsEntity.class);
- private ClientDetailsEntity client2 = Mockito.mock(ClientDetailsEntity.class);
- private ClientDetailsEntity client3 = Mockito.mock(ClientDetailsEntity.class);
- private ClientDetailsEntity client4 = Mockito.mock(ClientDetailsEntity.class);
-
@Mock
private ApprovedSiteService approvedSiteService;
@@ -102,12 +97,6 @@ public class TestDefaultStatsService {
Mockito.when(ap6.getClientId()).thenReturn(clientId4);
Mockito.when(approvedSiteService.getAll()).thenReturn(Sets.newHashSet(ap1, ap2, ap3, ap4));
-
- Mockito.when(client1.getId()).thenReturn(1L);
- Mockito.when(client2.getId()).thenReturn(2L);
- Mockito.when(client3.getId()).thenReturn(3L);
- Mockito.when(client4.getId()).thenReturn(4L);
-
Mockito.when(approvedSiteService.getByClientId(clientId1)).thenReturn(Sets.newHashSet(ap1, ap2));
Mockito.when(approvedSiteService.getByClientId(clientId2)).thenReturn(Sets.newHashSet(ap3));
Mockito.when(approvedSiteService.getByClientId(clientId3)).thenReturn(Sets.newHashSet(ap4));
diff --git a/openid-connect-server/src/test/java/org/mitre/openid/connect/service/impl/TestMITREidDataService_1_0.java b/openid-connect-server/src/test/java/org/mitre/openid/connect/service/impl/TestMITREidDataService_1_0.java
index 6d5e7ec7c..a17e775b9 100644
--- a/openid-connect-server/src/test/java/org/mitre/openid/connect/service/impl/TestMITREidDataService_1_0.java
+++ b/openid-connect-server/src/test/java/org/mitre/openid/connect/service/impl/TestMITREidDataService_1_0.java
@@ -61,7 +61,7 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
import org.springframework.format.annotation.DateTimeFormat.ISO;
import org.springframework.format.datetime.DateFormatter;
@@ -150,7 +150,6 @@ public class TestMITREidDataService_1_0 {
when(mockedClient1.getClientId()).thenReturn("mocked_client_1");
AuthenticationHolderEntity mockedAuthHolder1 = mock(AuthenticationHolderEntity.class);
- when(mockedAuthHolder1.getId()).thenReturn(1L);
OAuth2RefreshTokenEntity token1 = new OAuth2RefreshTokenEntity();
token1.setId(1L);
@@ -165,7 +164,6 @@ public class TestMITREidDataService_1_0 {
when(mockedClient2.getClientId()).thenReturn("mocked_client_2");
AuthenticationHolderEntity mockedAuthHolder2 = mock(AuthenticationHolderEntity.class);
- when(mockedAuthHolder2.getId()).thenReturn(2L);
OAuth2RefreshTokenEntity token2 = new OAuth2RefreshTokenEntity();
token2.setId(2L);
@@ -229,7 +227,6 @@ public class TestMITREidDataService_1_0 {
@Override
public AuthenticationHolderEntity answer(InvocationOnMock invocation) throws Throwable {
AuthenticationHolderEntity _auth = mock(AuthenticationHolderEntity.class);
- when(_auth.getId()).thenReturn(id);
id++;
return _auth;
}
@@ -267,7 +264,6 @@ public class TestMITREidDataService_1_0 {
when(mockedClient1.getClientId()).thenReturn("mocked_client_1");
AuthenticationHolderEntity mockedAuthHolder1 = mock(AuthenticationHolderEntity.class);
- when(mockedAuthHolder1.getId()).thenReturn(1L);
OAuth2AccessTokenEntity token1 = new OAuth2AccessTokenEntity();
token1.setId(1L);
@@ -285,10 +281,8 @@ public class TestMITREidDataService_1_0 {
when(mockedClient2.getClientId()).thenReturn("mocked_client_2");
AuthenticationHolderEntity mockedAuthHolder2 = mock(AuthenticationHolderEntity.class);
- when(mockedAuthHolder2.getId()).thenReturn(2L);
OAuth2RefreshTokenEntity mockRefreshToken2 = mock(OAuth2RefreshTokenEntity.class);
- when(mockRefreshToken2.getId()).thenReturn(1L);
OAuth2AccessTokenEntity token2 = new OAuth2AccessTokenEntity();
token2.setId(2L);
@@ -359,7 +353,6 @@ public class TestMITREidDataService_1_0 {
@Override
public AuthenticationHolderEntity answer(InvocationOnMock invocation) throws Throwable {
AuthenticationHolderEntity _auth = mock(AuthenticationHolderEntity.class);
- when(_auth.getId()).thenReturn(id);
id++;
return _auth;
}
@@ -554,13 +547,6 @@ public class TestMITREidDataService_1_0 {
return _site;
}
});
- when(wlSiteRepository.getById(anyLong())).thenAnswer(new Answer() {
- @Override
- public WhitelistedSite answer(InvocationOnMock invocation) throws Throwable {
- Long _id = (Long) invocation.getArguments()[0];
- return fakeDb.get(_id);
- }
- });
dataService.importData(reader);
verify(wlSiteRepository, times(3)).save(capturedWhitelistedSites.capture());
@@ -580,8 +566,6 @@ public class TestMITREidDataService_1_0 {
Date accessDate1 = formatter.parse("2014-09-10T23:49:44.090+0000", Locale.ENGLISH);
OAuth2AccessTokenEntity mockToken1 = mock(OAuth2AccessTokenEntity.class);
- when(mockToken1.getId()).thenReturn(1L);
-
ApprovedSite site1 = new ApprovedSite();
site1.setId(1L);
site1.setClientId("foo");
@@ -589,7 +573,6 @@ public class TestMITREidDataService_1_0 {
site1.setAccessDate(accessDate1);
site1.setUserId("user1");
site1.setAllowedScopes(ImmutableSet.of("openid", "phone"));
- when(mockToken1.getApprovedSite()).thenReturn(site1);
Date creationDate2 = formatter.parse("2014-09-11T18:49:44.090+0000", Locale.ENGLISH);
Date accessDate2 = formatter.parse("2014-09-11T20:49:44.090+0000", Locale.ENGLISH);
@@ -648,25 +631,13 @@ public class TestMITREidDataService_1_0 {
return fakeDb.get(_id);
}
});
- when(wlSiteRepository.getById(isNull(Long.class))).thenAnswer(new Answer() {
- Long id = 244L;
- @Override
- public WhitelistedSite answer(InvocationOnMock invocation) throws Throwable {
- WhitelistedSite _site = mock(WhitelistedSite.class);
- when(_site.getId()).thenReturn(id++);
- return _site;
- }
- });
when(tokenRepository.getAccessTokenById(isNull(Long.class))).thenAnswer(new Answer() {
Long id = 221L;
@Override
public OAuth2AccessTokenEntity answer(InvocationOnMock invocation) throws Throwable {
- OAuth2AccessTokenEntity _token = mock(OAuth2AccessTokenEntity.class);
- when(_token.getId()).thenReturn(id++);
- return _token;
+ return mock(OAuth2AccessTokenEntity.class);
}
});
- when(tokenRepository.getAccessTokensForApprovedSite(site1)).thenReturn(Lists.newArrayList(mockToken1));
dataService.importData(reader);
//2 for sites, 1 for updating access token ref on #1
@@ -835,7 +806,6 @@ public class TestMITREidDataService_1_0 {
Date expirationDate1 = formatter.parse(expiration1, Locale.ENGLISH);
ClientDetailsEntity mockedClient1 = mock(ClientDetailsEntity.class);
- when(mockedClient1.getClientId()).thenReturn("mocked_client_1");
OAuth2Request req1 = new OAuth2Request(new HashMap(), "client1", new ArrayList(),
true, new HashSet(), new HashSet(), "http://foo.com",
@@ -858,7 +828,6 @@ public class TestMITREidDataService_1_0 {
Date expirationDate2 = formatter.parse(expiration2, Locale.ENGLISH);
ClientDetailsEntity mockedClient2 = mock(ClientDetailsEntity.class);
- when(mockedClient2.getClientId()).thenReturn("mocked_client_2");
OAuth2Request req2 = new OAuth2Request(new HashMap(), "client2", new ArrayList(),
true, new HashSet(), new HashSet(), "http://bar.com",
@@ -929,7 +898,6 @@ public class TestMITREidDataService_1_0 {
public ClientDetailsEntity answer(InvocationOnMock invocation) throws Throwable {
String _clientId = (String) invocation.getArguments()[0];
ClientDetailsEntity _client = mock(ClientDetailsEntity.class);
- when(_client.getClientId()).thenReturn(_clientId);
return _client;
}
});
@@ -967,4 +935,4 @@ public class TestMITREidDataService_1_0 {
dataService.exportData(writer);
}
-}
\ No newline at end of file
+}
diff --git a/openid-connect-server/src/test/java/org/mitre/openid/connect/service/impl/TestMITREidDataService_1_1.java b/openid-connect-server/src/test/java/org/mitre/openid/connect/service/impl/TestMITREidDataService_1_1.java
index d7ab851fd..f98ea784f 100644
--- a/openid-connect-server/src/test/java/org/mitre/openid/connect/service/impl/TestMITREidDataService_1_1.java
+++ b/openid-connect-server/src/test/java/org/mitre/openid/connect/service/impl/TestMITREidDataService_1_1.java
@@ -152,7 +152,6 @@ public class TestMITREidDataService_1_1 {
when(mockedClient1.getClientId()).thenReturn("mocked_client_1");
AuthenticationHolderEntity mockedAuthHolder1 = mock(AuthenticationHolderEntity.class);
- when(mockedAuthHolder1.getId()).thenReturn(1L);
OAuth2RefreshTokenEntity token1 = new OAuth2RefreshTokenEntity();
token1.setId(1L);
@@ -168,7 +167,6 @@ public class TestMITREidDataService_1_1 {
when(mockedClient2.getClientId()).thenReturn("mocked_client_2");
AuthenticationHolderEntity mockedAuthHolder2 = mock(AuthenticationHolderEntity.class);
- when(mockedAuthHolder2.getId()).thenReturn(2L);
OAuth2RefreshTokenEntity token2 = new OAuth2RefreshTokenEntity();
token2.setId(2L);
@@ -232,7 +230,6 @@ public class TestMITREidDataService_1_1 {
@Override
public AuthenticationHolderEntity answer(InvocationOnMock invocation) throws Throwable {
AuthenticationHolderEntity _auth = mock(AuthenticationHolderEntity.class);
- when(_auth.getId()).thenReturn(id);
id++;
return _auth;
}
@@ -271,7 +268,6 @@ public class TestMITREidDataService_1_1 {
when(mockedClient1.getClientId()).thenReturn("mocked_client_1");
AuthenticationHolderEntity mockedAuthHolder1 = mock(AuthenticationHolderEntity.class);
- when(mockedAuthHolder1.getId()).thenReturn(1L);
OAuth2AccessTokenEntity token1 = new OAuth2AccessTokenEntity();
token1.setId(1L);
@@ -289,10 +285,8 @@ public class TestMITREidDataService_1_1 {
when(mockedClient2.getClientId()).thenReturn("mocked_client_2");
AuthenticationHolderEntity mockedAuthHolder2 = mock(AuthenticationHolderEntity.class);
- when(mockedAuthHolder2.getId()).thenReturn(2L);
OAuth2RefreshTokenEntity mockRefreshToken2 = mock(OAuth2RefreshTokenEntity.class);
- when(mockRefreshToken2.getId()).thenReturn(1L);
OAuth2AccessTokenEntity token2 = new OAuth2AccessTokenEntity();
token2.setId(2L);
@@ -363,7 +357,6 @@ public class TestMITREidDataService_1_1 {
@Override
public AuthenticationHolderEntity answer(InvocationOnMock invocation) throws Throwable {
AuthenticationHolderEntity _auth = mock(AuthenticationHolderEntity.class);
- when(_auth.getId()).thenReturn(id);
id++;
return _auth;
}
@@ -557,13 +550,6 @@ public class TestMITREidDataService_1_1 {
return _site;
}
});
- when(wlSiteRepository.getById(anyLong())).thenAnswer(new Answer() {
- @Override
- public WhitelistedSite answer(InvocationOnMock invocation) throws Throwable {
- Long _id = (Long) invocation.getArguments()[0];
- return fakeDb.get(_id);
- }
- });
dataService.importData(reader);
verify(wlSiteRepository, times(3)).save(capturedWhitelistedSites.capture());
@@ -583,7 +569,6 @@ public class TestMITREidDataService_1_1 {
Date accessDate1 = formatter.parse("2014-09-10T23:49:44.090+0000", Locale.ENGLISH);
OAuth2AccessTokenEntity mockToken1 = mock(OAuth2AccessTokenEntity.class);
- when(mockToken1.getId()).thenReturn(1L);
ApprovedSite site1 = new ApprovedSite();
site1.setId(1L);
@@ -592,7 +577,6 @@ public class TestMITREidDataService_1_1 {
site1.setAccessDate(accessDate1);
site1.setUserId("user1");
site1.setAllowedScopes(ImmutableSet.of("openid", "phone"));
- when(mockToken1.getApprovedSite()).thenReturn(site1);
Date creationDate2 = formatter.parse("2014-09-11T18:49:44.090+0000", Locale.ENGLISH);
Date accessDate2 = formatter.parse("2014-09-11T20:49:44.090+0000", Locale.ENGLISH);
@@ -651,21 +635,11 @@ public class TestMITREidDataService_1_1 {
return fakeDb.get(_id);
}
});
- when(wlSiteRepository.getById(isNull(Long.class))).thenAnswer(new Answer() {
- Long id = 432L;
- @Override
- public WhitelistedSite answer(InvocationOnMock invocation) throws Throwable {
- WhitelistedSite _site = mock(WhitelistedSite.class);
- when(_site.getId()).thenReturn(id++);
- return _site;
- }
- });
when(tokenRepository.getAccessTokenById(isNull(Long.class))).thenAnswer(new Answer() {
Long id = 245L;
@Override
public OAuth2AccessTokenEntity answer(InvocationOnMock invocation) throws Throwable {
OAuth2AccessTokenEntity _token = mock(OAuth2AccessTokenEntity.class);
- when(_token.getId()).thenReturn(id++);
return _token;
}
});
@@ -837,7 +811,6 @@ public class TestMITREidDataService_1_1 {
Date expirationDate1 = formatter.parse(expiration1, Locale.ENGLISH);
ClientDetailsEntity mockedClient1 = mock(ClientDetailsEntity.class);
- when(mockedClient1.getClientId()).thenReturn("mocked_client_1");
OAuth2Request req1 = new OAuth2Request(new HashMap(), "client1", new ArrayList(),
true, new HashSet(), new HashSet(), "http://foo.com",
@@ -860,7 +833,6 @@ public class TestMITREidDataService_1_1 {
Date expirationDate2 = formatter.parse(expiration2, Locale.ENGLISH);
ClientDetailsEntity mockedClient2 = mock(ClientDetailsEntity.class);
- when(mockedClient2.getClientId()).thenReturn("mocked_client_2");
OAuth2Request req2 = new OAuth2Request(new HashMap(), "client2", new ArrayList(),
true, new HashSet(), new HashSet(), "http://bar.com",
@@ -931,7 +903,6 @@ public class TestMITREidDataService_1_1 {
public ClientDetailsEntity answer(InvocationOnMock invocation) throws Throwable {
String _clientId = (String) invocation.getArguments()[0];
ClientDetailsEntity _client = mock(ClientDetailsEntity.class);
- when(_client.getClientId()).thenReturn(_clientId);
return _client;
}
});
diff --git a/openid-connect-server/src/test/java/org/mitre/openid/connect/service/impl/TestMITREidDataService_1_2.java b/openid-connect-server/src/test/java/org/mitre/openid/connect/service/impl/TestMITREidDataService_1_2.java
index 594900ae2..2f72a9ea2 100644
--- a/openid-connect-server/src/test/java/org/mitre/openid/connect/service/impl/TestMITREidDataService_1_2.java
+++ b/openid-connect-server/src/test/java/org/mitre/openid/connect/service/impl/TestMITREidDataService_1_2.java
@@ -154,7 +154,6 @@ public class TestMITREidDataService_1_2 {
when(mockedClient1.getClientId()).thenReturn("mocked_client_1");
AuthenticationHolderEntity mockedAuthHolder1 = mock(AuthenticationHolderEntity.class);
- when(mockedAuthHolder1.getId()).thenReturn(1L);
OAuth2RefreshTokenEntity token1 = new OAuth2RefreshTokenEntity();
token1.setId(1L);
@@ -170,7 +169,6 @@ public class TestMITREidDataService_1_2 {
when(mockedClient2.getClientId()).thenReturn("mocked_client_2");
AuthenticationHolderEntity mockedAuthHolder2 = mock(AuthenticationHolderEntity.class);
- when(mockedAuthHolder2.getId()).thenReturn(2L);
OAuth2RefreshTokenEntity token2 = new OAuth2RefreshTokenEntity();
token2.setId(2L);
@@ -234,7 +232,6 @@ public class TestMITREidDataService_1_2 {
@Override
public AuthenticationHolderEntity answer(InvocationOnMock invocation) throws Throwable {
AuthenticationHolderEntity _auth = mock(AuthenticationHolderEntity.class);
- when(_auth.getId()).thenReturn(id);
id++;
return _auth;
}
@@ -273,7 +270,6 @@ public class TestMITREidDataService_1_2 {
when(mockedClient1.getClientId()).thenReturn("mocked_client_1");
AuthenticationHolderEntity mockedAuthHolder1 = mock(AuthenticationHolderEntity.class);
- when(mockedAuthHolder1.getId()).thenReturn(1L);
OAuth2AccessTokenEntity token1 = new OAuth2AccessTokenEntity();
token1.setId(1L);
@@ -291,10 +287,8 @@ public class TestMITREidDataService_1_2 {
when(mockedClient2.getClientId()).thenReturn("mocked_client_2");
AuthenticationHolderEntity mockedAuthHolder2 = mock(AuthenticationHolderEntity.class);
- when(mockedAuthHolder2.getId()).thenReturn(2L);
OAuth2RefreshTokenEntity mockRefreshToken2 = mock(OAuth2RefreshTokenEntity.class);
- when(mockRefreshToken2.getId()).thenReturn(1L);
OAuth2AccessTokenEntity token2 = new OAuth2AccessTokenEntity();
token2.setId(2L);
@@ -365,7 +359,6 @@ public class TestMITREidDataService_1_2 {
@Override
public AuthenticationHolderEntity answer(InvocationOnMock invocation) throws Throwable {
AuthenticationHolderEntity _auth = mock(AuthenticationHolderEntity.class);
- when(_auth.getId()).thenReturn(id);
id++;
return _auth;
}
@@ -559,13 +552,6 @@ public class TestMITREidDataService_1_2 {
return _site;
}
});
- when(wlSiteRepository.getById(anyLong())).thenAnswer(new Answer() {
- @Override
- public WhitelistedSite answer(InvocationOnMock invocation) throws Throwable {
- Long _id = (Long) invocation.getArguments()[0];
- return fakeDb.get(_id);
- }
- });
dataService.importData(reader);
verify(wlSiteRepository, times(3)).save(capturedWhitelistedSites.capture());
@@ -585,7 +571,6 @@ public class TestMITREidDataService_1_2 {
Date accessDate1 = formatter.parse("2014-09-10T23:49:44.090+0000", Locale.ENGLISH);
OAuth2AccessTokenEntity mockToken1 = mock(OAuth2AccessTokenEntity.class);
- when(mockToken1.getId()).thenReturn(1L);
ApprovedSite site1 = new ApprovedSite();
site1.setId(1L);
@@ -594,7 +579,6 @@ public class TestMITREidDataService_1_2 {
site1.setAccessDate(accessDate1);
site1.setUserId("user1");
site1.setAllowedScopes(ImmutableSet.of("openid", "phone"));
- when(mockToken1.getApprovedSite()).thenReturn(site1);
Date creationDate2 = formatter.parse("2014-09-11T18:49:44.090+0000", Locale.ENGLISH);
Date accessDate2 = formatter.parse("2014-09-11T20:49:44.090+0000", Locale.ENGLISH);
@@ -653,21 +637,11 @@ public class TestMITREidDataService_1_2 {
return fakeDb.get(_id);
}
});
- when(wlSiteRepository.getById(isNull(Long.class))).thenAnswer(new Answer() {
- Long id = 432L;
- @Override
- public WhitelistedSite answer(InvocationOnMock invocation) throws Throwable {
- WhitelistedSite _site = mock(WhitelistedSite.class);
- when(_site.getId()).thenReturn(id++);
- return _site;
- }
- });
when(tokenRepository.getAccessTokenById(isNull(Long.class))).thenAnswer(new Answer() {
Long id = 245L;
@Override
public OAuth2AccessTokenEntity answer(InvocationOnMock invocation) throws Throwable {
OAuth2AccessTokenEntity _token = mock(OAuth2AccessTokenEntity.class);
- when(_token.getId()).thenReturn(id++);
return _token;
}
});
@@ -839,7 +813,6 @@ public class TestMITREidDataService_1_2 {
Date expirationDate1 = formatter.parse(expiration1, Locale.ENGLISH);
ClientDetailsEntity mockedClient1 = mock(ClientDetailsEntity.class);
- when(mockedClient1.getClientId()).thenReturn("mocked_client_1");
OAuth2Request req1 = new OAuth2Request(new HashMap(), "client1", new ArrayList(),
true, new HashSet(), new HashSet(), "http://foo.com",
@@ -862,7 +835,6 @@ public class TestMITREidDataService_1_2 {
Date expirationDate2 = formatter.parse(expiration2, Locale.ENGLISH);
ClientDetailsEntity mockedClient2 = mock(ClientDetailsEntity.class);
- when(mockedClient2.getClientId()).thenReturn("mocked_client_2");
OAuth2Request req2 = new OAuth2Request(new HashMap(), "client2", new ArrayList(),
true, new HashSet(), new HashSet(), "http://bar.com",
@@ -933,7 +905,6 @@ public class TestMITREidDataService_1_2 {
public ClientDetailsEntity answer(InvocationOnMock invocation) throws Throwable {
String _clientId = (String) invocation.getArguments()[0];
ClientDetailsEntity _client = mock(ClientDetailsEntity.class);
- when(_client.getClientId()).thenReturn(_clientId);
return _client;
}
});
diff --git a/openid-connect-server/src/test/java/org/mitre/openid/connect/service/impl/TestMITREidDataService_1_3.java b/openid-connect-server/src/test/java/org/mitre/openid/connect/service/impl/TestMITREidDataService_1_3.java
index 29a04d932..73c9bc466 100644
--- a/openid-connect-server/src/test/java/org/mitre/openid/connect/service/impl/TestMITREidDataService_1_3.java
+++ b/openid-connect-server/src/test/java/org/mitre/openid/connect/service/impl/TestMITREidDataService_1_3.java
@@ -280,8 +280,6 @@ public class TestMITREidDataService_1_3 {
when(mockedClient1.getClientId()).thenReturn("mocked_client_1");
AuthenticationHolderEntity mockedAuthHolder1 = mock(AuthenticationHolderEntity.class);
- when(mockedAuthHolder1.getId()).thenReturn(1L);
-
OAuth2RefreshTokenEntity token1 = new OAuth2RefreshTokenEntity();
token1.setId(1L);
token1.setClient(mockedClient1);
@@ -296,8 +294,6 @@ public class TestMITREidDataService_1_3 {
when(mockedClient2.getClientId()).thenReturn("mocked_client_2");
AuthenticationHolderEntity mockedAuthHolder2 = mock(AuthenticationHolderEntity.class);
- when(mockedAuthHolder2.getId()).thenReturn(2L);
-
OAuth2RefreshTokenEntity token2 = new OAuth2RefreshTokenEntity();
token2.setId(2L);
token2.setClient(mockedClient2);
@@ -360,7 +356,6 @@ public class TestMITREidDataService_1_3 {
@Override
public AuthenticationHolderEntity answer(InvocationOnMock invocation) throws Throwable {
AuthenticationHolderEntity _auth = mock(AuthenticationHolderEntity.class);
- when(_auth.getId()).thenReturn(id);
id++;
return _auth;
}
@@ -530,8 +525,6 @@ public class TestMITREidDataService_1_3 {
when(mockedClient1.getClientId()).thenReturn("mocked_client_1");
AuthenticationHolderEntity mockedAuthHolder1 = mock(AuthenticationHolderEntity.class);
- when(mockedAuthHolder1.getId()).thenReturn(1L);
-
OAuth2AccessTokenEntity token1 = new OAuth2AccessTokenEntity();
token1.setId(1L);
token1.setClient(mockedClient1);
@@ -548,11 +541,7 @@ public class TestMITREidDataService_1_3 {
when(mockedClient2.getClientId()).thenReturn("mocked_client_2");
AuthenticationHolderEntity mockedAuthHolder2 = mock(AuthenticationHolderEntity.class);
- when(mockedAuthHolder2.getId()).thenReturn(2L);
-
OAuth2RefreshTokenEntity mockRefreshToken2 = mock(OAuth2RefreshTokenEntity.class);
- when(mockRefreshToken2.getId()).thenReturn(1L);
-
OAuth2AccessTokenEntity token2 = new OAuth2AccessTokenEntity();
token2.setId(2L);
token2.setClient(mockedClient2);
@@ -622,7 +611,6 @@ public class TestMITREidDataService_1_3 {
@Override
public AuthenticationHolderEntity answer(InvocationOnMock invocation) throws Throwable {
AuthenticationHolderEntity _auth = mock(AuthenticationHolderEntity.class);
- when(_auth.getId()).thenReturn(id);
id++;
return _auth;
}
@@ -1109,13 +1097,6 @@ public class TestMITREidDataService_1_3 {
return _site;
}
});
- when(wlSiteRepository.getById(anyLong())).thenAnswer(new Answer() {
- @Override
- public WhitelistedSite answer(InvocationOnMock invocation) throws Throwable {
- Long _id = (Long) invocation.getArguments()[0];
- return fakeDb.get(_id);
- }
- });
dataService.importData(reader);
verify(wlSiteRepository, times(3)).save(capturedWhitelistedSites.capture());
@@ -1135,7 +1116,6 @@ public class TestMITREidDataService_1_3 {
Date accessDate1 = formatter.parse("2014-09-10T23:49:44.090+0000", Locale.ENGLISH);
OAuth2AccessTokenEntity mockToken1 = mock(OAuth2AccessTokenEntity.class);
- when(mockToken1.getId()).thenReturn(1L);
ApprovedSite site1 = new ApprovedSite();
site1.setId(1L);
@@ -1144,7 +1124,6 @@ public class TestMITREidDataService_1_3 {
site1.setAccessDate(accessDate1);
site1.setUserId("user1");
site1.setAllowedScopes(ImmutableSet.of("openid", "phone"));
- when(mockToken1.getApprovedSite()).thenReturn(site1);
Date creationDate2 = formatter.parse("2014-09-11T18:49:44.090+0000", Locale.ENGLISH);
Date accessDate2 = formatter.parse("2014-09-11T20:49:44.090+0000", Locale.ENGLISH);
@@ -1250,7 +1229,6 @@ public class TestMITREidDataService_1_3 {
Date accessDate1 = formatter.parse("2014-09-10T23:49:44.090+0000", Locale.ENGLISH);
OAuth2AccessTokenEntity mockToken1 = mock(OAuth2AccessTokenEntity.class);
- when(mockToken1.getId()).thenReturn(1L);
ApprovedSite site1 = new ApprovedSite();
site1.setId(1L);
@@ -1259,7 +1237,6 @@ public class TestMITREidDataService_1_3 {
site1.setAccessDate(accessDate1);
site1.setUserId("user1");
site1.setAllowedScopes(ImmutableSet.of("openid", "phone"));
- when(mockToken1.getApprovedSite()).thenReturn(site1);
Date creationDate2 = formatter.parse("2014-09-11T18:49:44.090+0000", Locale.ENGLISH);
Date accessDate2 = formatter.parse("2014-09-11T20:49:44.090+0000", Locale.ENGLISH);
@@ -1318,21 +1295,11 @@ public class TestMITREidDataService_1_3 {
return fakeDb.get(_id);
}
});
- when(wlSiteRepository.getById(isNull(Long.class))).thenAnswer(new Answer() {
- Long id = 432L;
- @Override
- public WhitelistedSite answer(InvocationOnMock invocation) throws Throwable {
- WhitelistedSite _site = mock(WhitelistedSite.class);
- when(_site.getId()).thenReturn(id++);
- return _site;
- }
- });
when(tokenRepository.getAccessTokenById(isNull(Long.class))).thenAnswer(new Answer() {
Long id = 245L;
@Override
public OAuth2AccessTokenEntity answer(InvocationOnMock invocation) throws Throwable {
OAuth2AccessTokenEntity _token = mock(OAuth2AccessTokenEntity.class);
- when(_token.getId()).thenReturn(id++);
return _token;
}
});
@@ -1721,7 +1688,6 @@ public class TestMITREidDataService_1_3 {
Date expirationDate1 = formatter.parse(expiration1, Locale.ENGLISH);
ClientDetailsEntity mockedClient1 = mock(ClientDetailsEntity.class);
- when(mockedClient1.getClientId()).thenReturn("mocked_client_1");
OAuth2Request req1 = new OAuth2Request(new HashMap(), "client1", new ArrayList(),
true, new HashSet(), new HashSet(), "http://foo.com",
@@ -1744,7 +1710,6 @@ public class TestMITREidDataService_1_3 {
Date expirationDate2 = formatter.parse(expiration2, Locale.ENGLISH);
ClientDetailsEntity mockedClient2 = mock(ClientDetailsEntity.class);
- when(mockedClient2.getClientId()).thenReturn("mocked_client_2");
OAuth2Request req2 = new OAuth2Request(new HashMap(), "client2", new ArrayList(),
true, new HashSet(), new HashSet(), "http://bar.com",
@@ -1815,7 +1780,6 @@ public class TestMITREidDataService_1_3 {
public ClientDetailsEntity answer(InvocationOnMock invocation) throws Throwable {
String _clientId = (String) invocation.getArguments()[0];
ClientDetailsEntity _client = mock(ClientDetailsEntity.class);
- when(_client.getClientId()).thenReturn(_clientId);
return _client;
}
});
diff --git a/pom.xml b/pom.xml
index 74337f5a1..630d1a214 100644
--- a/pom.xml
+++ b/pom.xml
@@ -358,23 +358,24 @@
2.4.1.RELEASE
2.11.0
1.2
- 4.0.1
+ 2.5
2.2
8.0.20
2.4.0
2.7.7
2.2.1
- 2.12.0
+ 3.4.5
+ 1.2.3
1.7.30
2.13.3
- 5.6.2
+ 4.13
4.2
- 1.10.19
+ 3.2.4
29.0-jre
2.8.6
4.5.12
8.17.1
- 1.65.01
+ 1.65
2.7
1.9.0
@@ -402,6 +403,12 @@
spring-security-oauth2
${spring-security-oauth2.version}