HTTPCLIENT-1649: serialization of auth schemes is broken
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1681016 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e4157e5d24
commit
8fc08b322e
|
@ -56,7 +56,7 @@ import org.apache.http.util.CharArrayBuffer;
|
||||||
@NotThreadSafe
|
@NotThreadSafe
|
||||||
public abstract class AuthSchemeBase implements ContextAwareAuthScheme {
|
public abstract class AuthSchemeBase implements ContextAwareAuthScheme {
|
||||||
|
|
||||||
private ChallengeState challengeState;
|
protected ChallengeState challengeState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an instance of {@code AuthSchemeBase} with the given challenge
|
* Creates an instance of {@code AuthSchemeBase} with the given challenge
|
||||||
|
|
|
@ -158,6 +158,7 @@ public abstract class RFC2617Scheme extends AuthSchemeBase implements Serializab
|
||||||
private void writeObject(final ObjectOutputStream out) throws IOException {
|
private void writeObject(final ObjectOutputStream out) throws IOException {
|
||||||
out.defaultWriteObject();
|
out.defaultWriteObject();
|
||||||
out.writeUTF(this.credentialsCharset.name());
|
out.writeUTF(this.credentialsCharset.name());
|
||||||
|
out.writeObject(this.challengeState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -167,6 +168,7 @@ public abstract class RFC2617Scheme extends AuthSchemeBase implements Serializab
|
||||||
if (this.credentialsCharset == null) {
|
if (this.credentialsCharset == null) {
|
||||||
this.credentialsCharset = Consts.ASCII;
|
this.credentialsCharset = Consts.ASCII;
|
||||||
}
|
}
|
||||||
|
this.challengeState = (ChallengeState) in.readObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readObjectNoData() throws ObjectStreamException {
|
private void readObjectNoData() throws ObjectStreamException {
|
||||||
|
|
|
@ -141,7 +141,25 @@ public class TestBasicScheme {
|
||||||
Assert.assertEquals(basicScheme.getSchemeName(), authScheme.getSchemeName());
|
Assert.assertEquals(basicScheme.getSchemeName(), authScheme.getSchemeName());
|
||||||
Assert.assertEquals(basicScheme.getRealm(), authScheme.getRealm());
|
Assert.assertEquals(basicScheme.getRealm(), authScheme.getRealm());
|
||||||
Assert.assertEquals(basicScheme.isComplete(), authScheme.isComplete());
|
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue