More generics all over
git-svn-id: https://svn.apache.org/repos/asf/jakarta/httpcomponents/httpclient/trunk@603318 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3337029c96
commit
89ffb0f780
|
@ -49,8 +49,12 @@ import org.apache.http.params.HttpParams;
|
|||
*/
|
||||
public final class AuthSchemeRegistry {
|
||||
|
||||
private final Map<String,AuthSchemeFactory> registeredSchemes =
|
||||
new LinkedHashMap<String,AuthSchemeFactory>();
|
||||
private final Map<String,AuthSchemeFactory> registeredSchemes;
|
||||
|
||||
public AuthSchemeRegistry() {
|
||||
super();
|
||||
this.registeredSchemes = new LinkedHashMap<String,AuthSchemeFactory>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a {@link AuthSchemeFactory} with the given identifier. If a factory with the
|
||||
|
|
|
@ -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<String, Header> getChallenges(
|
||||
HttpResponse response,
|
||||
HttpContext context) throws MalformedChallengeException;
|
||||
|
||||
AuthScheme selectScheme(Map challenges, HttpResponse response, HttpContext context)
|
||||
throws AuthenticationException;
|
||||
AuthScheme selectScheme(
|
||||
Map<String, Header> challenges,
|
||||
HttpResponse response,
|
||||
HttpContext context) throws AuthenticationException;
|
||||
|
||||
}
|
||||
|
|
|
@ -82,13 +82,13 @@ public class HttpOptions extends HttpRequestBase {
|
|||
return METHOD_NAME;
|
||||
}
|
||||
|
||||
public Set getAllowedMethods(final HttpResponse response) {
|
||||
public Set<String> 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<String> methods = new HashSet<String>();
|
||||
while (it.hasNext()) {
|
||||
Header header = it.nextHeader();
|
||||
HeaderElement[] elements = header.getElements();
|
||||
|
|
|
@ -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<Cookie> matchedCookies = new ArrayList<Cookie>(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++) {
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@ public final class SchemeRegistry {
|
|||
*
|
||||
* @return List containing registered scheme names.
|
||||
*/
|
||||
public synchronized final List getSchemeNames() {
|
||||
public synchronized final List<String> getSchemeNames() {
|
||||
return new ArrayList<String>(registeredSchemes.keySet());
|
||||
}
|
||||
|
||||
|
|
|
@ -43,11 +43,9 @@ import java.util.Comparator;
|
|||
*
|
||||
* @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
|
||||
*/
|
||||
public class CookieIdentityComparator implements Comparator {
|
||||
public class CookieIdentityComparator implements Comparator<Cookie> {
|
||||
|
||||
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
|
||||
|
|
|
@ -47,7 +47,7 @@ import java.util.Comparator;
|
|||
*
|
||||
* @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
|
||||
*/
|
||||
public class CookiePathComparator implements Comparator {
|
||||
public class CookiePathComparator implements Comparator<Cookie> {
|
||||
|
||||
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)) {
|
||||
|
|
|
@ -138,7 +138,7 @@ public final class CookieSpecRegistry {
|
|||
*
|
||||
* @return list of registered cookie spec names
|
||||
*/
|
||||
public synchronized List getSpecNames(){
|
||||
public synchronized List<String> getSpecNames(){
|
||||
return new ArrayList<String>(registeredSpecs.keySet());
|
||||
}
|
||||
|
||||
|
|
|
@ -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<String> 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<String, Header> parseChallenges(
|
||||
final Header[] headers) throws MalformedChallengeException {
|
||||
|
||||
Map map = new HashMap(headers.length);
|
||||
Map<String, Header> map = new HashMap<String, Header>(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<String> getAuthPreferences() {
|
||||
return DEFAULT_SCHEME_PRIORITY;
|
||||
}
|
||||
|
||||
public AuthScheme selectScheme(
|
||||
final Map challenges,
|
||||
final Map<String, Header> 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<String> 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<String> it = authPrefs.iterator(); it.hasNext(); ) {
|
||||
String id = it.next();
|
||||
Header challenge = (Header) challenges.get(id.toLowerCase());
|
||||
if (challenge != null) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
|
|
Loading…
Reference in New Issue