The information in this chapter applies only to Java SE applications, and the audience are developers of Java SE applications.
For similar information about Java EE applications, see Chapter 23, "Configuring Java EE Applications to Use OPSS."
This chapter includes in the following topics:
In order to use OPSS in a Java SE application, the developer should be aware that:
The file oracle_common/modules/oracle.jps_11.1.1/jps-manifest.jar
must be in the class path.
The application must call JpsStartup.start()
at initialization.
The following system properties must be set:
oracle.security.jps.config
, the file path to the file jps-config-jse.xml
.
common.components.home
, the path to the oracle common directory.
java.security.policy
, the file path to the file java.policy
.
The file java.policy
must be standard compliant and you customize its contents according to your needs; for a sample java.policy
file, see domain_config/jse/java.policy
. This file and the file weblogic.policy
have similar contents.
opss.audit.logDirectory
, the path to a writable directory where audit records are written.
For other (optional) system properties you can set, see Section F.1, "OPSS System Properties."
The JVM option -Djava.security.policy
specifies the location of the Oracle WebLogic Server policy file weblogic.policy
, typically located in the directory wl_home/server/lib
.
The application should use the OPSS class AppSecurityContext
, as illustrated in the following sample snippet:
Note:
The sample snippet is not required if you want to use only CSF/KSS functionality.String appID = AppSecurityContext.getApplicationID(); try { setApplicationID(appName); ..... } finally { setApplicationID(appID ); } } private static void setApplicationID(final String applicationID) { AccessController.doPrivileged(new PrivilegedAction() { public Object run() { AppSecurityContext.setApplicationID(applicationID); return null; } }); }
The call AppSecurityContext.setApplicationID
requires a codesource permission like the following:
<grant> <grantee> <codesource> <url>myJavaSEapp/-</url> </codesource> </grantee> <permissions> <permission> <class>oracle.security.jps.JpsPermission</class> <name>AppSecurityContext.setApplicationID.myAppStripeID</name> </permission> </permissions> </grant>
The OPSS policy provider must be explicitly set in Java SE applications, as illustrated in the following snippet:
java.security.Policy.setPolicy(new oracle.security.jps.internal.policystore.JavaPolicyProvider())
Not setting the policy provider explicitly in a Java SE application may cause runtime methods (such as JpsAuth.checkPermission
) to return incorrect values.
For information about how to configure the OPSS security store, see Chapter 8, "Configuring the OPSS Security Store."
This section describes the following enhancements to the class JpsStartup
:
A set of OPSS states for the method JpsStartup.start()
Several run-time options for the method JpsStartup.start()
A new constructor for the class JpsStartup
The method JpsStartup.getState()
For complete information about this class, see Oracle Fusion Middleware Java API Reference for Oracle Platform Security Services. For examples of use, see OPSS Starting Examples.
This section contains the following information:
The transition states of JpsStartup.start()
are defined by the following constants:
UNINITIALIZED - The default state before JpsStartup.start()
is invoked.
INITIALIZING - The state to which it transitions after JpsStartup.start()
has been invoked.
FAILURE - The state to which it transitions if any failure has occurred during the INITIALIZING state.
ACTIVE - The state to which it transitions if all services have been started without failures, that is, if no failures have occurred in the INITIALIZING state.
INACTIVE - The state to which it transitions after JpsStatup.stop()
is invoked.
The run-time options with which you can invoke the class constructor jpsStartup()
are described in the following table:
Table 24-1 JpsStartup Run-Time Options
Option | Values | Default | Description |
---|---|---|---|
ACTIVE_CONTEXT |
The name of an active context or the string "default". |
"default" |
If passed, use the specified context; otherwise, use the "default" context. |
ENABLE_JAVA_POLICY_PROVIDER |
TRUE or FALSE |
TRUE |
Set to TRUE to use the Java2 policy provider; otherwise, set to FALSE. |
ENABLE_AUDIT_SERVICE_EXT |
TRUE or FALSE |
TRUE |
Set to TRUE to start the audit service with audit monitoring and auditloader; otherwise, set to FALSE. |
ENABLE_POLICY_STORE_SERVICE_EXT |
TRUE or FALSE |
TRUE |
Set to TRUE to start the Policy Distribution Point (PDP) with policy change scanner thread; otherwise, set to FALSE. |
ENABLE_DEPLOYMENT_HANDLING |
TRUE or FALSE |
TRUE |
Set to TRUE to create deployment handlers; otherwise, set to FALSE. |
RUNTIME_MODE |
DEFAULT or SCRIPT |
DEFAULT |
Set to SCRIPT to have the options ENABLE_JAVA_POLICY_PROVIDER , ENABLE_AUDIT_SERVICE_EXT, ENABLE_POLICY_STORE_SERVICE_EXT, and ENABLE_DEPLOYMENT_HANDLING set to FALSE; otherwise set to DEFAULT. |
JPS_CONFIG |
The path to the file jps.config.xml |
The path specified by the property oracle.security.jps.config |
If passed, used the specified path; otherwise, use the default path. |
The following constructor has been added to the class:
JpsStatup(java.lang.String platformType, java.util.Map<java.lang.String, ContextConfiguration> ctxtCfgs, java.util.Map<java.lang.String,?> options)
The argument ContextConfiguration
holds the details about the context within <jpsContext> in the configuration file jps-config-jse.xml
. To obtain ContextConfiguration before calling JpsStartup, see examples 3 and 4 in OPSS Starting Examples.
To start multiple contexts (in addition to the "default" context), pass multiple context information; see example 4 in OPSS Starting Examples. To start some context (other than the "default" context), then pass the context name; if nothing is passed, then the default context is started.
The argument options
encloses all the startup properties used to start OPSS; for the list of available options, see Table 24-1.
This constructor is typically invoked when OPSS is to be started with additional ContextConfiguration
details; see example 3 in OPSS Starting Examples.
This method returns the state OPSS is at the point of invocation, that is, it returns one of INITIALIZING, UNINITIALIZED, FAILURE, ACTIVE or INACTIVE.
The following code examples illustrate the use of the class JpsStartup
in typical starting scenarios.
The following example illustrates how to start OPSS without any explicit parameters.
JpsStartup jpsStartUp = new JpsStartup(); jpsStartUp.start(); jpsStartUp.getState(); jpsStartUp.stop();
The following example illustrates how to start OPSS with the following configuration:
default1
is the default context passed as part of the contextConfig
map.
To disable audit runtime services, such as the audit loader and the audit monitoring, then pass the parameter "ENABLE_AUDIT_SERVICE_EXT" set to "FALSE"; note that by default this parameter is enabled.
To disable runtime services, such as policy changes scanner thread, pass the parameter "ENABLE_POLICY_STORE_SERVICE_EXT" set to "FALSE"; note that by default this parameter is enabled.
ConfigurationServiceProvider prov = ConfigurationServiceProvider.newInstance(); ConfigurationService configService = prov.getConfigurationService(); ContextConfiguration configuration = configService.getContextConfiguration("default1"); Map<String, ContextConfiguration> contextConfig = new HashMap<String, ContextConfiguration>(); contextConfig.put(JpsConstants.DEFAULT_CONTEXT_KEY, configuration); Map<String, Object> option = new HashMap<String, Object>(); option.put(JpsConstants.ENABLE_AUDIT_SERVICE_EXT, "FALSE"); option.put(JpsConstants.ENABLE_POLICY_STORE_SERVICE_EXT, "FALSE"); JpsStartup jpsStartUp = new JpsStartup("JSE", contextConfig, option); jpsStartUp.start(); jpsStartUp.stop();
The following example illustrates how to start OPSS with additional ContextConfigurations
details.
Map<String, Object> startupOption = new HashMap<String, Object>(); ConfigurationServiceProvider prov = ConfigurationServiceProvider.newInstance(); ConfigurationService configService = prov.getConfigurationService(); ContextConfiguration configuration = configService.getContextConfiguration("default1"); Map<String, ContextConfiguration> contextConfig = new HashMap<String, ContextConfiguration>(); contextConfig.put(JpsConstants.DEFAULT_CONTEXT_KEY, configuration); JpsStartup jpsStartUp = new JpsStartup("JSE", contextConfig, startupOption); jpsStartUp.start(); jpsStartUp.stop();
The following example illustrates how to start OPSS with multiple contexts. It is assumed that the jps.config.xml
file contains the following contexts:
<jpsContexts default="default"> <jpsContext name="default"> <serviceInstanceRef ref="credstore"/> ... </jpsContext> <jpsContext name="default1"> <serviceInstanceRef ref="idstore.loginmodule"/> ... </jpsContext> <jpsContext name="default2"> <serviceInstanceRef ref="keystore"/> ... </jpsContext> <jpsContext name="default3"> <serviceInstanceRef ref="policystore "/> ... </jpsContext> <jpsContext name="bootstrap_credstore_context"> <serviceInstanceRef ref="bootstrap.credstore"/> </jpsContext> </jpsContexts> ConfigurationServiceProvider prov = ConfigurationServiceProvider.newInstance(); ConfigurationService configService = prov.getConfigurationService(); ContextConfiguration configuration1 = configService.getContextConfiguration("default1"); ContextConfiguration configuration2 = configService.getContextConfiguration("default2"); ContextConfiguration configuration3 = configService.getContextConfiguration("default3"); Map<String, ContextConfiguration> contextConfig = new HashMap<String, ContextConfiguration>(); contextConfig.put(JpsConstants.DEFAULT_CONTEXT_KEY, configuration); contextConfig.put(("default1", configuration1); contextConfig.put(("default2", configuration2); contextConfig.put(("default3", configuration3); Map<String, Object> startupOption = new HashMap<String, Object>(); startupOption.put(JpsConstants.ACTIVE_CONTEXT, "default"); JpsStartup jpsStartUp = new JpsStartup("JSE", contextConfig, startupOption); jpsStartUp.start(); jpsStartUp.stop();
The parameter "ACTIVE_CONTEXT" specifies the context to use as default. If the JpsConstants.DEFAULT_CONTEXT_KEY is not passed as part of map, then by default the "default" context is started provided there is no "ACTIVE_CONTEXT" key is passed as part of startupOption
map.
The following example illustrates how to start OPSS in "SCRIPT" mode. This mode is typically used during migration or upgrading, when runtime services are not required to be started.
Map<String, Object> startupOption = new HashMap<String, Object>(); startupOption.put(JpsConstants.RUNTIME_MODE, "SCRIPT"); JpsStartup jpsStartUp = new JpsStartup("JSE", startupOption); jpsStartUp.start(); jpsStartUp.stop();
This sections describes, per sevice, the OPSS support in Java SE applications.
This section explains the identity store support for Java SE applications, and it includes the following sections:
For certification information, see Certification Matrix at http://www.oracle.com/technetwork/middleware/downloads/fmw-11gr1certmatrix.xls
.
Authentication is the mechanism by which callers prove that they are acting on behalf of specific users or system. Using data, such as name-password combinations, authentication answers the question Who are you? The term identity store refers to the storage where identity data is kept, and authentication providers are ways to access an identity store.
An application obtains information from an OPSS security store (identity, policy, or credential store) and manages its contents using the OPSS APIs, as illustrated in the following graphic:
A Java SE application can use an LDAP-based identity store configured in the file jps-config-jse.xml
with the elements <serviceProvider>
, <serviceInstance>
, and <jpsContext>
, as illustrated in the following snippet:
<serviceProviders> <serviceProvider type="IDENTITY_STORE" name="idstore.ldap.provider" class="oracle.security.jps.internal.idstore.ldap.LdapIdentityStoreProvider"> <description>Prototype LDAP-based ID store</description> </serviceProvider> </serviceProviders> <serviceInstances> <serviceInstance name="idstore.ldap" provider="idstore.ldap.provider"> <property name="idstore.type" value="OID"/> <property name="max.search.filter.length" value="500"/> <extendedProperty> <name>user.search.bases</name> <values> <value>cn=users,dc=us,dc=oracle,dc=com</value> </values> </extendedProperty> <extendedProperty> <name>group.search.bases</name> <values> <value>cn=groups,dc=us,dc=oracle,dc=com</value> </values> </extendedProperty> </serviceInstance> </serviceInstances> <jpsContexts default="ldap_idstore"> <jpsContext name="ldap_idstore"> <serviceInstanceRef ref="idstore.ldap"/> </jpsContext> <jpsContext name="bootstrap_credstore_context"> <serviceInstanceRef ref="bootstrap.cred"/> </jpsContext> </jpsContexts>
Note the following points:
The name of the <serviceInstance>
(idstore.ldap
in the example above) can have any value, but it must match the instance referenced in element <serviceInstanceRef>
.
The name of the <serviceProvider>
(idstore.ldap.provider
in the example above) can have any value, but it must match the provider in element <serviceInstance>
.
To add properties to a provider instance with a prescribed script, see Appendix E, "Configuring OPSS Service Provider Instances with a Script."
A login module is a component that authenticates users and populates a subject with principals. This process occurs in two distinct phases: during the first phase, the login module attempts to authenticate a user requesting, as necessary, a name and a password or some other credential data; only if this phase succeeds, the second phase is invoked. During the second phase, the login module assigns relevant principals to a subject, which is eventually used to perform some privileged action.
A Java SE application can use a stack of login modules to authenticate its users; each module performs its own computations independently from the others in the stack. These and other services are specified in the file jps-config-jse.xml
.
OPSS APIs includes the interface oracle.security.jps.service.login.LoginService
which allows a Java SE application to invoke not just all login modules in a stack, but a subset of them in a prescribed order.
The name of the jps context (defined in the configuration file jps-config-jse.xml)
passed to the method LoginContext
in the LoginService
interface determines the stack of login modules that an application uses. The standard JAAS API LoginContext
can also be used to invoke the login modules defined in the default context
The sequence in which a jps context lists the login modules in a stack is significant, since the authentication algorithm takes this order into account in addition to other data, such as the flag that identifies the module security level (required, sufficient, requisite, or optional).
Out-of-the-box, the identity store service is file-based, its contents being provisioned in the file system-jazn-data.xml; the service can be reconfigured to use an LDAP-based identity store.
OPSS supports the Identity Store login module in Java SE applications, which can be used for authentication or identity assertion, as explained in the following sections:
The class associated with this login module is the following:
oracle.security.jps.internal.jaas.module.idstore.IdStoreLoginModule
An instance of this module is configured in the file jps-config-jse.xml
as illustrated in the following fragment:
<serviceInstance name="idstore.loginmodule" provider="jaas.login.provider"> <description>Identity Store Login Module</description> <property name="loginModuleClassName" value="oracle.security.jps.internal.jaas.module.idstore.IdStoreLoginModule"/> <property name="jaas.login.controlFlag" value="REQUIRED"/> </serviceInstance>
Properties specific to this login module include the following:
remove.anonymous.role (defaults to true) add.application.role (defaults to true)
This section illustrates the use of the Identity Store login module for basic username and password authentication.
The following code fragment illustrates how to set a callback handler and a context:
import javax.security.auth.Subject; import javax.security.auth.login.LoginContext; Subject sub = new Subject(); CallbackHandler cbh = new YourCallbackHandler(); LoginContext context = new LoginContext(appName, subject, cbh); context.login();
The callback handler must be able to handle NameCallback
and PasswordCallback
.
Configuring jps-config-jse.xml
The following jps-config-jse.xml
file fragment illustrates the configuration of the context appName
:
<jpsContext name="appName"> <serviceInstanceRef ref="jaaslm.idstore1"/> </jpsContext> <serviceProvider type="JAAS_LM" name="jaaslm.idstore" class="oracle.security.jps.internal.jaas.module.idstore.IdStoreLoginModule"> <description>Identity Store-based LoginModule </description> </serviceProvider> <serviceInstance name="jaaslm.idstore1" provider="jaaslm.idstore"> <property name="jaas.login.controlFlag" value="REQUIRED"/> <property name="debug" value="true"/> <property name="addAllRoles" value="true"/> </serviceInstance>
The following code snippet illustrates a callback handler able to handle name and password callback:
import javax.security.auth.callback.*; import java.io.IOException; public class SampleCallbackHandler implements CallbackHandler { //For name/password callbacks private String name = null;private char[] password = null; public SampleCallbackHandler(String name, char[] pwd) { if (name == null || name.length() == 0 ) throw new IllegalArgumentException("Invalid name "); else this.name = name; if (pwd == null || pwd.length == 0) throw new IllegalArgumentException("Invalid password "); else this.password = pwd; } public String getName() { return name; } public char[] getPassword() { return password; } public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { if (callbacks != null && callbacks.length > 0) { for (Callback c : callbacks) { if (c instanceof NameCallback) { ((NameCallback) c).setName(name); } else if (c instanceof PasswordCallback) { ((PasswordCallback) c).setPassword(password); } else { throw new UnsupportedCallbackException(c); } } } } }
To use the Identity Store login module for assertion, a developer must:
Provide the appropriate permission for the caller to execute the protected method setIdentity
. This requires granting the permission oracle.security.jps.JpsPermission
with the name IdentityAssertion
.
Implement a callback handler that uses the class oracle.security.jps.callback.IdentityCallback
as shown in the code sample below.
The above two requirements are illustrated in the following configuration and code samples.
Provisioning the JpsPermission
The following configuration sample illustrates a grant allowing the code MyApp
the required JpsPermission
to execute protected methods in the assertion login module:
<grant> <grantee> <codesource> <url>file:${soa.oracle.home}/application/myApp.ear</url> <--! soa.oracle.home is a system property set when the server JVM is started --> </codesource> </grantee> <permissions> <permission> <class>oracle.security.jps.JpsPermission</class> <name>IdentityAssertion</name> </permission> </permissions> </grant>
The following configuration sample illustrates a grant allowing the principal jdoe
the required JpsPermission
to execute the assertion login module:
<grant> <grantee> <principals> <principal> <class>weblogic.security.principal.WLSUserImpl</class> <name>jdoe</name> </principal> </principals> </grantee> <permissions> <permission> <class>oracle.security.jps.JpsPermission</class> <name>IdentityAssertion</name> </permission> </permissions> </grant>
Implementing the CallbackHandler
The following code fragment illustrates an implementation of the callback handler:
import javax.security.auth.callback.Callback; import javax.security.auth.callback.CallbackHandler; import javax.security.auth.callback.NameCallback; import javax.security.auth.callback.PasswordCallback; import javax.security.auth.callback.UnsupportedCallbackException; import oracle.security.jps.callback.IdentityCallback; public class CustomCallbackHandler implements CallbackHandler { private String name = null; private char[] password; public CustomCallbackHandler(String name) { this.name = name; } public CustomCallbackHandler(String name, char[] password) { this.name = name; this.password = password; } public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (Callback callback : callbacks) { if (callback instanceof NameCallback) { NameCallback nc = (NameCallback) callback; nc.setName(name); } else if (callback instanceof PasswordCallback) { PasswordCallback pc = (PasswordCallback) callback; pc.setPassword(password); } else if (callback instanceof IdentityCallback) { IdentityCallback idcb = (IdentityCallback)callback; idcb.setIdentity(name); idcb.setIdentityAsserted(true); idcb.setAuthenticationType("CUSTOM"); } else { //throw exception throw new UnsupportedCallbackException(callback); } } } }
The following code fragment illustrates the implementation of a login module:
import javax.security.auth.callback.CallbackHandler; import javax.security.auth.login.LoginContext; import oracle.security.jps.service.JpsServiceLocator; import oracle.security.jps.service.login.LoginService; public class LoginModuleExample { private static final String CONTEXT_NAME = "JSE_UserAuthnAssertion"; public LoginModuleExample() { super(); } public Subject assertUser(final String username) throws Exception { CallbackHandler cbh = AccessController.doPrivileged(new PrivilegedExceptionAction<CallbackHandler>() { public CallbackHandler run() throws Exception { return new CustomCallbackHandler(username); } }); Subject sub = new Subject(); LoginService ls = JpsServiceLocator.getServiceLocator().lookup(LoginService.class); LoginContext context = ls.getLoginContext(sub, cbh); context.login(); Subject s = context.getSubject(); return s; } public Subject authenticate(final String username, final char[] password) throws Exception { CallbackHandler cbh = new CustomCallbackHandler(username, password); Subject sub = new Subject(); LoginService ls = JpsServiceLocator.getServiceLocator().lookup(LoginService.class); LoginContext context = ls.getLoginContext(sub, cbh); context.login(); Subject s = context.getSubject(); return s; } public static void main(String[] args) { LoginModuleExample loginModuleExample = new LoginModuleExample(); try { System.out.println("authenticated user subject = " + loginModuleExample.authenticate("testUser", "welcome1".toCharArray())); System.out.println("asserted user subject = " + loginModuleExample.assertUser("testUser")); } catch (Exception e) { e.printStackTrace(); } } }
To invoke a login module programmatically in Java SE applications, use the method getLoginContex
t of the interface oracle.security.jps.service.login.LoginService
.
Similar to the method LoginContext
in the standard JAAS API, getLoginContext
returns an instance of a LoginContext object that can be used to authenticate a user, but, more generally, it also allows the use of any number of login modules in any order. Authentication is then performed on just those login modules and in the order they were passed.
The following code fragment illustrates user authentication against a subset of login modules in a prescribed order using getLoginContext
:
import oracle.security.jps.service.ServiceLocator; import oracle.security.jps.service.JpsServiceLocator; import oracle.security.jps.service.login.LoginService; //Obtain the login service ServiceLocator locator = JpsServiceLocator.getServiceLocator(); LoginService loginService = locator.lookup(LoginService.class); //Create the handler for given name and password CallbackHandler cbh = new MyCallbackHandler("name", "password".toCharArray()); //Invoke login modules selectively in a given order selectiveModules = new String[]{"lmName1", "lmName2", "lmName3"}; LoginContext ctx = loginService.getLoginContext(new Subject(), cbh, selectiveModules); ctx.login(); Subject s = ctx.getSubject();
selectiveModules
is an array of (login module) names, and the authentication uses precisely those login modules named in the array in the order listed in the array. Each name in the array must be the name of a service instance listed in the default context of the file jps-config-jse.xml
.
The following fragment illustrates the configuration of a stack of two login modules:
<serviceProvider type="LOGIN" name="jaas.login.provider" class="oracle.security.jps.internal.login.jaas.JaasLoginServiceProvider"> <description>Common definition for any login module instances</description> </serviceProvider> <serviceInstance name="auth.loginmodule" provider="jaas.login.provider"> <description>User Authentication Login Module</description> <property name="loginModuleClassName" value="oracle.security.jps.internal.jaas.module.authentication.JpsUserAuthenticationLoginModule"/> <property name="jaas.login.controlFlag" value="REQUIRED"/> </serviceInstance> <serviceInstance name="custom.loginmodule" provider="jaas.login.provider"> <description>My Custom Login Module</description> <property name="loginModuleClassName" value="my.custom.MyLoginModuleClass"/> <property name="jaas.login.controlFlag" value="REQUIRED"/> </serviceInstance> <jpsContexts default="aJpsContext"> <jpsContext name="aJpsContext"> <serviceInstanceRef ref="auth.loginmodule"/> <serviceInstanceRef ref="custom.loginmodule"/> </jpsContext> </jpsContexts>
This section provides the background you need to get started leveraging the Common Audit Framework (CAF) to audit events with your Java SE applications. It explains basic requirements and describes some common audit usage scenarios for Java SE clients. It contains these topics:
This section explains useful audit concepts.
See Also:
For background information about using OPSS in Java SE environments, see Section 24.1.Audit Configuration Properties
As explained in Section 24.1, the audit configuration resides in the jps-config-jse.xml
file.
Here is an example fragment from that file showing the audit properties:
<serviceInstance provider="audit.provider" name="audit"> <property value="Medium" name="audit.filterPreset"/> <property value="0" name="audit.maxDirSize"/> <property value="104857600" name="audit.maxFileSize"/> <property value="" name="audit.specialUsers"/> <property value="" name="audit.customEvents"/> <property value="Db" name="audit.loader.repositoryType"/> <property value="file" name="auditstore.type"/> </serviceInstance>
See Also:
See Table 13-1 for descriptions of these properties.The audit run-time service enables the application to audit various events dictated by conditions specified in audit metadata (which resided in audit store), and records each event in the bus-stop files.
Other notable processes include the audit loaders which move data from bus-stop files to the database.
These files are explicitly designed to hold the newly generated audit records. Although they are sometimes referred to mistakenly as audit logs, they should not be confused with system log files.
The following sections provide more details about aspects of audit operation including requirements and recommendations for the JavaSE environment.
Note:
Starting with 11gRelease 1 (11.1.1.9), the naming format of bus-stop files has changed to:$hostname_$processId_audit_$majorVersion_$minorVersion.log
For example:
example.myhost.com_12345_audit_1_0.log
Java SE clients must specify a writable directory to which audit bus-stop files will be written. To configure this directory:
In a WebLogic environment, use the setAuditRepository
() WLST command. For example:
setAuditRepository(logDirectory="/Audit")
Outside a WebLogic environment, set it using the audit service property audit.logDirectory
in the file jps-config-jse.xml
file.
WARNING:
If the runtime process is unable to determine a writable directory, the audit service may stop working.
This directory can be shared between JavaSE client processes if:
You set the directory with the audit.logDirectory service property in the file jps-config-jse.xml
and all the Java SE clients/processes in the environment use the same jps-config-jse.xml
or
the same value for the bus-stop directory is passed as a system property to all Java SE clients.
The audit data loader is a thread/process that pushes the data from the bus-stop file to a database.
Note:
Having the audit.loader.repositoryType property set to 'Db' is the default requirement for the audit service loader for both JavaEE and JavaSE environments.There are two kinds of loaders for JavaSE applications:
The first is the JavaSE audit service loader, a thread started by the runtime OPSS audit service.
Out-of-the-box, this audit loader is disabled. To enable it, pass "audit.loader.enable=true" to the JVM.
The second loader is a standalone JavaSE application. It is the recommended loader for this environment, especially if you are using a shared directory as described in Section 24.4.2.
For details about starting the stand-alone loader, see Section 13.2.6.2 and the example in the final step of Section 24.4.4.1.
This section describes some common scenarios that implement auditing in Java SE.
We consider environments with and without a co-located Oracle WebLogic Server.
After setting up the domain, take these steps as administrator:
Set up the audit loader configuration by either executing the setAuditRepository() WLST command or by using Fusion Middleware Control.
Note:
setAuditRepository is an online command.This step also updates appropriate properties in the file jps-config.xml
and jps-config-jse.xml
, thus enabling both Java SE and Java EE scenarios. The WLST script is similar to the following example:
# logDirectory is the location of the audit log directory # jdbcSring is the connect string # user and pass refer to the IAU append schema user and password # (These get stored in bootstrap credential store) setAuditRepository(switchToDB = "true",dataSourceName = "jdbc/AuditDB",interval = "20", timezone="utc", logDirectory="/foo/bar", jdbcString="jdbc:oracle:thin:@host:1521:sid", dbUser="test_iau_append", dbPassword="password");
Note:
A standalone audit loader is not needed if the writable audit directory for JavaSE processes is set to be the same directory as the log directory for Oracle WebLogic Server (say DOMAIN_HOME/servers/AdminServer/logs). The container's audit loader process takes care of this task.If choosing a separate writable audit directory for JavaSE processes, start a standalone audit loader to push these records to the database. Pass one of the system properties, setting it to the value of the bus-stop directory. In the example below, oracle.instance is used:
$JAVA_HOME/bin/java
-classpath $COMMON_COMPONENTS_HOME/modules/oracle.jps_11.1.1/jps-manifest.jar:
$COMMON_COMPONENTS_HOME/modules/oracle.jdbc_11.1.1/ojdbc6dms.jar:
$COMMON_COMPONENTS_HOME/modules/oracle.iau_11.1.1./fmw_audit.jar
-Doracle.instance=$ORACLE_INST
-Doracle.security.jps.config=path_to_jps-config-jse.xml
oracle.security.audit.ajl.loader.StandaloneAuditLoader
See Also:
The final step in Section 24.4.4.2.The assumption here is that a middleware home is available but no Oracle WebLogic Server is running. So Fusion Middleware Control or online WLST commands such as setAuditRepository() cannot be used.
The steps are as follows:
Out-of-the-box, audit runtime is enabled in JavaSE if a writable directory is provided to the JVM.
Since audit.logDirectory service property is not available by default in the file jps-config-jse.xml
, we recommend that you set either opss.audit.logDirectory OR oracle.instance system property to specify the bus-stop directory.
As administrator, you then add a bootstrap credential to the bootstrap credential store as defined in the file jps-config-jse.xml
using the addBootStrapCredential( ) WLST command:
addBootStrapCredential(jpsConfigFile='../../../user_projects/domains/base_domain/config/fmwconfig/jps-config-jse.xml', map='AuditDbPrincipalMap', key='AuditDbPrincipalMap', username='TEST_IAU_APPEND', password='password')
If JavaSE processes use a shared audit directory, start the standalone audit loader to push these records to the database.
Finally, ensure that the relevant audit loader is operational. There are two scenarios:
The audit directory is not shared (that is, every JavaSE process writes to its own audit directory).
In this case, simply enable the runtime service's audit loader by specifying audit.loader.enable=true.
The audit directory is shared (that is, multiple JavaSE processes write to the same audit directory).
In this case, start the standalone audit loader as shown in Section 24.4.4.1.
Note:
The standalone audit loader can also be used when the directory is not shared.This section illustrates the configuration of the following artifacts:
XML policy and credential stores
XML and LDAP identity stores
Login Module Principals
XML Policy and Credential Stores Configuration
The following snippets illustrate the configuration of XML-based policy and credential stores. The contents of an XML-based policy store is specified in the file system-jazn-data.xml
; the contents of an XML-based credential store is specified in the file cwallet.sso
.
<serviceProviders> <serviceProvider class="oracle.security.jps.internal.policystore.xml.XmlPolicyStoreProvider" name="policystore.xml.provider" type="POLICY_STORE"> <description>XML-based PolicyStore Provider</description> </serviceProvider> <serviceProvider class="oracle.security.jps.internal.credstore.ssp.SspCredentialStoreProvider" name="credstoressp" type="CREDENTIAL_STORE"> <description>SecretStore-based CSF Provider</description> </serviceProvider> </serviceProviders> <serviceInstances> <serviceInstance location="./" provider="credstoressp" name="credstore"> <description>File-based Credential Store Service Instance</description> </serviceInstance> <serviceInstance location="./system-jazn-data.xml" provider="policystore.xml.provider" name="policystore.xml"> <description>File-based Policy Store Service Instance</description> </serviceInstance> </serviceInstances>
XML Identity Store Configuration
The following snippets illustrate the configuration of an XML-based identity store. The contents of an XML-based identity store is specified in the file system-jazn-data.xml
.
<serviceProvider class="oracle.security.jps.internal.idstore.xml.XmlIdentityStoreProvider" name="idstore.xml.provider" type="IDENTITY_STORE"> <description>XML-based Identity Store Service Provider</description> </serviceProvider> <serviceInstance location="./system-jazn-data.xml" provider="idstore.xml.provider" name="idstore.xml"> <description>File Based Identity Store Service Instance</description> <property value="jazn.com" name="subscriber.name"/> </serviceInstance>
LDAP Identity Store Configuration
The snippets below illustrate the configuration of an LDAP-based identity store, including the required configuration for the bootstrap credentials to access the LDAP server. The service instance property idstore.type
can have the values stated in the Certification Matrix.
For certification information, see Certification Matrix at http://www.oracle.com/technetwork/middleware/downloads/fmw-11gr1certmatrix.xls
.
<serviceProvider class="oracle.security.jps.internal.idstore.ldap.LdapIdentityStoreProvider" name="idstore.ldap.provider" type="IDENTITY_STORE"> <description>LDAP-based Identity Store Service Provider</description> </serviceProvider> <serviceProvider class="oracle.security.jps.internal.credstore.ssp.SspCredentialStoreProvider" name="credstoressp" type="CREDENTIAL_STORE"> <description>SecretStore-based CSF Provider</description> </serviceProvider> <serviceInstance name="idstore.oid" provider="idstore.ldap.provider"> <property name="subscriber.name" value="dc=us,dc=oracle,dc=com"/> <property name="idstore.type" value="OID"/> <property value=ldap://myOID.com:3555 name="ldap.url"/> <extendedProperty> <name>user.search.bases</name> <values> <value>cn=users,dc=us,dc=oracle,dc=com</value> </values> </extendedProperty> <extendedProperty> <name>group.search.bases</name> <values> <value>cn=groups,dc=us,dc=oracle,dc=com</value> </values> </extendedProperty> <property name="username.attr" value="uid"/> <propperty name="group.attr" value="cn"/> </serviceInstance> <serviceInstance location="./bootstrap" provider="credstoressp" name="bootstrap.cred"> <property value="./bootstrap" name="location"/> </serviceInstance>
The following properties are set in the out-of-the-box jps-config-jse.xml
file:
<property name="oracle.security.jps.enterprise.user.class" value="weblogic.security.principal.WLSUserImpl"/> <property name="oracle.security.jps.enterprise.role.class" value="weblogic.security.principal.WLSGroupImpl"/>
The above propeties must be used in any login module; this implies that the principals that represent users and groups in the identity store are the following:
weblogic.security.principal.WLSUserImpl weblogic.security.principal.WLSGroupImpl