<?xml version="1.0"?>
<component name="org.nuxeo.ecm.directory.storage.override">

  <require>org.nuxeo.ecm.directory.storage</require>

  <?xml version='1.0' encoding='UTF-8'?>
<extension point="directories" target="org.nuxeo.ecm.directory.GenericDirectory">

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

      <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 directory="groupDirectory" dualReferenceField="members" field="groups"/>
      </references>

    </directory>

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

      <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 dataFile="user2group.csv" directory="userDirectory" field="members" name="user2group" source="groupId" target="userId"/>
        <!-- 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 directory="groupDirectory" field="subGroups" name="group2group" source="parentGroupId" target="childGroupId"/>
        <inverseReference directory="groupDirectory" dualReferenceField="subGroups" field="parentGroups"/>
      </references>

    </directory>

    <directory extends="template-directory" name="digestauth">
      <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>
