我需要为我的 web 应用程序的三个不同部分定义安全约束。一个/admin/*
,一个,/account/*
一个棘手的。最后一个应该匹配除前面的 url 模式(/*
不包括/admin/*
and /account/*
)之外的所有内容。如何创建此约束?
<security-constraint>
<web-resource-collection>
<web-resource-name>AdminPanel</web-resource-name>
<url-pattern>/admin/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>AccountPanel</web-resource-name>
<url-pattern>/account/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>account</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>HTTPSOnly</web-resource-name>
<url-pattern>`/* excluding /admin/*, /account/*`</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>visitor</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>