I would normally host my webservices using a web server (nginx/apache) and/or a app server (tomcat) and configure the basic authentication there. You get better control, logging and monitoring options this way. Specially if you want to authenticate against a database, LDAP or active directory.
I use embeded Jetty and I deployed Axis2 war.
I added basic authentication to Jetty using the example from here with 2 small changes:
loginService.putUser("username", Credential.getCredential("password"), new String[] {"user"});
mapping.setPathSpec("/*");
is changed to match only my service web path so user and password will not be required for the rest of the axis interface.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.