sebb wrote:
> On 21/01/2010, Usha_N <[email protected]> wrote:
>> Hello,
>>
>> We are using apache commons HttpClient library
>> (commons-httpclient-3.1.jar).
>>
>> Users are providing username and password that has multibyte
>> characters in it. Base64 encoding of the mutlitbyte characters in
>> HttpClient doesn’t seem to be working.
>>
>>
>> Below API’s are used:
>>
>> Credentials credents = new UsernamePasswordCredentials(userId,
>> password); m_httpState.setCredentials(realm, m_host, credents);
>>
>> m_httpClient.executeMethod(m_hostConf,httpmethod,m_httpState);
>>
>> I have a text
>>
>> test1:测试组:Designer:test1
>>
>> Capturing the network trace from the client that uses the above jar
>> (note: the authorization header): HEAD /tc/FileAccess/ HTTP/1.1
>> User-Agent: DAKCLIENT/7.0 Accept-Language: zh-CN Authorization:
>> Basic dGVzdDE6Pz8/OkRlc2lnbmVyOnRlc3Qx Host: ahi6w033:8888
>>
>>
>> Using the online Base64 decoder utility
>> (http://www.opinionatedgeek.com/dotnet/tools/Base64Decode/Default.aspx)
>> , passing dGVzdDE6Pz8/OkRlc2lnbmVyOnRlc3Qx results the decoding to
>> be test1:???:Designer:test1 (note: ???)
>>
>> Using the online encoder utility: test1:测试组:Designer:test1 gets
>> Base64 encoded as : dGVzdDE65rWL6K+V57uEOkRlc2lnbmVyOnRlc3Qx
>>
>> This makes me believe that Base64 encodign in common’s apache isn’t
>> working correctly.
>>
>> Please help and advice.
>
> AIUI, HTTP Basic Authentication does not support any character set
> apart from the default ISO-8859-1.
>
RFC 2617 does not seem to define what charset encoding can be used for
BASIC user credentials. Basic password can consist of octets except
control characters.This seems to imply ISO-8859-1.
2 Basic Authentication Scheme
---
basic-credentials = base64-user-pass
base64-user-pass = <base64 [4] encoding of user-pass,
except not limited to 76 char/line>
user-pass = userid ":" password
userid = *<TEXT excluding ":">
password = *TEXT
---
---
TEXT = <any OCTET except CTLs,
but including LWS>
---
Anyways, HttpClient can be configured to use any charset encoding
supported by JRE by using "http.protocol.credential-charset" parameter.
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]