OpenSSO Policy Agents 3.0 on Glass Fish Cluster

October 13, 2009 by indirat

OpenSSO Policy Agents (PA)3.0  on Glass Fish  Cluster

1.0 Introduction

The goal of this document is to enable the reader to be able to  protect their Java EE application deployed on Glass Fish Enterprise Server 2.1 Cluster using OpenSSO and Policy Agents 3.0. This document is verified and validated with OpenSSO policy agents 3.0 and GFv2.1 EE cluster as described in the next section.

2.0 Product versions

This procedure is verified with OpenSSO Server Express 8 build with the corresponding Java EE agents 3.0. Glassfish version is Sun GlassFish Enterprise Server v2.1 (9.1.1) (build b60f-fcs). Assumes an OpenSSO server and GFv2.1 cluster is already setup.

3.0 Glass Fish Cluster

For simplicity I have created a simple cluster with one node agent and 2 instances. These instances are load balanced with a Big IP Load Balancer Virtual IP. Creating glass fish cluster is out of scope for this document. There are lot of resources available in the internet including  the aquarium.

Typical GFv2.1 Cluster Deployment

Typical GFv2.1 Cluster Deployment

You should edit the config/asadminenv.conf to set AS_ADMIN_SECURE=false , since   the cluster profile sets admin port as non SSL.

Once this cluster is setup, you are pretty much ready to install the agents. For illustration purposes I am going to use ‘agents30‘ is my cluster it has corresponding ‘agents30-config’ node in the domain.xml (or simply agents30-config if you view from UI) This configuration name is the key information for the OpenSSO Policy  agents configuration.

You can verify the cluster setup by accessing the sample application ‘clusterjsp’ using the LB url
for eg: http://is-lb-2.red.iplanet.com:38181/clusterjsp

4.0 Installing the OpenSSO Policy Agents.

The typical glassfish cluster scenario is depicted in the image below, this I have made for simplicity. A Cluster can have multiple remote node agents with many clusters along with server instances. The same procedure can be applied irrespective of the complexity of the clusters setup.  Protecting the Java EE clustered applications using OpenSSO policy agents is a two step process.

  1. Installing OpenSSO Policy Agents on the  Domain Administration Server(DAS) running on Host A
  2. Performing the OpenSSO Policy Agents specific configuration changes on the Glass Fish clustered instances

Performing  OpenSSO Policy Agents installation on the  Domain Administration Server is a straight forward procedure, Policy agents installer facilitate this step. The second step  is inherently manual require meticulous  planning and execution, Any erroneous execution could potentially render  the cluster unusable. Detailed  procedure of these two steps are in the following sections.

4.1 Installation of OpenSSO Policy Agents on DAS

The Domain Administration Server (DAS) is the one that manage the cluster where the Java EE application is deployed. To install the policy agents first obtain the latest Java EE agents for Glass Fish v2/Application Server 9.1 from http://download.java.net/
Unzip the binary appserver_v9_agent_3.zip to a directory that can be accessed by the DAS process. Follow the Policy Agents installation procedure to install and configure for the DAS instance. During this process make sure the server instance name is the default configuration(server).
Login to your OpenSSO server and create an agent profile for this agent, let us call ‘remotecluster’ as the agent identity that will be used while installing the agents.

Agents Profile

Agents Profile

Here is the sample silent installation response file to configure the policy agents to the DAS instance. You need to invoke
./agentadmin  –custom-install   –useResponse filename.inf

where filename.inf is

## Agent User Response File START OF FILE
 CONFIG_DIR= /export/sun/gf2.1/domains/telco/config
 INSTANCE_NAME= server
 AM_SERVER_URL= http://cal2.red.iplanet.com:33030/opensso
 DAS_HOST_IS_REMOTE= false
 AGENT_URL= http://is-lb-2.red.iplanet.com:38181/agentapp
 AGENT_ENCRYPT_KEY= cW18Pj2R9Mt7mdvzDUL5+LMMUhm+qeIp
 AGENT_PROFILE_NAME= remotecluster
 AGENT_PASSWORD_FILE= /tmp/pass
 CREATE_AGENT_PROFILE_NAME= false
 AGENT_ADMINISTRATOR_NAME=
 AGENT_ADMINISTRATOR_PASSWORD_FILE=
 REMOTE_INSTANCE_LOCAL_DAS= false
 AGENT_INSTANCE_NAME=
 REMOTE_AGENT_INSTALL_DIR=
 ##Agent User Response File END OF FILE

NOTE:
Remember to   stop   all the domains,instances and node agents before starting the policy agents installation process.  If you fail to do so, you might lose all the OpenSSO policy agents installation changes in the domain.xml of the DAS instance. This happens because the OpenSSO policy agent installer manipulates the domain.xml using file editing tools.(Work in progress to use asadmin for these changes).

Then the policy agents configuration files, appropriate JARs and the locale files will be copied to the cluster configuration directory of the domain  directory that manages the cluster. Glass Fish cluster configuration automatically replicate the policy agent specific files to the remote cluster instances. This feature helps us from not installing the policy agents on the remote GF server instances.

In essence the policy agents installer makes following changes in the DAS instance.

  • Java Class Path Suffix added with the JARs and locale files of the agents in the domain.xml  for the ’server-config’ target only(this is because we selected ’server’ instance at the time of installation of PA). Neither for the default-config nor the ‘agents30-config’  targets.  This distinction is critical to make sure we properly configure the agents to protect the application deployed on the target ‘agents30-config’.(agents30 is our cluster configuration)
  • ${path.separator}/export/sun/j2ee_agents/appserver_v9_agent/lib/agent.jar${path.separator}/export/sun/j2ee_agents/appserver_v9_agent/lib/openssoclientsdk.jar${path.separator}/export/sun/j2ee_agents/appserver_v9_agent/locale${path.separator}/export/sun/j2ee_agents/appserver_v9_agent/Agent_001/config”

where

  • /export/sun is the base directory(BASE_DIR) where you have unzipped the appserver_v9_agent_3.zip
  • Agent_001 is the agent instance that is created in sec 4.1
  • Adding the JVM option for the target ’server-config’  to enable the policy agents logging

- Djava.util.logging.config.file=<BASE_DIR>/j2ee_agents/appserver_v9_agent/config/OpenSSOAgentLogConfig.properties”

  • Adding the J2EE permissions to read the agents JARs in the server.policy, following policy will be added in server.policy

grant codeBase “file:<BASE_DIR>/j2ee_agents/appserver_v9_agent/lib/*” {
permission java.security.AllPermission;
};

  • Add the agent realm in config/login.conf

agentRealm {
com.sun.identity.agents.appserver.v81.AmASLoginModule  required;
};

  • A new authentication  realm ‘ agentRealm’ will be created for the ’server’ instance
  • The default authentication realm for ’server’ instance will be set to ‘ agentRealm’

That is all happens under the cover when you install the policy agents installer.
Now we need to apply these changes to the cluster configuration so the applications deployed on these clusters can be protected using OpenSSO Policy agents.

4.2 Performing PA Configuration on the Cluster

This step involves running a sequence of GF v2.1 EE administrative commands. The sequence and syntax all matters, please follow the instructions as it is given.  First make sure you have started the DAS instance in order to run the following sequence of commands. Just start only the DAS instance not the cluster instances.
Login to the DAS server(Host A) and make sure the asadmin command line utility is in the PATH.

4.2.1 Copy the agents configuration to cluster configuration directory

From the DAS host copy the PA’s configuration files and libraries to the GF cluster configuration directory so that these files will be available in the remote instances. If this is not done then PA sould be installed on each instance that belong to the cluster. To avoid this duplicate effort as well as to manage the policy configuration from the centralized location(in this case from DAS) you should do the following steps.
change directory to <BASE_DIR>/j2ee_agents/appserver_v9_agent

 /bin/cp -r  Agent_001  config lib  locale   ${com.sun.aas.instanceRoot}/config/agents30-config/

Any subsequent change that you make in these directories must be copied to the above location otherwise the cluster will not get the updates you make in the agents configuration files.

4.2.2 Make the configuration changes

Create a text file named   P_FILE containing the GF admin and master password.

 P_FILE=/tmp/.gfpass
 echo 'AS_ADMIN_ADMINPASSWORD=secret12' > $P_FILE
 echo 'AS_ADMIN_PASSWORD=secret12' >> $P_FILE
 echo 'AS_ADMIN_MASTERPASSWORD=changeit' >> $P_FILE

make sure the asadmin command is in the PATH

 export PATH=/export/sun/gf2.1/bin/:$PATH

Following sequence of commands add the necessary PA configuration parameters to the agents30 cluster configuration. Once this process is complete you need to restart the whol cluster setup. At this point only the DAS administration server is running on port 34848, rest all are shut down.  All these commands are executed in a unix terminal(on DAS host, assuming admin server running on http) in this example, please follow respective syntax that is suitable for your environment.

4.2.2.1 Set the logging properties

asadmin create-jvm-options --port 34848 --user admin --passwordfile $P_FILE --target agents30-config "-Djava.util.logging.config.file=\${com.sun.aas.instanceRoot}/config/agents30-config/config/OpenSSOAgentLogConfig.properties"

4.2.2.2 Set the COMPAT mode OFF

asadmin create-jvm-options --port 34848 --user admin --passwordfile $P_FILE --target agents30-config "-DLOG_COMPATMODE=Off"

4.2.2.3 Create the agent authentication realm

asadmin create-auth-realm --port 34848 --user admin --passwordfile $P_FILE --classname com.sun.identity.agents.appserver.v81.AmASRealm --property jaas-context=agentRealm --target agents30-config agentRealm

4.2.2.4 Set the default realm to agents realm

asadmin set agents30-config.security-service.default-realm=agentRealm

4.2.2.5 Add the Classpath suffix

asadmin set  agents30-config.java-config.classpath-suffix="\${path.separator}/\${com.sun.aas.instanceRoot}/config/agents30-config/lib/agent.jar\${path.separator}\${com.sun.aas.instanceRoot}/config/agents30-config/lib/openssoclientsdk.jar\${path.separator}/\${com.sun.aas.instanceRoot}/config/agents30-config/locale\${path.separator}\${com.sun.aas.instanceRoot}/config/agents30-config/Agent_001/config"

Note the $ is escaped with backslash(\) this is required when it is executed in the shell environment.

4.2.2.6 Edit the server.policy

If you have enabled the J2EE security(means you have -Djava.security.manager JVM option) for the cluster then you have to allow permission to read the agent’s JARs located in {com.sun.aas.instanceRoot}/config/agents30-config/lib directory. This can be done by editing the {com.sun.aas.instanceRoot}/config/server.policy. Append the following line in the {com.sun.aas.instanceRoot}/config/server.policy.

  • grant codeBase “file:${com.sun.aas.instanceRoot}/config/agents30-config/lib/-” {

permission java.security.AllPermission;
};

This update will be automatically pushed to the remote instances when you restart the cluster after completing this procedure.

4.2.2.7 Deploy the agentapp.war on the cluster

This is one of the critical step that you need to perform. Make sure this application is deployed on the cluster not just on one instance.
For instance in this example agentapp.war is deployed using the following command

 ./asadmin deploy --target agents30  --host hostA.red.iplanet.com  --port 34848 --availabilityenabled=true /export/sun/j2ee_agents/appserver_v9_agent/etc/agentapp.war

This application is required for the agents receive notification as well as this app is required to perform   Cross Domain SSO

5.0 Verification of PA configuration

Once you complete the section 4.x, now the cluster is ready to be tested. In order to test the  Java EE policy agents there is a sample called agentsample.ear that shipped with the PA binary. You have to deploy this EAR file in to your cluster.  This can be done by simply invoking the ‘asadmin’ with deploy option on the host where DAS is running.

 ./asadmin deploy --target agents30 --port 34848 --availabilityenabled=true /export/sun/j2ee_agents/appserver_v9_agent/sampleapp/dist/agentsample.ear

Now Login to OpenSSO server and navigate to the J2EE agent identity ‘remotecluster’ property with the label Agent Filter Mode, remove the current value ‘ALL’ and add the value SSO_ONLY. This will ask only for authentication for the resource being access from the cluster URL which is http://is-lb-2.red.iplanet.com:38181/agentsample/index.html When you access this URL the cluster will redirect to your OpenSSO server, with valid user name/password pair you will get access to this page.

You can do much more using this sample such as exhibiting Java EE programmatic and declarative security. You can find more on this by reading the readme under /export/sun/j2ee_agents/appserver_v9_agent/sampleapp directory.

Make sure restart the DAS and cluster together with node agent to get these configuration change propagated.  Even though the documents say that changes will be published to the nodes automatically, I need to supply the –syncinstances=true option while starting the node agent, only then I could see the configuration changes reflected in the remote instances.

APPENDIX

Creating cluster

P_FILE=/tmp/.gfpass
echo ‘AS_ADMIN_ADMINPASSWORD=secret12′ > $P_FILE
echo ‘AS_ADMIN_PASSWORD=secret12′ >> $P_FILE
echo ‘AS_ADMIN_MASTERPASSWORD=changeit’ >> $P_FILE
GF_INSTALL_DIR/bin/asadmin create-domain –adminport 34848 –user admin –passwordfile $P_FILE –interactive=false –profile cluster telco
GF_INSTALL_DIR/bin/asadmin start-domain –user admin –passwordfile $P_FILE  telco
GF_INSTALL_DIR/bin/asadmin create-node-agent –user admin –port 34848 –interactive=false –passwordfile $P_FILE telco-nodeagent
GF_INSTALL_DIR/bin/asadmin create-cluster –port 34848 agents30
GF_INSTALL_DIR/bin/asadmin create-instance –port 34848 –nodeagent telco-nodeagent –systemproperties HTTP_LISTENER_PORT=38080 –cluster agents30 sales
GF_INSTALL_DIR/bin/asadmin create-instance –port 34848 –nodeagent telco-nodeagent –systemproperties HTTP_LISTENER_PORT=38081 –cluster agents30 eng
GF_INSTALL_DIR/bin/asadmin start-node-agent –user admin –interactive=false –passwordfile $P_FILE telco-nodeagent
GF_INSTALL_DIR/bin/asadmin deploy –target agents30 –port 34848 –availabilityenabled=true samples/quickstart/clusterjsp/clusterjsp.ear
GF_INSTALL_DIR/bin/asadmin start-cluster –port 34848 –interactive=false –passwordfile $P_FILE agents30

To start and Stop the cluster

asadmin stop-cluster agents30
asadmin stop-node-agent
asadmin stop-domain telco
asadmin start-domain telco
asadmin start-node-agent --syncinstances=true
asadmin start-cluster agents30

Re-Publishing my interview from developers.sun.com

August 4, 2009 by indirat

From the Trenches at Sun Identity, Part 8: Quality Assurance

Article

From the Trenches at Sun Identity, Part 8: Quality Assurance






By Marina Sum, October 14, 2008



See also:

- Part 1: Access Management for Web Applications
- Part 2: OpenSSO, a Thriving Community
- Part 3: Federated Access Management Simplified
- Part 4: Virtual Federation, a Pioneering Way for Exchanging Authentication Data
- Part 5: Support for OpenSSO
- Part 6: Identity Services for Securing Web Applications
- Part 7:
Security for Web Services


— Indira Thangasamy, senior quality engineering manager, access and federation management, Sun Microsystems

Indira Thangasamy, senior quality engineering manager for Sun OpenSSO Enterprise, started his career as a developer of embedded systems at Robert Bosch in India and then in Germany. Shortly after moving to the United States in the late 1990s, he joined Sun in 1998 as a kernel test development engineer for the Solaris OS. Later on, Indira moved to the access and federation management team to lead its QA efforts.

Indira sat down with me recently to share his insight on testing OpenSSO Enterprise, the related tools, and the process.

The Harness

“It’s said that finding bugs costs a lot more than preventing them,” Indira says. “That’s spot on. It makes absolute sense to test software thoroughly so that it’s as bug-free as possible. In terms of efficiency, automation is the key.” Because Sun is committed to open source, Indira’s QA team opts for open-source tools to guarantee transparency to the community.

“The harness we’ve chosen is TestNG, an open-source, structured framework that enables scenario testing, which is necessary for a multitier product like OpenSSO Enterprise,” continues Indira. A harness, he explains, is a tool that runs test cases and generates a report of the results.

Besides being a scenario-based testing tool, TestNG features a robust grouping mechanism with which the QA team can test multiple LDAPv3 directories without replicating the code. “An example is the LDAP roles supported by Sun Java System Directory Server,” Indira points out. “We can just combine those specific tests as a separate group; the rest of the LDAPv3-compliant feature tests then go into a common group. TestNG is truly a flexible tool.”


The Process

Indira strongly believes that “quality is something to be built into the development phase itself, not an add-on to be plugged into the product later.” Given that philosophy, his QA team partners with product development to implement the relevant processes. For instance, each code check-in must undergo two reviews: one from a peer developer and the other from QA. “That way, we ensure that a fix or feature is thoroughly tested and that the related documentation is made available to QA and Tech Pubs,” Indira explains. Subsequently, QA recommends the fixes that must pass the automated regression test suite, preventing the bugs from occurring in the source itself as much as possible.

“With such a process, QA detects regression before the nightly build starts. Otherwise, we would catch regression only at the end of the day while running the nightly automated tests. By then, one day would already have been lost. Bottom line: QA is geared for efficiency and productivity,” says Indira.

The high quality of the nightly builds ensures that the community receives no “dead on arrival” builds. How? Altogether, approximately 2,500 core functional regression tests are executed on seven operating systems and six Web containers, as follows:

  • Operating systems: Solaris on x86 architecture, Solaris on SPARC technology, OpenSolaris, Windows Vista, Windows 2003 Enterprise Server, Ubuntu, and Red Hat Linux
  • Web containers: GlassFish application server, Sun Java System Application Server, BEA WebLogic, IBM WebSphere, Sun Java System Web Server, and Apache Tomcat

Once those nightly regression tests pass on all the deployment configurations, Release Engineering creates a nightly build, ready for deployment by the community. A plan is underway to share the nightly results with the community on opensso.org. In addition, nightly CRON jobs produce a consolidated results report. If a failure occurs, the development engineer concerned is alerted for a priority fix.

Indira emphasizes that the tests are all modular and extensible. Each module takes as little as 1 minute to 20 minutes to run, hence enabling the community to quickly validate a particular module without having to run the entire suite of tests.

Furthermore, the QA team runs nightly tests on Policy Agents 2.2 and 3.0 on Sun Java System Application Server, Apache Web Server, and the agents for GlassFish application Server, BEA WebLogic, and IBM WebSphere. Such a process ensures that any changes in the current release do not negatively impact the existing applications that work on the previous versions of OpenSSO Server and Policy Agents.

Other processes ensure product quality. Here are a few examples:

  • The development engineers run unit tests of their new code in parallel with development. A pass is mandatory before code check-in.
  • After a bug fix, QA invariably adds a corresponding test case to its test-case repository to eliminate recurrence of the bug in future patches or releases.
  • The QA team actively involves itself in the design phase to prepare in advance for testing new features and to influence the development team to introduce “hooks” in the code that would optimize QA’s productivity.

“We collaborate closely with the support and sustaining teams, too,” Indira continues. “Whenever issues arise at customer sites, the support folks will bring us into the loop so that we can add regression test cases to the repository if applicable. Our goal is to prevent recurrence in future releases.”

The test cases and test plans are well documented and will soon be available for free. You can download the automated test suite in the OpenSSO code base. Executing the tests takes only a few minutes: Just follow the simple procedure. All you need are the Java SDK and a few open-source Java archive (JAR) files.

Stay tuned for an upcoming article, in which Indira will share the details of the automation framework, including troubleshooting tips.

“A Wonderful Team”

“A common misconception is that QA work is boring,” Indira observes. “I completely disagree. It’s a rewarding and challenging field that requires expertise with the product being tested and with many internal and external tools, so QA engineers get to learn a lot. Customers count on QA—it’s a critical phase of the product development cycle.”

Indira credits his manager, director of engineering Jamie Nelson, for his tremendous leadership and support. “Not only does Jamie trust us to do our jobs, he sees that the necessary resources are there for us—people, software, tools,” beams Indira. “Our team is motivated, vigilant, and on top of the game. If a test fails, we don’t just say that it failed; we also explain why and where it did. We share excellent rapport with one another and with the development engineers. Communications are open and transparent because we have full and ready access to engineers, architects, and management alike. It’s truly a wonderful team.”

As Indira looks to the future, his number-one goal is to “automate testing as much as feasible” and eliminate manual test cases, which are error-prone. He also aims to include as many customer scenarios as possible. “Ultimately, QA is about making certain that our product works in the real world,” he concludes.

Note: Three openings are currently available in the OpenSSO QA team. Be sure to check them out!

References


//

Rate and Review
Tell us what you think of the content of this page.

Excellent
Good
Fair
Poor

Comments:
Your email address (no reply is possible without an address):

Sun Privacy Policy

Note: We are not able to respond to all submitted comments.



copyright © Sun Microsystems, Inc

Hello world!

July 21, 2009 by indirat

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!