<?xml version="1.0"?>

<component name="org.nuxeo.ecm.directory.storage">

  <require>org.nuxeo.ecm.platform.digestauth.config</require>

  <extension target="org.nuxeo.ecm.directory.GenericDirectory" point="directories">

    <directory name="userDirectory" extends="template-user">

      <schema>user</schema>

      <types>
        <type>system</type>
      </types>

      <idField>username</idField>
      <passwordField>password</passwordField>
      <passwordHashAlgorithm>SSHA</passwordHashAlgorithm>
      <autoincrementIdField>false</autoincrementIdField>
      <dataFile>users.csv</dataFile>
      <createTablePolicy>on_missing_columns</createTablePolicy>
      <querySizeLimit>50</querySizeLimit>

      <!-- comment <cache* /> tags to disable the cache -->
      <cacheEntryName>user-entry-cache</cacheEntryName>
      <cacheEntryWithoutReferencesName>user-entry-cache-without-references</cacheEntryWithoutReferencesName>

      <references>
        <inverseReference field="groups" directory="groupDirectory"
                          dualReferenceField="members"/>
      </references>

    </directory>

    <directory name="groupDirectory" extends="template-group">

      <schema>group</schema>
      <types>
        <type>system</type>
      </types>
      <idField>groupname</idField>
      <dataFile>groups.csv</dataFile>
      <createTablePolicy>on_missing_columns</createTablePolicy>
      <autoincrementIdField>false</autoincrementIdField>

      <!-- comment <cache* /> tags to disable the cache -->
      <cacheEntryName>group-entry-cache</cacheEntryName>
      <cacheEntryWithoutReferencesName>group-entry-cache-without-references</cacheEntryWithoutReferencesName>

      <references>
        <reference field="members" directory="userDirectory"
                   name="user2group" source="groupId" target="userId"
                   dataFile="user2group.csv"/>
        <!-- Warning ! From Nuxeo 5.3.1, a wrong setting has been fixed. See
        http://jira.nuxeo.org/browse/NXP-4401 . Nuxeo upgrades would need a fix in the
        database (inverting parentGroupId and childGroupId in the group2group)  -->
        <reference field="subGroups" directory="groupDirectory"
                   name="group2group" source="parentGroupId"
                   target="childGroupId"/>
        <inverseReference field="parentGroups" directory="groupDirectory"
                          dualReferenceField="subGroups"/>
      </references>

    </directory>

    <directory name="digestauth" extends="template-directory">
      <schema>digestauth</schema>
      <idField>username</idField>
      <passwordField>password</passwordField>
      <types>
        <type>system</type>
      </types>
      <cacheEntryName>digestauth-entry-cache</cacheEntryName>
      <cacheEntryWithoutReferencesName>digestauth-entry-cache-without-references</cacheEntryWithoutReferencesName>
    </directory>

  </extension>

</component>
