[jira] [Resolved] (AXIS2-6055) Basic Auth credentials are missing in request
"Robert Lazarski (Jira)" <[email protected]> Mon, 20 Apr 2026 07:35:00 +0000 (UTC)
| Newsgroups | gmane.text.xml.axis.devel |
|---|---|
| Message-ID | <[email protected]> |
[ https://issues.apache.org/jira/browse/AXIS2-6055?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Robert Lazarski resolved AXIS2-6055.
------------------------------------
Resolution: Fixed
Fixed on trunk, shipping in 2.0.1. When preemptiveAuthentication is set to true on the
HTTPAuthenticator, the Authorization: Basic header is now sent on the first request without
waiting for a 401 challenge. This restores the Axis2 1.7 behavior that was lost during the
HttpClient 4 to HttpClient 5 migration.
Your existing code will work as-is — no changes needed on the client side:
HttpTransportPropertiesImpl.Authenticator auth = new HttpTransportPropertiesImpl.Authenticator();
auth.setUsername("testUser");
auth.setPassword("testUserPassword");
auth.setPreemptiveAuthentication(true);
msgContext.setProperty(HTTPConstants.AUTHENTICATE, auth);
The workaround of setting the Authorization header manually is no longer necessary.
> Basic Auth credentials are missing in request
> ---------------------------------------------
>
> Key: AXIS2-6055
> URL: https://issues.apache.org/jira/browse/AXIS2-6055
> Project: Axis2
> Issue Type: Bug
> Components: TCP transport
> Affects Versions: 1.8.0
> Reporter: Markus I.
> Assignee: Robert Lazarski
> Priority: Major
> Fix For: 2.0.1
>
>
> There is a changed behaviour between Axis2 1.7 and Axis2 1.8 when using the preemptive authentication in the HttpTransportPropertiesImpl.Authenticator.
> In Axis2 1.7 following code was used to achive this behaviour:
> _HttpTransportPropertiesImpl.Authenticator auth = new HttpTransportPropertiesImpl.Authenticator();_
> _List<String> authpref = new ArrayList<>();_
> _authpref.add(AuthPolicy.BASIC);_
> _auth.setAuthSchemes(authpref);_
> _auth.setUsername("testUser");_
> _auth.setPassword("testUserPassword");_
> _auth.setPreemptiveAuthentication(true);_
> _msgContext.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth); //msgContext = org.apache.axis2.context.MessageContext_
> Since Axis2 1.8 the code above does not work anymore, because org.apache.axis2.transport.http.HTTPAuthenticator.getPreemptiveAuthentication() is not called anymore by the AXIS implementation. Is this an intended behaviour or a bug? We are using at the moment Axis2 1.8.2.
> The current workaround for us is to set the header directly as shown in following example:
> _List<NamedValue> l = new ArrayList<>();_
> _String credentials = "testUser:testUserPassword";_
> _l.add(new NamedValue(org.apache.axis2.kernel.http.HTTPConstants.HEADER_AUTHORIZATION, "Basic " + Base64.encode(credentials.getBytes())));_
> _msgContext.setProperty(org.apache.axis2.kernel.http.HTTPConstants.HTTP_HEADERS, l); //msgContext = org.apache.axis2.context.MessageContext_
--
This message was sent by Atlassian Jira
(v8.20.10#820010)