diff --git a/module-client/src/main/java/org/apache/http/auth/AuthSchemeRegistry.java b/module-client/src/main/java/org/apache/http/auth/AuthSchemeRegistry.java index d3b4d2e72..41a84e5cc 100644 --- a/module-client/src/main/java/org/apache/http/auth/AuthSchemeRegistry.java +++ b/module-client/src/main/java/org/apache/http/auth/AuthSchemeRegistry.java @@ -49,8 +49,12 @@ import org.apache.http.params.HttpParams; */ public final class AuthSchemeRegistry { - private final Map registeredSchemes = - new LinkedHashMap(); + private final Map registeredSchemes; + + public AuthSchemeRegistry() { + super(); + this.registeredSchemes = new LinkedHashMap(); + } /** * Registers a {@link AuthSchemeFactory} with the given identifier. If a factory with the diff --git a/module-client/src/main/java/org/apache/http/client/AuthenticationHandler.java b/module-client/src/main/java/org/apache/http/client/AuthenticationHandler.java index a14d89d20..49529c189 100644 --- a/module-client/src/main/java/org/apache/http/client/AuthenticationHandler.java +++ b/module-client/src/main/java/org/apache/http/client/AuthenticationHandler.java @@ -33,6 +33,7 @@ package org.apache.http.client; import java.util.Map; +import org.apache.http.Header; import org.apache.http.HttpResponse; import org.apache.http.auth.AuthScheme; import org.apache.http.auth.AuthenticationException; @@ -44,12 +45,17 @@ import org.apache.http.protocol.HttpContext; */ public interface AuthenticationHandler { - boolean isAuthenticationRequested(HttpResponse response, HttpContext context); + boolean isAuthenticationRequested( + HttpResponse response, + HttpContext context); - Map getChallenges(HttpResponse response, HttpContext context) - throws MalformedChallengeException; + Map getChallenges( + HttpResponse response, + HttpContext context) throws MalformedChallengeException; - AuthScheme selectScheme(Map challenges, HttpResponse response, HttpContext context) - throws AuthenticationException; + AuthScheme selectScheme( + Map challenges, + HttpResponse response, + HttpContext context) throws AuthenticationException; } diff --git a/module-client/src/main/java/org/apache/http/client/methods/HttpOptions.java b/module-client/src/main/java/org/apache/http/client/methods/HttpOptions.java index 0eb5c132c..4459797d0 100644 --- a/module-client/src/main/java/org/apache/http/client/methods/HttpOptions.java +++ b/module-client/src/main/java/org/apache/http/client/methods/HttpOptions.java @@ -82,13 +82,13 @@ public class HttpOptions extends HttpRequestBase { return METHOD_NAME; } - public Set getAllowedMethods(final HttpResponse response) { + public Set getAllowedMethods(final HttpResponse response) { if (response == null) { throw new IllegalArgumentException("HTTP response may not be null"); } HeaderIterator it = response.headerIterator("Allow"); - Set methods = new HashSet(); + Set methods = new HashSet(); while (it.hasNext()) { Header header = it.nextHeader(); HeaderElement[] elements = header.getElements(); diff --git a/module-client/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java b/module-client/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java index ac44750bf..99c1e4845 100644 --- a/module-client/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java +++ b/module-client/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java @@ -148,7 +148,7 @@ public class RequestAddCookies implements HttpRequestInterceptor { // Get all cookies available in the HTTP state Cookie[] cookies = cookieStore.getCookies(); // Find cookies matching the given origin - List matchedCookies = new ArrayList(cookies.length); + List matchedCookies = new ArrayList(cookies.length); for (int i = 0; i < cookies.length; i++) { Cookie cookie = cookies[i]; if (cookieSpec.match(cookie, cookieOrigin)) { @@ -159,7 +159,7 @@ public class RequestAddCookies implements HttpRequestInterceptor { } } // Generate Cookie request headers - cookies = (Cookie[]) matchedCookies.toArray(new Cookie[matchedCookies.size()]); + cookies = matchedCookies.toArray(new Cookie[matchedCookies.size()]); if (cookies.length > 0) { Header[] headers = cookieSpec.formatCookies(cookies); for (int i = 0; i < headers.length; i++) { diff --git a/module-client/src/main/java/org/apache/http/client/protocol/RequestDefaultHeaders.java b/module-client/src/main/java/org/apache/http/client/protocol/RequestDefaultHeaders.java index f10a7fadc..268a21946 100644 --- a/module-client/src/main/java/org/apache/http/client/protocol/RequestDefaultHeaders.java +++ b/module-client/src/main/java/org/apache/http/client/protocol/RequestDefaultHeaders.java @@ -63,10 +63,10 @@ public class RequestDefaultHeaders implements HttpRequestInterceptor { throw new IllegalArgumentException("HTTP request may not be null"); } // Add default headers - Collection defHeaders = (Collection) request.getParams().getParameter( + Collection defHeaders = (Collection) request.getParams().getParameter( ClientPNames.DEFAULT_HEADERS); if (defHeaders != null) { - for (Iterator it = defHeaders.iterator(); it.hasNext(); ) { + for (Iterator it = defHeaders.iterator(); it.hasNext(); ) { request.addHeader((Header) it.next()); } } diff --git a/module-client/src/main/java/org/apache/http/conn/SchemeRegistry.java b/module-client/src/main/java/org/apache/http/conn/SchemeRegistry.java index 730c3674c..ef2d1f0d8 100644 --- a/module-client/src/main/java/org/apache/http/conn/SchemeRegistry.java +++ b/module-client/src/main/java/org/apache/http/conn/SchemeRegistry.java @@ -166,7 +166,7 @@ public final class SchemeRegistry { * * @return List containing registered scheme names. */ - public synchronized final List getSchemeNames() { + public synchronized final List getSchemeNames() { return new ArrayList(registeredSchemes.keySet()); } diff --git a/module-client/src/main/java/org/apache/http/cookie/CookieIdentityComparator.java b/module-client/src/main/java/org/apache/http/cookie/CookieIdentityComparator.java index b9463aaf5..414d3e897 100644 --- a/module-client/src/main/java/org/apache/http/cookie/CookieIdentityComparator.java +++ b/module-client/src/main/java/org/apache/http/cookie/CookieIdentityComparator.java @@ -43,11 +43,9 @@ import java.util.Comparator; * * @author Oleg Kalnichevski */ -public class CookieIdentityComparator implements Comparator { +public class CookieIdentityComparator implements Comparator { - public int compare(final Object o1, final Object o2) { - Cookie c1 = (Cookie) o1; - Cookie c2 = (Cookie) o2; + public int compare(final Cookie c1, final Cookie c2) { int res = c1.getName().compareTo(c2.getName()); if (res == 0) { // do not differentiate empty and null domains diff --git a/module-client/src/main/java/org/apache/http/cookie/CookiePathComparator.java b/module-client/src/main/java/org/apache/http/cookie/CookiePathComparator.java index 866ae9295..b38b2fa5c 100644 --- a/module-client/src/main/java/org/apache/http/cookie/CookiePathComparator.java +++ b/module-client/src/main/java/org/apache/http/cookie/CookiePathComparator.java @@ -47,7 +47,7 @@ import java.util.Comparator; * * @author Oleg Kalnichevski */ -public class CookiePathComparator implements Comparator { +public class CookiePathComparator implements Comparator { private String normalizePath(final Cookie cookie) { String path = cookie.getPath(); @@ -60,9 +60,7 @@ public class CookiePathComparator implements Comparator { return path; } - public int compare(final Object o1, final Object o2) { - Cookie c1 = (Cookie) o1; - Cookie c2 = (Cookie) o2; + public int compare(final Cookie c1, final Cookie c2) { String path1 = normalizePath(c1); String path2 = normalizePath(c2); if (path1.equals(path2)) { diff --git a/module-client/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java b/module-client/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java index 34816678d..5e0a245a2 100644 --- a/module-client/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java +++ b/module-client/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java @@ -138,7 +138,7 @@ public final class CookieSpecRegistry { * * @return list of registered cookie spec names */ - public synchronized List getSpecNames(){ + public synchronized List getSpecNames(){ return new ArrayList(registeredSpecs.keySet()); } diff --git a/module-client/src/main/java/org/apache/http/impl/client/AbstractAuthenticationHandler.java b/module-client/src/main/java/org/apache/http/impl/client/AbstractAuthenticationHandler.java index 78da9fd75..a39f11db9 100644 --- a/module-client/src/main/java/org/apache/http/impl/client/AbstractAuthenticationHandler.java +++ b/module-client/src/main/java/org/apache/http/impl/client/AbstractAuthenticationHandler.java @@ -59,7 +59,7 @@ public abstract class AbstractAuthenticationHandler implements AuthenticationHan private static final Log LOG = LogFactory.getLog(AbstractAuthenticationHandler.class); - private static List DEFAULT_SCHEME_PRIORITY = Arrays.asList(new String[] { + private static List DEFAULT_SCHEME_PRIORITY = Arrays.asList(new String[] { "digest", "basic" }); @@ -68,10 +68,10 @@ public abstract class AbstractAuthenticationHandler implements AuthenticationHan super(); } - protected Map parseChallenges( + protected Map parseChallenges( final Header[] headers) throws MalformedChallengeException { - Map map = new HashMap(headers.length); + Map map = new HashMap(headers.length); for (int i = 0; i < headers.length; i++) { Header header = headers[i]; CharArrayBuffer buffer; @@ -102,12 +102,12 @@ public abstract class AbstractAuthenticationHandler implements AuthenticationHan return map; } - protected List getAuthPreferences() { + protected List getAuthPreferences() { return DEFAULT_SCHEME_PRIORITY; } public AuthScheme selectScheme( - final Map challenges, + final Map challenges, final HttpResponse response, final HttpContext context) throws AuthenticationException { @@ -117,15 +117,15 @@ public abstract class AbstractAuthenticationHandler implements AuthenticationHan throw new IllegalStateException("AuthScheme registry not set in HTTP context"); } - List authPrefs = getAuthPreferences(); + List authPrefs = getAuthPreferences(); if (LOG.isDebugEnabled()) { LOG.debug("Supported authentication schemes in the order of preference: " + authPrefs); } AuthScheme authScheme = null; - for (Iterator it = authPrefs.iterator(); it.hasNext(); ) { - String id = (String) it.next(); + for (Iterator it = authPrefs.iterator(); it.hasNext(); ) { + String id = it.next(); Header challenge = (Header) challenges.get(id.toLowerCase()); if (challenge != null) { if (LOG.isDebugEnabled()) {