140 lines
15 KiB
HTML
140 lines
15 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<LINK rel="stylesheet" type="text/css" href="../../../rzahg/ic.css">
|
|
|
|
<title>Java 2 Security</title>
|
|
</head>
|
|
|
|
<BODY>
|
|
<!-- Java sync-link -->
|
|
<SCRIPT LANGUAGE="Javascript" SRC="../../../rzahg/synch.js" TYPE="text/javascript"></SCRIPT>
|
|
|
|
<h4><a name="java2"></a>Java 2 Security</h4>
|
|
|
|
<p>Java 2 Security is a supported feature in WebSphere Application Server - Express. Java 2 Security provides a policy-based, fine-grain access control mechanism that increases overall system integrity by checking for permissions before allowing access to certain protected system resources. Java 2 Security is independent of J2EE role-based authorization. Java 2 Security guards access to system resources such as file input and output, sockets, and properties, whereas J2EE security guards access to Web resources such as servlets and JSP files. WebSphere global security includes J2EE role-based authorization, the CSIv2 authentication protocol, and SSL configuration. Java 2 Security can be disabled and enabled independently of WebSphere global security (the <strong>Enforce Java 2 Security</strong> check box in the Global Security Panel or Server Level Security Panel). However, when WebSphere global security is enabled, by default Java 2 Security is also enabled. Note that Java 2 security can be disabled even though WebSphere Global Security may be enabled.</p>
|
|
|
|
<p>Because Java 2 Security is relatively new to the industry and new to WebSphere, many existing or even new applications may not be prepared for the very fine-grain access control programming model that Java 2 Security is capable of enforcing. Administrators should understand the possible consequences of enabling Java 2 Security if applications are not prepared for Java 2 Security. Java 2 Security places some new requirements on application developers and administrators.</p>
|
|
|
|
<p><strong>Java 2 Security for deployers and administrators</strong></p>
|
|
|
|
<p>Before you enable Java 2 Security, you need to make sure that all the applications are granted the required permissions, otherwise, applications may fail to run. By default, applications are granted the permissions recommended in the J2EE 1.3 Specification. For details of default permissions granted to applications in WebSphere, please refer to the following policy files:</p>
|
|
|
|
<ul>
|
|
<li>/QIBM/ProdData/Java400/jdk13/lib/security/java.policy</li>
|
|
<li>/QIBM/UserData/WebASE/ASE5/<em>instance</em>/properties/server.policy</li>
|
|
<li>/QIBM/UserData/WebASE/ASE5/<em>instance</em>/config/cells/<em>cell</em>/nodes/<em>node</em>/app.policy</li>
|
|
</ul>
|
|
|
|
<p>where <em>instance</em> is the name of your instance, <em>cell</em> is the name of your cell, and <em>node</em> is the name of your node.</p>
|
|
|
|
<p>WebSphere Application Server- Express does not support a more restrictive policy than the default one that is embodied in these policy files. This is because WebSphere may not have the necessary Java 2 Security doPrivileged APIs in place. The result of attempting to make the default policy more restrictive may result in WebSphere throwing Java 2 security access control exceptions and causing applications or WebSphere Application Server - Express itself to fail unexpectedly.</p>
|
|
|
|
<p>Several policy files are used to define the security policy for Java processes. Some policy files are static (the code base is statically defined in the policy file). An example of a static policy file is the java.policy file that is provided by the Java development kit.</p>
|
|
|
|
<p>Other policy files are dynamic. WebSphere provides support for both static and dynamic policy files. Dynamic policy files are used with enterprise applications, resources and utility libraries. For dynamic policy files, the codebase is dynamically calculated (based on deployment information) and permissions are granted (based on template policy files) during run time.</p>
|
|
|
|
<p>For more information about policy files, see <a href="seccj2po.htm">Configure Java 2 policy files</a>.</p>
|
|
|
|
<p>If an application is not prepared for Java 2 Security, if the application provider does not provide a was.policy file as part of the application, or if the application provider does not communicate the expected permissions that should be granted to one of the WebSphere policy files, the application is likely to cause Java 2 security access control exceptions at runtime (if Java 2 Security is enabled in WebSphere) and probably runs incorrectly.</p>
|
|
|
|
<p>It may not be obvious that a application is or is not prepared for Java 2 security. WebSphere provides several runtime debugging aids to help determine troubleshoot applications that may be experiencing Java 2 Security-related access control exceptions.</p>
|
|
|
|
<p><strong>Java 2 Security for application developers</strong></p>
|
|
|
|
<p>Application developers must understand the permissions that are granted in the default WebSphere policy and the permission requirements of the Java SDK APIs. You need to know whether the APIs that your application calls requires additional permissions or not. For more information about which Java APIs require permissions, see <a href="http://java.sun.com/j2se/1.3/docs/guide/security/permissions.html" target="_">Permissions in the Java 2 SDK</a> <img src="www.gif" width="19" height="15" alt="Link outside Information Center"> (http://java.sun.com/j2se/1.3/docs/guide/security/permissions.html).</p>
|
|
|
|
<p>Application providers can assume that applications are granted the necessary permissions in the default policy. Applications that access resources that are not covered by the default WebSphere policy are required to grant the additional Java 2 security permissions to the application.</p>
|
|
|
|
<p>While it is possible to grant the application additional permissions in one of the other dynamic WebSphere policy files or in one of the more traditional static policy files, such as java.policy, the was.policy file (which is embedded in the EAR file) ensures that the additional permissions are scoped to the exact application that requires them. If permissions are scoped to the application code that requires the permission, application code that normally does not have permission to access secured resources is not granted that permission.</p>
|
|
|
|
<p>If a component of an application (such as a library) is included in more than one EAR file, then the library developer should document the required Java 2 permissions that are needed by the application assembler. There is no was.policy type of file for library type components, the developer must communicate the required permissions through external documentation. If the component library is shared by multiple enterprise applications, the permissions can be granted to all enterprise applications on the node in the app.policy.</p>
|
|
|
|
<p>If the permission is only used internally by the component library and the application is never granted access to resources that are protected by the permission, then it may be necessary to mark the code as privileged (by inserting a doPrivileged block). (For more information, see <a href="secj2ace.htm">AccessControlException</a>.) However, improperly inserting a doPrivileged block could open up security holes, so great care and understanding should be employed when decided whether to use a doPriveleged block or not</p>
|
|
|
|
<p>See <a href="seccj2wa.htm">Configure the was.policy file</a> for a description of how the permissions in was.policy files are granted at runtime.</p>
|
|
|
|
<p>Developing an application with Java 2 Security in mind may be a new skill and impose a security awareness that was not previously required of application developers. Describing the Java 2 Security model and the implications on application development is beyond the scope of this section. For more information, see <a href="http://java.sun.com/j2se/1.3/docs/guide/security/index.html" target="_">The J2SDK 1.3 Security documentation</a> <img src="www.gif" width="19" height="15" alt="Link outside Information Center"> (http://java.sun.com/j2se/1.3/docs/guide/security/index.html).</p>
|
|
|
|
<p><strong>Debugging aids</strong></p>
|
|
|
|
<p>There are two primary aids to debugging Java 2 Security:</p>
|
|
|
|
<ul>
|
|
<li><p><strong>The WebSphere SystemOut.log file</strong>
|
|
<br>The AccessControl exception is logged in the SystemOut.log, and it contains the permission violation that causes the exception, the exception call stack, and the permissions that are granted to each stack frame. This information is usually enough to determine the missing permission and the code that requires the permission.</p></li>
|
|
|
|
<li><p><strong>The com.ibm.websphere.java2secman.norethrow property</strong>
|
|
<br>When Java 2 Security is enabled in WebSphere, by default the Security Manager component throws an java.security.AccessControl exception when a permission violation occurs. If this exception is not handled, it may cause a runtime failure. (This exception is also logged in the SystemOut.log.) However, when the com.ibm.websphere.java2secman.norethrow property is set to <tt>true</tt>, the Security Manager logs the AccessControl exception rather than throw it.</p>
|
|
|
|
<p><strong>Note:</strong> Because this property instructs the Security Manager to not throw the exception, the Security Manager is technically not enforcing Java 2 Security. The norethrow property should not be used in a production environment.</p>
|
|
|
|
<p>This property is valuable in a sandbox or test environment where the application can be thoroughly tested and the SystemOut.log can be inspected for AccessControl exceptions. Because this property causes the AccessControl exception not to be thrown, the exception is not propagated up the call stack and does not cause a failure. Without this property, AccessControl exceptions would have to be found and fixed, one at a time.</p></li>
|
|
</ul>
|
|
|
|
<p><strong>Handling applications that are not ready for Java 2 Security</strong></p>
|
|
|
|
<p>If you use a third-party application and the increased system integrity that is provided by Java 2 Security is important, contact the application provider to request support for Java 2 Security or, at least, to understand the additional permissions beyond the default WebSphere policy that are needed.</p>
|
|
|
|
<p>The easiest way to deal with applications that do not support Java 2 Security is to disable Java 2 Security in WebSphere. The downside is that this solution applies to the entire system and the integrity of the system is not as strong as it could be. This should be a consideration that is not taken lightly. In some cases, disabling Java 2 Security may be an acceptable risk.</p>
|
|
|
|
<p>Another approach is to leave Java 2 Security enabled but either grant only enough additional permissions or grant all permissions to only the problematic application. Determining how many permissions are enough may not be trivial. If the application provider has not communicated the required permissions in some way, then there is no easy way to determine the required permissions, so granting all permissions may be the only choice. You can minimize this risk by deploying such an application on a different node; this may help to isolate it from certain resources. Then, you can grant java.security.AllPermission in the was.policy file that is embedded in the application's EAR file, for example:</p>
|
|
|
|
<pre> grant codeBase "file:${application}" {
|
|
permission java.security.AllPermission;
|
|
};</pre>
|
|
|
|
|
|
<p><strong>The server.policy file</strong></p>
|
|
|
|
<p>This policy defines the policy for the WebSphere classes.</p>
|
|
|
|
<p>The server.policy file should be used to define the Java 2 security policy for server resources. For enterprise application resources, use the app.policy file for node-scoped permissions or the was.policy file for application-scoped permissions.</p>
|
|
|
|
<p><strong>The java.policy file</strong></p>
|
|
|
|
<p>This file represents the default permissions granted to all classes. The policy of this file applies to all the processes that are launched by the Java virtual machine in which WebSphere Application Server - Express runs. For more information, see <a href="seccj2ja.htm">Configure the java.policy file</a>.</p>
|
|
|
|
|
|
<p><strong>Troubleshooting</strong></p>
|
|
|
|
<ul>
|
|
<li><p><strong>Symptom</strong>
|
|
<br>Error message <tt>SECJ0314E: Current Java 2 Security policy reported a potential violation of Java 2 Security Permission. Please refer to Problem Determination Guide for further information.{0}Permission\:{1}Code\:{2}{3}Stack Trace\:{4}Code Base Location\:{5}</tt></p></li>
|
|
|
|
<li><p><strong>Problem</strong>
|
|
<br>The Java Security Manager checkPermission() reported a SecurityException on the subject Permission with debugging information. The reported information can be different with respect to the system configuration. This report is enabled by configuring RAS trace into debug mode. For more information, see <a href="../trb/trbenabletrace.htm">Enable and disable the trace service</a> in the <em>Troubleshooting</em> topic.</p></li>
|
|
|
|
<li><p><strong>Recommended response</strong>
|
|
<br>The reported exception may be critical to the secure system. Turn on security trace to determine the potential code that may have violated the security policy. After you determine the violating code, your should verify if the attempted operation is permitted (with respect to Java 2 Security) by examining all applicable Java 2 security policy files and the application code itself.</p>
|
|
|
|
<p><strong>Note:</strong> If the application uses Java Mail, this message may be benign. You can update the was.policy file to grant the following permissions to the application:</p>
|
|
|
|
<pre> permission java.io.FilePermission "${user.home}${/}.mailcap", "read";
|
|
permission java.io.FilePermission "${user.home}${/}.mime.types", "read";
|
|
permission java.io.FilePermission "${java.home}${/}lib${/}mailcap", "read";
|
|
permission java.io.FilePermission "${java.home}${/}lib${/}mime.types", "read";</pre>
|
|
|
|
<p><strong>Note:</strong> If the application uses the <tt>getResourceAsStream(<em>foo</em>)</tt> method of the ClassLoader class where <em>foo</em> is some file name, this message may be benign. You can update the was.policy file to grant the following permission to the application (or update the app.policy file to grant the permission to all applications on node):</p>
|
|
|
|
<pre> permission java.io.FilePermission "/QIBM/ProdData/Java400/<em>foo</em>", "read";</pre></li>
|
|
</ul>
|
|
|
|
<p><strong>Messages</strong></p>
|
|
|
|
<ul>
|
|
<li><p><strong>Message:</strong> <tt>SECJ0313E: Java 2 Security Manager debug message flags are initialized: TrDebug: {0}, Access: {1}, Stack: {2}, Failure: {3}</tt>
|
|
<br><strong>Problem:</strong> Configured values of the valid debug message flags for Security Manager.
|
|
<br><strong>Recommended response:</strong> None.</p></li>
|
|
|
|
<li><p><strong>Message:</strong> <tt>SECJ0307E: Unexpected exception is caught when trying to determine the code base location. Exception: {0}</tt>
|
|
<br><strong>Problem:</strong> An unexpected exception is caught when the code base location is being determined.
|
|
<br><strong>Recommended response:</strong> Please contact an IBM representative.</p></li>
|
|
</ul>
|
|
|
|
|
|
</body>
|
|
</html>
|
|
|