アクセス制限の定義は、security-constraintタグで定義します。
記述形式
<security-constraint> <web-resource-collection> <web-resource-name>resource-name</web-resource-name> <url-pattern>pattern</url-pattern> <http-method>method</http-method> </web-resource-collection> <auth-constraint> <role-name>name</role-name> </auth-constraint> <user-data-constraint> <transport-guarantee>guarantee-type</transport-guarantee> </user-data-constraint> </security-constraint>
タグの内容
タグ名 | 説明 | タグの省略 | 複数の指定 |
---|---|---|---|
web-resource-collection | Webリソースコレクションを定義します。 | × | ○ |
web-resource-name | webリソースのコレクション名を定義します。 | × | × |
url-pattern | URLパターンを定義します。 | × | ○ |
http-method | HTTPのメソッド(GET、POSTなど)を定義します。 | ○ | ○ |
auth-constraint | Webリソースコレクションにアクセス可能なセキュリティロールを定義します。 | ○ | × |
role-name | セキュリティロール名を定義します。 | ○ | ○ |
user-data-constraint | データ保護属性を定義します。クライアント-コンテナ間で通信するデータをどう保護すべきであるかを定義します。 | ○ | × |
transport-guarantee | クライアント-サーバ間の転送方法を定義します。
INTEGRALまたはCONFIDENTIALを指定された場合は、SSLによる通信であることを保証します。 | × | × |
記述例
<security-constraint> <web-resource-collection> <web-resource-name>Hello</web-resource-name> <url-pattern>/Hello.jsp</url-pattern> <http-method>GET</http-method> </web-resource-collection> <auth-constraint> <role-name>Administrator</role-name> </auth-constraint> <user-data-constraint> <transport-guarantee>NONE</transport-guarantee> </user-data-constraint> </security-constraint>