automated code formatting and cleanup

pull/544/merge
Justin Richer 2013-12-03 14:19:34 -05:00
parent e1e7f7a579
commit ebbc7209aa
184 changed files with 1633 additions and 1641 deletions

View File

@ -16,6 +16,8 @@
******************************************************************************/
package org.mitre.oauth2.introspectingfilter;
import static org.mitre.oauth2.model.ClientDetailsEntity.AuthMethod.SECRET_BASIC;
import java.io.IOException;
import java.net.URI;
import java.util.Date;
@ -29,7 +31,6 @@ import org.mitre.oauth2.introspectingfilter.service.IntrospectionAuthorityGrante
import org.mitre.oauth2.introspectingfilter.service.IntrospectionConfigurationService;
import org.mitre.oauth2.introspectingfilter.service.impl.SimpleIntrospectionAuthorityGranter;
import org.mitre.oauth2.model.RegisteredClient;
import org.mitre.openid.connect.client.service.ClientConfigurationService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpMethod;
@ -53,8 +54,6 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.nimbusds.jose.util.Base64;
import static org.mitre.oauth2.model.ClientDetailsEntity.AuthMethod.SECRET_BASIC;
/**
* This ResourceServerTokenServices implementation introspects incoming tokens at a
* server's introspection endpoint URL and passes an Authentication object along

View File

@ -32,7 +32,6 @@ import org.springframework.security.oauth2.common.OAuth2RefreshToken;
import com.google.common.base.Splitter;
import com.google.common.collect.Sets;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;

View File

@ -16,6 +16,8 @@
******************************************************************************/
package org.mitre.openid.connect.client;
import static org.mitre.oauth2.model.ClientDetailsEntity.AuthMethod.SECRET_BASIC;
import java.io.IOException;
import java.math.BigInteger;
import java.net.URI;
@ -63,8 +65,6 @@ import com.nimbusds.jose.util.Base64;
import com.nimbusds.jwt.ReadOnlyJWTClaimsSet;
import com.nimbusds.jwt.SignedJWT;
import static org.mitre.oauth2.model.ClientDetailsEntity.AuthMethod.*;
/**
* OpenID Connect Authentication Filter class
*

View File

@ -19,6 +19,13 @@
*/
package org.mitre.openid.connect.client.service.impl;
import static org.mitre.discovery.util.JsonUtils.getAsBoolean;
import static org.mitre.discovery.util.JsonUtils.getAsEncryptionMethodList;
import static org.mitre.discovery.util.JsonUtils.getAsJweAlgorithmList;
import static org.mitre.discovery.util.JsonUtils.getAsJwsAlgorithmList;
import static org.mitre.discovery.util.JsonUtils.getAsString;
import static org.mitre.discovery.util.JsonUtils.getAsStringList;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ExecutionException;
@ -40,8 +47,6 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import static org.mitre.discovery.util.JsonUtils.*;
/**
*
* Dynamically fetches OpenID Connect server configurations based on the issuer. Caches the server configurations.

View File

@ -16,6 +16,11 @@
******************************************************************************/
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 org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -27,11 +32,6 @@ 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;
/**
* @author wkim
*

View File

@ -17,6 +17,11 @@
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 org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -27,11 +32,6 @@ 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;
/**
* @author wkim
*

View File

@ -16,7 +16,9 @@
******************************************************************************/
package org.mitre.openid.connect.client.service.impl;
import java.util.Collections;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import java.util.Map;
import org.junit.Before;
@ -29,9 +31,6 @@ import org.springframework.security.authentication.AuthenticationServiceExceptio
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
/**
* @author wkim
*

View File

@ -16,6 +16,10 @@
******************************************************************************/
package org.mitre.openid.connect.client.service.impl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.net.URI;
import java.net.URISyntaxException;
import java.security.NoSuchAlgorithmException;
@ -46,10 +50,6 @@ import com.nimbusds.jose.util.Base64URL;
import com.nimbusds.jwt.ReadOnlyJWTClaimsSet;
import com.nimbusds.jwt.SignedJWT;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
* @author wkim
*

View File

@ -16,6 +16,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;
@ -28,12 +34,6 @@ 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;
/**
* @author wkim
*

View File

@ -16,6 +16,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;
@ -26,12 +32,6 @@ 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;
/**
* @author wkim
*

View File

@ -16,6 +16,10 @@
******************************************************************************/
package org.mitre.openid.connect.client.service.impl;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
import javax.servlet.http.HttpServletRequest;
import org.junit.Before;
@ -26,10 +30,6 @@ import org.springframework.security.authentication.AuthenticationServiceExceptio
import com.google.common.collect.Sets;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
/**
* @author wkim
*

View File

@ -20,6 +20,14 @@
package org.mitre.openid.connect;
import static org.mitre.discovery.util.JsonUtils.getAsArray;
import static org.mitre.discovery.util.JsonUtils.getAsDate;
import static org.mitre.discovery.util.JsonUtils.getAsJweAlgorithm;
import static org.mitre.discovery.util.JsonUtils.getAsJweEncryptionMethod;
import static org.mitre.discovery.util.JsonUtils.getAsJwsAlgorithm;
import static org.mitre.discovery.util.JsonUtils.getAsString;
import static org.mitre.discovery.util.JsonUtils.getAsStringSet;
import org.mitre.oauth2.model.ClientDetailsEntity;
import org.mitre.oauth2.model.ClientDetailsEntity.AppType;
import org.mitre.oauth2.model.ClientDetailsEntity.AuthMethod;
@ -33,8 +41,6 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import static org.mitre.discovery.util.JsonUtils.*;
/**
* @author jricher
*

View File

@ -16,13 +16,13 @@
******************************************************************************/
package org.mitre.discovery.util;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.springframework.web.util.UriComponents;
import com.google.common.collect.ImmutableMap;
import static org.junit.Assert.assertEquals;
/**
* @author wkim
*

View File

@ -19,14 +19,14 @@
*/
package org.mitre.jose;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.nimbusds.jose.EncryptionMethod;
import com.nimbusds.jose.JWEAlgorithm;
import com.nimbusds.jose.JWSAlgorithm;
import static org.junit.Assert.assertEquals;
/**
*
* These tests make sure that the algorithm name processing

View File

@ -84,11 +84,11 @@ public class TestDefaultJwtEncryptionAndDecryptionService {
Use.ENCRYPTION, JWEAlgorithm.RSA_OAEP, RSAkid, null, null, null);
// AES key wrap not yet tested
// private String AESkid = "aes123";
// private JWK AESjwk = new OctetSequenceKey(new Base64URL("GawgguFyGrWKav7AX4VKUg"), Use.ENCRYPTION, JWEAlgorithm.A128KW, AESkid);
//
// private Map<String, JWK> keys = new ImmutableMap.Builder<String, JWK>().
// put(RSAkid, RSAjwk).put(AESkid, AESjwk).build();
// private String AESkid = "aes123";
// private JWK AESjwk = new OctetSequenceKey(new Base64URL("GawgguFyGrWKav7AX4VKUg"), Use.ENCRYPTION, JWEAlgorithm.A128KW, AESkid);
//
// private Map<String, JWK> keys = new ImmutableMap.Builder<String, JWK>().
// put(RSAkid, RSAjwk).put(AESkid, AESjwk).build();
private Map<String, JWK> keys = new ImmutableMap.Builder<String, JWK>().
put(RSAkid, RSAjwk).build();

View File

@ -19,18 +19,16 @@
*/
package org.mitre.oauth2.model;
import static org.junit.Assert.assertEquals;
import java.util.Date;
import org.junit.Test;
import org.mitre.jose.JWEAlgorithmEmbed;
import org.mitre.jose.JWEEncryptionMethodEmbed;
import com.google.common.collect.ImmutableSet;
import com.nimbusds.jose.EncryptionMethod;
import com.nimbusds.jose.JWEAlgorithm;
import static org.junit.Assert.assertEquals;
/**
* @author jricher
*

View File

@ -19,18 +19,16 @@
*/
package org.mitre.oauth2.model;
import static org.junit.Assert.assertEquals;
import java.sql.Date;
import org.junit.Test;
import org.mitre.jose.JWEAlgorithmEmbed;
import org.mitre.jose.JWEEncryptionMethodEmbed;
import com.google.common.collect.ImmutableSet;
import com.nimbusds.jose.EncryptionMethod;
import com.nimbusds.jose.JWEAlgorithm;
import static org.junit.Assert.assertEquals;
/**
* @author jricher
*

View File

@ -19,11 +19,12 @@
*/
package org.mitre.openid.connect;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.sql.Date;
import org.junit.Test;
import org.mitre.jose.JWEAlgorithmEmbed;
import org.mitre.jose.JWEEncryptionMethodEmbed;
import org.mitre.oauth2.model.ClientDetailsEntity;
import org.mitre.oauth2.model.RegisteredClient;
@ -33,9 +34,6 @@ import com.google.gson.JsonObject;
import com.nimbusds.jose.EncryptionMethod;
import com.nimbusds.jose.JWEAlgorithm;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* @author jricher
*

View File

@ -19,10 +19,10 @@
*/
package org.mitre.openid.connect.config;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
/**
* @author jricher
*

View File

@ -19,11 +19,11 @@
*/
package org.mitre.openid.connect.config;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
/**
* @author jricher
*

View File

@ -3,13 +3,11 @@
*/
package org.mitre.oauth2.token;
import java.util.Map;
import java.util.Set;
import org.mitre.oauth2.service.SystemScopeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.oauth2.common.exceptions.InvalidScopeException;
import org.springframework.security.oauth2.common.util.OAuth2Utils;
import org.springframework.security.oauth2.provider.AuthorizationRequest;
import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.security.oauth2.provider.OAuth2RequestValidator;

View File

@ -36,9 +36,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.oauth2.common.exceptions.InvalidClientException;
import org.springframework.security.oauth2.common.util.OAuth2Utils;
import org.springframework.security.oauth2.provider.AuthorizationRequest;
import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.security.oauth2.provider.DefaultOAuth2RequestFactory;
import org.springframework.security.oauth2.provider.OAuth2Request;
import org.springframework.stereotype.Component;
import com.google.common.base.Strings;

View File

@ -43,8 +43,6 @@ import org.springframework.security.oauth2.provider.OAuth2RequestFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.GenericFilterBean;
import com.google.common.base.Strings;
/**
* @author jricher
*

View File

@ -16,6 +16,8 @@
******************************************************************************/
package org.mitre.openid.connect.repository.impl;
import static org.mitre.util.jpa.JpaUtil.saveOrUpdate;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
@ -24,8 +26,6 @@ import org.mitre.openid.connect.repository.AddressRepository;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import static org.mitre.util.jpa.JpaUtil.saveOrUpdate;
/**
* JPA Address repository implementation
*

View File

@ -19,6 +19,8 @@
*/
package org.mitre.openid.connect.repository.impl;
import static org.mitre.util.jpa.JpaUtil.saveOrUpdate;
import java.util.Collection;
import javax.persistence.EntityManager;
@ -30,8 +32,6 @@ import org.mitre.openid.connect.repository.BlacklistedSiteRepository;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import static org.mitre.util.jpa.JpaUtil.saveOrUpdate;
/**
* @author jricher
*

View File

@ -3,6 +3,9 @@
*/
package org.mitre.openid.connect.repository.impl;
import static org.mitre.util.jpa.JpaUtil.getSingleResult;
import static org.mitre.util.jpa.JpaUtil.saveOrUpdate;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
@ -12,9 +15,6 @@ import org.mitre.openid.connect.repository.PairwiseIdentifierRepository;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import static org.mitre.util.jpa.JpaUtil.getSingleResult;
import static org.mitre.util.jpa.JpaUtil.saveOrUpdate;
/**
* @author jricher
*

View File

@ -16,6 +16,9 @@
******************************************************************************/
package org.mitre.openid.connect.repository.impl;
import static org.mitre.util.jpa.JpaUtil.getSingleResult;
import static org.mitre.util.jpa.JpaUtil.saveOrUpdate;
import java.util.Collection;
import javax.persistence.EntityManager;
@ -28,9 +31,6 @@ import org.mitre.openid.connect.repository.UserInfoRepository;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import static org.mitre.util.jpa.JpaUtil.getSingleResult;
import static org.mitre.util.jpa.JpaUtil.saveOrUpdate;
/**
* JPA UserInfo repository implementation
*

View File

@ -16,6 +16,8 @@
******************************************************************************/
package org.mitre.openid.connect.repository.impl;
import static org.mitre.util.jpa.JpaUtil.saveOrUpdate;
import java.util.Collection;
import javax.persistence.EntityManager;
@ -28,8 +30,6 @@ import org.mitre.util.jpa.JpaUtil;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import static org.mitre.util.jpa.JpaUtil.saveOrUpdate;
/**
* JPA WhitelistedSite repository implementation
*

View File

@ -36,7 +36,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.oauth2.common.util.OAuth2Utils;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.OAuth2Request;
import org.springframework.stereotype.Service;
@ -130,6 +129,7 @@ public class DefaultOIDCTokenService implements OIDCTokenService {
* @return
* @throws AuthenticationException
*/
@Override
public OAuth2AccessTokenEntity createRegistrationAccessToken(ClientDetailsEntity client) {
Map<String, String> authorizationParameters = Maps.newHashMap();

View File

@ -6,7 +6,6 @@ package org.mitre.openid.connect.service.impl;
import java.util.Set;
import java.util.UUID;
import org.apache.http.client.utils.URIBuilder;
import org.mitre.oauth2.model.ClientDetailsEntity;
import org.mitre.openid.connect.model.PairwiseIdentifier;
import org.mitre.openid.connect.model.UserInfo;

View File

@ -110,7 +110,7 @@ public class ConnectTokenEnhancer implements TokenEnhancer {
UserInfo userInfo = userInfoService.getByUsernameAndClientId(username, clientId);
OAuth2AccessTokenEntity idTokenEntity = connectTokenService.createIdToken(client,
originalAuthRequest, (java.util.Date) claims.getIssueTime(),
originalAuthRequest, claims.getIssueTime(),
userInfo.getSub(), signingAlg, token);
// attach the id token to the parent access token

View File

@ -20,8 +20,8 @@ import java.io.IOException;
import java.io.Writer;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

View File

@ -17,12 +17,9 @@
package org.mitre.openid.connect.web;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.client.utils.URLEncodedUtils;
import org.mitre.jwt.signer.service.JwtSigningAndValidationService;
import org.mitre.oauth2.model.ClientDetailsEntity;
import org.mitre.oauth2.model.ClientDetailsEntity.AuthMethod;
@ -42,7 +39,6 @@ import org.springframework.http.HttpStatus;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationDetails;
import org.springframework.security.web.util.UrlUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;

View File

@ -16,6 +16,11 @@
******************************************************************************/
package org.mitre.oauth2.service.impl;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import java.util.Set;
import org.junit.Before;
@ -38,11 +43,6 @@ import org.springframework.security.oauth2.common.exceptions.InvalidClientExcept
import com.google.common.collect.Sets;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
/**
* @author wkim
*

View File

@ -43,9 +43,7 @@ import org.mockito.InjectMocks;
import org.mockito.Matchers;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
import org.springframework.security.authentication.AuthenticationCredentialsNotFoundException;
import org.springframework.security.oauth2.common.exceptions.InvalidClientException;
import org.springframework.security.oauth2.common.exceptions.InvalidScopeException;

View File

@ -16,6 +16,11 @@
******************************************************************************/
package org.mitre.oauth2.service.impl;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
import java.util.Set;
import org.junit.Before;
@ -32,11 +37,6 @@ import org.mockito.stubbing.Answer;
import com.google.common.collect.Sets;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
/**
* @author wkim
*

View File

@ -16,6 +16,10 @@
******************************************************************************/
package org.mitre.openid.connect.service.impl;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import java.util.HashSet;
import java.util.Set;
@ -34,10 +38,6 @@ import org.springframework.test.annotation.Rollback;
import com.google.common.collect.Sets;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
@RunWith(MockitoJUnitRunner.class)
public class TestDefaultApprovedSiteService {

View File

@ -16,6 +16,10 @@
******************************************************************************/
package org.mitre.openid.connect.service.impl;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.times;
import java.util.Set;
import org.junit.Before;
@ -30,10 +34,6 @@ import org.mockito.runners.MockitoJUnitRunner;
import com.google.common.collect.Sets;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.times;
/**
* @author wkim
*

View File

@ -16,6 +16,9 @@
******************************************************************************/
package org.mitre.openid.connect.service.impl;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import java.util.HashSet;
import java.util.Map;
@ -33,9 +36,6 @@ import org.mockito.runners.MockitoJUnitRunner;
import com.google.common.collect.Sets;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
/**
* @author wkim
*

View File

@ -3,6 +3,9 @@
*/
package org.mitre.openid.connect.service.impl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -14,15 +17,13 @@ import org.mitre.openid.connect.model.UserInfo;
import org.mitre.openid.connect.repository.UserInfoRepository;
import org.mitre.openid.connect.service.PairwiseIdentiferService;
import org.mockito.InjectMocks;
import org.mockito.Matchers;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
/**
* @author jricher
*
@ -171,7 +172,7 @@ public class TestDefaultUserInfoService {
Mockito.when(userInfoRepository.getByUsername(regularUsername)).thenReturn(userInfoRegular);
Mockito.verify(pairwiseIdentiferService, Mockito.never()).getIdentifier(Mockito.any(UserInfo.class), Mockito.any(ClientDetailsEntity.class));
Mockito.verify(pairwiseIdentiferService, Mockito.never()).getIdentifier(Matchers.any(UserInfo.class), Matchers.any(ClientDetailsEntity.class));
UserInfo user1 = service.getByUsernameAndClientId(regularUsername, publicClientId1);
UserInfo user2 = service.getByUsernameAndClientId(regularUsername, publicClientId2);
@ -192,6 +193,7 @@ public class TestDefaultUserInfoService {
Mockito.when(clientDetailsEntityService.loadClientByClientId(pairwiseClientId4)).thenReturn(pairwiseClient4);
Mockito.when(userInfoRepository.getByUsername(regularUsername)).thenAnswer(new Answer<UserInfo>() {
@Override
public UserInfo answer(InvocationOnMock invocation) throws Throwable {
UserInfo userInfo = new DefaultUserInfo();
userInfo.setPreferredUsername(regularUsername);

View File

@ -16,6 +16,11 @@
******************************************************************************/
package org.mitre.openid.connect.service.impl;
import static org.hamcrest.core.IsNot.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.matchers.JUnitMatchers.hasItem;
import java.util.ArrayList;
import org.junit.Before;
@ -34,11 +39,6 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException;
import com.google.common.collect.Lists;
import static org.hamcrest.core.IsNot.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.matchers.JUnitMatchers.hasItem;
@RunWith(MockitoJUnitRunner.class)
public class TestDefaultUserInfoUserDetailsService {

View File

@ -16,6 +16,11 @@
******************************************************************************/
package org.mitre.openid.connect.service.impl;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -26,11 +31,6 @@ 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.junit.Assert.assertThat;
import static org.junit.Assert.fail;
/**
* @author wkim
*

View File

@ -3,6 +3,9 @@
*/
package org.mitre.openid.connect.service.impl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
import java.util.Set;
import java.util.UUID;
@ -16,15 +19,13 @@ import org.mitre.openid.connect.model.PairwiseIdentifier;
import org.mitre.openid.connect.model.UserInfo;
import org.mitre.openid.connect.repository.PairwiseIdentifierRepository;
import org.mockito.InjectMocks;
import org.mockito.Matchers;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import com.google.common.collect.ImmutableSet;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
/**
* @author jricher
*
@ -135,7 +136,7 @@ public class TestUUIDPairwiseIdentiferService {
public void testGetIdentifier_newEqual() {
String pairwise1 = service.getIdentifier(userInfoRegular, pairwiseClient1);
Mockito.verify(pairwiseIdentifierRepository, Mockito.atLeast(1)).save(Mockito.any(PairwiseIdentifier.class));
Mockito.verify(pairwiseIdentifierRepository, Mockito.atLeast(1)).save(Matchers.any(PairwiseIdentifier.class));
PairwiseIdentifier pairwiseId = new PairwiseIdentifier();
pairwiseId.setUserSub(regularSub);