Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

SAML2 IdP Solution

Revision as of 00:31, 5 November 2007 by Markus.sabadello.gmail.com (Talk | contribs) (New page: This page describes how to download, build, configure and deploy the Higgins SAML2 IdP. This deployment is a web application that is able to act as a SAML 2.0 IdP endpoint to authenticate ...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This page describes how to download, build, configure and deploy the Higgins SAML2 IdP. This deployment is a web application that is able to act as a SAML 2.0 IdP endpoint to authenticate users against a Higgins IdAS context. By default, an LDAP context is used, however any technology for which a Higgins context provider exists can be used instead.

In addition, a second web application is provided that acts as a sample relying party to test the IdP. This is not necessary if you have your own SAML 2.0 relying party application.

Note: In SAML 2.0 terminology, the terms "relying party" (RP) and "service provider" (SP) are synonymous.

See SAML2 IdP for a more detailled description and screenshots of how the two web applications interact with each other.

Prerequisites

This guide assumes you have the following software:

Set up your Eclipse workspace

Open a blank workspace

After you start Eclipse, it should display a blank workspace. If you have already been working in Eclipse and your workspace is not empty, you can create a new empty one by selecting File -> Switch Workspace -> Other. Select a folder to use for your new, blank workspace.

Your workspace should look like this:

Blank Eclipse workspace

Configure JRE

You should specify the JDK or JRE (Java Runtime Environment) you want to use to build the Higgins components. Click Window -> Preferences and select Java -> Installed JREs. The default JRE is the one that was used to launch Eclipse, however you may want to add a different one and set it as the workspace-default one for building. Higgins components are usually built with a Java 1.4 compiler.

Configure JRE

Note: You should also check Java -> Compiler -> Compiler compliance level, and make sure this matches the JRE you use to build the projects.

Configure server runtime

In order to work with web applications, Eclipse needs to know about the servlet container (e.g. Tomcat) you want to use. Click Window -> Preferences and select Server -> Installed Runtimes. Click "Add...". Select the server you want to use (e.g. Tomcat 5.5), click "Next", specify the installation directory and click "Finish".

Configure server runtime

Note: It is recommended to install Tomcat at a path that does not contain any spaces.

Populate the Eclipse workspace

The next step is to populate your Eclipse workspace with the required projects. There are two ways of doing this:

  • Download and import .war files. This is a quick and simple approach that already includes all third party libraries.
  • Check out and build sources manually. This will always give you the latest versions of all components, but requires manually downloading and installing dependencies.

Download and import .WAR files

Two .WAR files (one for the IdP, one for the RP) are provided for download that constitute snapshots done at one point in time:

http://graceland.parityinc.net/~msabadello/saml2idp/org.eclipse.higgins.saml2idp.server.war for the IdP web application. http://graceland.parityinc.net/~msabadello/saml2idp/org.eclipse.higgins.saml2idp.test.war for the RP web application (optional).

Download these files to your computer. Then in your blank Eclipse workspace, click File -> Import. In the import source list, select Web -> WAR file. Click "Browse" and select the org.eclipse.higgins.saml2idp.server.war file you just downloaded. Click "Finish". Eclipse will create a project containing the SAML2 IdP Server web application. When asked to switch to the Java EE perspective, click "Yes".

Optional: Also import the org.eclipse.higgins.saml2idp.test.war file, if you want to use the RP as well.

Now your workspace should look like this:

Two imported web application projects

Check out sources manually

The other option is to manually check out and build components from the Eclipse CVS. The primary source of information is the Components wiki page.

In order to do check out the components needed for the SAML2 IdP, click File -> Import. In the import source list, select CVS -> Projects from CVS. The information for connecting to the Eclipse CVS is as follows:

Connection Type Committers  :ext:
Anon access  :pserver:
Host dev.eclipse.org
Repository Path /cvsroot/technology

This information should be entered in the "Checkout from CVS" dialog as follows:

Checkout from CVS

Click "Use an existing module" to see a list of modules available for checking out.

In order to build the SAML2 IdP Server, you need to check out the following projects:

  • org.eclipse.higgins/app/org.eclipse.higgins.saml2idp.server
  • org.eclipse.higgins/plugins/org.eclipse.higgins.configuration.api
  • org.eclipse.higgins/plugins/org.eclipse.higgins.configuration.common
  • org.eclipse.higgins/plugins/org.eclipse.higgins.configuration.xml
  • org.eclipse.higgins/plugins/org.eclipse.higgins.configuration.xrds
  • org.eclipse.higgins/plugins/org.eclipse.higgins.idas.api
  • org.eclipse.higgins/plugins/org.eclipse.higgins.idas.common
  • org.eclipse.higgins/plugins/org.eclipse.higgins.cp.jndi
  • org.eclipse.higgins/plugins/org.eclipse.higgins.idas.registry
  • org.eclipse.higgins/plugins/org.eclipse.higgins.idas.spi
  • org.eclipse.higgins/plugins/org.eclipse.higgins.messages
  • org.eclipse.higgins/plugins/org.eclipse.higgins.saml2idp.saml2
  • org.eclipse.higgins/plugins/org.eclipse.higgins.util.idas.cp
  • org.eclipse.higgins/plugins/org.eclipse.higgins.util.jscript
  • org.eclipse.higgins/plugins/org.eclipse.higgins.util.socket

If you also want to use the Test RP, you need to check out the following:

  • org.eclipse.higgins/app/org.eclipse.higgins.saml2idp.test

Select them all and click "Finish". They will be checked out as projects into your Eclipse workspace.

An alternative way of checking out these projects from CVS is to use the following Team Project Sets:

A Team Project Set contains CVS information and a list of projects. To import a Team Project Set, click File -> Import. In the import source list, select Team -> Team Project Set. Select a Team Project Set file (.psf) and click "Finish". All projects contained in that set will be checked out.

After checking out the projects either manually or using the Team Project Sets, your workspace should look like this:

Checked out Higgins projects

Note that it contains several build errors, since third party libraries are not stored in the Eclipse CVS. These have to be downloaded manually according to the Components page.

First, the third party libraries for the plugin projects have to be downloaded and installed into the lib/ folders of the respective projects. Plugin projects are all projects except the web applications (saml2idp.server and saml2idp.test). For example, after installing libraries for configuration.common and configuration.xml, these projects should build without errors:

Projects build after libraries have been placed into lib/

After the libraries of all plugin projects have been installed, your workspace should look like this:

All libraries have been installed

Next step is to build .jar files from the plugin projects. To do this, add an Ant view to the Eclipse workspace. To do this, click Window -> Show View -> Other. Select Ant -> Ant and click "OK". The Ant view should appear in the workspace. You can drag it around in the workspace. Now for all plugin projects, find the "build.xml" file and drag it into the Ant view. Then your workspace should look like this:

Getting ready to build plugin projects

Now, run the "jar" build target for all the Ant scripts. This will create .jar files in the build/lib folders of the plugin projects. For example, the configuration.xml project should then contain the file build/lib/higgins-configuration-xml_0.9.0.jar. You may need to right-click on the project and hit "Refresh" (F5) before you see the file.

Building the plugin project .jar files

We are almost done. Now the only remaining step is to copy the plugin .jar files PLUS their third party dependencies to the WebContent/WEB-INF/lib folders of the two web application projects.

In total, this means that the WebContent/WEB-INF/lib folder of the saml2idp.server project should contain the following files:

axiom-api-1.2.jar
axiom-impl-1.2.jar
bandit-jndi-0.2.1030.jar
bandit-misc-0.2.1030.jar
commons-codec-1.3.jar
commons-logging-1.0.4.jar
dom4j-1.6.1.jar
higgins-configuration-api_0.9.0.jar
higgins-configuration-common_0.9.0.jar
higgins-configuration-xml_0.9.0.jar
higgins-configuration-xrds_0.9.0.jar
higgins-idas-api_0.9.0.jar
higgins-idas-common_0.9.0.jar
higgins-idas-cp-jndi_0.9.0.jar
higgins-idas-registry_0.9.0.jar
higgins-idas-spi_0.9.0.jar
higgins-messages_0.9.0.jar
higgins-saml2idp-saml2_0.9.0.jar
higgins-util-idas-cp_0.9.0.jar
higgins-util-jscript_0.9.0.jar
higgins-util-socket_0.9.0.jar
js.jar
ldap.jar
log4j-1.2.13.jar
openxdas-0.5.257.jar
openxri-client.jar
openxri-syntax.jar
stax-api-1.0.1.jar
wstx-asl-3.0.1.jar
xalan-2.6.0.jar
xercesImpl.jar
xml-apis.jar
xmlsec-1.4.0.jar

And the WebContent/WEB-INF/lib folder of the saml2idp.test project should contain these:

commons-codec-1.3.jar
commons-logging-1.0.4.jar
higgins-saml2idp-saml2_0.9.0.jar
log4j-1.2.13.jar
xalan-2.6.0.jar
xercesImpl.jar
xmlsec-1.4.0.jar

Now the workspace should be without errors. If not, try cleaning and rebuilding the workspace by clicking Project -> Clean.

All dependencies have been installed

Configure the web applications

Both web application projects (saml2idp.server and saml2idp.test) have a WebConten/conf folder that contains configuration files. These can be edited in the Eclipse workspace. They can also be edited after the web application has been deployed on a production server.

Configure the SAML2 IdP

The saml2idp.server web application project contains the following files in the WebContent/conf folder:

  • application.properties: General configuration options for the IdP.
  • HigginsConfiguration.xml: Configuration for the Higgins context to be used for authenticating users.
  • privkey.der: This is the private key used to sign SAML 2.0 messages. This can be either a DSA or RSA key. The file is expected to have a PKCS8 structure and be in DER (binary) format.
  • cacert.pem: This is the matching certificate (including a public key) for the private key. It is used for constructing the <KeyInfo> element in XML Signatures in SAML 2.0 messages. The file is expected to have a X509 structure and be in PEM (ascii) format.

The private key and certificate files can be created using OpenSSL. See below for a very quick start for creating these files.

The application.properties file contains the following options:

  • saml2-issuer: This is a human readable string that will be put into the <Issuer> element of SAML messages.
  • saml2-assertion-validity-millis: This is used to construct the value of the NotOnOrAfter attribute of the <Conditions> element of SAML messages.

The HigginsConfiguration.xml configures the Higgins context to be used for authenticating users. By default, an LDAP context is used. You may want to edit several settings in this file:

  • The setting "Address" holds the URL of the LDAP server (e.g. "ldap://localhost:389")
  • The setting "java.naming.security.principal" holds the DN of the principal to bs used to connect to the LDAP server (e.g. "cn=Manager,dc=parityinc,dc=net")
  • The setting "java.naming.security.credentials" holds the password of the principal to bs used to connect to the LDAP server (e.g. "secret")
  • The setting "consumerSubjectIDToProvider" contains a JavaScript to transform usernames to LDAP DNs. A DN usually looks like "uid=saba,dc=parityinc,dc=net", but you only want your user to enter "saba", therefore this little JavaScript is used to transform the name entered by the user to a full LDAP DN.

Configure the SAML2 RP

The saml2idp.test web application project contains the following files in the WebContent/conf folder:

  • application.properties: General configuration options for the IdP.
  • cacert.pem: This is the matching certificate (including a public key) for the private key. It is used to verify XML Signatures in SAML 2.0 messages received from the IdP. The file is expected to have a X509 structure and be in PEM (ascii) format.

The private key and certificate files can be created using OpenSSL. See below for a very quick start for creating these files.

The application.properties file contains the following options:

  • saml2-idp-endpoint: This is the URL of the IdP endpoint.
  • saml2-rp-endpoint: This is the URL of the RP endpoint.
  • saml2-providername: This is a human readable string that will be put into the ProviderName attribute of a <AuthnRequest> SAML message.
  • saml2-issuer: This is a human readable string that will be put into the <Issuer> element of SAML messages.

Run the web applications from within Eclipse

To test the web applications, you can run them directly on your localhost from within Eclipse. To do so, follow these steps:

  1. Make sure the Java EE perspective is open. Click Window -> Open Perspective -> Other. Select "Java EE".
  2. Open the "Server" view. Click Window -> Show View -> Servers.
  3. Right-click on the Server view and click New -> Server.
  4. Select the server type and runtime you want to use. This should be the same as the one you configured when you set up your workspace.
Create a new server
  1. Click "Next". You are now asked to add web application projects to be deployed on the server. In the "Available projects" list there should be two projects (or only one if you did not download the test RP project).
  2. Click "Add All".
Add projects to the server

You should now see the new server in the Server view. If you double-click on it, you can further configure it. One setting you may want to check is the HTTP/1.1 TCP Port (set this to 80).

Further server configuration

You can now start the server. Right-click on the server in the Server view and click "Start". Some logging information should appear in the Console view, and the server should be running.

Try accessing http://localhost/org.eclipse.higgins.saml2idp.test/

The Test RP running on localhost

Export the web applications to .WAR files

Deploying a web application on a production server usually requires a .WAR (web archive) file. If you followed section 3.1 on this page, you already have such files and can immediately deploy them, however in this case you will have to edit the configuration files directly on your production machines after the applications are deployed, as opposed to editing them in Eclipse beforehand.

If you want to create a .WAR file from the web applications in your Eclipse workspace, you can right-click on the project, then click Export -> WAR file. Enter a destination file name and click "Finish".

The Test RP running on localhost

Deploy the web applications on Tomcat

Deploying a .WAR file on Tomcat is usually done by placing the file into the webapps/ directory of Tomcat. Under the default configuration, it will be auto-deployed (i.e. decompressed into a context subdirectory). By default, the name of the .WAR file directly maps to the name of the context, which also becomes part of the URL under which the context can be accessed.

For example, if you are running Tomcat at your website www.example.com, and you place the file org.eclipse.higgins.saml2idp.server.war in the webapps/ directory, it will be auto-deployed to the webapps/org.eclipse.higgins.saml2idp.server context subdirectory, and becomes available at the URL http://www.example.com/org.eclipse.higgins.saml2idp.server/. The SAML endpoint servlet will be at http://www.example.com/org.eclipse.higgins.saml2idp.server/SAMLEndpoint.

It may be a good idea to rename the .WAR file before deploying it (e.g. to saml2idp-server.war) for prettier URLs.

Please refer to the documentation of Tomcat or your other servlet container for more information on how to deploy web applications.

Misc

This section contains various other helpful information for getting started with the Higgins SAML2 IdP.

OpenLDAP quick start

http://www.openldap.org/

LDAP TCP port: 389

Check if the LDAP server is running: ps -e -f|grep slapd

Stop the LDAP server: kill -INT `cat /usr/local/var/run/slapd.pid`

Start the LDAP server: /usr/local/libexec/slapd

Location of the LDAP server configuration file: /usr/local/etc/openldap/slapd.conf

How to search for all entries: ldapsearch -x -b 'dc=parityinc,dc=net' '(objectclass=*)'

How to create user saba with password testpass:

  • Create a file named saba.ldif:
dn: uid=saba,dc=parityinc,dc=net
objectclass: inetOrgPerson
objectClass: person
uid: saba
cn: Markus Sabadello
givenname: Markus
sn: Sabadello
userPassword: testpass
  • Add the entry: ldapadd -x -D "cn=Manager,dc=parityinc,dc=net" -W -f saba.ldif

How to delete user saba: ldapdelete -x -D "cn=Manager,dc=parityinc,dc=net" -W "uid=saba,dc=parityinc,dc=net"

OpenSSL quick start

http://www.openssl.org/

How to generate a DSA private key without password: (this also automatically generates the public key):

openssl dsaparam -out dsaparam.pem 2048
openssl gendsa -out privkey.pem dsaparam.pem

How to convert the private key to PKCS8 structure and DER format:

openssl pkcs8 -topk8 -nocrypt -in privkey.pem -outform der -out privkey.der

How to generate a self-signed certificate in X509 structure and PEM format:

openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095

Back to the top