This article is the sequel of my precedent post.

I am already able to deploy my JRuby on Rails application into OC4J standalone and Oracle App Server 10.1.3.1 (SOASuite); now, i need to try first how to integrate it with Oracle SSO.

I have followed the tips given by Oracle AppLabs, and have been helped by Rich Manalan thanks to Twitter ;-)

The principle steps are :

- Register your deployment platform (midTier) as a partner application in Oracle SSO

- Enable mod_osso in your HTTP Server (deployment platform)

- Add restful_authentication plugin in your JRuby on Rails application, and modify it to make it run with Oracle SSO.

- Protect the pages in your application

For Oracle SSO partner application registration and mod_osso activation, follow these steps :

Open a SSH connection on your SSO Server mid-tier then run the following command to register the deployment host for your application as a partner application :

# mv $ORACLE_HOME/Apache/Apache/conf/osso/osso.conf $ORACLE_HOME/Apache/Apache/conf/osso/osso.conf.orig

# $ORACLE_HOME/sso/bin/ssoreg.sh -oracle_home_path $ORACLE_HOME \
-site_name 10gAS1013_dev \
-config_mod_osso TRUE \
-mod_osso_url http://<host>:<port> \
-remote_midtier \
-config_file $ORACLE_HOME/Apache/Apache/conf/osso/osso.conf

Copy the new osso.conf from the SSO mid-tier to your remote mid-tier in :

$ORACLE_HOME/Apache/Apache/conf/osso

Open a SSH session on the deployment platform then enable mod_osso for your HTTP Server AS 10.1.3.

# cd $ORACLE_HOME/cd Apache/Apache/bin

# ./osso1013 $ORACLE_HOME/Apache/Apache/conf/osso/osso.conf


This script writes the following lines in your $ORACLE_HOME/Apache/Apache/conf/mod_osso.conf

<IfModule mod_osso.c>

OssoConfigFile $ORACLE_HOME/Apache/Apache/conf/osso/osso.conf
OssoIpCheck off
OssoIdleTimeout off

</IfModule>

And finally uncomments the line in $ORACLE_HOME/Apache/Apache/conf/httpd.conf

include “$ORACLE_HOME/Apache/Apache/conf/mod_osso.conf”

Restart HTTP server on your mid-tier (deployment host)

#opmnctl stopall

#opmnctl startall

Prepare your RoR application for SSO :

1) Install the plugin restful_authentication :
$ cd /path/to/app_root
$ script/plugin install restful_authentication

2) Modify the source code of lib/authenticated_system.rb as is :
http://pastie.org/158338

3) Protect actions in your controllers , where you want a user authentication:
class MyController < ApplicationController
include AuthenticatedSystem

before_filter :login_required, :o nly => ['new', 'list', 'destroy', 'create', 'update' ]

Package and deploy your application :

If you installed Warbler 0.9.9 before, uninstall it and reinstall warbler 0.9.5 , that is based on Goldspike 1.6.1 and does not include JRuby Rack. The reason being we use in the authenticated_system.rb file the $java_servlet_response to write in the HTTP Header, that is not set when using JRuby Rack (whereas the RailsServlet in GoldSpike 1.6.1 does include the assignment)

# gem remove warbler

# gem install warbler -v=0.9.5

cd /path/to/app_root
# jruby -S warble config

Package the war :
# jruby -S warble

Transfer the war to your mid-tier:
scp <app_name>.war oracle@<hostname>:/tmp

Open a SSH session on your deployment platform then, deploy the war into an OC4J instance of your App Server 10g:

#java -jar $ORACLE_HOME/j2ee/home/admin_client.jar deployer:oc4j:opmn://localhost:opmnPort/OC4JInstanceName \

oc4jadmin <pwd> -deploy -file /tmp/<app_name>.war -deploymentName <app_name> \

-bindAllWebApps -contextRoot /<app_name>

Open your browser and go to a protected page on your RoR application. You should first be redirected to the SSO Login page. After authentication process, you should come back on the protected page of your application.