<?xml version="1.0" encoding="UTF-8"?>
<!--
  ! CCPL HEADER START
  !
  ! This work is licensed under the Creative Commons
  ! Attribution-NonCommercial-NoDerivs 3.0 Unported License.
  ! To view a copy of this license, visit
  ! http://creativecommons.org/licenses/by-nc-nd/3.0/
  ! or send a letter to Creative Commons, 444 Castro Street,
  ! Suite 900, Mountain View, California, 94041, USA.
  !
  ! You can also obtain a copy of the license at
  ! src/main/resources/legal-notices/CC-BY-NC-ND.txt.
  ! See the License for the specific language governing permissions
  ! and limitations under the License.
  !
  ! If applicable, add the following below this CCPL HEADER, with the fields
  ! enclosed by brackets "[]" replaced with your own identifying information:
  !      Portions Copyright [yyyy] [name of copyright owner]
  !
  ! CCPL HEADER END
  !
  !      Copyright 2011 ForgeRock AS
  !    
-->
<chapter xml:id='chap-install'
 xmlns='http://docbook.org/ns/docbook'
 version='5.0' xml:lang='en'
 xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
 xsi:schemaLocation='http://docbook.org/ns/docbook http://docbook.org/xml/5.0/xsd/docbook.xsd'
 xmlns:xlink='http://www.w3.org/1999/xlink'
 xmlns:xinclude='http://www.w3.org/2001/XInclude'>
 <title>Installing OpenAM Core Services &amp; Gateway</title>

 <para>This chapter covers tasks required to install OpenAM core services,
 and to ensure they run properly. It includes instructions on preparing your
 application server to run OpenAM, preparing your identity repository to
 handle OpenAM identities, deploying component .war files, installing
 OpenAM administration tools, and performing post-installation
 configuration.</para>
 
 <!-- TODO: Add olink when the machinery is available. -->
 <para>To manage access to web resources on other servers, you can install
 policy agents that provide tight integration with OpenAM. See the
 <citetitle>Policy Agent Installation Guide</citetitle> for instructions
 on installing OpenAM agents in supported web servers and Java EE
 application containers.</para>
 
 <section xml:id="prepare-prerequisites">
  <title>Preparing Prerequisite Software</title>

  <itemizedlist>
   <para>OpenAM core services require the following prerequisite
   software installed before you begin OpenAM installation.</para>
   <listitem>
    <para>A Java 6 runtime environment</para>
    <screen>$ java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing)</screen>
   </listitem>
   <listitem>
    <!-- TODO: Add olink when the machinery is available. -->
    <para>A supported application server as the deployment container</para>
    <para>See the <citetitle>Release Notes</citetitle> for a list.</para>
    
    <para>OpenAM core services require a minimum JVM heap size of 1 GB,
    and a permanent generation size of 256 MB. Apply the following JVM options
    before start your application server.</para>
    <programlisting>-Xmx1024m -XX:MaxPermSize=256m</programlisting>
    
    <para>If a Java Security Manager is enabled for your deployment container,
    add permissions before installing OpenAM.</para>
    <!-- TODO: Define permissions for supported containers. Could these be
    separate files available in the product directory when you unpack?-->
    
    <para>OpenAM examples here use Apache Tomcat as the deployment container.
    Tomcat is installed on <literal>openam.example.com</literal>, and listens
    on the default ports, with no Java Security Manager enabled. The script
    <filename>/etc/init.d/tomcat</filename> manages the service at system
    startup and shutdown.</para>
    
    <programlisting language="shell">#!/bin/sh
#
# tomcat
#
# chkconfig: 345 95 5
# description: Manage Tomcat web application container
CATALINA_HOME="/path/to/tomcat"
export CATALINA_HOME
JAVA_HOME=/path/to/jdk1.6
export JAVA_HOME
JAVA_OPTS="-Xmx1024m -XX:MaxPermSize=256m"
export JAVA_OPTS

case "${1}" in
start)
  /bin/su mark -c "${CATALINA_HOME}/bin/startup.sh"
  exit ${?}
  ;;
stop)
  /bin/su mark -c "${CATALINA_HOME}/bin/shutdown.sh"
  exit ${?}
  ;;
*)
  echo "Usage:  $0 { start | stop }"
  exit 1
  ;;
esac
</programlisting>
    
    <!-- TODO: see also http://resources.apexidentity.com/projects/docs/wiki/Containerhelp -->
   </listitem>
   <listitem>
    <para>A supported identity repository for user identity data</para>
     <!-- TODO: Add olink when the machinery is available. -->
    <para>See the <citetitle>Release Notes</citetitle> for a list. If you
    plan to use OpenAM for evaluation or testing, you can use the embedded
    identity repository. ForgeRock does not recommend using the embedded
    identity repository for production deployments, however.</para>
    
    <para>Examples here use OpenDJ as the identity repository. OpenDJ
    is installed on <literal>openam.example.com</literal>, and listens
    on the following ports.</para>
    <itemizedlist>
     <listitem><para>Port 1389 for LDAP requests and StartTLS</para></listitem>
     <listitem><para>Port 1636 for LDAP requests over SSL</para></listitem>
     <listitem><para>Port 4444 for administrative traffic</para></listitem>
    </itemizedlist>
    <para>The script <filename>/etc/init.d/opendj</filename>, created with the
    OpenDJ <command>create-rc-script</command> command, manages the service
    at system startup and shutdown.</para>
    
    <programlisting language="shell">#!/bin/sh
#...
# chkconfig: 345 95 5
# description: Control the OpenDJ Directory Server


# Set the path to the OpenDJ instance to manage
INSTALL_ROOT="/path/to/OpenDJ"
export INSTALL_ROOT

cd ${INSTALL_ROOT}

# Determine what action should be performed on the server
case "${1}" in
start)
  /bin/su mark -c "${INSTALL_ROOT}/bin/start-ds --quiet"
  exit ${?}
  ;;
stop)
  /bin/su mark -c "${INSTALL_ROOT}/bin/stop-ds --quiet"
  exit ${?}
  ;;
restart)
  /bin/su mark -c "${INSTALL_ROOT}/bin/stop-ds --restart --quiet"
  exit ${?}
  ;;
*)
  echo "Usage:  $0 { start | stop | restart }"
  exit 1
  ;;
esac
</programlisting>
    <para>The Example.com sample data loaded into OpenDJ are taken from
    the file, <link xlink:href="http://mcraig.org/ldif/Example.ldif"
    >Example.ldif</link> that you can download.</para>
    <para>See the <citetitle>OpenDJ Installation Guide</citetitle> for
    detailed installation instructions.</para>
   </listitem>
  </itemizedlist>
 </section>

 <section xml:id="download-openam-software">
  <title>Obtaining OpenAM Software</title>
  
  <para>Download OpenAM releases from <link
  xlink:href='http://forgerock.com/downloads.html'
  >http://forgerock.com/downloads.html</link>. At the download location you
  find links to stable releases, nightly builds for testing, previous
  releases, and also OpenAM policy agent releases.</para>
  
  <para>For each release of the OpenAM core services, you can download the
  entire package as a .zip archive, only the OpenAM .war file, or only the
  administrative tools as a .zip archive.</para> 
  
  <variablelist>
   <para>After you unzip the archive of the entire package, you get an
   <filename>opensso</filename> directory including a README, a set of license
   files, and the following directories.</para>
   <!-- TODO: As of nightly from 17 May 2011, where is the universal gateway? -->
   <varlistentry>
    <term><filename>deployable-war</filename></term>
    <listitem><para>The deployable .war file as well as the tools and files
    required to create any specialized .war files you deploy.</para></listitem>
   </varlistentry>
   <varlistentry>
    <term><filename>docs</filename></term>
    <listitem><para>Javadoc API specifications for the public APIs exposed by
    OpenAM</para></listitem>
   </varlistentry>
   <varlistentry>
    <term><filename>fedlet</filename></term>
    <listitem><para>The lightweight service provider implementation that you
    embed in your Java EE application to enable it to use federated access
    management</para></listitem>
   </varlistentry>
   <varlistentry>
    <term><filename>integrations</filename></term>
    <listitem><para>Resources for integrating OpenAM with third-party access
    and identity management software</para></listitem>
   </varlistentry>
   <varlistentry>
    <term><filename>ldif</filename></term>
    <listitem><para>Schema and index definitions for use with external
    LDAP identity repositories</para></listitem>
   </varlistentry>
   <varlistentry>
    <term><filename>legal</filename></term>
    <listitem><para>Additional license and entitlement files</para></listitem>
   </varlistentry>
   <varlistentry>
    <term><filename>libraries</filename></term>
    <listitem><para>Client SDK and policy agent libraries</para></listitem>
   </varlistentry>
   <varlistentry>
    <term><filename>patches</filename></term>
    <listitem><para>Location for patches to apply to OpenAM</para></listitem>
   </varlistentry>
   <varlistentry>
    <term><filename>samples</filename></term>
    <listitem><para>Sample source files demonstrating how to use the OpenAM
    client SDK</para></listitem>
   </varlistentry>
   <varlistentry>
    <term><filename>tools</filename></term>
    <listitem><para>OpenAM tools for managing SSO, configuring deployed
    .war files, patching deployed .war files, managing sessions, and diagnosing
    deployment issues</para></listitem>
   </varlistentry>
   <varlistentry>
    <term><filename>upgrade</filename></term>
    <listitem><para>Content for upgrading from legacy versions of Sun
    Access Manager and Federation Manager</para></listitem>
   </varlistentry>
   <varlistentry>
    <term><filename>xml</filename></term>
    <listitem><para>OpenAM service and default delegation policy configuration
    files</para></listitem>
   </varlistentry>
  </variablelist>
 </section>

 <section xml:id="install-openam-web-application">
  <title>Install the OpenAM Web Application</title>
  <para>The <filename>deployable-war/opensso.war</filename> file contains all
  OpenAM server components and samples. How you deploy the .war file depends
  on your web application container.</para>
  <procedure xml:id="deploy-openam-on-tomcat">
   <title>To Deploy OpenAM on Tomcat</title>
   <step>
    <para>Copy the .war file to the directory where web applications are
    stored.</para>
    <screen>$ cp deployable-war/opensso.war /path/to/tomcat/webapps/openam.war</screen>
   </step>
   <step>
    <para>Check that you see the initial configuration screen in your browser.</para>
    <mediaobject>
     <alt>Initial OpenAM configuration screen</alt>
     <imageobject>
      <imagedata fileref="images/openam-start.png" format="PNG" />
     </imageobject>
     <caption><para>Port is 8080, but 12380 here because the port is
     redirected to a virtual machine.</para></caption>
    </mediaobject>
   </step>
  </procedure>
  
  <procedure xml:id="configure-openam-defaults">
   <title>To Configure OpenAM With Defaults (For Testing)</title>
   
   <step>
    <para>In the initial configuration screen, click
    Create Default Configuration under Default Configuration.</para>
   </step>
   <step>
    <para>Provide different passwords for the default OpenAM administrator,
    <literal>amadmin</literal>, and default Policy Agent users.</para>
    <mediaobject>
     <alt>OpenAM default configuration</alt>
     <imageobject>
      <imagedata fileref="images/openam-default-conf.png" format="PNG" />
     </imageobject>
     <textobject><para>The default configuration asks only for two
     passwords.</para></textobject>
    </mediaobject>
   </step>
   <step>
    <para>When the configuration completes, click Proceed to Login, and then
    login as OpenAM administrator with the first of the two passwords you
    provided.</para>
    <mediaobject>
     <alt>OpenAM first login</alt>
     <imageobject>
      <imagedata fileref="images/openam-first-login.png" format="PNG" />
     </imageobject>
     <textobject><para>The home page for OpenAM when logged in as the OpenAM
     Administrator, <literal>amadmin</literal></para></textobject>
    </mediaobject>
   </step>
  </procedure>
  
  <procedure xml:id="delete-config-start-over">
   <title>To Delete an OpenAM Configuration Before Redploying</title>
  
   <step>
    <para>Stop the OpenAM web application to clear the configuration held
    in memory.</para>
    <para>The following example shuts down Tomcat configured as described
    above.</para>
    <screen>$ /etc/init.d/tomcat stop
Password: 
Using CATALINA_BASE:   /path/to/tomcat
Using CATALINA_HOME:   /path/to/tomcat
Using CATALINA_TMPDIR: /path/to/tomcat/temp
Using JRE_HOME:        /path/to/jdk1.6/jre
Using CLASSPATH:
       /path/to/tomcat/bin/bootstrap.jar:/path/to/tomcat/bin/tomcat-juli.jar</screen>
   </step>
   <step>
    <para>Delete OpenAM configuration files, by default in
    <filename>$HOME/openam</filename>.</para>
    <screen>$ rm -rf $HOME/openam</screen>
   </step>
   <step>
    <para>Restart the OpenAM web application.</para>
    <para>The following example restarts the Tomcat container.</para>
    <screen>$ /etc/init.d/tomcat start
Password: 
Using CATALINA_BASE:   /path/to/tomcat
Using CATALINA_HOME:   /path/to/tomcat
Using CATALINA_TMPDIR: /path/to/tomcat/temp
Using JRE_HOME:        /path/to/jdk1.6/jre
Using CLASSPATH:
       /path/to/tomcat/bin/bootstrap.jar:/path/to/tomcat/bin/tomcat-juli.jar</screen>
   </step>
  </procedure>
  
  <procedure xml:id="configure-openam-custom">
   <title>To Configure OpenAM</title>
   
   <step>
    <para>In the initial configuration screen, click
    Create New Configuration under Custom Configuration.</para>
   </step>
   <step>
    <para>Provide a password having at least 8 characters for the OpenAM
    Administrator, <literal>amadmin</literal>.</para>
    <mediaobject>
     <alt>OpenAM amadmin password</alt>
     <imageobject>
      <imagedata fileref="images/openam-conf-amadmin.png" format="PNG" />
     </imageobject>
     <textobject><para>The OpenAM Administrator has username
     <literal>amadmin</literal>.</para></textobject>
    </mediaobject>
   </step>
   <step>
    <para>Make sure the server settings are valid for your configuration.</para>
    <mediaobject>
     <alt>OpenAM server settings</alt>
     <imageobject>
      <imagedata fileref="images/openam-conf-server-settings.png" format="PNG" />
     </imageobject>
     <textobject><para>See OpenAM server settings below</para></textobject>
    </mediaobject>
    <variablelist>
     <varlistentry>
      <term>Server URL</term>
      <listitem>
       <para>Provide a valid URL to the base of your OpenAM web
       container, including a fully qualified domain name (FQDN).</para>
       <para>In a test environment, you can fake the FQDN by adding it to
       your <filename>/etc/hosts</filename> as an alias. The following excerpt
       shows lines from the <filename>/etc/hosts</filename> file on a Linux
       system where OpenAM is installed.</para>
       <programlisting>127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
127.0.1.1 openam openam.example.com</programlisting>
      </listitem>
     </varlistentry>
     <varlistentry>
      <term>Cookie Domain</term>
      <listitem>
       <para>Starts with a dot, <literal>.</literal></para>
      </listitem>
     </varlistentry>
     <varlistentry>
      <term>Platform Locale</term>
      <listitem>
       <para>Supported locales include en_US (English), de (German),
       es (Spanish), fr (French), ja (Japanese), zh_CN (Simplified Chinese),
       and zh_TW (Traditional Chinese).</para>
      </listitem>
     </varlistentry>
     <varlistentry>
      <term>Configuration Directory</term>
      <listitem>
       <para>Location on server for OpenAM configuration files. OpenAM must
       be able to write to this directory.</para>
      </listitem>
     </varlistentry>
    </variablelist>
   </step>
   <step>
    <para>In the Configuration Store screen, you can accept the defaults
    to allow OpenAM to store configuration data in an embedded directory.
    The embedded directory can be configured separately to replicate data
    for high availability if necessary.</para>
    <para>You can also add this OpenAM installation to an existing deployment,
    proving the URL to reach an existing OpenAM instance.</para>
    <para>Alternatively, if you already manage an OpenDJ or DSEE deployment,
    you can choose to store OpenAM configuration data in your existing
    directory service. If you decide to use an existing installation of
    OpenDJ for configuration data, then you must first relax the restriction
    on objects with multiple structural object classes, by using the OpenDJ
    <command>dsconfig</command> command before completing OpenAM
    configuration.</para>
    <screen>$ dsconfig -h <replaceable>hostname</replaceable> -p 4444 -D "cn=Directory Manager" -w <replaceable>password</replaceable>
 set-global-configuration-prop
 --set single-structural-objectclass-behavior:warn -X -n</screen>
   </step>
   <step>
    <para>In the User Store screen, you configure where OpenAM looks for
    user identities.</para>
    <para>OpenAM must have write access to the directory service you choose,
    as it adds to the directory schema needed to allow OpenAM to manage access
    for users in the user store.</para>
    <mediaobject>
     <alt>OpenAM user store settings</alt>
     <imageobject>
      <imagedata fileref="images/openam-conf-user-store.png" format="PNG" />
     </imageobject>
     <textobject><para>See OpenAM user store settings below</para></textobject>
    </mediaobject>
    <variablelist>
     <varlistentry>
      <term>User Data Store Type</term>
      <listitem>
       <para>If you have a directory service already provisioned with users in
       a supported user data store, then select that type of directory from the
       options available. For OpenDJ, select OpenDS.</para>
      </listitem>
     </varlistentry>
     <varlistentry>
      <term>SSL/TLS Enabled</term>
      <listitem>
       <para>To use a secure connection, check this box, then make sure
       the Port you define corresponds to the port on which the directory
       listens for StartTLS or SSL connections.</para>
      </listitem>
     </varlistentry>
     <varlistentry>
      <term>Directory Name</term>
      <listitem>
       <para>FQDN for the host housing the directory service</para>
      </listitem>
     </varlistentry>
     <varlistentry>
      <term>Port</term>
      <listitem>
       <para>LDAP directory port. The default for LDAP and LDAP with StartTLS
       to protect the connection is port 389. The default for LDAP over SSL
       is port 636. Your directory service might use a different port.</para>
      </listitem>
     </varlistentry>
     <varlistentry>
      <term>Root Suffix</term>
      <listitem>
       <para>Base distinguished name (DN) where user data are stored</para>
      </listitem>
     </varlistentry>
     <varlistentry>
      <term>Login ID</term>
      <listitem>
       <para>Directory administrator user DN. The administrator must be capable
       of updating schema and user data.</para>
      </listitem>
     </varlistentry>
     <varlistentry>
      <term>Password</term>
      <listitem>
       <para>Password for the directory administrator user</para>
      </listitem>
     </varlistentry>
    </variablelist>
   </step>
   <step>
    <para>In the Site Configuration screen, you can set up OpenAM as part of
    a site where the load is balanced across multiple OpenAM servers.</para>
    <para>For your first OpenAM installation, accept the defaults.</para>
    <mediaobject>
     <alt>OpenAM site configuration</alt>
     <imageobject>
      <imagedata fileref="images/openam-conf-site.png" format="PNG" />
     </imageobject>
     <textobject><para>Accept the defaults unless you load balance across
     multiple OpenAM servers.</para></textobject>
    </mediaobject>
   </step>
   <step>
    <para>In the Agent Information screen, provide a password having at least
    8 characters to be used by policy agents to connect to OpenAM.</para>
    <mediaobject>
     <alt>OpenAM policy agent password</alt>
     <imageobject>
      <imagedata fileref="images/openam-conf-pa.png" format="PNG" />
     </imageobject>
     <textobject><para>OpenAM policy agents use the password you provide
     to access centralized configuration information.</para></textobject>
    </mediaobject>
   </step>
   <step>
    <para>When the configuration completes, click Proceed to Login, and then
    login as OpenAM administrator.</para>
    <mediaobject>
     <alt>OpenAM first login</alt>
     <imageobject>
      <imagedata fileref="images/openam-first-login.png" format="PNG" />
     </imageobject>
     <textobject><para>The home page for OpenAM when logged in as the OpenAM
     Administrator, <literal>amadmin</literal></para></textobject>
    </mediaobject>
   </step>
  </procedure>
 </section>

 <section xml:id="install-openam-tools">
  <title>Installing OpenAM Tools</title>
  <para>OpenAM tools are found in the <filename>tools/</filename> directory
  where you unpacked the archive of the entire package.</para>
  <variablelist>
   <varlistentry>
    <term><filename>tools/ssoAdminTools.zip</filename></term>
    <listitem>
     <para>Administration tools like <command>ssoadm</command> and
     <command>amtune</command></para>
    </listitem>
   </varlistentry>
   <varlistentry>
    <term><filename>tools/ssoConfiguratorTools.zip</filename></term>
    <listitem>
     <para>Tools for command line installation and configuration</para>
    </listitem>
   </varlistentry>
   <varlistentry>
    <term><filename>tools/ssoDiagnosticTools.zip</filename></term>
    <listitem>
     <para>Tool to check for problems with your deployment and
     configuration</para>
    </listitem>
   </varlistentry>
   <varlistentry>
    <term><filename>tools/ssoSessionTools.zip</filename></term>
    <listitem>
     <para>Session failover utilities</para>
    </listitem>
   </varlistentry>
  </variablelist>
  
  <procedure xml:id="install-openam-admin-tools">
   <title>To Set Up Administration Tools</title>
   <step>
    <para>Make sure the <literal>JAVA_HOME</literal> environment variable
    is properly set.</para>
    <screen>$ echo $JAVA_HOME
/path/to/jdk1.6</screen>
   </step>
   <step>
    <para>Unpack the tools from where you unzipped OpenAM.</para>
    <screen>$ cd /path/to/admin/tools
$ unzip /path/to/OpenAM/tools/ssoAdminTools.zip
...
  inflating: template/windows/bin/amtune/amtune.bat.template  
  inflating: template/windows/bin/amverifyarchive.bat.template  
  inflating: template/windows/bin/ssoadm.bat.template</screen>
   </step>
   <step>
    <para>Run the <command>setup</command> utility (<command>setup.bat</command>
    on Windows), providing the path to the directory where OpenAM configuration
    files are located, and where you want debug and log information to be
    located.</para>
    <screen>$ setup
Path to config files of OpenAM server (example: /opensso):/home/mark/openam
Debug Directory:/home/mark/openam
Log Directory:/home/mark/openam
The scripts are properly setup under directory: /path/to/admin/tools/openam
Debug directory is /home/mark/openam.
Log directory is /home/mark/openam.
The version of this tools.zip is: (2011-July-11 00:05)
The version of your server instance is: (2011-July-11 00:05)</screen>
    <para>After setup, the tools are located under a directory named after the
    instance of OpenAM.</para>
    <screen>$ ls openam/bin/
ampassword  amtune/  amverifyarchive  ssoadm</screen>
   </step>
   <step>
    <para>Activate <command>ssoadm</command>, which is disabled by
    default.</para>
    <substeps>
     <step>
      <para>Login to the console as the OpenAM administrator,
      <literal>amadmin</literal>.</para>
     </step>
     <step>
      <para>Under Configuration &gt; Servers and Sites, click the server
      to configure to edit the properties.</para>
     </step>
     <step>
      <para>On the Advanced tab page, add a property with name
      <literal>ssoadm.disabled</literal> and value <literal>false</literal>,
      and then save your work.</para>
     </step>
    </substeps>
   </step>
   <step>
    <para>Check that <command>ssoadm</command> works properly.</para>
    <screen>$ echo password > /tmp/pwd.txt
$ chmod 400 /tmp/pwd.txt 
$ ./openam/bin/ssoadm list-servers -u amadmin -f /tmp/pwd.txt 

http://openam.example.com:8080/openam</screen>
    <para>The <command>ssoadm</command> commands can also be run from
    <filename>ssoadm.jsp</filename> in OpenAM, for example at
    <literal>http://openam.example.com:8080/openam/ssoadm.jsp</literal>.</para>
   </step>
  </procedure>
  
  <procedure xml:id="install-openam-config-tools">
   <title>To Set Up Configuration Tools</title>
   
   <step>
    <para>Make sure the <literal>JAVA_HOME</literal> environment variable
    is properly set.</para>
    <screen>$ echo $JAVA_HOME
/path/to/jdk1.6</screen>
   </step>
   <step>
    <para>Unpack the tools from where you unzipped OpenAM.</para>
    <screen>$ unzip /path/to/OpenAM/tools/ssoConfiguratorTools.zip 
Archive:  /path/to/OpenAM/tools/ssoConfiguratorTools.zip
  inflating: README.setup            
  inflating: configurator.jar        
  inflating: sampleconfiguration</screen>
    <para>Set up configuration files based on the
    <filename>sampleconfiguration</filename> example, and then apply the
    configuration to a deployed OpenAM .war file using the following
    command.</para>
    <screen>$ java -jar configurator.jar -f <replaceable>config.file</replaceable></screen>
   </step>
  </procedure>
  
  <procedure xml:id="install-openam-diagnostic-tool">
   <title>To Set Up Diagnostic Tool</title>
   <para>The diagnostic tool, <command>ssodtool.sh</command>
   (<command>ssodtool.bat</command> on Windows), works in both graphical and
   console mode.</para>
   <step>
        <para>Make sure the <literal>JAVA_HOME</literal> environment variable
    is properly set.</para>
    <screen>$ echo $JAVA_HOME
/path/to/jdk1.6</screen>
   </step>
   <step>
    <para>Unpack the tools from where you unzipped OpenAM.</para>
    <screen>$ unzip /path/to/OpenAM/tools/ssoDiagnosticTools.zip
...
  inflating: services/webcontainer/service.xml
  inflating: ssodtool.bat            
  inflating: ssodtool.sh</screen>
  <para>You can start the graphical user interface by using the tools without
  options, or in console mode using the <command>ssodtool.sh --console</command>
  command.</para>
   </step>
  </procedure>
  
  <procedure xml:id="install-openam-session-tools">
   <title>To Set Up Session Tools</title>
   
   <note>
    <para>Expect this procedure to change as the new, OpenDJ-based session
    failover capabilities are included in OpenAM.</para>
   </note>
   
   <step>
    <para>Make sure the <literal>JAVA_HOME</literal> environment variable
    is properly set.</para>
    <screen>$ echo $JAVA_HOME
/path/to/jdk1.6</screen>
   </step>
   <step>
    <para>Install the necessary scripts for session failover.</para>
<screen>$ setup -p scripts
The scripts are properly setup under directory: /path/to/session/tools/scripts
...</screen>
    <!-- TODO: Add olink when the machinery is available. -->
    <para>For instructions on making sessions available across a site, see
    the chapter on <citetitle>Setting Up OpenAM Session
    Failover</citetitle>.</para>
   </step>
  </procedure>
 </section>

 <section xml:id="install-universal-gateway">
  <title>Installing the Universal Gateway</title>
  <!-- TODO: see http://resources.apexidentity.com/projects/docs/wiki/Installation -->
  <para>TODO</para>
 </section>
 
 <section xml:id="install-federation-gateway">
  <title>Installing the Federation Gateway</title>
  <!-- TODO: see http://resources.apexidentity.com/projects/docs/wiki/Federation -->
  <para>TODO</para>
 </section>

 <section xml:id="deploy-distributed-auth">
  <title>Deploying Distributed Authentication Across a DMZ</title>
  
  <para>When you need to prevent end users from having direct access to the
  service URLs OpenAM uses to manage access, you can deploy the distributed
  authentication service (DAS) in your DMZ, leaving OpenAM core services behind
  the firewall that end users cannot access.</para>
  
  <para>You complete the following stages in deployment the DAS web
  service.</para>
  <orderedlist>
   <listitem>
    <para>Create the .war file for the DAS using OpenAM software.</para>
   </listitem>
   <listitem>
    <para>Deploy the DAS .war file into your web application container.</para>
    <para>How you deploy the DAS .war file depends on your web application
    container. The procedure in this section shows how to deploy on
    Apache Tomcat.</para>
   </listitem>
   <listitem>
    <para>Create an agent profile for the DAS.</para>
   </listitem>
   <listitem>
    <para>Configure the DAS UI to access OpenAM core services.</para>
   </listitem>
   <listitem>
    <para>Configure your firewall to allow end user access to the DAS.</para>
    <para>Firewall configuration is not described here.</para>
   </listitem>
  </orderedlist>
  
  <procedure xml:id="create-distributed-auth-file">
   <title>To Create the DAS <filename>.war</filename> File</title>
   
   <step>
    <para>Unpack the <filename>opensso.war</filename> file into a temporary
    directory.</para>
    <screen>$ mkdir -p /tmp/das ; cd /tmp/das
$ jar xf /path/to/OpenAM/deployable-war/opensso.war</screen>
   </step>
   <step>
    <para>Create the <filename>das.war</filename> file.</para>
    <screen>$ cd /path/to/OpenAM/deployable-war
$ sh createwar.sh --staging /tmp/das --type distauth --warfile das.war</screen>
   </step>
  </procedure>
  
  <procedure xml:id="deploy-distributed-auth-on-tomcat">
   <title>To Deploy the DAS on Tomcat</title>
  
   <step>
    <para>Put the <filename>das.war</filename> you created in the Tomcat
    <filename>webapps/</filename> directory.</para>
    <screen>$ mv das.war /path/to/tomcat/webapps/</screen>
   </step>
   <step>
    <para>Check that you see the initial DAS configuration screen
    in your browser.</para>
    <mediaobject>
     <alt>Initial DAS configuration screen</alt>
     <imageobject>
      <imagedata fileref="images/das-initial-screen.png" format="PNG" />
     </imageobject>
     <caption><para>The first time you access the DAS, you must configure
     access to OpenAM.</para></caption>
    </mediaobject>
   </step>
  </procedure>
  
  <procedure xml:id="create-distributed-auth-user">
   <title>To Create an Agent Profile for the DAS</title>
  
   <step>
    <para>Login to OpenAM as the administrator,
    <literal>amadmin</literal>.</para>
   </step>
   <step>
    <para>Under the Access Control &gt; click <literal>/ (Top Level
    Realm)</literal>.</para>
   </step>
   <step>
    <para>Under the Agents &gt; 2.2 Agents tab, click New... to open the
    New Agent page.</para>
   </step>
   <step>
    <para>Create a new agent user profile.</para>
    <para>The subsequent procedures in this section have an agent with name
    <literal>dasUser</literal> and password <literal>password</literal>.</para>
   </step>
  </procedure>
  
  <procedure xml:id="configure-distributed-auth">
   <title>To Configure the DAS</title>
  
   <step>
    <para>Configure the DAS using the agent profile to connect to OpenAM.</para>
    <mediaobject>
     <alt>Completed DAS configuration screen</alt>
     <imageobject>
      <imagedata fileref="images/das-complete-config.png" format="PNG" />
     </imageobject>
     <caption><para>Configure access to OpenAM.</para></caption>
    </mediaobject>
   </step>
   <step>
    <para>Login through the DAS to access OpenAM services.</para>
    <para>The first time you test this in your lab or on your laptop, you
    can set up sample authentication data, and a sample realm that gives
    you a landing page after successful login. Otherwise the default
    result of successful login is a redirect to the default success
    login URL, which is <literal>/openam/console</literal>, resulting in
    a successful login, but an error in the browser. Indeed,
    <literal>/openam/console</literal> is a URL you probably do not want to
    expose outside the firewall. Instead, follow these steps to see the DAS
    at work.</para>
    <substeps>
     <step>
      <para>When setting up OpenAM, use OpenDJ with the sample data mentioned
      above.</para>
     </step>
     <step>
      <para>Login to the OpenAM console as the OpenAM Administrator,
      <literal>amadmin</literal>.</para>
     </step>
     <step>
      <para>Under the Access Control tab, in the Realms section, click New...
      to create a new Realm called Example.</para>
      <para>On the General tab for the Example realm, add
      <literal>.example.com</literal>.</para>
      <para>On the Authentication tab for the Example realm, make sure the
      Default Success Login URL list contains only the value
      <literal>/das/click/index.html</literal>.</para>
     </step>
     <step>
      <para>Edit the file
      <filename>/path/to/tomcat/webapps/das/click/index.html</filename> so it
      looks like this:</para>
      <programlisting language="html">&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Successful login&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;p&gt;Congratulations, you have logged in successfully.&lt;/p&gt;
&lt;p&gt;Click &lt;a href="../UI/Logout.jsp"&gt;here&lt;/a&gt; to logout.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</programlisting>
     </step>
     <step>
      <para>In your browser, visit the login page.</para>
      <para>For example, if Apache Tomcat is listening on
      <literal>localhost:8080</literal>, then browse to
      <literal>http://localhost:8081/das/UI/Login?org=/Example</literal>.</para>
     </step>
     <step>
      <para>Login as a sample user from the <filename>Example.ldif</filename>
      file, such as user <literal>bjensen</literal> who has password
      <literal>hifalutin</literal>.</para>
     <mediaobject>
      <alt>Logging into OpenAM through the DAS</alt>
      <imageobject>
       <imagedata fileref="images/das-login-page.png" format="PNG" />
      </imageobject>
      <caption><para>The DAS UI handles access to OpenAM.</para></caption>
     </mediaobject>
     </step>
    </substeps>
    <mediaobject>
     <alt>Successfully logged in through the DAS</alt>
     <imageobject>
      <imagedata fileref="images/das-login-success.png" format="PNG" />
     </imageobject>
     <caption><para>The DAS UI redirects the user to the URL you
     configured for the realm.</para></caption>
    </mediaobject>
   </step>
  </procedure>
 </section>
 
  <section xml:id="deploy-idp-discovery">
  <title>Deploying the Identity Provider Discovery Service</title>
  <!-- TODO -->
  <para>TODO</para>
 </section>

 <!-- TODO -->
</chapter>

