<?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-2012 ForgeRock AS
  !    
-->
<chapter xml:id='chap-realms'
 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>Configuring Realms</title>
 
 <indexterm><primary>Realms</primary></indexterm>
 <para>This chapter shows how to configure OpenAM <firstterm>realms</firstterm>,
 which are used to group configuration and identities together. For example,
 you might have one realm for OpenAM administrators and agents, and another
 realm for users. In this two-realm setup, the OpenAM administrator can
 login to the administrative realm to manage the services, but cannot
 authenticate as OpenAM administrator to the realm that protects web sites
 with HR and financial information.</para>
 
 <para>OpenAM associates a realm with at least one identity repository and
 authentication process. OpenAM also associates the realm with authorization
 policies and entitlements for users, and privileges for administrators. Each
 realm can have its own configuration for services.</para>
 
 <para>When you first configure OpenAM, OpenAM sets up the default
 <literal>/ (Top Level Realm)</literal>, containing OpenAM configuration
 data, and allowing authentication using the identity repository you choose
 during initial configuration. The top level realm might hold the overall
 configuration for Example.com for instance.</para>
 
 <para>You create new realms to subdivide authentication, and authorization,
 and to delegate management of sub-realms. For example, your organization
 might require separate realms for payroll, human resources, and IT management
 domains and their applications.</para>
 
 <procedure xml:id="create-new-realm">
  <title>To Create a New Realm</title>
  <indexterm>
   <primary>Realms</primary>
   <secondary>Creating</secondary>
  </indexterm>
  
  <para>You can create a new realm through the OpenAM console as described
  below, or by using the <command>ssoadm create-realm</command> command.</para>
  
  <step>
   <para>Login to the OpenAM console as OpenAM Administrator,
   <literal>amadmin</literal>.</para>
  </step>
  <step>
   <para>On the Access Control tab &gt; Realms table, click New... to open
   the New Realm page, where you configure the realm.</para>
   <para>If you configure the realm to be inactive, then users cannot use
   it to authenticate or be granted access to protected resources.</para>
   <para>Realm/DNS aliases must be meaningful in DNS terms, such as
   <literal>.hr.example.com</literal> or
   <literal>pay.example.com</literal>.</para>
  </step>
  <step>
   <para>Save your work after defining the configuration for the new realm.</para>
  </step>
 </procedure>
 
 <para>You configure a realm through the console starting from the Access
 Control tab &gt; Realms table. By default the new realm inherits configuration
 from the global configuration. The default identity repository is the one you
 choose when configuring OpenAM after deployment. The default authentication
 mechanism corresponds to that identity repository as well. You can, however,
 constrain authentication to rely on different data stores, and set policy
 for agents to define authorization in the realm.</para>
 
 <procedure xml:id="delegate-realm-administration">
  <title>To Delegate Administration</title>
  <indexterm><primary>Delegating administration</primary></indexterm>
  
  <para>You can delegate administration in a realm. OpenAM grants
  administrative capabilities to members of groups having administrative
  privileges.</para>
  
  <para>You can grant privileges through the OpenAM console as described
  below, or by using the <command>ssoadm add-privileges</command> command.</para>
  
  <step>
   <para>On the Access Control tab &gt; Realms table, click the realm
   for which you want to delegate administration to view the realm
   configuration.</para>
  </step>
  <step>
   <para>On the Privileges tab, click the name of the group to whom you intend
   to grant access.</para>
  </step>
  <step>
   <para>Select the administrative privileges to delegate for the realm,
   and then save your work.</para>
  </step>
 </procedure>
 
 <procedure xml:id="delegate-policy-to-realm">
  <title>To Delegate Policy Management</title>
  <indexterm>
   <primary>Policy</primary>
   <secondary>Delegating</secondary>
  </indexterm>
  
  <para>When you delegate access management for a realm, you might want to
  delegate policy management. You can delegate policy management by creating a
  referral.</para>
  
  <step>
   <para>In the OpenAM console, browse to Access Control &gt;
   <replaceable>Realm Name</replaceable> &gt; Policies, where
   <replaceable>Realm Name</replaceable> is the realm <emphasis>from
   which</emphasis> you intend to delegate policy.</para>
  </step>
  <step>
   <para>Click the New Referral... button in the Policies table.</para>
  </step>
  <step>
   <para>In the New Referral screen, provide at minimum a name for the
   referral.</para>
  </step>
  <step>
   <para>Set up rules to identify the resources to which the referral
   applies.</para>
   <para>You specify only a rule Name, and a Resource Name for the resource to
   manage, so that the realm administrator has access to set up the policy
   for the specified resource.</para>
  </step>
  <step>
   <para>Set up referrals to identify the realms <emphasis>to which</emphasis>
   to delegate policy management.</para>
   <para>You can delegate to peer realms or sub realms (child realms), but
   not to parent realms.</para>
  </step>
  <step>
   <para>Save your work.</para>
   <para>At this point you can let the realm administrator know that she
   can create policies in her realm for the resources you specified in the
   rules of the referral.</para>
  </step>
 </procedure>
 
 <procedure xml:id="realm-data-store">
  <title>To Configure a Data Store for a Realm</title>
  
  <para>When you first set up a realm, the new realm inherits the data store
  from the parent realm. Yet, if your administrators are in one realm and
  your users in another, your new child realm might retrieve users from
  a different data store.</para>
  
  <step>
   <para>In the OpenAM console, browse to Access Control &gt;
   <replaceable>Realm Name</replaceable> &gt; Data Store.</para>
  </step>
  <step>
   <para>Click New... in the Data Stores table to create a data store
   profile, and to provide the information needed to connect to the
   data store.</para>
  </step>
  <step>
   <para>In the first screen, name the data store and select the type
   of data store to use.</para>
   <para>Most data stores are directory services, though the Database
   Repository lets you connect to an SQL database through JDBC.</para>
  </step>
  <step>
   <para>In the second screen, provide information on how to connect
   to your data store, and then click Finish to save your work.</para>
   
   <para>See the <link xlink:href="admin-guide#chap-auth-services"
   xlink:role="http://docbook.org/xlink/role/olink">chapter on
   authentication</link> for hints on connecting to
   <link xlink:href="admin-guide#ad-module-conf-hints"
   xlink:role="http://docbook.org/xlink/role/olink">Active Directory</link>,
   <link xlink:href="admin-guide#ldap-module-conf-hints"
   xlink:role="http://docbook.org/xlink/role/olink">LDAP directory</link>, and
   <link xlink:href="admin-guide#jdbc-module-conf-hints"
   xlink:role="http://docbook.org/xlink/role/olink">JDBC</link> data
   sources.</para>
  </step>
  <step>
   <para>Click the Subjects tab, and make sure the connection to your
   new data store is working, by searching for a known identity.</para>
   <para>By default the Subjects list only retrieves 100 entries from the
   data store. Narrow your search if you do not see the identity you are
   looking for in the list.</para>
  </step>
  <step>
   <para>If you no longer need the connection to the inherited data store
   <emphasis>in this realm</emphasis>, then you can delete its entry in the
   Data Stores table.</para>
   
   <para>Also, once you change the data store for a realm, you might
   opt to change the <link xlink:href="admin-guide#configure-authn-modules"
   xlink:role="http://docbook.org/xlink/role/olink">authentication module
   configuration</link> as described in the chapter on authentication to use
   your realm data store, rather than the inherited settings.</para>
  </step>
 </procedure>
 
 <procedure xml:id="agent-redirect-login-to-realm">
  <title>To Configure a Web or J2EE Agent For Login to a Realm</title>
  
  <para>You might choose to configure your agent in one realm, yet
  have your real users authenticate through another realm. In this case,
  you want your agents to redirect users to authenticate to their realm,
  rather than the agent realm.</para>
  
  <step>
   <para>In the OpenAM console, browse to Access Control &gt;
   <replaceable>Realm Name</replaceable> &gt; Agents &gt; <replaceable>Web
   or J2EE Agent Type</replaceable> &gt; <replaceable>Agent Name</replaceable>
   &gt; OpenAM Services.</para>
  </step>
  <step>
   <para>Add login and logout URLs, including the realm in the query
   string.</para>
   <itemizedlist>
    <para>For example, if your <replaceable>Realm Name</replaceable> is
    <literal>hr</literal>, and you access OpenAM at
    <literal>http://openam.example.com:8080/openam</literal>:</para>
    <listitem>
     <para>Login URL:
     <literal>http://openam.example.com:8080/openam/UI/Login?realm=hr</literal></para>
    </listitem>
    <listitem>
     <para>Logout URL:
     <literal>http://openam.example.com:8080/openam/UI/Logout?realm=hr</literal></para>
    </listitem>
   </itemizedlist>
  </step>
  <step>
   <para>Save your work.</para>
  </step>
 </procedure>
</chapter>

