3.4.2. 配置应用以使用带基于证书的身份验证的安全域
与将应用配置为使用其他形式身份验证的安全域类似,您需要同时正确配置 jboss-web.xml 和 web.xml 文件。
对于 jboss-web.xml,添加对您为基于证书的身份验证配置的安全域的引用。
jboss-web.xml 示例
<jboss-web> <security-domain>cert-roles-domain</security-domain> </jboss-web>
对于 web.xml,将 < 属性设置为 login-config> 中的 <auth-method >CLIENT-CERT。您还需要定义 <security-constraint> 和 <security-roles>。
web.xml 示例
<web-app>
<!-- URL for secured portion of application-->
<security-constraint>
<web-resource-collection>
<web-resource-name>secure</web-resource-name>
<url-pattern>/secure/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>All</role-name>
</auth-constraint>
</security-constraint>
<!-- Security roles referenced by this web application -->
<security-role>
<description>The role that is required to log in to the application</description>
<role-name>All</role-name>
</security-role>
<login-config>
<auth-method>CLIENT-CERT</auth-method>
<realm-name>cert-roles-domain</realm-name>
</login-config>
</web-app>