wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r1029782 - in /incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/handlers: AbstractAuthSecurityHandler.java BasicAuthSecurityHandler.java ProxyAuthSecurityHandler.java
Date Mon, 01 Nov 2010 18:19:58 GMT
Author: bluk
Date: Mon Nov  1 18:19:58 2010
New Revision: 1029782

URL: http://svn.apache.org/viewvc?rev=1029782&view=rev
Log:
Cache the encoded string credential

Thanks to Jason Dillon for the suggestion.

Modified:
    incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/handlers/AbstractAuthSecurityHandler.java
    incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/handlers/BasicAuthSecurityHandler.java
    incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/handlers/ProxyAuthSecurityHandler.java

Modified: incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/handlers/AbstractAuthSecurityHandler.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/handlers/AbstractAuthSecurityHandler.java?rev=1029782&r1=1029781&r2=1029782&view=diff
==============================================================================
--- incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/handlers/AbstractAuthSecurityHandler.java
(original)
+++ incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/handlers/AbstractAuthSecurityHandler.java
Mon Nov  1 18:19:58 2010
@@ -35,6 +35,8 @@ public class AbstractAuthSecurityHandler
     
     protected volatile String  handlerUsername = null;
     protected volatile String  handlerPassword = null;
+    
+    protected volatile String handlerEncodedCredentials = null;
 
     public AbstractAuthSecurityHandler() {
         super();
@@ -53,6 +55,7 @@ public class AbstractAuthSecurityHandler
     public void setUserName(String aUserName) {
         logger.trace("Setting the username to {}", aUserName); //$NON-NLS-1$
         this.handlerUsername = aUserName;
+        this.handlerEncodedCredentials = null;
     }
 
     /**
@@ -63,6 +66,7 @@ public class AbstractAuthSecurityHandler
     public void setPassword(String aPassword) {
         logger.trace("Setting the password"); //$NON-NLS-1$
         this.handlerPassword = aPassword;
+        this.handlerEncodedCredentials = null;
     }
     
     protected static String getEncodedString(String userid, String password) {

Modified: incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/handlers/BasicAuthSecurityHandler.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/handlers/BasicAuthSecurityHandler.java?rev=1029782&r1=1029781&r2=1029782&view=diff
==============================================================================
--- incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/handlers/BasicAuthSecurityHandler.java
(original)
+++ incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/handlers/BasicAuthSecurityHandler.java
Mon Nov  1 18:19:58 2010
@@ -74,8 +74,11 @@ public class BasicAuthSecurityHandler ex
             if (!(handlerUsername == null || handlerUsername.equals("") || handlerPassword
== null || handlerPassword.equals(""))) { //$NON-NLS-1$ //$NON-NLS-2$
                 logger.trace("userid and password set so setting Authorization header");
//$NON-NLS-1$
                 // we have a user credential
+                if (handlerEncodedCredentials == null) {
+                    handlerEncodedCredentials = getEncodedString(handlerUsername, handlerPassword);
+                }
                 request.getHeaders()
-                    .putSingle("Authorization", getEncodedString(handlerUsername, handlerPassword));
//$NON-NLS-1$
+                    .putSingle("Authorization", handlerEncodedCredentials); //$NON-NLS-1$
                 logger.trace("Issuing request again with Authorization header"); //$NON-NLS-1$
                 response = context.doChain(request);
                 if (response.getStatusCode() == UNAUTHORIZED) {

Modified: incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/handlers/ProxyAuthSecurityHandler.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/handlers/ProxyAuthSecurityHandler.java?rev=1029782&r1=1029781&r2=1029782&view=diff
==============================================================================
--- incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/handlers/ProxyAuthSecurityHandler.java
(original)
+++ incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/handlers/ProxyAuthSecurityHandler.java
Mon Nov  1 18:19:58 2010
@@ -80,9 +80,12 @@ public class ProxyAuthSecurityHandler ex
                 logger.trace("userid and password set so setting Proxy-Authorization header");
//$NON-NLS-1$
                 // we have a user credential
                 request.getHeaders().putSingle("Proxy-Connection", "Keep-Alive"); //$NON-NLS-1$
$NON-NLS-2$
+                if (handlerEncodedCredentials == null) {
+                    handlerEncodedCredentials = getEncodedString(handlerUsername, handlerPassword);
+                }
                 request
                     .getHeaders()
-                    .putSingle("Proxy-Authorization", getEncodedString(handlerUsername, handlerPassword));
//$NON-NLS-1$
+                    .putSingle("Proxy-Authorization", handlerEncodedCredentials); //$NON-NLS-1$
                 logger.trace("Issuing request again with Proxy-Authorization header"); //$NON-NLS-1$
                 response = context.doChain(request);
                 if (response.getStatusCode() == PROXY_AUTH_REQ_CODE) {



Mime
View raw message