Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add Basic authentication in Apache Axis Web Service (SOAP)?

I use a Maven plugin (org.codehaus.mojo > axistools-maven-plugin) + a WSDL file to generate a Soap Web Service.

Genarated files in target/generated-source/wsdl2java/com.comp.proj are:

  • Foo.java (java interface)
  • FooServiceLocator.java
  • FooSoapBindingImpl.java (java empty implementation)
  • FooSoapBindingSkeleton.java
  • FooSoapBindingStub.java

In my project, i create FooSoapBindingImpl.java in a package with the same name + add my custom code in this java implementation.

This Web services is ready for use in production.

So, today I add Basic authentication on my client (header => Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==)

How to add a check on this Basic authentication in my Axis Web Service?

like image 740
Stéphane GRILLON Avatar asked Feb 20 '18 16:02

Stéphane GRILLON


People also ask

How do you authenticate a SOAP web service?

The basic authentication is encoded in the HTTP request that carries the SOAP message. When the application server receives the HTTP request, the user name and password are retrieved and verified using the authentication mechanism specific to the server. Use transport-level security to enable basic authentication.


1 Answers

The "Axis security section 'Authenticating the caller'" mentions:

Clients can authenticate themselves with client certificates, or HTTP basic authentication.
The latter is too weak to be trustable on a non-encrypted channel, but works over HTTPS.

The MessageContext class will be configured with the username and password of the sender when SOAP messages are posted to the endpoint;*

See an example here.

use the appropriate getters to see these values. Note that Axis does not yet integrate with the servlet API authentication stuff.

See a getter example in this answer.

like image 134
VonC Avatar answered Oct 22 '22 18:10

VonC