此内容没有您所选择的语言版本。
11.4. Authentication
Read this section to learn how to authenticate a web service user using a number of available methods.
Procedure 11.1. Authenticate a Web Service User
The following procedure describes how to authenticate a web service user with JBossWS.
Secure access to the Stateless Session Bean
Secure access to the Stateless Session Bean (SLSB) using the@RolesAllowed,@PermitAll,@DenyAllannotations.The allowed user roles can be set with these annotations both on the bean class and on any of its business methods.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Secure POJO endpoints
Secure Plain Old Java Object (POJO) endpoints by defining a <security-constraint> in theWEB-INF/web.xmlfile of the application.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Define the security domain
Declare the security domain by appending the @SecurityDomain annotationCopy to Clipboard Copied! Toggle word wrap Toggle overflow - You can also modify
JBOSS_HOME/server/PROFILE/deploy/jbossws.sar/jboss-management.war/WEB-INF/jboss-web.xmland specify the security domain.<jboss-web> <security-domain>JBossWS</security-domain> </jboss-web>
<jboss-web> <security-domain>JBossWS</security-domain> </jboss-web>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Note
For more information about Security Domains, refer to the JBoss Security Guide.Define the security context
Configure the security context in theJBOSS_HOME/server/PROFILE/conf/login-config.xmlfile.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Note
The defaultUsersRolesLoginModuleshould be changed to another login module that offers security suitable for your enterprise deployment. Refer to the JBoss Security Guide for more information about the available login modules, and how you can create your own custom login module.
A web service client can use the
javax.xml.ws.BindingProvider interface to set the username and password combination.
Example 11.1. BindingProvider Configuration
HTTP Basic Authentication
You can enable HTTP Basic Authentication by using the @WebContext annotation on the bean class, or by appending an <auth-method> element to the JBOSS_HOME/server/PROFILE/deploy/jbossws.sar/jboss-management.war/WEB-INF/jboss-web.xml <login-config> element.
Example 11.2. @WebContext HTTP Basic Authentication
Example 11.3. jboss-web.xml HTTP Basic Authentication
<login-config> <auth-method>BASIC</auth-method> <realm-name>Test Realm</realm-name> </login-config>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>Test Realm</realm-name>
</login-config>