Use diamond syntax instead of explicit types

pull/844/head
Mark Janssen 2015-06-01 02:26:12 +02:00 committed by Justin Richer
parent 13f5e4f8a6
commit 9e74e40453
45 changed files with 165 additions and 168 deletions

View File

@ -83,7 +83,7 @@ public class IntrospectingTokenService implements ResourceServerTokenServices {
}
}
private Map<String, TokenCacheObject> authCache = new HashMap<String, TokenCacheObject>();
private Map<String, TokenCacheObject> authCache = new HashMap<>();
/**
* Logger for this class
*/
@ -135,11 +135,11 @@ public class IntrospectingTokenService implements ResourceServerTokenServices {
private OAuth2Request createStoredRequest(final JsonObject token) {
String clientId = token.get("client_id").getAsString();
Set<String> scopes = new HashSet<String>();
Set<String> scopes = new HashSet<>();
if (token.has("scope")) {
scopes.addAll(OAuth2Utils.parseParameterList(token.get("scope").getAsString()));
}
Map<String, String> parameters = new HashMap<String, String>();
Map<String, String> parameters = new HashMap<>();
parameters.put("client_id", clientId);
parameters.put("scope", OAuth2Utils.formatParameterList(scopes));
OAuth2Request storedRequest = new OAuth2Request(parameters, clientId, null, true, scopes, null, null, null, null);
@ -175,7 +175,7 @@ public class IntrospectingTokenService implements ResourceServerTokenServices {
String validatedToken = null;
RestTemplate restTemplate;
MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>();
MultiValueMap<String, String> form = new LinkedMultiValueMap<>();
final String clientId = client.getClientId();
final String clientSecret = client.getClientSecret();

View File

@ -34,7 +34,7 @@ public class OAuth2AccessTokenImpl implements OAuth2AccessToken {
private JsonObject introspectionResponse;
private String tokenString;
private Set<String> scopes = new HashSet<String>();
private Set<String> scopes = new HashSet<>();
private Date expireDate;

View File

@ -49,12 +49,12 @@ public class NamedAdminAuthoritiesMapper implements OIDCAuthoritiesMapper {
private static final SimpleGrantedAuthority ROLE_ADMIN = new SimpleGrantedAuthority("ROLE_ADMIN");
private static final SimpleGrantedAuthority ROLE_USER = new SimpleGrantedAuthority("ROLE_USER");
private Set<SubjectIssuerGrantedAuthority> admins = new HashSet<SubjectIssuerGrantedAuthority>();
private Set<SubjectIssuerGrantedAuthority> admins = new HashSet<>();
@Override
public Collection<? extends GrantedAuthority> mapAuthorities(JWT idToken, UserInfo userInfo) {
Set<GrantedAuthority> out = new HashSet<GrantedAuthority>();
Set<GrantedAuthority> out = new HashSet<>();
try {
ReadOnlyJWTClaimsSet claims = idToken.getJWTClaimsSet();

View File

@ -299,7 +299,7 @@ public class OIDCAuthenticationFilter extends AbstractAuthenticationProcessingFi
ServerConfiguration serverConfig = servers.getServerConfiguration(issuer);
final RegisteredClient clientConfig = clients.getClientConfiguration(serverConfig);
MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>();
MultiValueMap<String, String> form = new LinkedMultiValueMap<>();
form.add("grant_type", "authorization_code");
form.add("code", authorizationCode);
form.setAll(authOptions.getTokenOptions(serverConfig, clientConfig, request));

View File

@ -91,7 +91,7 @@ public class UserInfoFetcher {
userInfoString = restTemplate.getForObject(serverConfiguration.getUserInfoUri(), String.class);
} else if (serverConfiguration.getUserInfoTokenMethod().equals(UserInfoTokenMethod.FORM)) {
MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>();
MultiValueMap<String, String> form = new LinkedMultiValueMap<>();
form.add("access_token", token.getAccessTokenValue());
RestTemplate restTemplate = new RestTemplate(factory);

View File

@ -66,8 +66,8 @@ public class DynamicRegistrationClientConfigurationService implements ClientConf
private RegisteredClient template;
private Set<String> whitelist = new HashSet<String>();
private Set<String> blacklist = new HashSet<String>();
private Set<String> whitelist = new HashSet<>();
private Set<String> blacklist = new HashSet<>();
public DynamicRegistrationClientConfigurationService() {
clients = CacheBuilder.newBuilder().build(new DynamicClientRegistrationLoader());
@ -192,7 +192,7 @@ public class DynamicRegistrationClientConfigurationService implements ClientConf
headers.setContentType(MediaType.APPLICATION_JSON);
headers.setAccept(Lists.newArrayList(MediaType.APPLICATION_JSON));
HttpEntity<String> entity = new HttpEntity<String>(serializedClient, headers);
HttpEntity<String> entity = new HttpEntity<>(serializedClient, headers);
String registered = restTemplate.postForObject(serverConfig.getRegistrationEndpointUri(), entity, String.class);
// TODO: handle HTTP errors
@ -212,7 +212,7 @@ public class DynamicRegistrationClientConfigurationService implements ClientConf
headers.set("Authorization", String.format("%s %s", OAuth2AccessToken.BEARER_TYPE, knownClient.getRegistrationAccessToken()));
headers.setAccept(Lists.newArrayList(MediaType.APPLICATION_JSON));
HttpEntity<String> entity = new HttpEntity<String>(headers);
HttpEntity<String> entity = new HttpEntity<>(headers);
String registered = restTemplate.exchange(knownClient.getRegistrationClientUri(), HttpMethod.GET, entity, String.class).getBody();
// TODO: handle HTTP errors

View File

@ -65,8 +65,8 @@ public class DynamicServerConfigurationService implements ServerConfigurationSer
// map of issuer -> server configuration, loaded dynamically from service discovery
private LoadingCache<String, ServerConfiguration> servers;
private Set<String> whitelist = new HashSet<String>();
private Set<String> blacklist = new HashSet<String>();
private Set<String> whitelist = new HashSet<>();
private Set<String> blacklist = new HashSet<>();
public DynamicServerConfigurationService() {
// initialize the cache

View File

@ -31,7 +31,7 @@ import org.mitre.openid.connect.client.service.RegisteredClientService;
*/
public class InMemoryRegisteredClientService implements RegisteredClientService {
private Map<String, RegisteredClient> clients = new HashMap<String, RegisteredClient>();
private Map<String, RegisteredClient> clients = new HashMap<>();
/* (non-Javadoc)
* @see org.mitre.openid.connect.client.service.RegisteredClientService#getByIssuer(java.lang.String)

View File

@ -73,7 +73,7 @@ public class JsonFileRegisteredClientService implements RegisteredClientService
private File file;
private Map<String, RegisteredClient> clients = new HashMap<String, RegisteredClient>();
private Map<String, RegisteredClient> clients = new HashMap<>();
public JsonFileRegisteredClientService(String filename) {
this.file = new File(filename);

View File

@ -44,8 +44,8 @@ public class ThirdPartyIssuerService implements IssuerService {
private String accountChooserUrl;
private Set<String> whitelist = new HashSet<String>();
private Set<String> blacklist = new HashSet<String>();
private Set<String> whitelist = new HashSet<>();
private Set<String> blacklist = new HashSet<>();
/* (non-Javadoc)
* @see org.mitre.openid.connect.client.service.IssuerService#getIssuer(javax.servlet.http.HttpServletRequest)

View File

@ -63,8 +63,8 @@ public class WebfingerIssuerService implements IssuerService {
// map of user input -> issuer, loaded dynamically from webfinger discover
private LoadingCache<UriComponents, String> issuers;
private Set<String> whitelist = new HashSet<String>();
private Set<String> blacklist = new HashSet<String>();
private Set<String> whitelist = new HashSet<>();
private Set<String> blacklist = new HashSet<>();
/**
* Name of the incoming parameter to check for discovery purposes.

View File

@ -57,7 +57,7 @@ public class TestStaticClientConfigurationService {
service = new StaticClientConfigurationService();
Map<String, RegisteredClient> clients = new HashMap<String, RegisteredClient>();
Map<String, RegisteredClient> clients = new HashMap<>();
clients.put(issuer, mockClient);
service.setClients(clients);

View File

@ -53,7 +53,7 @@ public class TestStaticServerConfigurationService {
service = new StaticServerConfigurationService();
Map<String, ServerConfiguration> servers = new HashMap<String, ServerConfiguration>();
Map<String, ServerConfiguration> servers = new HashMap<>();
servers.put(issuer, mockServerConfig);
service.setServers(servers);

View File

@ -58,10 +58,10 @@ public class DefaultJWTEncryptionAndDecryptionService implements JWTEncryptionAn
private static final Logger logger = LoggerFactory.getLogger(DefaultJWTEncryptionAndDecryptionService.class);
// map of identifier to encrypter
private Map<String, JWEEncrypter> encrypters = new HashMap<String, JWEEncrypter>();
private Map<String, JWEEncrypter> encrypters = new HashMap<>();
// map of identifier to decrypter
private Map<String, JWEDecrypter> decrypters = new HashMap<String, JWEDecrypter>();
private Map<String, JWEDecrypter> decrypters = new HashMap<>();
private String defaultEncryptionKeyId;
@ -70,7 +70,7 @@ public class DefaultJWTEncryptionAndDecryptionService implements JWTEncryptionAn
private JWEAlgorithm defaultAlgorithm;
// map of identifier to key
private Map<String, JWK> keys = new HashMap<String, JWK>();
private Map<String, JWK> keys = new HashMap<>();
/**
* Build this service based on the keys given. All public keys will be used to make encrypters,
@ -253,7 +253,7 @@ public class DefaultJWTEncryptionAndDecryptionService implements JWTEncryptionAn
@Override
public Map<String, JWK> getAllPublicKeys() {
Map<String, JWK> pubKeys = new HashMap<String, JWK>();
Map<String, JWK> pubKeys = new HashMap<>();
// pull out all public keys
for (String keyId : keys.keySet()) {
@ -269,7 +269,7 @@ public class DefaultJWTEncryptionAndDecryptionService implements JWTEncryptionAn
@Override
public Collection<JWEAlgorithm> getAllEncryptionAlgsSupported() {
Set<JWEAlgorithm> algs = new HashSet<JWEAlgorithm>();
Set<JWEAlgorithm> algs = new HashSet<>();
for (JWEEncrypter encrypter : encrypters.values()) {
algs.addAll(encrypter.supportedAlgorithms());
@ -287,7 +287,7 @@ public class DefaultJWTEncryptionAndDecryptionService implements JWTEncryptionAn
*/
@Override
public Collection<EncryptionMethod> getAllEncryptionEncsSupported() {
Set<EncryptionMethod> encs = new HashSet<EncryptionMethod>();
Set<EncryptionMethod> encs = new HashSet<>();
for (JWEEncrypter encrypter : encrypters.values()) {
encs.addAll(encrypter.supportedEncryptionMethods());

View File

@ -50,10 +50,10 @@ import com.nimbusds.jwt.SignedJWT;
public class DefaultJWTSigningAndValidationService implements JWTSigningAndValidationService {
// map of identifier to signer
private Map<String, JWSSigner> signers = new HashMap<String, JWSSigner>();
private Map<String, JWSSigner> signers = new HashMap<>();
// map of identifier to verifier
private Map<String, JWSVerifier> verifiers = new HashMap<String, JWSVerifier>();
private Map<String, JWSVerifier> verifiers = new HashMap<>();
/**
* Logger for this class
@ -65,7 +65,7 @@ public class DefaultJWTSigningAndValidationService implements JWTSigningAndValid
private JWSAlgorithm defaultAlgorithm;
// map of identifier to key
private Map<String, JWK> keys = new HashMap<String, JWK>();
private Map<String, JWK> keys = new HashMap<>();
/**
* Build this service based on the keys given. All public keys will be used
@ -269,7 +269,7 @@ public class DefaultJWTSigningAndValidationService implements JWTSigningAndValid
@Override
public Map<String, JWK> getAllPublicKeys() {
Map<String, JWK> pubKeys = new HashMap<String, JWK>();
Map<String, JWK> pubKeys = new HashMap<>();
// pull all keys out of the verifiers if we know how
for (String keyId : keys.keySet()) {
@ -289,7 +289,7 @@ public class DefaultJWTSigningAndValidationService implements JWTSigningAndValid
@Override
public Collection<JWSAlgorithm> getAllSigningAlgsSupported() {
Set<JWSAlgorithm> algs = new HashSet<JWSAlgorithm>();
Set<JWSAlgorithm> algs = new HashSet<>();
for (JWSSigner signer : signers.values()) {
algs.addAll(signer.supportedAlgorithms());

View File

@ -86,16 +86,16 @@ public class ClientDetailsEntity implements ClientDetails {
/** Fields from the OAuth2 Dynamic Registration Specification */
private String clientId = null; // client_id
private String clientSecret = null; // client_secret
private Set<String> redirectUris = new HashSet<String>(); // redirect_uris
private Set<String> redirectUris = new HashSet<>(); // redirect_uris
private String clientName; // client_name
private String clientUri; // client_uri
private String logoUri; // logo_uri
private Set<String> contacts; // contacts
private String tosUri; // tos_uri
private AuthMethod tokenEndpointAuthMethod = AuthMethod.SECRET_BASIC; // token_endpoint_auth_method
private Set<String> scope = new HashSet<String>(); // scope
private Set<String> grantTypes = new HashSet<String>(); // grant_types
private Set<String> responseTypes = new HashSet<String>(); // response_types
private Set<String> scope = new HashSet<>(); // scope
private Set<String> grantTypes = new HashSet<>(); // grant_types
private Set<String> responseTypes = new HashSet<>(); // response_types
private String policyUri;
private String jwksUri; // URI pointer to keys
private JWKSet jwks; // public key stored by value
@ -127,11 +127,11 @@ public class ClientDetailsEntity implements ClientDetails {
private Set<String> requestUris; // request_uris
/** Fields to support the ClientDetails interface **/
private Set<GrantedAuthority> authorities = new HashSet<GrantedAuthority>();
private Set<GrantedAuthority> authorities = new HashSet<>();
private Integer accessTokenValiditySeconds = 0; // in seconds
private Integer refreshTokenValiditySeconds = 0; // in seconds
private Set<String> resourceIds = new HashSet<String>();
private Map<String, Object> additionalInformation = new HashMap<String, Object>();
private Set<String> resourceIds = new HashSet<>();
private Map<String, Object> additionalInformation = new HashMap<>();
/** Our own fields **/
private String clientDescription = ""; // human-readable description
@ -151,7 +151,7 @@ public class ClientDetailsEntity implements ClientDetails {
private final String value;
// map to aid reverse lookup
private static final Map<String, AuthMethod> lookup = new HashMap<String, AuthMethod>();
private static final Map<String, AuthMethod> lookup = new HashMap<>();
static {
for (AuthMethod a : AuthMethod.values()) {
lookup.put(a.getValue(), a);
@ -177,7 +177,7 @@ public class ClientDetailsEntity implements ClientDetails {
private final String value;
// map to aid reverse lookup
private static final Map<String, AppType> lookup = new HashMap<String, AppType>();
private static final Map<String, AppType> lookup = new HashMap<>();
static {
for (AppType a : AppType.values()) {
lookup.put(a.getValue(), a);
@ -203,7 +203,7 @@ public class ClientDetailsEntity implements ClientDetails {
private final String value;
// map to aid reverse lookup
private static final Map<String, SubjectType> lookup = new HashMap<String, SubjectType>();
private static final Map<String, SubjectType> lookup = new HashMap<>();
static {
for (SubjectType u : SubjectType.values()) {
lookup.put(u.getValue(), u);

View File

@ -142,7 +142,7 @@ public class OAuth2AccessTokenEntity implements OAuth2AccessToken {
@Override
@Transient
public Map<String, Object> getAdditionalInformation() {
Map<String, Object> map = new HashMap<String, Object>(); //super.getAdditionalInformation();
Map<String, Object> map = new HashMap<>(); //super.getAdditionalInformation();
if (getIdToken() != null) {
map.put(ID_TOKEN_FIELD_NAME, getIdTokenString());
}

View File

@ -72,7 +72,7 @@ public class DefaultClientUserDetailsService implements UserDetailsService {
boolean accountNonExpired = true;
boolean credentialsNonExpired = true;
boolean accountNonLocked = true;
Collection<GrantedAuthority> authorities = new HashSet<GrantedAuthority>(client.getAuthorities());
Collection<GrantedAuthority> authorities = new HashSet<>(client.getAuthorities());
authorities.add(ROLE_CLIENT);
return new User(clientId, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);

View File

@ -58,7 +58,7 @@ public class JWKSetView extends AbstractView {
//BiMap<String, PublicKey> keyMap = (BiMap<String, PublicKey>) model.get("keys");
Map<String, JWK> keys = (Map<String, JWK>) model.get("keys");
JWKSet jwkSet = new JWKSet(new ArrayList<JWK>(keys.values()));
JWKSet jwkSet = new JWKSet(new ArrayList<>(keys.values()));
try {

View File

@ -205,7 +205,7 @@ public class JsonUtils {
public static List<JWSAlgorithm> getAsJwsAlgorithmList(JsonObject o, String member) {
List<String> strings = getAsStringList(o, member);
if (strings != null) {
List<JWSAlgorithm> algs = new ArrayList<JWSAlgorithm>();
List<JWSAlgorithm> algs = new ArrayList<>();
for (String alg : strings) {
algs.add(JWSAlgorithm.parse(alg));
}
@ -221,7 +221,7 @@ public class JsonUtils {
public static List<JWEAlgorithm> getAsJweAlgorithmList(JsonObject o, String member) {
List<String> strings = getAsStringList(o, member);
if (strings != null) {
List<JWEAlgorithm> algs = new ArrayList<JWEAlgorithm>();
List<JWEAlgorithm> algs = new ArrayList<>();
for (String alg : strings) {
algs.add(JWEAlgorithm.parse(alg));
}
@ -237,7 +237,7 @@ public class JsonUtils {
public static List<EncryptionMethod> getAsEncryptionMethodList(JsonObject o, String member) {
List<String> strings = getAsStringList(o, member);
if (strings != null) {
List<EncryptionMethod> algs = new ArrayList<EncryptionMethod>();
List<EncryptionMethod> algs = new ArrayList<>();
for (String alg : strings) {
algs.add(EncryptionMethod.parse(alg));
}
@ -248,7 +248,7 @@ public class JsonUtils {
}
public static Map readMap(JsonReader reader) throws IOException {
Map map = new HashMap<String, Object>();
Map map = new HashMap<>();
reader.beginObject();
while(reader.hasNext()) {
String name = reader.nextName();
@ -279,13 +279,13 @@ public class JsonUtils {
reader.beginArray();
switch (reader.peek()) {
case STRING:
arraySet = new HashSet<String>();
arraySet = new HashSet<>();
while (reader.hasNext()) {
arraySet.add(reader.nextString());
}
break;
case NUMBER:
arraySet = new HashSet<Long>();
arraySet = new HashSet<>();
while (reader.hasNext()) {
arraySet.add(reader.nextLong());
}

View File

@ -82,7 +82,7 @@ public class TestJWKSetKeyStore {
KeyUse.ENCRYPTION, null, JWEAlgorithm.RSA1_5, RSAkid_rsa2, null, null, null);
List<JWK> keys_list = new LinkedList<JWK>();
List<JWK> keys_list = new LinkedList<>();
private JWKSet jwkSet;
private String ks_file = "ks.txt";
private String ks_file_badJWK = "ks_badJWK.txt";

View File

@ -135,7 +135,7 @@ public class TestDefaultJWTEncryptionAndDecryptionService {
.build();
private List<JWK> keys_list = new LinkedList<JWK>();
private List<JWK> keys_list = new LinkedList<>();
private DefaultJWTEncryptionAndDecryptionService service;
private DefaultJWTEncryptionAndDecryptionService service_2;

View File

@ -299,7 +299,7 @@ public class DiscoveryEndpoint {
Algorithm.NONE);
ArrayList<String> grantTypes = Lists.newArrayList("authorization_code", "implicit", "urn:ietf:params:oauth:grant-type:jwt-bearer", "client_credentials", "urn:ietf:params:oauth:grant_type:redelegate");
Map<String, Object> m = new HashMap<String, Object>();
Map<String, Object> m = new HashMap<>();
m.put("issuer", config.getIssuer());
m.put("authorization_endpoint", baseUrl + "authorize");
m.put("token_endpoint", baseUrl + "token");

View File

@ -48,13 +48,13 @@ public class JpaOAuth2TokenRepository implements OAuth2TokenRepository {
@Override
public Set<OAuth2AccessTokenEntity> getAllAccessTokens() {
TypedQuery<OAuth2AccessTokenEntity> query = manager.createNamedQuery(OAuth2AccessTokenEntity.QUERY_ALL, OAuth2AccessTokenEntity.class);
return new LinkedHashSet<OAuth2AccessTokenEntity>(query.getResultList());
return new LinkedHashSet<>(query.getResultList());
}
@Override
public Set<OAuth2RefreshTokenEntity> getAllRefreshTokens() {
TypedQuery<OAuth2RefreshTokenEntity> query = manager.createNamedQuery(OAuth2RefreshTokenEntity.QUERY_ALL, OAuth2RefreshTokenEntity.class);
return new LinkedHashSet<OAuth2RefreshTokenEntity>(query.getResultList());
return new LinkedHashSet<>(query.getResultList());
}
@ -187,7 +187,7 @@ public class JpaOAuth2TokenRepository implements OAuth2TokenRepository {
TypedQuery<OAuth2AccessTokenEntity> query = manager.createNamedQuery(OAuth2AccessTokenEntity.QUERY_EXPIRED_BY_DATE, OAuth2AccessTokenEntity.class);
query.setParameter(OAuth2AccessTokenEntity.PARAM_DATE, new Date());
query.setMaxResults(MAXEXPIREDRESULTS);
return new LinkedHashSet<OAuth2AccessTokenEntity>(query.getResultList());
return new LinkedHashSet<>(query.getResultList());
}
@Override
@ -195,7 +195,7 @@ public class JpaOAuth2TokenRepository implements OAuth2TokenRepository {
TypedQuery<OAuth2RefreshTokenEntity> query = manager.createNamedQuery(OAuth2RefreshTokenEntity.QUERY_EXPIRED_BY_DATE, OAuth2RefreshTokenEntity.class);
query.setParameter(OAuth2RefreshTokenEntity.PARAM_DATE, new Date());
query.setMaxResults(MAXEXPIREDRESULTS);
return new LinkedHashSet<OAuth2RefreshTokenEntity>(query.getResultList());
return new LinkedHashSet<>(query.getResultList());
}
}

View File

@ -52,7 +52,7 @@ public class JpaSystemScopeRepository implements SystemScopeRepository {
public Set<SystemScope> getAll() {
TypedQuery<SystemScope> query = em.createNamedQuery(SystemScope.QUERY_ALL, SystemScope.class);
return new LinkedHashSet<SystemScope>(query.getResultList());
return new LinkedHashSet<>(query.getResultList());
}
/* (non-Javadoc)

View File

@ -330,7 +330,7 @@ public class DefaultOAuth2ClientDetailsEntityService implements ClientDetailsEnt
JsonElement json = parser.parse(jsonString);
if (json.isJsonArray()) {
List<String> redirectUris = new ArrayList<String>();
List<String> redirectUris = new ArrayList<>();
for (JsonElement el : json.getAsJsonArray()) {
redirectUris.add(el.getAsString());
}

View File

@ -272,12 +272,12 @@ public class DefaultOAuth2ProviderTokenService implements OAuth2TokenEntityServi
OAuth2AccessTokenEntity token = new OAuth2AccessTokenEntity();
// get the stored scopes from the authentication holder's authorization request; these are the scopes associated with the refresh token
Set<String> refreshScopesRequested = new HashSet<String>(refreshToken.getAuthenticationHolder().getAuthentication().getOAuth2Request().getScope());
Set<String> refreshScopesRequested = new HashSet<>(refreshToken.getAuthenticationHolder().getAuthentication().getOAuth2Request().getScope());
Set<SystemScope> refreshScopes = scopeService.fromStrings(refreshScopesRequested);
// remove any of the special system scopes
refreshScopes = scopeService.removeReservedScopes(refreshScopes);
Set<String> scopeRequested = authRequest.getScope() == null ? new HashSet<String>() : new HashSet<String>(authRequest.getScope());
Set<String> scopeRequested = authRequest.getScope() == null ? new HashSet<String>() : new HashSet<>(authRequest.getScope());
Set<SystemScope> scope = scopeService.fromStrings(scopeRequested);
// remove any of the special system scopes

View File

@ -165,7 +165,7 @@ public class DefaultSystemScopeService implements SystemScopeService {
if (scope == null) {
return null;
} else {
return new LinkedHashSet<SystemScope>(Collections2.filter(Collections2.transform(scope, stringToSystemScope), Predicates.notNull()));
return new LinkedHashSet<>(Collections2.filter(Collections2.transform(scope, stringToSystemScope), Predicates.notNull()));
}
}
@ -177,7 +177,7 @@ public class DefaultSystemScopeService implements SystemScopeService {
if (scope == null) {
return null;
} else {
return new LinkedHashSet<String>(Collections2.filter(Collections2.transform(scope, systemScopeToString), Predicates.notNull()));
return new LinkedHashSet<>(Collections2.filter(Collections2.transform(scope, systemScopeToString), Predicates.notNull()));
}
}

View File

@ -75,12 +75,12 @@ public class ChainedTokenGranter extends AbstractTokenGranter {
Set<String> requestedScopes = tokenRequest.getScope();
if (requestedScopes == null) {
requestedScopes = new HashSet<String>();
requestedScopes = new HashSet<>();
}
// do a check on the requested scopes -- if they exactly match the client scopes, they were probably shadowed by the token granter
if (client.getScope().equals(requestedScopes)) {
requestedScopes = new HashSet<String>();
requestedScopes = new HashSet<>();
}
// if our scopes are a valid subset of what's allowed, we can continue

View File

@ -163,7 +163,7 @@ public class OAuthConfirmationController {
// pre-process the scopes
Set<SystemScope> scopes = scopeService.fromStrings(authRequest.getScope());
Set<SystemScope> sortedScopes = new LinkedHashSet<SystemScope>(scopes.size());
Set<SystemScope> sortedScopes = new LinkedHashSet<>(scopes.size());
Set<SystemScope> systemScopes = scopeService.getAll();
// sort scopes for display based on the inherent order of system scopes
@ -180,12 +180,12 @@ public class OAuthConfirmationController {
// get the userinfo claims for each scope
UserInfo user = userInfoService.getByUsername(p.getName());
Map<String, Map<String, String>> claimsForScopes = new HashMap<String, Map<String, String>>();
Map<String, Map<String, String>> claimsForScopes = new HashMap<>();
if (user != null) {
JsonObject userJson = user.toJson();
for (SystemScope systemScope : sortedScopes) {
Map<String, String> claimValues = new HashMap<String, String>();
Map<String, String> claimValues = new HashMap<>();
Set<String> claims = scopeClaimTranslationService.getClaimsForScope(systemScope.getValue());
for (String claim : claims) {

View File

@ -235,7 +235,7 @@ public class AuthorizationRequestFilter extends GenericFilterBean {
* @return
*/
private Map<String, String> createRequestMap(Map<String, String[]> parameterMap) {
Map<String, String> requestMap = new HashMap<String, String>();
Map<String, String> requestMap = new HashMap<>();
for (String key : parameterMap.keySet()) {
String[] val = parameterMap.get(key);
if (val != null && val.length > 0) {

View File

@ -104,7 +104,7 @@ public class DefaultScopeClaimTranslationService implements ScopeClaimTranslatio
if (scopesToClaims.containsKey(scope)) {
return scopesToClaims.get(scope);
} else {
return new HashSet<String>();
return new HashSet<>();
}
}
@ -113,7 +113,7 @@ public class DefaultScopeClaimTranslationService implements ScopeClaimTranslatio
*/
@Override
public Set<String> getClaimsForScopeSet(Set<String> scopes) {
Set<String> result = new HashSet<String>();
Set<String> result = new HashSet<>();
for (String scope : scopes) {
result.addAll(getClaimsForScope(scope));
}

View File

@ -88,14 +88,14 @@ public class DefaultStatsService implements StatsService {
Collection<ApprovedSite> allSites = approvedSiteService.getAll();
// process to find number of unique users and sites
Set<String> userIds = new HashSet<String>();
Set<String> clientIds = new HashSet<String>();
Set<String> userIds = new HashSet<>();
Set<String> clientIds = new HashSet<>();
for (ApprovedSite approvedSite : allSites) {
userIds.add(approvedSite.getUserId());
clientIds.add(approvedSite.getClientId());
}
Map<String, Integer> e = new HashMap<String, Integer>();
Map<String, Integer> e = new HashMap<>();
e.put("approvalCount", allSites.size());
e.put("userCount", userIds.size());
@ -145,7 +145,7 @@ public class DefaultStatsService implements StatsService {
* @return
*/
private Map<Long, Integer> getEmptyClientCountMap() {
Map<Long, Integer> counts = new HashMap<Long, Integer>();
Map<Long, Integer> counts = new HashMap<>();
Collection<ClientDetailsEntity> clients = clientService.getAllClients();
for (ClientDetailsEntity client : clients) {
counts.put(client.getId(), 0);

View File

@ -155,9 +155,9 @@ public class MITREidDataService_1_0 extends MITREidDataServiceSupport implements
}
fixObjectReferences();
}
private Map<Long, String> refreshTokenToClientRefs = new HashMap<Long, String>();
private Map<Long, Long> refreshTokenToAuthHolderRefs = new HashMap<Long, Long>();
private Map<Long, Long> refreshTokenOldToNewIdMap = new HashMap<Long, Long>();
private Map<Long, String> refreshTokenToClientRefs = new HashMap<>();
private Map<Long, Long> refreshTokenToAuthHolderRefs = new HashMap<>();
private Map<Long, Long> refreshTokenOldToNewIdMap = new HashMap<>();
/**
* @param reader
@ -220,11 +220,11 @@ public class MITREidDataService_1_0 extends MITREidDataServiceSupport implements
reader.endArray();
logger.info("Done reading refresh tokens");
}
private Map<Long, String> accessTokenToClientRefs = new HashMap<Long, String>();
private Map<Long, Long> accessTokenToAuthHolderRefs = new HashMap<Long, Long>();
private Map<Long, Long> accessTokenToRefreshTokenRefs = new HashMap<Long, Long>();
private Map<Long, Long> accessTokenToIdTokenRefs = new HashMap<Long, Long>();
private Map<Long, Long> accessTokenOldToNewIdMap = new HashMap<Long, Long>();
private Map<Long, String> accessTokenToClientRefs = new HashMap<>();
private Map<Long, Long> accessTokenToAuthHolderRefs = new HashMap<>();
private Map<Long, Long> accessTokenToRefreshTokenRefs = new HashMap<>();
private Map<Long, Long> accessTokenToIdTokenRefs = new HashMap<>();
private Map<Long, Long> accessTokenOldToNewIdMap = new HashMap<>();
/**
* @param reader
@ -305,7 +305,7 @@ public class MITREidDataService_1_0 extends MITREidDataServiceSupport implements
reader.endArray();
logger.info("Done reading access tokens");
}
private Map<Long, Long> authHolderOldToNewIdMap = new HashMap<Long, Long>();
private Map<Long, Long> authHolderOldToNewIdMap = new HashMap<>();
/**
* @param reader
@ -387,12 +387,12 @@ public class MITREidDataService_1_0 extends MITREidDataServiceSupport implements
//used by readAuthenticationHolders
private OAuth2Request readAuthorizationRequest(JsonReader reader) throws IOException {
Set<String> scope = new LinkedHashSet<String>();
Set<String> resourceIds = new HashSet<String>();
Set<String> scope = new LinkedHashSet<>();
Set<String> resourceIds = new HashSet<>();
boolean approved = false;
Collection<GrantedAuthority> authorities = new HashSet<GrantedAuthority>();
Map<String, String> authorizationParameters = new HashMap<String, String>();
Set<String> responseTypes = new HashSet<String>();
Collection<GrantedAuthority> authorities = new HashSet<>();
Map<String, String> authorizationParameters = new HashMap<>();
Set<String> responseTypes = new HashSet<>();
String redirectUri = null;
String clientId = null;
reader.beginObject();
@ -416,7 +416,7 @@ public class MITREidDataService_1_0 extends MITREidDataServiceSupport implements
resourceIds = readSet(reader);
} else if (name.equals("authorities")) {
Set<String> authorityStrs = readSet(reader);
authorities = new HashSet<GrantedAuthority>();
authorities = new HashSet<>();
for (String s : authorityStrs) {
GrantedAuthority ga = new SimpleGrantedAuthority(s);
authorities.add(ga);
@ -492,11 +492,9 @@ public class MITREidDataService_1_0 extends MITREidDataServiceSupport implements
return savedUserAuth;
}
Map<Long, Long> grantOldToNewIdMap = new HashMap<Long, Long>();
Map<Long, Long> grantToWhitelistedSiteRefs = new HashMap<Long, Long>();
Map<Long, Set<Long>> grantToAccessTokensRefs = new HashMap<Long, Set<Long>>();
Map<Long, Long> grantOldToNewIdMap = new HashMap<>();
Map<Long, Long> grantToWhitelistedSiteRefs = new HashMap<>();
Map<Long, Set<Long>> grantToAccessTokensRefs = new HashMap<>();
/**
* @param reader
@ -565,7 +563,7 @@ public class MITREidDataService_1_0 extends MITREidDataServiceSupport implements
reader.endArray();
logger.info("Done reading grants");
}
Map<Long, Long> whitelistedSiteOldToNewIdMap = new HashMap<Long, Long>();
Map<Long, Long> whitelistedSiteOldToNewIdMap = new HashMap<>();
/**
* @param reader
@ -677,7 +675,7 @@ public class MITREidDataService_1_0 extends MITREidDataServiceSupport implements
client.setScope(scope);
} else if (name.equals("authorities")) {
Set<String> authorityStrs = readSet(reader);
Set<GrantedAuthority> authorities = new HashSet<GrantedAuthority>();
Set<GrantedAuthority> authorities = new HashSet<>();
for (String s : authorityStrs) {
GrantedAuthority ga = new SimpleGrantedAuthority(s);
authorities.add(ga);
@ -909,7 +907,7 @@ public class MITREidDataService_1_0 extends MITREidDataServiceSupport implements
whitelistedSiteOldToNewIdMap.clear();
for (Long oldGrantId : grantToAccessTokensRefs.keySet()) {
Set<Long> oldAccessTokenIds = grantToAccessTokensRefs.get(oldGrantId);
Set<OAuth2AccessTokenEntity> tokens = new HashSet<OAuth2AccessTokenEntity>();
Set<OAuth2AccessTokenEntity> tokens = new HashSet<>();
for(Long oldTokenId : oldAccessTokenIds) {
Long newTokenId = accessTokenOldToNewIdMap.get(oldTokenId);
tokens.add(tokenRepository.getAccessTokenById(newTokenId));

View File

@ -158,9 +158,9 @@ public class MITREidDataService_1_1 extends MITREidDataServiceSupport implements
}
fixObjectReferences();
}
private Map<Long, String> refreshTokenToClientRefs = new HashMap<Long, String>();
private Map<Long, Long> refreshTokenToAuthHolderRefs = new HashMap<Long, Long>();
private Map<Long, Long> refreshTokenOldToNewIdMap = new HashMap<Long, Long>();
private Map<Long, String> refreshTokenToClientRefs = new HashMap<>();
private Map<Long, Long> refreshTokenToAuthHolderRefs = new HashMap<>();
private Map<Long, Long> refreshTokenOldToNewIdMap = new HashMap<>();
/**
* @param reader
@ -223,11 +223,11 @@ public class MITREidDataService_1_1 extends MITREidDataServiceSupport implements
reader.endArray();
logger.info("Done reading refresh tokens");
}
private Map<Long, String> accessTokenToClientRefs = new HashMap<Long, String>();
private Map<Long, Long> accessTokenToAuthHolderRefs = new HashMap<Long, Long>();
private Map<Long, Long> accessTokenToRefreshTokenRefs = new HashMap<Long, Long>();
private Map<Long, Long> accessTokenToIdTokenRefs = new HashMap<Long, Long>();
private Map<Long, Long> accessTokenOldToNewIdMap = new HashMap<Long, Long>();
private Map<Long, String> accessTokenToClientRefs = new HashMap<>();
private Map<Long, Long> accessTokenToAuthHolderRefs = new HashMap<>();
private Map<Long, Long> accessTokenToRefreshTokenRefs = new HashMap<>();
private Map<Long, Long> accessTokenToIdTokenRefs = new HashMap<>();
private Map<Long, Long> accessTokenOldToNewIdMap = new HashMap<>();
/**
* @param reader
@ -308,7 +308,7 @@ public class MITREidDataService_1_1 extends MITREidDataServiceSupport implements
reader.endArray();
logger.info("Done reading access tokens");
}
private Map<Long, Long> authHolderOldToNewIdMap = new HashMap<Long, Long>();
private Map<Long, Long> authHolderOldToNewIdMap = new HashMap<>();
/**
* @param reader
@ -390,13 +390,13 @@ public class MITREidDataService_1_1 extends MITREidDataServiceSupport implements
//used by readAuthenticationHolders
private OAuth2Request readAuthorizationRequest(JsonReader reader) throws IOException {
Set<String> scope = new LinkedHashSet<String>();
Set<String> resourceIds = new HashSet<String>();
Set<String> scope = new LinkedHashSet<>();
Set<String> resourceIds = new HashSet<>();
boolean approved = false;
Collection<GrantedAuthority> authorities = new HashSet<GrantedAuthority>();
Map<String, String> requestParameters = new HashMap<String, String>();
Set<String> responseTypes = new HashSet<String>();
Map<String, Serializable> extensions = new HashMap<String, Serializable>();
Collection<GrantedAuthority> authorities = new HashSet<>();
Map<String, String> requestParameters = new HashMap<>();
Set<String> responseTypes = new HashSet<>();
Map<String, Serializable> extensions = new HashMap<>();
String redirectUri = null;
String clientId = null;
reader.beginObject();
@ -418,7 +418,7 @@ public class MITREidDataService_1_1 extends MITREidDataServiceSupport implements
resourceIds = readSet(reader);
} else if (name.equals("authorities")) {
Set<String> authorityStrs = readSet(reader);
authorities = new HashSet<GrantedAuthority>();
authorities = new HashSet<>();
for (String s : authorityStrs) {
GrantedAuthority ga = new SimpleGrantedAuthority(s);
authorities.add(ga);
@ -502,12 +502,10 @@ public class MITREidDataService_1_1 extends MITREidDataServiceSupport implements
return savedUserAuth;
}
Map<Long, Long> grantOldToNewIdMap = new HashMap<Long, Long>();
Map<Long, Long> grantToWhitelistedSiteRefs = new HashMap<Long, Long>();
Map<Long, Set<Long>> grantToAccessTokensRefs = new HashMap<Long, Set<Long>>();
Map<Long, Long> grantOldToNewIdMap = new HashMap<>();
Map<Long, Long> grantToWhitelistedSiteRefs = new HashMap<>();
Map<Long, Set<Long>> grantToAccessTokensRefs = new HashMap<>();
/**
* @param reader
* @throws IOException
@ -575,7 +573,7 @@ public class MITREidDataService_1_1 extends MITREidDataServiceSupport implements
reader.endArray();
logger.info("Done reading grants");
}
Map<Long, Long> whitelistedSiteOldToNewIdMap = new HashMap<Long, Long>();
Map<Long, Long> whitelistedSiteOldToNewIdMap = new HashMap<>();
/**
* @param reader
@ -687,7 +685,7 @@ public class MITREidDataService_1_1 extends MITREidDataServiceSupport implements
client.setScope(scope);
} else if (name.equals("authorities")) {
Set<String> authorityStrs = readSet(reader);
Set<GrantedAuthority> authorities = new HashSet<GrantedAuthority>();
Set<GrantedAuthority> authorities = new HashSet<>();
for (String s : authorityStrs) {
GrantedAuthority ga = new SimpleGrantedAuthority(s);
authorities.add(ga);
@ -922,7 +920,7 @@ public class MITREidDataService_1_1 extends MITREidDataServiceSupport implements
grantToWhitelistedSiteRefs.clear();
for (Long oldGrantId : grantToAccessTokensRefs.keySet()) {
Set<Long> oldAccessTokenIds = grantToAccessTokensRefs.get(oldGrantId);
Set<OAuth2AccessTokenEntity> tokens = new HashSet<OAuth2AccessTokenEntity>();
Set<OAuth2AccessTokenEntity> tokens = new HashSet<>();
for(Long oldTokenId : oldAccessTokenIds) {
Long newTokenId = accessTokenOldToNewIdMap.get(oldTokenId);
tokens.add(tokenRepository.getAccessTokenById(newTokenId));

View File

@ -778,9 +778,10 @@ public class MITREidDataService_1_2 extends MITREidDataServiceSupport implements
return savedUserAuth;
}
Map<Long, Long> grantOldToNewIdMap = new HashMap<Long, Long>();
Map<Long, Long> grantToWhitelistedSiteRefs = new HashMap<Long, Long>();
Map<Long, Set<Long>> grantToAccessTokensRefs = new HashMap<Long, Set<Long>>();
Map<Long, Long> grantOldToNewIdMap = new HashMap<>();
Map<Long, Long> grantToWhitelistedSiteRefs = new HashMap<>();
Map<Long, Set<Long>> grantToAccessTokensRefs = new HashMap<>();
/**
* @param reader
* @throws IOException

View File

@ -290,7 +290,7 @@ public class TofuUserApprovalHandler implements UserApprovalHandler {
@Override
public Map<String, Object> getUserApprovalRequest(AuthorizationRequest authorizationRequest,
Authentication userAuthentication) {
Map<String, Object> model = new HashMap<String, Object>();
Map<String, Object> model = new HashMap<>();
// In case of a redirect we might want the request parameters to be included
model.putAll(authorizationRequest.getRequestParameters());
return model;

View File

@ -144,8 +144,8 @@ public class UserInfoView extends AbstractView {
JsonObject obj = ui.toJson();
Set<String> allowedByScope = translator.getClaimsForScopeSet(scope);
Set<String> authorizedByClaims = new HashSet<String>();
Set<String> requestedByClaims = new HashSet<String>();
Set<String> authorizedByClaims = new HashSet<>();
Set<String> requestedByClaims = new HashSet<>();
if (authorizedClaims != null) {
JsonObject userinfoAuthorized = authorizedClaims.getAsJsonObject().get("userinfo").getAsJsonObject();

View File

@ -409,7 +409,7 @@ public class DynamicClientRegistrationEndpoint {
// filter out unknown grant types
// TODO: make this a pluggable service
Set<String> requestedGrantTypes = new HashSet<String>(newClient.getGrantTypes());
Set<String> requestedGrantTypes = new HashSet<>(newClient.getGrantTypes());
requestedGrantTypes.retainAll(
ImmutableSet.of("authorization_code", "implicit",
"password", "client_credentials", "refresh_token",

View File

@ -104,7 +104,7 @@ public class TestDefaultIntrospectionResultAssembler {
.put("sub", "sub")
.put("exp", 123L)
.put("expires_at", dateFormat.valueToString(new Date(123 * 1000L)))
.put("permissions", new ImmutableSet.Builder<Object>()
.put("permissions", new ImmutableSet.Builder<>()
.add(new ImmutableMap.Builder<String, Object>()
.put("resource_set_id", "1") // note that the resource ID comes out as a string
.put("scopes", new ImmutableSet.Builder<>()

View File

@ -183,7 +183,7 @@ public class TestDefaultOAuth2ClientDetailsEntityService {
ClientDetailsEntity client = new ClientDetailsEntity();
Set<String> grantTypes = new HashSet<String>();
Set<String> grantTypes = new HashSet<>();
grantTypes.add("refresh_token");
client.setGrantTypes(grantTypes);
@ -320,7 +320,7 @@ public class TestDefaultOAuth2ClientDetailsEntityService {
ClientDetailsEntity oldClient = new ClientDetailsEntity();
ClientDetailsEntity client = new ClientDetailsEntity();
Set<String> grantTypes = new HashSet<String>();
Set<String> grantTypes = new HashSet<>();
grantTypes.add("refresh_token");
client.setGrantTypes(grantTypes);

View File

@ -193,7 +193,7 @@ public class TestMITREidDataService_1_0 {
System.err.println(configJson);
JsonReader reader = new JsonReader(new StringReader(configJson));
final Map<Long, OAuth2RefreshTokenEntity> fakeDb = new HashMap<Long, OAuth2RefreshTokenEntity>();
final Map<Long, OAuth2RefreshTokenEntity> fakeDb = new HashMap<>();
when(tokenRepository.saveRefreshToken(isA(OAuth2RefreshTokenEntity.class))).thenAnswer(new Answer<OAuth2RefreshTokenEntity>() {
Long id = 343L;
@Override
@ -324,7 +324,7 @@ public class TestMITREidDataService_1_0 {
JsonReader reader = new JsonReader(new StringReader(configJson));
final Map<Long, OAuth2AccessTokenEntity> fakeDb = new HashMap<Long, OAuth2AccessTokenEntity>();
final Map<Long, OAuth2AccessTokenEntity> fakeDb = new HashMap<>();
when(tokenRepository.saveAccessToken(isA(OAuth2AccessTokenEntity.class))).thenAnswer(new Answer<OAuth2AccessTokenEntity>() {
Long id = 343L;
@Override
@ -540,7 +540,7 @@ public class TestMITREidDataService_1_0 {
JsonReader reader = new JsonReader(new StringReader(configJson));
final Map<Long, WhitelistedSite> fakeDb = new HashMap<Long, WhitelistedSite>();
final Map<Long, WhitelistedSite> fakeDb = new HashMap<>();
when(wlSiteRepository.save(isA(WhitelistedSite.class))).thenAnswer(new Answer<WhitelistedSite>() {
Long id = 345L;
@Override
@ -631,7 +631,7 @@ public class TestMITREidDataService_1_0 {
JsonReader reader = new JsonReader(new StringReader(configJson));
final Map<Long, ApprovedSite> fakeDb = new HashMap<Long, ApprovedSite>();
final Map<Long, ApprovedSite> fakeDb = new HashMap<>();
when(approvedSiteRepository.save(isA(ApprovedSite.class))).thenAnswer(new Answer<ApprovedSite>() {
Long id = 343L;
@Override
@ -738,7 +738,7 @@ public class TestMITREidDataService_1_0 {
JsonReader reader = new JsonReader(new StringReader(configJson));
final Map<Long, AuthenticationHolderEntity> fakeDb = new HashMap<Long, AuthenticationHolderEntity>();
final Map<Long, AuthenticationHolderEntity> fakeDb = new HashMap<>();
when(authHolderRepository.save(isA(AuthenticationHolderEntity.class))).thenAnswer(new Answer<AuthenticationHolderEntity>() {
Long id = 356L;
@Override
@ -909,8 +909,8 @@ public class TestMITREidDataService_1_0 {
System.err.println(configJson);
JsonReader reader = new JsonReader(new StringReader(configJson));
final Map<Long, OAuth2RefreshTokenEntity> fakeRefreshTokenTable = new HashMap<Long, OAuth2RefreshTokenEntity>();
final Map<Long, AuthenticationHolderEntity> fakeAuthHolderTable = new HashMap<Long, AuthenticationHolderEntity>();
final Map<Long, OAuth2RefreshTokenEntity> fakeRefreshTokenTable = new HashMap<>();
final Map<Long, AuthenticationHolderEntity> fakeAuthHolderTable = new HashMap<>();
when(tokenRepository.saveRefreshToken(isA(OAuth2RefreshTokenEntity.class))).thenAnswer(new Answer<OAuth2RefreshTokenEntity>() {
Long id = 343L;
@Override

View File

@ -197,7 +197,7 @@ public class TestMITREidDataService_1_1 {
System.err.println(configJson);
JsonReader reader = new JsonReader(new StringReader(configJson));
final Map<Long, OAuth2RefreshTokenEntity> fakeDb = new HashMap<Long, OAuth2RefreshTokenEntity>();
final Map<Long, OAuth2RefreshTokenEntity> fakeDb = new HashMap<>();
when(tokenRepository.saveRefreshToken(isA(OAuth2RefreshTokenEntity.class))).thenAnswer(new Answer<OAuth2RefreshTokenEntity>() {
Long id = 332L;
@Override
@ -329,7 +329,7 @@ public class TestMITREidDataService_1_1 {
JsonReader reader = new JsonReader(new StringReader(configJson));
final Map<Long, OAuth2AccessTokenEntity> fakeDb = new HashMap<Long, OAuth2AccessTokenEntity>();
final Map<Long, OAuth2AccessTokenEntity> fakeDb = new HashMap<>();
when(tokenRepository.saveAccessToken(isA(OAuth2AccessTokenEntity.class))).thenAnswer(new Answer<OAuth2AccessTokenEntity>() {
Long id = 324L;
@Override
@ -544,7 +544,7 @@ public class TestMITREidDataService_1_1 {
JsonReader reader = new JsonReader(new StringReader(configJson));
final Map<Long, WhitelistedSite> fakeDb = new HashMap<Long, WhitelistedSite>();
final Map<Long, WhitelistedSite> fakeDb = new HashMap<>();
when(wlSiteRepository.save(isA(WhitelistedSite.class))).thenAnswer(new Answer<WhitelistedSite>() {
Long id = 333L;
@Override
@ -635,7 +635,7 @@ public class TestMITREidDataService_1_1 {
JsonReader reader = new JsonReader(new StringReader(configJson));
final Map<Long, ApprovedSite> fakeDb = new HashMap<Long, ApprovedSite>();
final Map<Long, ApprovedSite> fakeDb = new HashMap<>();
when(approvedSiteRepository.save(isA(ApprovedSite.class))).thenAnswer(new Answer<ApprovedSite>() {
Long id = 364L;
@Override
@ -742,7 +742,7 @@ public class TestMITREidDataService_1_1 {
JsonReader reader = new JsonReader(new StringReader(configJson));
final Map<Long, AuthenticationHolderEntity> fakeDb = new HashMap<Long, AuthenticationHolderEntity>();
final Map<Long, AuthenticationHolderEntity> fakeDb = new HashMap<>();
when(authHolderRepository.save(isA(AuthenticationHolderEntity.class))).thenAnswer(new Answer<AuthenticationHolderEntity>() {
Long id = 243L;
@Override
@ -921,8 +921,8 @@ public class TestMITREidDataService_1_1 {
System.err.println(configJson);
JsonReader reader = new JsonReader(new StringReader(configJson));
final Map<Long, OAuth2RefreshTokenEntity> fakeRefreshTokenTable = new HashMap<Long, OAuth2RefreshTokenEntity>();
final Map<Long, AuthenticationHolderEntity> fakeAuthHolderTable = new HashMap<Long, AuthenticationHolderEntity>();
final Map<Long, OAuth2RefreshTokenEntity> fakeRefreshTokenTable = new HashMap<>();
final Map<Long, AuthenticationHolderEntity> fakeAuthHolderTable = new HashMap<>();
when(tokenRepository.saveRefreshToken(isA(OAuth2RefreshTokenEntity.class))).thenAnswer(new Answer<OAuth2RefreshTokenEntity>() {
Long id = 343L;
@Override

View File

@ -237,7 +237,7 @@ public class TestMITREidDataService_1_2 {
assertThat(refreshTokens.size(), is(2));
// check for both of our refresh tokens in turn
Set<OAuth2RefreshTokenEntity> checked = new HashSet<OAuth2RefreshTokenEntity>();
Set<OAuth2RefreshTokenEntity> checked = new HashSet<>();
for (JsonElement e : refreshTokens) {
assertThat(e.isJsonObject(), is(true));
JsonObject token = e.getAsJsonObject();
@ -327,7 +327,7 @@ public class TestMITREidDataService_1_2 {
logger.debug(configJson);
JsonReader reader = new JsonReader(new StringReader(configJson));
final Map<Long, OAuth2RefreshTokenEntity> fakeDb = new HashMap<Long, OAuth2RefreshTokenEntity>();
final Map<Long, OAuth2RefreshTokenEntity> fakeDb = new HashMap<>();
when(tokenRepository.saveRefreshToken(isA(OAuth2RefreshTokenEntity.class))).thenAnswer(new Answer<OAuth2RefreshTokenEntity>() {
Long id = 332L;
@Override
@ -481,7 +481,7 @@ public class TestMITREidDataService_1_2 {
assertThat(accessTokens.size(), is(2));
// check for both of our access tokens in turn
Set<OAuth2AccessTokenEntity> checked = new HashSet<OAuth2AccessTokenEntity>();
Set<OAuth2AccessTokenEntity> checked = new HashSet<>();
for (JsonElement e : accessTokens) {
assertTrue(e.isJsonObject());
JsonObject token = e.getAsJsonObject();
@ -596,7 +596,7 @@ public class TestMITREidDataService_1_2 {
JsonReader reader = new JsonReader(new StringReader(configJson));
final Map<Long, OAuth2AccessTokenEntity> fakeDb = new HashMap<Long, OAuth2AccessTokenEntity>();
final Map<Long, OAuth2AccessTokenEntity> fakeDb = new HashMap<>();
when(tokenRepository.saveAccessToken(isA(OAuth2AccessTokenEntity.class))).thenAnswer(new Answer<OAuth2AccessTokenEntity>() {
Long id = 324L;
@Override
@ -729,7 +729,7 @@ public class TestMITREidDataService_1_2 {
assertThat(clients.size(), is(2));
// check for both of our clients in turn
Set<ClientDetailsEntity> checked = new HashSet<ClientDetailsEntity>();
Set<ClientDetailsEntity> checked = new HashSet<>();
for (JsonElement e : clients) {
assertThat(e.isJsonObject(), is(true));
JsonObject client = e.getAsJsonObject();
@ -899,7 +899,7 @@ public class TestMITREidDataService_1_2 {
assertThat(sites.size(), is(3));
// check for both of our sites in turn
Set<BlacklistedSite> checked = new HashSet<BlacklistedSite>();
Set<BlacklistedSite> checked = new HashSet<>();
for (JsonElement e : sites) {
assertThat(e.isJsonObject(), is(true));
JsonObject site = e.getAsJsonObject();
@ -1040,7 +1040,7 @@ public class TestMITREidDataService_1_2 {
assertThat(sites.size(), is(3));
// check for both of our sites in turn
Set<WhitelistedSite> checked = new HashSet<WhitelistedSite>();
Set<WhitelistedSite> checked = new HashSet<>();
for (JsonElement e : sites) {
assertThat(e.isJsonObject(), is(true));
JsonObject site = e.getAsJsonObject();
@ -1102,7 +1102,7 @@ public class TestMITREidDataService_1_2 {
JsonReader reader = new JsonReader(new StringReader(configJson));
final Map<Long, WhitelistedSite> fakeDb = new HashMap<Long, WhitelistedSite>();
final Map<Long, WhitelistedSite> fakeDb = new HashMap<>();
when(wlSiteRepository.save(isA(WhitelistedSite.class))).thenAnswer(new Answer<WhitelistedSite>() {
Long id = 333L;
@Override
@ -1222,7 +1222,7 @@ public class TestMITREidDataService_1_2 {
assertThat(sites.size(), is(2));
// check for both of our sites in turn
Set<ApprovedSite> checked = new HashSet<ApprovedSite>();
Set<ApprovedSite> checked = new HashSet<>();
for (JsonElement e : sites) {
assertThat(e.isJsonObject(), is(true));
JsonObject site = e.getAsJsonObject();
@ -1256,7 +1256,7 @@ public class TestMITREidDataService_1_2 {
assertTrue(compare.getApprovedAccessTokens() == null || compare.getApprovedAccessTokens().isEmpty());
} else {
assertNotNull(compare.getApprovedAccessTokens());
Set<String> tokenIds = new HashSet<String>();
Set<String> tokenIds = new HashSet<>();
for(OAuth2AccessTokenEntity entity : compare.getApprovedAccessTokens()) {
tokenIds.add(entity.getId().toString());
}
@ -1327,7 +1327,7 @@ public class TestMITREidDataService_1_2 {
JsonReader reader = new JsonReader(new StringReader(configJson));
final Map<Long, ApprovedSite> fakeDb = new HashMap<Long, ApprovedSite>();
final Map<Long, ApprovedSite> fakeDb = new HashMap<>();
when(approvedSiteRepository.save(isA(ApprovedSite.class))).thenAnswer(new Answer<ApprovedSite>() {
Long id = 364L;
@Override
@ -1466,7 +1466,7 @@ public class TestMITREidDataService_1_2 {
assertThat(holders.size(), is(2));
// check for both of our clients in turn
Set<AuthenticationHolderEntity> checked = new HashSet<AuthenticationHolderEntity>();
Set<AuthenticationHolderEntity> checked = new HashSet<>();
for (JsonElement e : holders) {
assertThat(e.isJsonObject(), is(true));
JsonObject holder = e.getAsJsonObject();
@ -1541,7 +1541,7 @@ public class TestMITREidDataService_1_2 {
JsonReader reader = new JsonReader(new StringReader(configJson));
final Map<Long, AuthenticationHolderEntity> fakeDb = new HashMap<Long, AuthenticationHolderEntity>();
final Map<Long, AuthenticationHolderEntity> fakeDb = new HashMap<>();
when(authHolderRepository.save(isA(AuthenticationHolderEntity.class))).thenAnswer(new Answer<AuthenticationHolderEntity>() {
Long id = 243L;
@Override
@ -1645,7 +1645,7 @@ public class TestMITREidDataService_1_2 {
assertThat(scopes.size(), is(3));
// check for both of our clients in turn
Set<SystemScope> checked = new HashSet<SystemScope>();
Set<SystemScope> checked = new HashSet<>();
for (JsonElement e : scopes) {
assertThat(e.isJsonObject(), is(true));
JsonObject scope = e.getAsJsonObject();
@ -1830,8 +1830,8 @@ public class TestMITREidDataService_1_2 {
logger.debug(configJson);
JsonReader reader = new JsonReader(new StringReader(configJson));
final Map<Long, OAuth2RefreshTokenEntity> fakeRefreshTokenTable = new HashMap<Long, OAuth2RefreshTokenEntity>();
final Map<Long, AuthenticationHolderEntity> fakeAuthHolderTable = new HashMap<Long, AuthenticationHolderEntity>();
final Map<Long, OAuth2RefreshTokenEntity> fakeRefreshTokenTable = new HashMap<>();
final Map<Long, AuthenticationHolderEntity> fakeAuthHolderTable = new HashMap<>();
when(tokenRepository.saveRefreshToken(isA(OAuth2RefreshTokenEntity.class))).thenAnswer(new Answer<OAuth2RefreshTokenEntity>() {
Long id = 343L;
@Override
@ -1889,7 +1889,7 @@ public class TestMITREidDataService_1_2 {
}
private Set<String> jsonArrayToStringSet(JsonArray a) {
Set<String> s = new HashSet<String>();
Set<String> s = new HashSet<>();
for (JsonElement jsonElement : a) {
s.add(jsonElement.getAsString());
}

View File

@ -46,7 +46,7 @@ public class UmaDiscoveryEndpoint {
@RequestMapping(".well-known/uma-configuration")
public String umaConfiguration(Model model) {
Map<String, Object> m = new HashMap<String, Object>();
Map<String, Object> m = new HashMap<>();
String issuer = config.getIssuer();
ImmutableSet<String> tokenProfiles = ImmutableSet.of("bearer");