SQL/MX Programming Manual for Java

Getting Started
HP NonStop SQL/MX Programming Manual for Java523726-003
2-6
Establishing Java Security
For more information about the java -cp option, see the NonStop Server for Java
Tools Reference Pages.
Establishing Java Security
Java has built-in security features, such as the Java security manager, that protect
against unauthorized use of or access to the system. With Java security enabled, the
Java security manager protects the Java environment by restricting access to system
resources.
By using a policy file, you can configure the Java security manager so that specific
Java classes and methods can perform restricted operations, such as accessing a
directory or network address.
Turning On Java Security
The SQLJ product does not have a security manager, so it does not call the
System.setSecuritymanager(securityManager) method on its own. To enable
Java security for SQLJ programs, use one of these approaches:
Specify this Java option on the command line during translation or execution of an
SQLJ program:
-Djava.security.manager
Code this method in an SQLJ source file so that it is called during the execution of
an SQLJ program:
System.setSecuritymanager(securityManager);
For information about writing an SQLJ source file, see Section 3, SQLJ Programming.
For information about using the command line, see Section 5, Processing SQLJ
Programs.
Required Permissions in the Policy File
If you enable Java security, the Java security manager reads the permissions specified
in the policy file at run time. Specific permissions must exist either in the default policy
file at JREHOME/lib/security/java.policy or in your own policy file specified by
-Djava.security.policy=my-policy-file.
To process and execute an SQLJ program, you must have these required permissions
for the SQLJ product file, sqlj.jar, and JDBC/MX driver, jdbcMx.jar, in the policy
file:
grant codeBase "file:/usr/tandem/sqlmx/lib/sqlj.jar" {
permission java.security.AllPermission;
};
grant codeBase "file:/usr/tandem/jdbcMx/current/lib/jdbcMx.jar"{
permission java.security.AllPermission;
};