The demo guide provides detailed instructions for setting up a multi-domain SSO demonstration for a quick start with CAS.
Problem StatementYou would like to show-off Single Sign On (SSO) to your boss and team ASAP. You have no clue about SSL, server certificates etc. But you know enough of Java, J2EE, Tomcat that someone is paying you for it. However, no matter how hard you try, you keep getting errors with basic CAS system install documentation. This wiki page will show you how to install and demonstrate CAS, first on your Windows PC and then to takes a step further and shows that you can do multi-domain (another Windows PC) SSO login as well using CAS. Except for Dilbert's boss, everyone should be reasonably impressed. If you have a team that grappled programmatically with multi-domain SSO authentication in any way shape or form they will worship you like a God. I am focussing on multi-domain because, if you have just one single tomcat instance in which you have all your applications, and would like to do SSO, you really don't need CAS at all (it would be overkill) just uncomment the following in your server.xml and you should be good to go (assuming your applications are setup to authenticate already):
Beginner IssuesLets get some newbie stuff out of the way first. These are the source of most problems:
With that preamble, let's begin... Stepwise InstructionsBasically, recommend starting fresh with (instruction are for a Windows XP professional computers) with no JDK/JRE or Tomcat. Using Microsoft Internet Explorer Version 7.0.5730.11 to verify SSL etc. Step 1: Install JDK Version
Step 2: Used keytool to self-author a server certificate for DEMOReference: http://www.ja-sig.org/wiki/display/CAS/Solving+SSL+issues Entire Command Prompt Dialog is below... Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\Documents and Settings\ukari>cd \program* The filename, directory name, or volume label syntax is incorrect. C:\Program Files>cd java C:\Program Files\Java>cd jdk* C:\Program Files\Java\jdk1.5.0_11>cd bin C:\Program Files\Java\jdk1.5.0_11\bin>keytool -genkey -alias tomcat -keypass changeit -keyalg RSA Enter keystore password: changeit What is your first and last name? [Unknown]: compA What is the name of your organizational unit? [Unknown]: Information Systems What is the name of your organization? [Unknown]: Pacific Disaster Center What is the name of your City or Locality? [Unknown]: Kihei What is the name of your State or Province? [Unknown]: HI What is the two-letter country code for this unit? [Unknown]: US Is CN=localhost, OU=Information Systems, O=Pacific Disaster Center, L=Kihei, ST=HI, C=US correct? [no]: yes C:\Program Files\Java\jdk1.5.0_11\bin>keytool -export -alias tomcat -keypass changeit -file server.crt Enter keystore password: changeit Certificate stored in file <server.crt> C:\Program Files\Java\jdk1.5.0_11\bin>keytool -import -file server.crt -keypass changeit -keystore ..\jre\lib\security\cacerts Enter keystore password: changeit Owner: CN=localhost, OU=Information Systems, O=Pacific Disaster Center, L=Kihei, ST=HI, C=US Issuer: CN=localhost, OU=Information Systems, O=Pacific Disaster Center, L=Kihei, ST=HI, C=US Serial number: 462030d8 Valid from: Fri Apr 13 15:39:36 HST 2007 until: Thu Jul 12 15:39:36 HST 2007 Certificate fingerprints: MD5: CC:3B:FB:FB:AE:12:AD:FB:3E:D 5:98:CB:2E:3B:0A:AD SHA1: A1:16:80:68:39:C7:58:EA:2F:48:59:AA:1D:73:5F:56:78:CE:A4:CE Trust this certificate? [no]: yes Certificate was added to keystore C:\Program Files\Java\jdk1.5.0_11\bin>
At this stage we have a .keystore file created in C:\Documents and Settings\<user> and the %JAVA_HOME%\jre\lib\security\cacerts file with the corresponding certificate. Step 3: Install Tomcat
Step 4: Configure Tomcat server.xml
You could need to add the following parameters to the Connector definition in order to activate the SSL on Tomcat: SSLEnabled="true" protocol="org.apache.coyote.http11.Http11NioProtocol" / protocol="org.apache.coyote.http11.Http11Protocol" Step 5: CASify HelloWorld Servlethttp://www.ja-sig.org/wiki/display/CASC/Using+CASFilter
Step 6: Drop CAS Client jar into the servlets-examples contextURL: http://www.ibiblio.org/maven/cas/jars/
Step 7: Download and Deploy CASURL: http://www.ja-sig.org/products/cas/downloads/index.html
Step 8. Clean start
stdout_20070413.log (looks "normal"): 2007-04-13 16:32:02,082 INFO [org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler] \- <No PasswordEncoder set. Using default: org.jasig.cas.authentication.handler.PlainTextPasswordEncoder> 2007-04-13 16:32:02,082 INFO [org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler] \- <No Class to Support set. Using default: org.jasig.cas.authentication.principal.UsernamePasswordCredentials> 2007-04-13 16:32:02,082 WARN [org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler] \- <org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler is only to be used in a testing environment. NEVER enable this in a production environment.> 2007-04-13 16:32:02,129 INFO [org.jasig.cas.ticket.proxy.support.Cas20ProxyHandler] \- <No UniqueTicketIdGenerator specified for org.jasig.cas.ticket.proxy.support.Cas20ProxyHandler. Using org.jasig.cas.util.DefaultUniqueTicketIdGenerator> 2007-04-13 16:32:04,316 INFO [org.jasig.cas.web.ServiceValidateController] \- <No successView specified. Using default of casServiceSuccessView> 2007-04-13 16:32:04,316 INFO [org.jasig.cas.web.ServiceValidateController] \- <No failureView specified. Using default of casServiceFailureView> 2007-04-13 16:32:04,363 INFO [org.jasig.cas.web.ServiceValidateController] \- <No authentication specification class set. Defaulting to org.jasig.cas.validation.Cas20ProtocolValidationSpecification> 2007-04-13 16:32:04,363 INFO [org.jasig.cas.web.ServiceValidateController] \- <No successView specified. Using default of casServiceSuccessView> 2007-04-13 16:32:04,363 INFO [org.jasig.cas.web.ServiceValidateController] \- <No failureView specified. Using default of casServiceFailureView> 2007-04-13 16:32:04,473 INFO [org.jasig.cas.web.flow.AuthenticationViaFormAction] \- <FormObjectClass not set. Using default class of org.jasig.cas.authentication.principal.UsernamePasswordCredentials with formObjectName credentials and validator org.jasig.cas.validation.UsernamePasswordCredentialsValidator.> 2007-04-13 16:32:22,223 INFO [org.jasig.cas.ticket.registry.support.DefaultTicketRegistryCleaner] \- <Starting cleaning of expired tickets from ticket registry at [Fri Apr 13 16:32:22 HST 2007]> 2007-04-13 16:32:22,223 INFO [org.jasig.cas.ticket.registry.support.DefaultTicketRegistryCleaner] \- <0 found to be removed. Removing now.> 2007-04-13 16:32:22,223 INFO [org.jasig.cas.ticket.registry.support.DefaultTicketRegistryCleaner] \- <Finished cleaning of expired tickets from ticket registry at [Fri Apr 13 16:32:22 HST 2007]> catalina.2007-04-13.log (looks "normal"): Apr 13, 2007 4:31:56 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Tomcat5.5.23\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ATI Technologies\ATI Control Panel;C:\Program Files\Common Files\Adobe\AGL Apr 13, 2007 4:31:57 PM org.apache.coyote.http11.Http11BaseProtocol init INFO: Initializing Coyote HTTP/1.1 on http-8080 Apr 13, 2007 4:31:58 PM org.apache.coyote.http11.Http11BaseProtocol init INFO: Initializing Coyote HTTP/1.1 on http-8443 Apr 13, 2007 4:31:58 PM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 2859 ms Apr 13, 2007 4:31:58 PM org.apache.catalina.core.StandardService start INFO: Starting service Catalina Apr 13, 2007 4:31:58 PM org.apache.catalina.core.StandardEngine start INFO: Starting Servlet Engine: Apache Tomcat/5.5.23 Apr 13, 2007 4:31:58 PM org.apache.catalina.core.StandardHost start INFO: XML validation disabled Apr 13, 2007 4:32:00 PM org.apache.catalina.startup.HostConfig deployWAR INFO: Deploying web application archive cas.war Apr 13, 2007 4:32:06 PM org.apache.coyote.http11.Http11BaseProtocol start INFO: Starting Coyote HTTP/1.1 on http-8080 Apr 13, 2007 4:32:07 PM org.apache.coyote.http11.Http11BaseProtocol start INFO: Starting Coyote HTTP/1.1 on http-8443 Apr 13, 2007 4:32:07 PM org.apache.jk.common.ChannelSocket init INFO: JK: ajp13 listening on /0.0.0.0:8009 Apr 13, 2007 4:32:07 PM org.apache.jk.server.JkMain start INFO: Jk running ID=0 time=0/47 config=null Apr 13, 2007 4:32:07 PM org.apache.catalina.storeconfig.StoreLoader load INFO: Find registry server-registry.xml at classpath resource Apr 13, 2007 4:32:07 PM org.apache.catalina.startup.Catalina start INFO: Server startup in 8891 ms localhost.2007-04-13.log (looks "normal"): Apr 13, 2007 4:32:04 PM org.apache.catalina.core.ApplicationContext log INFO: org.apache.webapp.balancer.BalancerFilter: init(): ruleChain: \[org.apache.webapp.balancer.RuleChain: [org.apache.webapp.balancer.rules.URLStringMatchRule: Target string: News / Redirect URL: http://www.cnn.com], [org.apache.webapp.balancer.rules.RequestParameterRule: Target param name: paramName / Target param value: paramValue / Redirect URL: http://www.yahoo.com], [org.apache.webapp.balancer.rules.AcceptEverythingRule: Redirect URL: http://jakarta.apache.org]\] Apr 13, 2007 4:32:05 PM org.apache.catalina.core.ApplicationContext log INFO: ContextListener: contextInitialized() Apr 13, 2007 4:32:05 PM org.apache.catalina.core.ApplicationContext log INFO: SessionListener: contextInitialized() Apr 13, 2007 4:32:05 PM org.apache.catalina.core.ApplicationContext log INFO: ContextListener: contextInitialized() Apr 13, 2007 4:32:05 PM org.apache.catalina.core.ApplicationContext log INFO: SessionListener: contextInitialized() All other log files stderr, admin, host-manager, jakarta_service, manager are of size 0K. Checked stderr just to make sure... Step 9. Try It
Logs stdout_20070413.log (three new records): 2007-04-13 16:39:01,238 INFO [org.jasig.cas.web.flow.AutomaticCookiePathSetterAction] \- <Setting ContextPath for cookies to: /cas> 2007-04-13 16:39:18,271 INFO [org.jasig.cas.authentication.AuthenticationManagerImpl] \- <AuthenticationHandler: org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler successfully authenticated the user which provided the following credentials: uday> 2007-04-13 16:39:18,286 INFO [org.jasig.cas.CentralAuthenticationServiceImpl] \- <Granted service ticket [ST-2-V03EdNba1e3cMxeoEbEHwXfoefftIeeRxuO-20] for service [http://compA:8080/servlets-examples/servlet/HelloWorldExample] for user [uday]> localhost.2007-04-13.log (new records): Apr 13, 2007 4:38:51 PM org.apache.catalina.core.ApplicationContext log INFO: SessionListener: sessionCreated('6ED4CFE9A5D7BA592372A3E67DF7D6E8') Apr 13, 2007 4:38:51 PM org.apache.catalina.core.ApplicationContext log INFO: SessionListener: attributeAdded('6ED4CFE9A5D7BA592372A3E67DF7D6E8', 'edu.yale.its.tp.cas.client.filter.didGateway', 'true') Apr 13, 2007 4:38:51 PM org.apache.catalina.core.ApplicationContext log INFO: InvokerFilter(ApplicationFilterConfig[name=Path Mapped Filter, filterClass=filters.ExampleFilter]): 31 milliseconds Apr 13, 2007 4:39:19 PM org.apache.catalina.core.ApplicationContext log INFO: SessionListener: attributeAdded('6ED4CFE9A5D7BA592372A3E67DF7D6E8', 'edu.yale.its.tp.cas.client.filter.user', 'uday') Apr 13, 2007 4:39:19 PM org.apache.catalina.core.ApplicationContext log INFO: SessionListener: attributeAdded('6ED4CFE9A5D7BA592372A3E67DF7D6E8', 'edu.yale.its.tp.cas.client.filter.receipt', '\[edu.yale.its.tp.cas.client.CASReceipt userName=[uday] casValidateUrl=[https://compA:8443/cas/serviceValidate] proxyCallbackUrl=[null] pgtIou=[null] casValidateUrl=[https://compA:8443/cas/serviceValidate] proxyList=\[\[\]\]\]') Apr 13, 2007 4:39:19 PM org.apache.catalina.core.ApplicationContext log INFO: SessionListener: attributeRemoved('6ED4CFE9A5D7BA592372A3E67DF7D6E8', 'edu.yale.its.tp.cas.client.filter.didGateway', 'true') Apr 13, 2007 4:39:19 PM org.apache.catalina.core.ApplicationContext log INFO: InvokerFilter(ApplicationFilterConfig[name=Path Mapped Filter, filterClass=filters.ExampleFilter]): 860 milliseconds All other logs unchanged. Done (Success). Well sorta. This is the absolute minimal "proof-of-life" with Yale CAs. Still need to CAS-ify some other application and see if it works between two applications on separate machines...which leads us to... Step 10: Setup up distinct domainRepeat repeat Steps 1 thru 4 above for compB. Just do it, dont worry about creating a server certificate etc...Tomcat seems to like a keystore. So just do it. Step 11: CAS-ify client on second domain slightly differently
The final compB web.xml modifications should look as follows:
Step 12: Drop CAS Client jar into the servlets-examples contextIdentical to Step 6, but for compB. Step 13: Establish trust with CAS SSO ServerRef: http://blogs.sun.com/andreas/entry/no_more_unable_to_find Here is the most elegant way to do it, I think.
This will add compA into trust store of compB (while neatly obviating the problem discussed in the Sun blog referenced above).
InstallCert.java - adapted from Sun Microsystems blog by Andreas Sterbenz
Step 14: Test
Congratulations. |