hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1681016 - in /httpcomponents/httpclient/trunk/httpclient/src: main/java/org/apache/http/impl/auth/AuthSchemeBase.java main/java/org/apache/http/impl/auth/RFC2617Scheme.java test/java/org/apache/http/impl/auth/TestBasicScheme.java
Date Fri, 22 May 2015 07:24:01 GMT
Author: olegk
Date: Fri May 22 07:24:01 2015
New Revision: 1681016

URL: http://svn.apache.org/r1681016
Log:
HTTPCLIENT-1649: serialization of auth schemes is broken

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/AuthSchemeBase.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/RFC2617Scheme.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestBasicScheme.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/AuthSchemeBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/AuthSchemeBase.java?rev=1681016&r1=1681015&r2=1681016&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/AuthSchemeBase.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/AuthSchemeBase.java
Fri May 22 07:24:01 2015
@@ -56,7 +56,7 @@ import org.apache.http.util.CharArrayBuf
 @NotThreadSafe
 public abstract class AuthSchemeBase implements ContextAwareAuthScheme {
 
-    private ChallengeState challengeState;
+    protected ChallengeState challengeState;
 
     /**
      * Creates an instance of {@code AuthSchemeBase} with the given challenge

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/RFC2617Scheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/RFC2617Scheme.java?rev=1681016&r1=1681015&r2=1681016&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/RFC2617Scheme.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/RFC2617Scheme.java
Fri May 22 07:24:01 2015
@@ -158,6 +158,7 @@ public abstract class RFC2617Scheme exte
     private void writeObject(final ObjectOutputStream out) throws IOException {
         out.defaultWriteObject();
         out.writeUTF(this.credentialsCharset.name());
+        out.writeObject(this.challengeState);
     }
 
     @SuppressWarnings("unchecked")
@@ -167,6 +168,7 @@ public abstract class RFC2617Scheme exte
         if (this.credentialsCharset == null) {
             this.credentialsCharset = Consts.ASCII;
         }
+        this.challengeState = (ChallengeState) in.readObject();
     }
 
     private void readObjectNoData() throws ObjectStreamException {

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestBasicScheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestBasicScheme.java?rev=1681016&r1=1681015&r2=1681016&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestBasicScheme.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestBasicScheme.java
Fri May 22 07:24:01 2015
@@ -141,7 +141,25 @@ public class TestBasicScheme {
         Assert.assertEquals(basicScheme.getSchemeName(), authScheme.getSchemeName());
         Assert.assertEquals(basicScheme.getRealm(), authScheme.getRealm());
         Assert.assertEquals(basicScheme.isComplete(), authScheme.isComplete());
+        Assert.assertEquals(true, basicScheme.isProxy());
+    }
+
+    @Test
+    public void testSerializationUnchallenged() throws Exception {
+        final BasicScheme basicScheme = new BasicScheme();
+
+        final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+        final ObjectOutputStream out = new ObjectOutputStream(buffer);
+        out.writeObject(basicScheme);
+        out.flush();
+        final byte[] raw = buffer.toByteArray();
+        final ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(raw));
+        final BasicScheme authScheme = (BasicScheme) in.readObject();
 
+        Assert.assertEquals(basicScheme.getSchemeName(), authScheme.getSchemeName());
+        Assert.assertEquals(basicScheme.getRealm(), authScheme.getRealm());
+        Assert.assertEquals(basicScheme.isComplete(), authScheme.isComplete());
+        Assert.assertEquals(false, basicScheme.isProxy());
     }
 
 }



Mime
View raw message