Search code examples
javahttpbasic-authenticationtomcat6

HTTP basic user authentication : "Authorization" header not accepted (case-sensitive)


I'm using HTTP Header Basic authentication to send username and password to the server:

Code:

List<String> as = new ArrayList<String>();
HttpTransportProperties.Authenticator basicAuth = new HttpTransportProperties.Authenticator();

as.add(Authenticator.BASIC);
basicAuth.setAuthSchemes(as);

basicAuth.setUsername("ABC");
basicAuth.setPassword("password");

basicAuth.setPreemptiveAuthentication(true);

serviceStub._getServiceClient().getOptions().setProperty(
                org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE,
                basicAuthenticator);

I'm using Tomcat 6 as a server.

In catalina.log file, I can see the following:

header=authorization=Basic U2hyZXlhczpwYXNzd29yZA==

I'm expecting "authorization" as "Authorization" i.e. Captial 'A' in authorization.

I've checked many existing post but not able to find the answer.

Could you please advice how to achieve above result?

Thanks in advance


Solution

  • HTTP Headers field names, as authorization, are case insensitive

    From RFC 2616 - "Hypertext Transfer Protocol -- HTTP/1.1", Section 4.2, "Message Headers":

    Each header field consists of a name followed by a colon (":") and the field value. Field names are case-insensitive.

    So case shouldn't matter

    EDIT Add a newer HTTP/1.1 document for reference