All Examples  This Package

Class examples.security.rdbmsrealm.RdbmsRealm

java.lang.Object
   |
   +----examples.security.rdbmsrealm.RdbmsRealm

public class RdbmsRealm
extends Object
implements ListableRealm, CacheableRealm
Implements a realm that uses data stored in a relational database. The data is pulled into memory as needed and cached. The realm is read-only but can be administered through the database.

The realm is configurable through a Java Properties resource named weblogic.realm_properties. Here is a description of its properties:

The implementation calls factory functions for users, groups, and ACLs so that subclasses can override these. The factory functions at this level assume a certain number and order of the columns in the ResultSet:

The implementation of newRdbmsAcl at this level also requires that the ResultSet enumerate ACL entries of the same name ordered by Principal name.

RdbmsUser implements CacheableRealm and uses the caching realm for internal calls to the BasicRealm API. Initially, the caching realm is the instance itself, which works. A caching realm will delegate to this realm when a call to the cache is unfulfilled.

RdbmsRealm can also be used to define the tables and/or populate the database. The special prefix fromScratch. in a realm name indicates that the real realm name is the remaining string, and that SQL from a Data Definition resource, composed from the real realm name with suffix .realm_ddl, should be executed.

You can run the RdbmsRealm in test mode to see a listing of users, groups, ACLs, and permissions for the realm by changing the static boolean "unitTest" to true and recompiling.

Scripts are provided in this directory that compile the Java files, copy the appropriate resources into WebLogic's CLASSPATH, and create the appropriate tables in an RDBMS. Edit weblogic.realm_properties for your DBMS. The scripts are designed to be run from the current directory (examples/security/rdbmsrealm/). See the DefaultRealmExtender examples for more details on using RdbmsRealm as a replacement for the WebLogic default realm.

Author:
Copyright (c) 1998-1999 by BEA Systems. All Rights Reserved.

Variable Index

 o aclOwner
 o cache
 o conn
 o DB_PASSWORD
 o DB_URL
 o DB_USER
 o DRIVER
 o GET_ACL_ENTRIES
 o GET_ACLS
 o GET_GROUP_MEMBERS
 o GET_GROUPS
 o GET_PERMISSIONS
 o GET_USER
 o GET_USERS
 o getAclEntriesStmt
 o getAclsStmt
 o getGroupMembersStmt
 o getGroupsStmt
 o getPermissionsStmt
 o getUsersStmt
 o getUserStmt
 o name
 o SPECIAL_PREFIX

Constructor Index

 o RdbmsRealm()

Method Index

 o getAcl(String)
Gets the access control list by the specified name.
 o getAcl(String, char)
Gets the access control list by the specified name, with an ACL name delimiter other than the default (dot, ".").
 o getAclOwner(Object)
Returns null.
 o getAcls()
Returns an Enumeration of the groups in a particular realm.
 o getCache()
Returns the cache of a BasicRealm.
 o getGroup(String)
Gets a Group for the specified name.
 o getGroups()
Returns an Enumeration of the groups in a listable realm.
 o getName()
 o getPermission(String)
Gets a Permission that matches the specified name.
 o getPermissions()
Returns an Enumeration of the permissions for a realm.
 o getPrincipal(String)
Resolves a name to a User or Group while giving the cache a try.
 o getUser(String)
 o getUser(UserInfo)
Gets a User that matches the specified user info.
 o getUsers()
Returns an Enumeration of the users in a particular realm.
 o init(String, Object)
 o load(String, Object)
Does nothing.
 o main(String[])
 o newRdbmsAcl(ResultSet, Notifiable)
Converts the ResultSet into a Group.
 o newRdbmsGroup(ResultSet, Notifiable)
Converts the ResultSet into a Group.
 o newRdbmsUser(ResultSet)
Converts the ResultSet into a User.
 o save(String)
Does nothing.
 o setCache(BasicRealm)
Sets the cache for the specified BasicRealm.

Variables

 o DRIVER
 public static final String DRIVER
 o DB_URL
 public static final String DB_URL
 o DB_USER
 public static final String DB_USER
 o DB_PASSWORD
 public static final String DB_PASSWORD
 o GET_USER
 public static final String GET_USER
 o GET_GROUP_MEMBERS
 public static final String GET_GROUP_MEMBERS
 o GET_ACL_ENTRIES
 public static final String GET_ACL_ENTRIES
 o GET_USERS
 public static final String GET_USERS
 o GET_GROUPS
 public static final String GET_GROUPS
 o GET_PERMISSIONS
 public static final String GET_PERMISSIONS
 o GET_ACLS
 public static final String GET_ACLS
 o SPECIAL_PREFIX
 public static final String SPECIAL_PREFIX
 o conn
 protected Connection conn
 o getUserStmt
 protected PreparedStatement getUserStmt
 o getGroupMembersStmt
 protected PreparedStatement getGroupMembersStmt
 o getAclEntriesStmt
 protected PreparedStatement getAclEntriesStmt
 o getUsersStmt
 protected PreparedStatement getUsersStmt
 o getGroupsStmt
 protected PreparedStatement getGroupsStmt
 o getAclsStmt
 protected PreparedStatement getAclsStmt
 o getPermissionsStmt
 protected PreparedStatement getPermissionsStmt
 o name
 protected String name
 o cache
 protected BasicRealm cache
 o aclOwner
 protected Principal aclOwner

Constructors

 o RdbmsRealm
 public RdbmsRealm()

Methods

 o main
 public static void main(String argv[]) throws Exception
 o init
 public void init(String name,
                  Object ignoredCredential) throws NotOwnerException
 o getName
 public String getName()
 o getUser
 public User getUser(String name)
 o getUser
 public User getUser(UserInfo userInfo)
Gets a User that matches the specified user info.

 o getAclOwner
 public Principal getAclOwner(Object credential)
Returns null. This way ACLs cannot be manipulated outside of the database.

 o getGroup
 public Group getGroup(String name)
Gets a Group for the specified name.

 o getAcl
 public Acl getAcl(String name)
Gets the access control list by the specified name.

 o getAcl
 public Acl getAcl(String name,
                   char separator)
Gets the access control list by the specified name, with an ACL name delimiter other than the default (dot, ".").

 o getPermission
 public Permission getPermission(String name)
Gets a Permission that matches the specified name.

 o load
 public void load(String name,
                  Object credential) throws ClassNotFoundException, IOException, NotOwnerException
Does nothing. This realm is not loaded and saved but implements its functions based on a persistently stored state.

 o save
 public void save(String name) throws IOException
Does nothing. This realm is not loaded and saved but implements its functions based on a persistently stored state.

 o newRdbmsUser
 protected User newRdbmsUser(ResultSet rs) throws SQLException
Converts the ResultSet into a User. Subclasses override this to work with other PreparedStatements and/or to returns different User implementations.

 o getPrincipal
 protected Principal getPrincipal(String name)
Resolves a name to a User or Group while giving the cache a try.

 o newRdbmsGroup
 protected Group newRdbmsGroup(ResultSet rs,
                               Notifiable n) throws SQLException
Converts the ResultSet into a Group. Subclasses override this to work with other PreparedStatements and/or to returns different Group implementations.

 o newRdbmsAcl
 protected Acl newRdbmsAcl(ResultSet rs,
                           Notifiable n) throws SQLException
Converts the ResultSet into a Group. Subclasses override this to work with other PreparedStatements and/or to returns different Group implementations.

At this level the implementation requires all Principal names to appear together.

 o getUsers
 public Enumeration getUsers()
Returns an Enumeration of the users in a particular realm.

 o getGroups
 public Enumeration getGroups()
Returns an Enumeration of the groups in a listable realm.

 o getAcls
 public Enumeration getAcls()
Returns an Enumeration of the groups in a particular realm.

 o getPermissions
 public Enumeration getPermissions()
Returns an Enumeration of the permissions for a realm.

 o getCache
 public BasicRealm getCache()
Returns the cache of a BasicRealm.

 o setCache
 public void setCache(BasicRealm r)
Sets the cache for the specified BasicRealm.


All Examples  This Package