hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r527681 - in /jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/auth: AuthPolicy.java AuthScope.java
Date Wed, 11 Apr 2007 21:27:30 GMT
Author: olegk
Date: Wed Apr 11 14:27:29 2007
New Revision: 527681

URL: http://svn.apache.org/viewvc?view=rev&rev=527681
Log:
Ported AuthPolicy and AuthScope from Commons HttpClient

Added:
    jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/auth/AuthPolicy.java
      - copied, changed from r527510, jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/auth/AuthPolicy.java
    jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/auth/AuthScope.java
      - copied, changed from r527510, jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/auth/AuthScope.java

Copied: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/auth/AuthPolicy.java
(from r527510, jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/auth/AuthPolicy.java)
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/auth/AuthPolicy.java?view=diff&rev=527681&p1=jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/auth/AuthPolicy.java&r1=527510&p2=jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/auth/AuthPolicy.java&r2=527681
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/auth/AuthPolicy.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/auth/AuthPolicy.java
Wed Apr 11 14:27:29 2007
@@ -1,5 +1,5 @@
 /*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/auth/AuthPolicy.java,v
1.6 2004/05/13 04:02:00 mbecke Exp $
+ * $HeadURL$
  * $Revision$
  * $Date$
  *
@@ -28,7 +28,7 @@
  *
  */
 
-package org.apache.commons.httpclient.auth;
+package org.apache.http.auth;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -36,6 +36,8 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.http.impl.auth.BasicScheme;
+import org.apache.http.impl.auth.DigestScheme;
 
 /**
  * Authentication policy class. The Authentication policy provides corresponding
@@ -97,7 +99,7 @@
     public static final String BASIC = "Basic";
     
     static {
-        AuthPolicy.registerAuthScheme(NTLM,   NTLMScheme.class);
+//        AuthPolicy.registerAuthScheme(NTLM,   NTLMScheme.class);
         AuthPolicy.registerAuthScheme(DIGEST, DigestScheme.class);
         AuthPolicy.registerAuthScheme(BASIC,  BasicScheme.class);
     }

Copied: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/auth/AuthScope.java
(from r527510, jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/auth/AuthScope.java)
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/auth/AuthScope.java?view=diff&rev=527681&p1=jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/auth/AuthScope.java&r1=527510&p2=jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/auth/AuthScope.java&r2=527681
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/auth/AuthScope.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/auth/AuthScope.java Wed
Apr 11 14:27:29 2007
@@ -1,5 +1,5 @@
 /*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/auth/AuthScope.java,v
1.2 2004/06/23 06:50:25 olegk Exp $
+ * $HeadURL$
  * $Revision$
  * $Date$
  *
@@ -28,9 +28,9 @@
  *
  */
 
-package org.apache.commons.httpclient.auth;
+package org.apache.http.auth;
 
-import org.apache.commons.httpclient.util.LangUtils;
+import org.apache.http.util.LangUtils;
 
 /** 
  * The class represents an authentication scope consisting of a host name,
@@ -201,30 +201,6 @@
         return this.scheme;
     }
 
-    /** Determines if the given parameters are equal.
-     * 
-     * @param p1 the parameter
-     * @param p2 the other parameter
-     * @return boolean true if the parameters are equal, otherwise false.
-     */
-    private static boolean paramsEqual(final String p1, final String p2) {
-        if (p1 == null) {
-            return p1 == p2;
-        } else {
-            return p1.equals(p2);
-        }
-    }
-
-    /** Determines if the given parameters are equal.  
-     * 
-     * @param p1 the parameter
-     * @param p2 the other parameter
-     * @return boolean true if the parameters are equal, otherwise false.
-     */
-    private static boolean paramsEqual(int p1, int p2) {
-        return p1 == p2;
-    }
-
     /**
      * Tests if the authentication scopes match. 
      * 
@@ -236,28 +212,28 @@
      */
     public int match(final AuthScope that) {
         int factor = 0;
-        if (paramsEqual(this.scheme, that.scheme)) {
+        if (LangUtils.equals(this.scheme, that.scheme)) {
             factor += 1;
         } else {
             if (this.scheme != ANY_SCHEME && that.scheme != ANY_SCHEME) {
                 return -1;
             }
         }
-        if (paramsEqual(this.realm, that.realm)) {
+        if (LangUtils.equals(this.realm, that.realm)) {
             factor += 2;
         } else {
             if (this.realm != ANY_REALM && that.realm != ANY_REALM) {
                 return -1;
             }
         }
-        if (paramsEqual(this.port, that.port)) {
+        if (this.port == that.port) {
             factor += 4;
         } else {
             if (this.port != ANY_PORT && that.port != ANY_PORT) {
                 return -1;
             }
         }
-        if (paramsEqual(this.host, that.host)) {
+        if (LangUtils.equals(this.host, that.host)) {
             factor += 8;
         } else {
             if (this.host != ANY_HOST && that.host != ANY_HOST) {
@@ -282,10 +258,10 @@
         }
         AuthScope that = (AuthScope) o;
         return 
-        paramsEqual(this.host, that.host) 
-          && paramsEqual(this.port, that.port)
-          && paramsEqual(this.realm, that.realm)
-          && paramsEqual(this.scheme, that.scheme);
+        LangUtils.equals(this.host, that.host) 
+          && this.port == that.port
+          && LangUtils.equals(this.realm, that.realm)
+          && LangUtils.equals(this.scheme, that.scheme);
     }
 
     /**



Mime
View raw message