リンク はじめに 管理者 アプリケーション開発者 Catalina開発者 Jasper開発者 | Security Manager HOW-TO| Background 背景 |
The Java SecurityManager is what allows a web browser
to run an applet in its own sandbox to prevent untrusted code from
accessing files on the local file system, connecting to a host other
than the one the applet was loaded from, and so on. In the same way
the SecurityManager protects you from an untrusted applet running in
your browser, use of a SecurityManager while running Tomcat can protect
your server from trojan servlets, JSPs, JSP beans, and tag libraries.
Or even inadvertent mistakes.
Java SecurityManagerは、信頼されてないコードがローカル・ファイル・システムのファイルにアクセスしたり、アプレットがロードされたのとは異なるホストへ接続したりする
ことなどを防ぐためにそれ自身のサンドボックスにおいてアプレットを実行するためにWebブラウザを許すことです。
同様に、SecurityManagerはあなたをTomcatを実行することはあなたのサーバーをトロイの木馬servlets、JSPs、JSP beanとタグ・ライブラリから保護することができるが、あなたのブラウザにおいて実行することはSecurityManagerの使う信頼されていないappletから保護します。
または不注意な間違いさえも。
Imagine if someone who is authorized to publish JSPs on your site
inadvertently included the following in their JSP:
不注意にあなたのサイトでJSPsを公開する許可を与えられる誰かが彼らのJSPで以下を含んだ場合を想像してください
Every time this JSP was executed by Tomcat, Tomcat would exit.
Using the Java SecurityManager is just one more line of defense a
system administrator can use to keep the server secure and reliable.
このJSPがTomcatによって実行されるたたびに、Tomcatは終了します。
Java SecurityManagerを使うことは、システム管理者がサーバーを安全で
で信頼できるようにしておくために使うことができる防御のもう一枚の壁です。
WARNING - Implementation of a SecurityManager in
Tomcat has not been fully tested or had a security audit. Make sure that
you are satisfied with your SecurityManager configuration before allowing
untrusted users to publish web applications, JSPs, servlets, beans, or
tag libraries. However, running with a SecurityManager is definitely
better than running without one.
警告 -
TomcatでのSecurityManagerの実装は、充分なテストやセキュリティ審査をしていません。
あなたがWebアプリケーション、JSPs、servlets、beanまたはタグ・ライブラリを公開するためにuntrustedされたユーザーを許可する前にあなたのSecurityManager構成を最低限確認してください。
しかし、SecurityManagerありで実行することは、無しで実行することよりマシです。
|
| Permissions 許可 |
Permission classes are used to define what Permissions a class loaded
by Tomcat will have. There are a number of Permission classes that are
a standard part of the JDK, and you can create your own Permission class
for use in your own web applications. Both techniques are used in
Tomcat 4.
許可クラスが、クラスがTomcatによって載せた許可が持つことになるものを定義するために使われます。
JDKの標準の部分であるたくさんの許可クラスがあります、そして、あなたはあなた自身のWebアプリケーションのために、あなた自身の許可クラスを作成することができます。
両方のテクニックが、Tomcat 4で使われます。
| Standard Permissions 標準許可 |
This is just a short summary of the standard system SecurityManager
Permission classes applicable to Tomcat. See
http://java.sun.com/security/
for more information.
これは、Tomcatに適用できる標準のシステムSecurityManager許可クラスの短い要約だけです。
詳細に関しては、
http://java.sun.com/security/
を参照してください。
- java.util.PropertyPermission - Controls read/write
access to JVM properties such as
java.home.
- java.util.PropertyPermission -
java.homeのようなJVMプロパティへの読み書きのアクセス制御
- java.lang.RuntimePermission - Controls use of
some System/Runtime functions like
exit() and
exec().
- java.lang.RuntimePermission -
exit()やexec()のようなSystem/Runtime関数の使用の制御
- java.io.FilePermission - Controls read/write/execute
access to files and directories.
- java.io.FilePermission -
ファイルやディレクトリに対する read/write/executeアクセスの制御
- java.net.SocketPermission - Controls use of
network sockets.
- java.net.SocketPermission - ネットワークソケットの使用の制御
- java.net.NetPermission - Controls use of
multicast network connections.
- java.net.NetPermission -
マルチキャストネットワーク接続の使用の制御
- java.lang.reflect.ReflectPermission - Controls
use of reflection to do class introspection.
- java.lang.reflect.ReflectPermission -
クラスイントロスペクションを行なうためのリフレクションの使用の制御
- java.security.SecurityPermission - Controls access
to Security methods.
- java.security.SecurityPermission -
セキュリティメソッドへのアクセス制御
- java.security.AllPermission - Allows access to all
permissions, just as if you were running Tomcat without a
SecurityManager.
- java.security.AllPermission -
SecurityManager無しでTomcatを実行するときのすべてのアクセスの許可
|
|
| Configuring Tomcat With A SecurityManager SecurityManagerを使ったTomcatの設定 |
Policy File Format Policyファイル形式
The security policies implemented by the Java SecurityManager are
configured in the $CATALINA_HOME/conf/catalina.policy file.
This file completely replaces the java.policy file present
in your JDK system directories. The catalina.policy file
can be edited by hand, or you can use the
policytool
application that comes with Java 1.2 or later.
Java SecurityManagerによって実装されるセキュリティポリシーは、
$CATALINA_HOME/conf/catalina.policyファイルで設定されます。
このファイルは、あなたのJDKシステム・ディレクトリに存在するjava.policyファイルを完全に置き換えます。
catalina.policyファイルは手で編集したり、Java 1.2以降で提供されるpolicytool アプリケーションを使用することもできます。
Entries in the catalina.policy file use the standard
java.policy file format, as follows:
次のように、catalina.policyファイルの中のエントリは、標準のjava.policyファイル・フォーマットを使います
 |  |  |  |
// Example policy file entry
grant [signedBy <signer>,] [codeBase <code source>] {
permission <class> [<name> [, <action list>]];
};
|  |  |  |  |
The signedBy and codeBase entries are
optional when granting permissions. Comment lines begin with "//" and
end at the end of the current line. The codeBase is in the
form of a URL, and for a file URL can use the ${java.home}
and ${catalina.home} properties (which are expanded out to
the directory paths defined for them by the JAVA_HOME and
CATALINA_HOME environment variables).
許可を与えるとき、signedByとcodeBaseエントリはオプションです。
コメント行は、「//」で始まり、その行末で終了します。
codeBaseはURLの形式です、そして、ファイルのために、URLは${java.home}と${catalina.home}プロパティ(それは、JAVA_HOMEとCATALINA_HOME環境変数によってそれらのために定義されるディレクトリ・パスが拡張されます)を使うことができます。
The Default Policy File デフォルトポリシーファイル
The default $CATALINA_HOME/conf/catalina.policy file
looks like this:
デフォルトの$CATALINA_HOME/conf/catalina.policyファイルは、このように見えます
 |  |  |  |
// ============================================================================
// catalina.corepolicy - Security Policy Permissions for Tomcat 4.0
//
// This file contains a default set of security policies to be enforced (by the
// JVM) when Catalina is executed with the "-security" option. In addition
// to the permissions granted here, the following additional permissions are
// granted to the codebase specific to each web application:
//
// * Read access to the document root directory
//
// $Id: security-manager-howto.html,v 1.1.1.1 2003/04/09 15:16:05 ytp Exp $
// ============================================================================
// ========== SYSTEM CODE PERMISSIONS =========================================
// These permissions apply to javac
grant codeBase "file:${java.home}/lib/-" {
permission java.security.AllPermission;
};
// These permissions apply to all shared system extensions
grant codeBase "file:${java.home}/jre/lib/ext/-" {
permission java.security.AllPermission;
};
// These permissions apply to javac when ${java.home] points at $JAVA_HOME/jre
grant codeBase "file:${java.home}/../lib/-" {
permission java.security.AllPermission;
};
// These permissions apply to all shared system extensions when
// ${java.home} points at $JAVA_HOME/jre
grant codeBase "file:${java.home}/lib/ext/-" {
permission java.security.AllPermission;
};
// ========== CATALINA CODE PERMISSIONS =======================================
// These permissions apply to the server startup code
grant codeBase "file:${catalina.home}/bin/bootstrap.jar" {
permission java.security.AllPermission;
};
// These permissions apply to the servlet API classes
// and those that are shared across all class loaders
// located in the "common" directory
grant codeBase "file:${catalina.home}/common/-" {
permission java.security.AllPermission;
};
// These permissions apply to the container's core code, plus any additional
// libraries installed in the "server" directory
grant codeBase "file:${catalina.home}/server/-" {
permission java.security.AllPermission;
};
// These permissions apply to the jasper page compiler
// located in the "jasper" directory.
grant codeBase "file:${catalina.home}/jasper/-" {
permission java.security.AllPermission;
};
// These permissions apply to shared web application libraries
// including the Jasper runtime library installed in the "lib" directory
grant codeBase "file:${catalina.home}/lib/-" {
permission java.security.AllPermission;
};
// These permissions apply to shared web application classes
// located in the "classes" directory
grant codeBase "file:${catalina.home}/classes/-" {
permission java.security.AllPermission;
};
// ========== WEB APPLICATION PERMISSIONS =====================================
// These permissions are granted by default to all web applications
// In addition, a web application will be given a read FilePermission
// and JndiPermission for all files and directories in its document root.
grant {
// Required for JNDI lookup of named JDBC DataSource's and
// javamail named MimePart DataSource used to send mail
permission java.util.PropertyPermission "java.home", "read";
permission java.util.PropertyPermission "java.naming.*", "read";
permission java.util.PropertyPermission "javax.sql.*", "read";
// OS Specific properties to allow read access
permission java.util.PropertyPermission "os.name", "read";
permission java.util.PropertyPermission "os.version", "read";
permission java.util.PropertyPermission "os.arch", "read";
permission java.util.PropertyPermission "file.separator", "read";
permission java.util.PropertyPermission "path.separator", "read";
permission java.util.PropertyPermission "line.separator", "read";
// JVM properties to allow read access
permission java.util.PropertyPermission "java.version", "read";
permission java.util.PropertyPermission "java.vendor", "read";
permission java.util.PropertyPermission "java.vendor.url", "read";
permission java.util.PropertyPermission "java.class.version", "read";
permission java.util.PropertyPermission "java.specification.version", "read";
permission java.util.PropertyPermission "java.specification.vendor", "read";
permission java.util.PropertyPermission "java.specification.name", "read";
permission java.util.PropertyPermission "java.vm.specification.version", "read";
permission java.util.PropertyPermission "java.vm.specification.vendor", "read";
permission java.util.PropertyPermission "java.vm.specification.name", "read";
permission java.util.PropertyPermission "java.vm.version", "read";
permission java.util.PropertyPermission "java.vm.vendor", "read";
permission java.util.PropertyPermission "java.vm.name", "read";
// Required for getting BeanInfo
permission java.lang.RuntimePermission "accessClassInPackage.sun.beans.*";
// Allow read of JAXP compliant XML parser debug
permission java.util.PropertyPermission "jaxp.debug", "read";
};
// You can assign additional permissions to particular web applications by
// adding additional "grant" entries here, based on the code base for that
// application, /WEB-INF/classes/, or /WEB-INF/lib/ jar files.
//
// Different permissions can be granted to JSP pages, classes loaded from
// the /WEB-INF/classes/ directory, all jar files in the /WEB-INF/lib/
// directory, or even to individual jar files in the /WEB-INF/lib/ directory.
//
// For instance, assume that the standard "examples" application
// included a JDBC driver that needed to establish a network connection to the
// corresponding database and used the scrape taglib to get the weather from
// the NOAA web server. You might create a "grant" entries like this:
//
// The permissions granted to the context root directory apply to JSP pages.
// grant codeBase "file:${catalina.home}/webapps/examples/-" {
// permission java.net.SocketPermission "dbhost.mycompany.com:5432", "connect";
// permission java.net.SocketPermission "*.noaa.gov:80", "connect";
// };
//
// The permissions granted to the context WEB-INF/classes directory
// grant codeBase "file:${catalina.home}/webapps/examples/WEB-INF/classes/-" {
// };
//
// The permission granted to your JDBC driver
// grant codeBase "file:${catalina.home}/webapps/examples/WEB-INF/lib/driver.jar!/-" {
// permission java.net.SocketPermission "dbhost.mycompany.com:5432", "connect";
// };
// The permission granted to the scrape taglib
// grant codeBase "file:${catalina.home}/webapps/examples/WEB-INF/lib/scrape.jar!/-" {
// permission java.net.SocketPermission "*.noaa.gov:80", "connect";
// };
|  |  |  |  |
Starting Tomcat With A SecurityManager SecurityManagerつきでTomcatを実行する
Once you have configured the catalina.policy file for use
with a SecurityManager, Tomcat can be started with a SecurityManager in
place by using the "-security" option:
一旦あなたがSecurityManagerを使うために、catalina.policyファイルを設定すれば、「-security」オプションを使用してTomcatを起動すれば、SecurityManager付きで起動します。
 |  |  |  |
$CATALINA_HOME/bin/catalina.sh start -security (Unix)
%CATALINA_HOME%\bin\catalina start -security (Windows)
|  |  |  |  |
|
|