| Sun Java System Application Server |
This sample application demonstrates:
The LDAP Dynamic Group Realm sample application consists of an enterprise bean and an application client. The methods of the enterprise bean have been associated with either the Administrator or the SecretRole in the enterprise bean deployment descriptor. The idea is to associate the Administrator role with a dynamic LDAP group, called ldapdynamicgroup. Then the application client verifies that user names belonging to ldapdynamicgroup have access to methods of the EJB that have been associated with the Administrator role, while access to methods not associated with that role will be denied.
The application base directory, app_dir is
install_dir/samples/security/ldaprealm/apps/dynamicgroup.
It contains the following sub-directories:
dynamicgroup-client/src/conf: application client deployment descriptors.
dynamicgroup-client/src/java/samples/security/ldaprealm/dynamicgroup/client:
application client source code
dynamicgroup-ejb/src/java/samples/security/ldaprealm/dynamicgroup/ejb: EJB source code
To associate the Administrator role with the dynamic group ldapdynamicgroup of an LDAP server, follow these basic steps:
setup/sjsas8.samples.ldif into an LDAP server.
setup/sjsas8.samples.ldif into an LDAP server.
src/conf/sun-application.xml deployment descriptor of the application,
associate the Administrator role with ldapdynamicgroup,
and this application with the ldaprealmperapp Realm.
domain.xml file,
located in domain_root_dir/domain_name.
See Directories and Variables for
information on the location of domain_root_dir.
<auth-realm classname="com.sun.enterprise.security.auth.realm.ldap.LDAPRealm" name="ldaprealmperapp">
<property name="directory" value="ldap://localhost:389"/>
<property name="base-dn" value="dc=top,dc=org,dc=company,dc=com"/>
<property name="jaas-context" value="ldapRealm"/> </auth-realm>
Be sure to configure the directory and base-dn properties for
the LDAP server to be used for testing.
The general instructions for building, deploying, and running sample applications are provided in Building, Deploying, and Running Sample Applications. In reading this document, use the following application-specific variables for this application:
install_dir is the directory where Application Server is installed.
app_dir is the application base directory:
install_dir/samples/security/ldaprealm/apps/dynamicgroup.
ldaprealm-dynamicgroup.ear.
Follow this general procedure:
build.xml, is in the app_dir directory.
app_dir/ldaprealm-dynamicgroup.ear.
In a shell window make app_dir your working directory.
Execute the command asant run.
This command invokes the application client, which looks up the enterprise bean and invokes some of its methods. Those methods associated with the Administrator role will be successfully executed. Access to the ones associated with the SecretRole will be denied.
This is the output that will displayed in the shell window:
[echo] Running the ldaprealm-dynamicgroup program: [exec] **************************************************************** [exec] * LDAP LdapRealmAppClient with DynamicGroup * [exec] **************************************************************** [exec] Testing with user: sjsasuser; role:Administrator [exec] [1] Calling testIsCallerInRole()... [exec] [1] PASSED [exec] [2] Calling testIsCallerExpected()... [exec] [2] PASSED [exec] [3] Calling authorized method - methodIsAuthorized() [exec] [3] PASSED [exec] [4] Calling unauthorized method - methodIsNotAuthorized(): [exec] [4] PASSED: Got expected AccessException!
Copyright © 2006 Sun Microsystems, Inc. All rights reserved.