1
0
mirror of synced 2026-08-02 16:27:08 +00:00

Use diamond type

This commit is contained in:
Johnny Lim
2017-11-20 02:25:30 +09:00
committed by Rob Winch
parent cfe40358bd
commit 57353d18e5
221 changed files with 423 additions and 428 deletions
@@ -42,7 +42,7 @@ public final class DefaultSecurityFilterChain implements SecurityFilterChain {
public DefaultSecurityFilterChain(RequestMatcher requestMatcher, List<Filter> filters) {
logger.info("Creating filter chain: " + requestMatcher + ", " + filters);
this.requestMatcher = requestMatcher;
this.filters = new ArrayList<Filter>(filters);
this.filters = new ArrayList<>(filters);
}
public RequestMatcher getRequestMatcher() {
@@ -41,7 +41,7 @@ public class PortMapperImpl implements PortMapper {
// ===================================================================================================
public PortMapperImpl() {
this.httpsPortMappings = new HashMap<Integer, Integer>();
this.httpsPortMappings = new HashMap<>();
this.httpsPortMappings.put(Integer.valueOf(80), Integer.valueOf(443));
this.httpsPortMappings.put(Integer.valueOf(8080), Integer.valueOf(8443));
}
@@ -88,7 +88,7 @@ public class ChannelDecisionManagerImpl implements ChannelDecisionManager,
@SuppressWarnings("cast")
public void setChannelProcessors(List<?> newList) {
Assert.notEmpty(newList, "A list of ChannelProcessors is required");
channelProcessors = new ArrayList<ChannelProcessor>(newList.size());
channelProcessors = new ArrayList<>(newList.size());
for (Object currentObject : newList) {
Assert.isInstanceOf(ChannelProcessor.class, currentObject,
@@ -114,7 +114,7 @@ public class ChannelProcessingFilter extends GenericFilterBean {
return;
}
Set<ConfigAttribute> unsupportedAttributes = new HashSet<ConfigAttribute>();
Set<ConfigAttribute> unsupportedAttributes = new HashSet<>();
for (ConfigAttribute attr : attrDefs) {
if (!this.channelDecisionManager.supports(attr)) {
@@ -68,7 +68,7 @@ public final class ExpressionBasedFilterInvocationSecurityMetadataSource
RequestMatcher request = entry.getKey();
Assert.isTrue(entry.getValue().size() == 1,
"Expected a single expression attribute for " + request);
ArrayList<ConfigAttribute> attributes = new ArrayList<ConfigAttribute>(1);
ArrayList<ConfigAttribute> attributes = new ArrayList<>(1);
String expression = entry.getValue().toArray(new ConfigAttribute[1])[0]
.getAttribute();
logger.debug("Adding web access control expression '" + expression + "', for "
@@ -78,7 +78,7 @@ public class DefaultFilterInvocationSecurityMetadataSource implements
// ========================================================================================================
public Collection<ConfigAttribute> getAllConfigAttributes() {
Set<ConfigAttribute> allAttributes = new HashSet<ConfigAttribute>();
Set<ConfigAttribute> allAttributes = new HashSet<>();
for (Map.Entry<RequestMatcher, Collection<ConfigAttribute>> entry : requestMap
.entrySet()) {
@@ -42,7 +42,7 @@ import org.springframework.util.Assert;
*/
public class ExceptionMappingAuthenticationFailureHandler extends
SimpleUrlAuthenticationFailureHandler {
private final Map<String, String> failureUrlMap = new HashMap<String, String>();
private final Map<String, String> failureUrlMap = new HashMap<>();
@Override
public void onAuthenticationFailure(HttpServletRequest request,
@@ -42,7 +42,7 @@ public class PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails extends
HttpServletRequest request, Collection<? extends GrantedAuthority> authorities) {
super(request);
List<GrantedAuthority> temp = new ArrayList<GrantedAuthority>(authorities.size());
List<GrantedAuthority> temp = new ArrayList<>(authorities.size());
temp.addAll(authorities);
this.authorities = Collections.unmodifiableList(temp);
}
@@ -67,7 +67,7 @@ public class J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource
* making the request.
*/
protected Collection<String> getUserRoles(HttpServletRequest request) {
ArrayList<String> j2eeUserRolesList = new ArrayList<String>();
ArrayList<String> j2eeUserRolesList = new ArrayList<>();
for (String role : j2eeMappableRoles) {
if (request.isUserInRole(role)) {
@@ -82,7 +82,7 @@ public class WebXmlMappableAttributesRetriever implements ResourceLoaderAware,
NodeList securityRoles = ((Element) webApp.item(0))
.getElementsByTagName("security-role");
ArrayList<String> roleNames = new ArrayList<String>();
ArrayList<String> roleNames = new ArrayList<>();
for (int i = 0; i < securityRoles.getLength(); i++) {
Element secRoleElt = (Element) securityRoles.item(i);
@@ -98,7 +98,7 @@ public class WebXmlMappableAttributesRetriever implements ResourceLoaderAware,
}
}
mappableAttributes = Collections.unmodifiableSet(new HashSet<String>(roleNames));
mappableAttributes = Collections.unmodifiableSet(new HashSet<>(roleNames));
}
/**
@@ -29,7 +29,7 @@ import java.util.Map;
* @author Luke Taylor
*/
public class InMemoryTokenRepositoryImpl implements PersistentTokenRepository {
private final Map<String, PersistentRememberMeToken> seriesTokens = new HashMap<String, PersistentRememberMeToken>();
private final Map<String, PersistentRememberMeToken> seriesTokens = new HashMap<>();
public synchronized void createNewToken(PersistentRememberMeToken token) {
PersistentRememberMeToken current = seriesTokens.get(token.getSeries());
@@ -117,7 +117,7 @@ public class SessionFixationProtectionStrategy extends
@SuppressWarnings("unchecked")
private HashMap<String, Object> createMigratedAttributeMap(HttpSession session) {
HashMap<String, Object> attributesToMigrate = new HashMap<String, Object>();
HashMap<String, Object> attributesToMigrate = new HashMap<>();
Enumeration enumer = session.getAttributeNames();
@@ -335,7 +335,7 @@ public class SwitchUserFilter extends GenericFilterBean
}
// add the new switch user authority
List<GrantedAuthority> newAuths = new ArrayList<GrantedAuthority>(orig);
List<GrantedAuthority> newAuths = new ArrayList<>(orig);
newAuths.add(switchAuthority);
// create the new authentication token
@@ -47,7 +47,7 @@ final class DigestAuthUtils {
return EMPTY_STRING_ARRAY;
}
List<String> list = new ArrayList<String>();
List<String> list = new ArrayList<>();
int i = 0;
int start = 0;
boolean match = false;
@@ -158,7 +158,7 @@ final class DigestAuthUtils {
return null;
}
Map<String, String> map = new HashMap<String, String>();
Map<String, String> map = new HashMap<>();
for (String s : array) {
String postRemove;
@@ -160,7 +160,7 @@ public final class CsrfFilter extends OncePerRequestFilter {
}
private static final class DefaultRequiresCsrfMatcher implements RequestMatcher {
private final HashSet<String> allowedMethods = new HashSet<String>(
private final HashSet<String> allowedMethods = new HashSet<>(
Arrays.asList("GET", "HEAD", "TRACE", "OPTIONS"));
/*
@@ -74,7 +74,7 @@ public final class CacheControlHeadersWriter implements HeaderWriter {
}
private static List<Header> createHeaders() {
List<Header> headers = new ArrayList<Header>(2);
List<Header> headers = new ArrayList<>(2);
headers.add(new Header(CACHE_CONTROL,
"no-cache, no-store, max-age=0, must-revalidate"));
headers.add(new Header(PRAGMA, "no-cache"));
@@ -113,7 +113,7 @@ public final class HpkpHeaderWriter implements HeaderWriter {
private final RequestMatcher requestMatcher = new SecureRequestMatcher();
private Map<String, String> pins = new LinkedHashMap<String, String>();
private Map<String, String> pins = new LinkedHashMap<>();
private long maxAgeInSeconds;
@@ -106,7 +106,7 @@ public class ReferrerPolicyHeaderWriter implements HeaderWriter {
private static final Map<String, ReferrerPolicy> REFERRER_POLICIES;
static {
Map<String, ReferrerPolicy> referrerPolicies = new HashMap<String, ReferrerPolicy>();
Map<String, ReferrerPolicy> referrerPolicies = new HashMap<>();
for (ReferrerPolicy referrerPolicy : values()) {
referrerPolicies.put(referrerPolicy.getPolicy(), referrerPolicy);
}
@@ -62,11 +62,11 @@ public class DefaultSavedRequest implements SavedRequest {
// ~ Instance fields
// ================================================================================================
private final ArrayList<SavedCookie> cookies = new ArrayList<SavedCookie>();
private final ArrayList<Locale> locales = new ArrayList<Locale>();
private final Map<String, List<String>> headers = new TreeMap<String, List<String>>(
private final ArrayList<SavedCookie> cookies = new ArrayList<>();
private final ArrayList<Locale> locales = new ArrayList<>();
private final Map<String, List<String>> headers = new TreeMap<>(
String.CASE_INSENSITIVE_ORDER);
private final Map<String, String[]> parameters = new TreeMap<String, String[]>();
private final Map<String, String[]> parameters = new TreeMap<>();
private final String contextPath;
private final String method;
private final String pathInfo;
@@ -163,7 +163,7 @@ public class DefaultSavedRequest implements SavedRequest {
List<String> values = headers.get(name);
if (values == null) {
values = new ArrayList<String>();
values = new ArrayList<>();
headers.put(name, values);
}
@@ -407,8 +407,8 @@ public class DefaultSavedRequest implements SavedRequest {
private List<SavedCookie> cookies = null;
private List<Locale> locales = null;
private Map<String, List<String>> headers = new TreeMap<String, List<String>>(String.CASE_INSENSITIVE_ORDER);
private Map<String, String[]> parameters = new TreeMap<String, String[]>();
private Map<String, List<String>> headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
private Map<String, String[]> parameters = new TreeMap<>();
private String contextPath;
private String method;
private String pathInfo;
@@ -92,7 +92,7 @@ public class Enumerator<T> implements Enumeration<T> {
this.iterator = iterator;
}
else {
List<T> list = new ArrayList<T>();
List<T> list = new ArrayList<>();
while (iterator.hasNext()) {
list.add(iterator.next());
@@ -65,10 +65,10 @@ public class FastHttpDateFormat {
protected static String currentDate = null;
/** Formatter cache. */
protected static final HashMap<Long, String> formatCache = new HashMap<Long, String>();
protected static final HashMap<Long, String> formatCache = new HashMap<>();
/** Parser cache. */
protected static final HashMap<String, Long> parseCache = new HashMap<String, Long>();
protected static final HashMap<String, Long> parseCache = new HashMap<>();
// ~ Methods
// ========================================================================================================
@@ -121,13 +121,13 @@ class SavedRequestAwareWrapper extends HttpServletRequestWrapper {
@Override
@SuppressWarnings("unchecked")
public Enumeration getHeaderNames() {
return new Enumerator<String>(savedRequest.getHeaderNames());
return new Enumerator<>(savedRequest.getHeaderNames());
}
@Override
@SuppressWarnings("unchecked")
public Enumeration getHeaders(String name) {
return new Enumerator<String>(savedRequest.getHeaderValues(name));
return new Enumerator<>(savedRequest.getHeaderValues(name));
}
@Override
@@ -156,11 +156,11 @@ class SavedRequestAwareWrapper extends HttpServletRequestWrapper {
if (locales.isEmpty()) {
// Fall back to default locale
locales = new ArrayList<Locale>(1);
locales = new ArrayList<>(1);
locales.add(Locale.getDefault());
}
return new Enumerator<Locale>(locales);
return new Enumerator<>(locales);
}
@Override
@@ -199,7 +199,7 @@ class SavedRequestAwareWrapper extends HttpServletRequestWrapper {
@SuppressWarnings("unchecked")
public Map getParameterMap() {
Set<String> names = getCombinedParameterNames();
Map<String, String[]> parameterMap = new HashMap<String, String[]>(names.size());
Map<String, String[]> parameterMap = new HashMap<>(names.size());
for (String name : names) {
parameterMap.put(name, getParameterValues(name));
@@ -210,7 +210,7 @@ class SavedRequestAwareWrapper extends HttpServletRequestWrapper {
@SuppressWarnings("unchecked")
private Set<String> getCombinedParameterNames() {
Set<String> names = new HashSet<String>();
Set<String> names = new HashSet<>();
names.addAll(super.getParameterMap().keySet());
names.addAll(savedRequest.getParameterMap().keySet());
@@ -238,7 +238,7 @@ class SavedRequestAwareWrapper extends HttpServletRequestWrapper {
// We have parameters in both saved and wrapped requests so have to merge them
List<String> wrappedParamsList = Arrays.asList(wrappedRequestParams);
List<String> combinedParams = new ArrayList<String>(wrappedParamsList);
List<String> combinedParams = new ArrayList<>(wrappedParamsList);
// We want to add all parameters of the saved request *apart from* duplicates of
// those already added
@@ -67,7 +67,7 @@ public final class CsrfRequestDataValueProcessor implements RequestDataValueProc
if (token == null) {
return Collections.emptyMap();
}
Map<String, String> hiddenFields = new HashMap<String, String>(1);
Map<String, String> hiddenFields = new HashMap<>(1);
hiddenFields.put(token.getParameterName(), token.getToken());
return hiddenFields;
}
@@ -75,4 +75,4 @@ public final class CsrfRequestDataValueProcessor implements RequestDataValueProc
public String processUrl(HttpServletRequest request, String url) {
return url;
}
}
}
@@ -50,7 +50,7 @@ public class HttpSessionDestroyedEvent extends SessionDestroyedEvent {
Enumeration<String> attributes = session.getAttributeNames();
ArrayList<SecurityContext> contexts = new ArrayList<SecurityContext>();
ArrayList<SecurityContext> contexts = new ArrayList<>();
while (attributes.hasMoreElements()) {
String attributeName = attributes.nextElement();
@@ -174,7 +174,7 @@ public class ThrowableAnalyzer {
throw new IllegalArgumentException("Invalid throwable: null");
}
List<Throwable> chain = new ArrayList<Throwable>();
List<Throwable> chain = new ArrayList<>();
Throwable currentThrowable = throwable;
while (currentThrowable != null) {
@@ -51,7 +51,7 @@ public class PortMapperImplTests {
PortMapperImpl portMapper = new PortMapperImpl();
try {
portMapper.setPortMappings(new HashMap<String, String>());
portMapper.setPortMappings(new HashMap<>());
fail("Should have thrown IllegalArgumentException");
}
catch (IllegalArgumentException expected) {
@@ -81,7 +81,7 @@ public class PortMapperImplTests {
@Test
public void testRejectsOutOfRangeMappings() {
PortMapperImpl portMapper = new PortMapperImpl();
Map<String, String> map = new HashMap<String, String>();
Map<String, String> map = new HashMap<>();
map.put("79", "80559");
try {
@@ -102,7 +102,7 @@ public class PortMapperImplTests {
@Test
public void testSupportsCustomMappings() {
PortMapperImpl portMapper = new PortMapperImpl();
Map<String, String> map = new HashMap<String, String>();
Map<String, String> map = new HashMap<>();
map.put("79", "442");
portMapper.setPortMappings(map);
@@ -148,7 +148,7 @@ public class RetryWithHttpEntryPointTests {
MockHttpServletResponse response = new MockHttpServletResponse();
PortMapperImpl portMapper = new PortMapperImpl();
Map<String, String> map = new HashMap<String, String>();
Map<String, String> map = new HashMap<>();
map.put("8888", "9999");
portMapper.setPortMappings(map);
@@ -138,7 +138,7 @@ public class RetryWithHttpsEntryPointTests {
MockHttpServletResponse response = new MockHttpServletResponse();
PortMapperImpl portMapper = new PortMapperImpl();
Map<String, String> map = new HashMap<String, String>();
Map<String, String> map = new HashMap<>();
map.put("8888", "9999");
portMapper.setPortMappings(map);
@@ -60,7 +60,7 @@ public class DelegatingEvaluationContextTests {
@Test
public void getConstructorResolvers() {
List<ConstructorResolver> expected = new ArrayList<ConstructorResolver>();
List<ConstructorResolver> expected = new ArrayList<>();
when(this.delegate.getConstructorResolvers()).thenReturn(expected);
assertThat(this.context.getConstructorResolvers()).isEqualTo(expected);
@@ -68,7 +68,7 @@ public class DelegatingEvaluationContextTests {
@Test
public void getMethodResolvers() {
List<MethodResolver> expected = new ArrayList<MethodResolver>();
List<MethodResolver> expected = new ArrayList<>();
when(this.delegate.getMethodResolvers()).thenReturn(expected);
assertThat(this.context.getMethodResolvers()).isEqualTo(expected);
@@ -76,7 +76,7 @@ public class DelegatingEvaluationContextTests {
@Test
public void getPropertyAccessors() {
List<PropertyAccessor> expected = new ArrayList<PropertyAccessor>();
List<PropertyAccessor> expected = new ArrayList<>();
when(this.delegate.getPropertyAccessors()).thenReturn(expected);
assertThat(this.context.getPropertyAccessors()).isEqualTo(expected);
@@ -44,7 +44,7 @@ public class DelegatingAuthenticationEntryPointTests {
@Before
public void before() {
defaultEntryPoint = mock(AuthenticationEntryPoint.class);
entryPoints = new LinkedHashMap<RequestMatcher, AuthenticationEntryPoint>();
entryPoints = new LinkedHashMap<>();
daep = new DelegatingAuthenticationEntryPoint(entryPoints);
daep.setDefaultEntryPoint(defaultEntryPoint);
}
@@ -43,7 +43,7 @@ public class ExceptionMappingAuthenticationFailureHandlerTests {
@Test
public void exceptionMapIsUsedIfMappingExists() throws Exception {
ExceptionMappingAuthenticationFailureHandler fh = new ExceptionMappingAuthenticationFailureHandler();
HashMap<String, String> mapping = new HashMap<String, String>();
HashMap<String, String> mapping = new HashMap<>();
mapping.put(
"org.springframework.security.authentication.BadCredentialsException",
"/badcreds");
@@ -109,7 +109,7 @@ public class LoginUrlAuthenticationEntryPointTests {
assertThat(response.getRedirectedUrl()).isEqualTo("https://www.example.com:8443/bigWebApp/hello");
PortMapperImpl portMapper = new PortMapperImpl();
Map<String, String> map = new HashMap<String, String>();
Map<String, String> map = new HashMap<>();
map.put("8888", "9999");
portMapper.setPortMappings(map);
response = new MockHttpServletResponse();
@@ -63,7 +63,7 @@ public class DelegatingLogoutSuccessHandlerTests {
@Before
public void setup() {
LinkedHashMap<RequestMatcher, LogoutSuccessHandler> matcherToHandler = new LinkedHashMap<RequestMatcher, LogoutSuccessHandler>();
LinkedHashMap<RequestMatcher, LogoutSuccessHandler> matcherToHandler = new LinkedHashMap<>();
matcherToHandler.put(this.matcher, this.handler);
matcherToHandler.put(this.matcher2, this.handler2);
this.delegatingHandler = new DelegatingLogoutSuccessHandler(matcherToHandler);
@@ -55,7 +55,7 @@ public class PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetailsTests {
private HttpServletRequest getRequest(final String userName, final String[] aRoles) {
MockHttpServletRequest req = new MockHttpServletRequest() {
private Set<String> roles = new HashSet<String>(Arrays.asList(aRoles));
private Set<String> roles = new HashSet<>(Arrays.asList(aRoles));
public boolean isUserInRole(String arg0) {
return roles.contains(arg0);
@@ -127,7 +127,7 @@ public class J2eeBasedPreAuthenticatedWebAuthenticationDetailsSourceTests {
assertThat(gas).hasSize(expectedRoles.length);
Collection<String> expectedRolesColl = Arrays.asList(expectedRoles);
Collection<String> gasRolesSet = new HashSet<String>();
Collection<String> gasRolesSet = new HashSet<>();
for (int i = 0; i < gas.size(); i++) {
gasRolesSet.add(gas.get(i).getAuthority());
}
@@ -170,7 +170,7 @@ public class J2eeBasedPreAuthenticatedWebAuthenticationDetailsSourceTests {
private HttpServletRequest getRequest(final String userName, final String[] aRoles) {
MockHttpServletRequest req = new MockHttpServletRequest() {
private Set<String> roles = new HashSet<String>(Arrays.asList(aRoles));
private Set<String> roles = new HashSet<>(Arrays.asList(aRoles));
public boolean isUserInRole(String arg0) {
return roles.contains(arg0);
@@ -53,7 +53,7 @@ public class J2eePreAuthenticatedProcessingFilterTests {
final String[] aRoles) {
MockHttpServletRequest req = new MockHttpServletRequest() {
private Set<String> roles = new HashSet<String>(Arrays.asList(aRoles));
private Set<String> roles = new HashSet<>(Arrays.asList(aRoles));
public boolean isUserInRole(String arg0) {
return roles.contains(arg0);
@@ -232,7 +232,7 @@ public class SwitchUserFilterTests {
"dano", "hawaii50", ROLES_12);
// set current user (Admin)
List<GrantedAuthority> adminAuths = new ArrayList<GrantedAuthority>();
List<GrantedAuthority> adminAuths = new ArrayList<>();
adminAuths.addAll(ROLES_12);
adminAuths.add(new SwitchUserGrantedAuthority("PREVIOUS_ADMINISTRATOR", source));
UsernamePasswordAuthenticationToken admin = new UsernamePasswordAuthenticationToken(
@@ -394,7 +394,7 @@ public class SwitchUserFilterTests {
public Collection<GrantedAuthority> modifyGrantedAuthorities(
UserDetails targetUser, Authentication currentAuthentication,
Collection<? extends GrantedAuthority> authoritiesToBeGranted) {
List<GrantedAuthority> auths = new ArrayList<GrantedAuthority>();
List<GrantedAuthority> auths = new ArrayList<>();
auths.add(new SimpleGrantedAuthority("ROLE_NEW"));
return auths;
}
@@ -33,7 +33,7 @@ import org.springframework.mock.web.MockHttpServletRequest;
* @author Luke Taylor
*/
public class RequestWrapperTests {
private static Map<String, String> testPaths = new LinkedHashMap<String, String>();
private static Map<String, String> testPaths = new LinkedHashMap<>();
@BeforeClass
// Some of these may be unrealistic values, but we can't be sure because of the
@@ -48,7 +48,7 @@ public class HeaderWriterFilterTests {
@Test(expected = IllegalArgumentException.class)
public void noHeadersConfigured() throws Exception {
List<HeaderWriter> headerWriters = new ArrayList<HeaderWriter>();
List<HeaderWriter> headerWriters = new ArrayList<>();
new HeaderWriterFilter(headerWriters);
}
@@ -59,7 +59,7 @@ public class HeaderWriterFilterTests {
@Test
public void additionalHeadersShouldBeAddedToTheResponse() throws Exception {
List<HeaderWriter> headerWriters = new ArrayList<HeaderWriter>();
List<HeaderWriter> headerWriters = new ArrayList<>();
headerWriters.add(writer1);
headerWriters.add(writer2);
@@ -37,7 +37,7 @@ public class HpkpHeaderWriterTests {
private static final Map<String, String> DEFAULT_PINS;
static
{
Map<String, String> defaultPins = new LinkedHashMap<String, String>();
Map<String, String> defaultPins = new LinkedHashMap<>();
defaultPins.put("d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=", "sha256");
DEFAULT_PINS = Collections.unmodifiableMap(defaultPins);
}
@@ -54,7 +54,7 @@ public class HpkpHeaderWriterTests {
writer = new HpkpHeaderWriter();
Map<String, String> defaultPins = new LinkedHashMap<String, String>();
Map<String, String> defaultPins = new LinkedHashMap<>();
defaultPins.put("d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=", "sha256");
writer.setPins(defaultPins);
@@ -33,7 +33,7 @@ public class WhiteListedAllowFromStrategyTests {
@Test(expected = IllegalArgumentException.class)
public void emptyListShouldThrowException() {
new WhiteListedAllowFromStrategy(new ArrayList<String>());
new WhiteListedAllowFromStrategy(new ArrayList<>());
}
@Test(expected = IllegalArgumentException.class)
@@ -43,7 +43,7 @@ public class WhiteListedAllowFromStrategyTests {
@Test
public void listWithSingleElementShouldMatch() {
List<String> allowed = new ArrayList<String>();
List<String> allowed = new ArrayList<>();
allowed.add("http://www.test.com");
WhiteListedAllowFromStrategy strategy = new WhiteListedAllowFromStrategy(allowed);
strategy.setAllowFromParameterName("from");
@@ -56,7 +56,7 @@ public class WhiteListedAllowFromStrategyTests {
@Test
public void listWithMultipleElementShouldMatch() {
List<String> allowed = new ArrayList<String>();
List<String> allowed = new ArrayList<>();
allowed.add("http://www.test.com");
allowed.add("http://www.springsource.org");
WhiteListedAllowFromStrategy strategy = new WhiteListedAllowFromStrategy(allowed);
@@ -70,7 +70,7 @@ public class WhiteListedAllowFromStrategyTests {
@Test
public void listWithSingleElementShouldNotMatch() {
List<String> allowed = new ArrayList<String>();
List<String> allowed = new ArrayList<>();
allowed.add("http://www.test.com");
WhiteListedAllowFromStrategy strategy = new WhiteListedAllowFromStrategy(allowed);
strategy.setAllowFromParameterName("from");
@@ -83,7 +83,7 @@ public class WhiteListedAllowFromStrategyTests {
@Test
public void requestWithoutParameterShouldNotMatch() {
List<String> allowed = new ArrayList<String>();
List<String> allowed = new ArrayList<>();
allowed.add("http://www.test.com");
WhiteListedAllowFromStrategy strategy = new WhiteListedAllowFromStrategy(allowed);
strategy.setAllowFromParameterName("from");
@@ -122,7 +122,7 @@ public class JaasApiIntegrationFilterTests {
public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
return new AppConfigurationEntry[] { new AppConfigurationEntry(
TestLoginModule.class.getName(), LoginModuleControlFlag.REQUIRED,
new HashMap<String, String>()) };
new HashMap<>()) };
}
};
LoginContext ctx = new LoginContext("SubjectDoAsFilterTest", authenticatedSubject,
@@ -75,7 +75,7 @@ public class SavedCookieMixinTests extends AbstractMixinTests {
@Test
public void serializeSavedCookieWithList() throws JsonProcessingException, JSONException {
List<SavedCookie> savedCookies = new ArrayList<SavedCookie>();
List<SavedCookie> savedCookies = new ArrayList<>();
savedCookies.add(new SavedCookie(new Cookie("SESSION", "123456789")));
String actualJson = mapper.writeValueAsString(savedCookies);
JSONAssert.assertEquals(COOKIES_JSON, actualJson, true);
@@ -42,7 +42,7 @@ public class CsrfRequestDataValueProcessorTests {
private CsrfRequestDataValueProcessor processor = new CsrfRequestDataValueProcessor();
private CsrfToken token = new DefaultCsrfToken("1", "a", "b");
private Map<String, String> expected = new HashMap<String, String>();
private Map<String, String> expected = new HashMap<>();
@Before
public void setup() {
@@ -39,7 +39,7 @@ public class CsrfRequestDataValueProcessorTests {
private CsrfRequestDataValueProcessor processor;
private CsrfToken token;
private Map<String, String> expected = new HashMap<String, String>();
private Map<String, String> expected = new HashMap<>();
@Before
public void setup() {
@@ -129,7 +129,7 @@ public class CsrfRequestDataValueProcessorTests {
public void createGetExtraHiddenFieldsHasCsrfToken() {
CsrfToken token = new DefaultCsrfToken("1", "a", "b");
request.setAttribute(CsrfToken.class.getName(), token);
Map<String, String> expected = new HashMap<String, String>();
Map<String, String> expected = new HashMap<>();
expected.put(token.getParameterName(), token.getToken());
RequestDataValueProcessor processor = new CsrfRequestDataValueProcessor();