JES: Policy Agent を使ってみよう(4): Web アプリケーションでの URL プロテクト
- Sun Java System Web Server
- Apache Web Server
- IBM HTTP Server
- Microsoft IIS
- Sun Java System Application Server
- BEA WebLogic Application Server
- IBM WebSphere Application Server
- Tomcat Application Server
J2EE ポリシーエージェントを使った Web アプリケーションの単純な URL プロテクト
J2EE ポリシーエージェントの複雑な設定をしなくても単純に Web アプリケーションに含まれる Web リソースをプロテクトしたい場合があります。Web アプリケーションに認証機能や複雑なポリシーの管理すを実装するよりも簡単に管理・設定ができますよね。
実は私はこれを実現しようといろいろドキュメントを読んだのですが読み方がおかしかったのかドキュメントの不備なのかなかなか成功しませんでしたが、 Policy Agent 担当の US のエンジニアなどにいろいろ聞いてようやく実現することができました。
詳しくは Sun ONE Identity Server Policy Agent 2.1 J2EE Agents Guide の Enabling Web-Tier Declarative Security を参照して下さい。
J2EE ポリシーエージェントはインストールしただけでは有効にならず Web アプリケーションの web.xml を編集します。
私が間違っていたのは次の3点です。
- <security-constraint> が web.xml には必要
- ログインページを持ってない Web アプリケーションでは <login-conf> は必要ない
com.sun.am.policy.amFilter.login.formList[0] = /sunweb/login.jsp
- Access Manager でリソースを設定する場合には次のような形式で指定する必要がある
http://host.../<webapp URL>/*
これを正しく修正した web.xml で再度アプリケーションサーバーに配備したところ無事に Web ポリシーエージェントと同様に動いてくれました。参考までに私の使っている web.xml を載せておきます。
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved.
Use is subject to license terms.
-->
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<security-constraint>
<web-resource-collection>
<web-resource-name>Protected Area</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>PUT</http-method>
<http-method>DELETE</http-method>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
</security-constraint>
<filter>
<filter-name>Agent</filter-name>
<filter-class>com.sun.identity.agents.filter.AmAgentFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Agent</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
</web-app>
Policy Agent についての詳しい説明は docs.sun.com の Sun ONE Identity Server Policy Agent 2.1 を参照して下さい。



