以下是JSP的安全權限設定:
<security-constraint>
<display-name>ManagerConstraint</display-name>
<web-resource-collection>
<web-resource-name>iBeaconServerPages</web-resource-name>
<description>Pages of iBeacon Project Server</description>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<description/>
<role-name>Manager</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<display-name>TicketCheckerConstarint</display-name>
<web-resource-collection>
<web-resource-name>PagesAboutTicketChecker</web-resource-name>
<description>Pages about Ticket Checker</description>
<url-pattern>/welcomePage.jsp</url-pattern>
<url-pattern>/ticketCheckUsers/*</url-pattern>
<url-pattern>/guestFlowMonitor/*</url-pattern>
<url-pattern>/logoutPage.jsp</url-pattern>
</web-resource-collection>
<auth-constraint>
<description/>
<role-name>TicketChecker</role-name>
<role-name>Manager</role-name>
</auth-constraint>
</security-constraint>
可以看到,在根目錄下的所有頁面將限制由Manager存取,而/welcomePage.jsp、/ticketCheckUsers/*、/guestFlowMonitor/*和logoutPage.jsp限制由Manager和TicketChecker存取,以上四個頁面在url匹配時會先在TicketCheckerConstarint的權限設定中被匹配到,所以如果不設Manager的話,Manager將無法存取。<display-name>ManagerConstraint</display-name>
<web-resource-collection>
<web-resource-name>iBeaconServerPages</web-resource-name>
<description>Pages of iBeacon Project Server</description>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<description/>
<role-name>Manager</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<display-name>TicketCheckerConstarint</display-name>
<web-resource-collection>
<web-resource-name>PagesAboutTicketChecker</web-resource-name>
<description>Pages about Ticket Checker</description>
<url-pattern>/welcomePage.jsp</url-pattern>
<url-pattern>/ticketCheckUsers/*</url-pattern>
<url-pattern>/guestFlowMonitor/*</url-pattern>
<url-pattern>/logoutPage.jsp</url-pattern>
</web-resource-collection>
<auth-constraint>
<description/>
<role-name>TicketChecker</role-name>
<role-name>Manager</role-name>
</auth-constraint>
</security-constraint>