6 Managing Security Realms with JMX

A security realm comprises mechanisms for protecting WebLogic resources. Each security realm consists of a set of configured security providers, which are modular components that handle specific aspects of security. You can create a JMX client that uses the providers in a realm to add or remove security data such as users and groups. You can also create a client that adds or removes providers and makes other changes to the realm configuration.

Understanding the Hierarchy of Security MBeans

Like other subsystems, the WebLogic Server security framework organizes its MBeans in a hierarchy that JMX clients can navigate without constructing JMX object names. However, the set of MBean types that are available in a security realm depends on which security providers you have installed in the realm, and the set of services that each security provider enables depends on how the provider was created.

The root of the security realm hierarchy is the RealmMBean. It contains all of the providers that have been configured for the realm. For example, its Authorizers attribute contains all authorization providers that have been configured for the realm. WebLogic Server installs a default set of security providers; therefore, by default the RealmMBeanAuthorizers attribute contains a DefaultAuthorizerMBean. However, you can uninstall these default providers and replace them with any number of your own providers or third-party providers. For information about the default security providers, see "Configuring WebLogic Security Providers" and "Configuring Authorization Providers" in Securing Oracle WebLogic Server.

Base Provider Types and Mix-In Interfaces

Each security provider must extend a base provider type. For example, DefaultAuthorizerMBean extends AuthorizerMBean, and any custom or third-party authorization provider also extends AuthorizerMBean. If a JMX client gets the value of the RealmMBeanAuthorizers attribute, the MBean server returns all MBeans in the realm that extend AuthorizerMBean. The JMX client can iterate through the list of providers and select one based on the value of its Name attribute or other criteria.

Base provider types can be enhanced by extending a set of optional mix-in interfaces. For example, if an authentication provider extends the UserEditorMBean, then the provider can add users to the realm.

Security MBeans

WebLogic Server's Security MBeans configure security providers in a security realm. The following tables describe the MBeans that configure different types of security providers.

Table 6-1 describes the MBeans that configure Authentication security providers, as well as the abstract MBean classes that Authentication providers must extend. In addition to the MBeans in this table, WebLogic Server includes configuration MBeans for each out-of-the-box Authentication provider.

The SSPI MBean that all Authentication providers with login services must extend. This MBean provides a ControlFlag to determine whether the Authentication provider is a REQUIRED, REQUISITE, SUFFICENT, or OPTIONAL part of the login sequence.

Configures and manages the certificate registry. It is both a builder and a validator. It supports building from the end certificate, the end certificate's subject DN, the end certificate's issuer DN and serial number, and the end certificate's subject key identifier.

The base MBean for Role Mapping providers. A Role Mapping provider for a non-deployable module must extend this MBean directly. A Role Mapping provider for a deployable module must extend the DeployableRoleMapperMBean.

Provides a set of methods for creating, editing, and removing a credential map that matches users, resources and credential action to keystore aliases and the corresponding passwords. A PKICredentialMapping provider MBean can optionally implement this MBean.

Provides a set of methods for reading a credential map that matches users and resources to keystore aliases and their corresponding passwords that can then be used to retrieve key information or public certificate information from the configured keystores. A PKICredentialMapping provider MBean can optionally implement this MBean.

Provides a set of methods for creating, editing, and removing a credential map that matches WebLogic users to remote usernames and their corresponding passwords. A Credential Mapping provider MBean can optionally extend this MBean.

Provides a set of methods for reading credentials and credential mappings. Credential mappings match WebLogic users to remote usernames and passwords. A Credential Mapping provider MBean can optionally extend this MBean.

Provides a set of methods for reading credentials and credential mappings. Credential mappings match WebLogic users to remote usernames and passwords. A Credential Mapping provider MBean can optionally extend this MBean.

Provides a general mechanism for returning lists. Derived MBeans extend this interface to add methods that access the data of the current object in the list. An optional mixin interface that any security provider may extend.

The SSPI MBean that security providers extend to indicate that the provider supports versionable applications. An optional mixin interface that a RoleMapper, Authorizer, or CredentialMapper provider MBean may extend.

Choosing an MBean Server to Manage Security Realms

When using JMX to manage security realms, you must use two different MBean servers depending on your task:

To set the value of a security MBean attribute, you must use the Edit MBean Server.

To add users, groups, roles, and policies, or to invoke other operations in a security provider MBean, you must use a Runtime MBean Server or the Domain Runtime MBean Server.

In addition, to prevent the possibility of incompatible changes, you cannot invoke operations in security provider MBeans if your client or another JMX client has an edit session currently active.

For example, the value of the MinimumPasswordLength attribute in DefaultAuthenticatorMBean is stored in the domain's configuration document. Because all modifications to this document are controlled by WebLogic Server, to change the value of this attribute you must use the Edit MBean Server and acquire a lock on the domain's configuration. The createUser operation in DefaultAuthenticatorMBean adds data to an LDAP server, which is not controlled by WebLogic Server. To prevent incompatible changes between the DefaultAuthenticatorMBean's configuration and the data that it uses in the LDAP server, you cannot invoke the createUser operation if you or other users are in the process of modifying the MinimumPasswordLength attribute. In addition, because changing this attribute requires you to restart WebLogic Server, you cannot invoke the createUser operation until you have restarted the server.

Working with Existing Security Providers

Because security providers can extend optional mix-in interfaces, not all security providers can perform all tasks. This flexibility enables your organization's security architect to design a realm for your security needs. The flexibility also makes the design of your JMX clients dependent upon the design and configuration of each realm.

For example, some realms might contain three types of Authentication providers:

One that extends UserEditorMBean to save administrative users to an LDAP server

One that extends UserEditorMBean to save customers to a database management system

One that does not extend UserEditorMBean and is used only to authenticate existing users

To work with the Authentication providers in this realm, your JMX client must be able to determine which one can add users to the appropriate repository.

Table 6-4 discusses techniques for finding a security provider that is appropriate for your task.

Table 6-4 Finding a Provider in the Realm

Technique

Description

Find by name

Each security provider instance is assigned a short name when an administrator configures it for the realm. Your JMX client can look up all providers of a specific type (such as all Authentication providers) and choose the one that matches a name.

For an example of such a JMX client, start the WebLogic Server Examples Server. From the Examples Server home page, click on "Extending a Realm Using JMX." The source for this JMX client is installed as

If you use this technique, consider saving the name of the security provider in a configuration file instead of hard-coding it in your JMX client. The configuration file enables system administrators to change the providers in the realm and update the properties file instead of requiring you to update and recompile the JMX client.

Find by MBean type

If the system administrator always wants to use the same type of provider for a task, then your JMX client can find the provider MBean that is of the specified type.

For example, if the system administrator always wants to use a SQLAuthenticatorMBean to add customers to a realm, your JMX client can find an instance of SQLAuthenticatorMBean.

While this technique requires no user input, it assumes:

There will always be an instance of SQLAuthenticatorMBean in the realm and this one instance extends UserEditorMBean.

If there are multiple instances of SQLAuthenticatorMBean, all of them extend UserEditorMBean and it does not matter which instance is used.

You can create a JMX client that learns about the class hierarchy for each provider MBean instance and chooses an instance that extends the mix-in interface you need for your task. For example, your client can discover which Authentication provider extends UserEditorMBean. See Discovering Available Services.

Use this technique if you know that your security realm will contain only one MBean that extends the needed mix-in interface, or if it does not matter which one you use.

Get the value of the RealmMBean attribute that contains instances of the security provider type.

For example, to get all Authentication providers, get the value of the RealmMBeanAuthenticationProviders attribute.

For each security provider MBean in the RealmMBean attribute, get the name of the MBean's class (see Example 6-1):

Get the provider MBean's javax.management.ModelMBeanInfo object.

Use MBeanServerConnection.getMBeanInfo(Provider-MBean)

where Provider-MBean is a provider MBean that you retrieved from RealmMBean.

Get the MBean info's javax.management.Descriptor object, and then get the value of the Descriptor's interfaceClassName field.

Use the WebLogic Server MBean type service to find all security provider MBean classes that extend a particular base type or mix-in interface (see Example 6-1):

Determine the fully-qualified interface name of the base type or mix-in interface.

Each entry in the WebLogic Server MBean Reference lists the fully-qualified interface name of WebLogic Server provider MBeans. If you use a third-party provider, refer to the third-party documentation for this information.

For example, the fully-qualified interface name of the UserEditorMBean mix-in interface is weblogic.management.security.authentication.UserEditorMBean. (See "UserEditorMBean" in the Oracle WebLogic Server MBean Reference.)

Construct the MBeanTypeService MBean's object name.

The MBeanTypeService MBean is always registered under the following javax.management.ObjectName:

Example: Adding Users to a Realm

The code example in Example 6-2 adds a user to a security realm and adds the user to the Administrators group by searching through all of the authentication providers in the realm and using the first one that extends UserEditorMBean.

Note the following about the code example:

Similar to the code in the MedRec example domain, the user name and password come from a JavaBean that was created from an Apache Struts action.

To see the MedRec code:

Start the WebLogic Server Examples Server.

From the Examples Server home page, click on "Extending a Realm Using JMX."

The code does not need to lock the domain's configuration because it is not modifying the configuration of the security MBean itself. Instead, it is invoking an operation in the default Authorization provider which saves security data in an LDAP server.

Modifying the Realm Configuration

While security provider MBeans handle specific aspects of security, such as authentication and authorization, two other MBeans handle general, realm-wide and domain-wide aspects of security:

RealmMBean represents a security realm. JMX clients can use it to add or remove security providers and to specify such behaviors as whether Web and EJB containers call the security framework on every access or only when security is set in the deployment descriptors.

These two MBeans persist their data in WebLogic Server configuration files. Therefore, to modify attribute values in RealmMBean or SecurityConfigurationMBean, you must use the Edit MBean Server and ConfigurationManagerMBean as described in Chapter 5, "Managing a Domain's Configuration with JMX."

Scripting on this page enhances content navigation, but does not change the content in any way.