You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2015/04/02 18:14:28 UTC

svn commit: r1670931 [7/8] - in /directory/studio/trunk: features/openldap.feature/ plugins/ plugins/openldap.acl.editor/ plugins/openldap.acl.editor/resources/ plugins/openldap.acl.editor/resources/icons/ plugins/openldap.acl.editor/resources/template...

Added: directory/studio/trunk/plugins/openldap.acl.editor/src/test/java/org/apache/directory/studio/openldap/config/acl/model/OpenLdapAclParserTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/test/java/org/apache/directory/studio/openldap/config/acl/model/OpenLdapAclParserTest.java?rev=1670931&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/test/java/org/apache/directory/studio/openldap/config/acl/model/OpenLdapAclParserTest.java (added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/test/java/org/apache/directory/studio/openldap/config/acl/model/OpenLdapAclParserTest.java Thu Apr  2 16:14:26 2015
@@ -0,0 +1,4448 @@
+package org.apache.directory.studio.openldap.config.acl.model;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+
+public class OpenLdapAclParserTest
+{
+    @Test
+    public void testEmpty() throws Exception
+    {
+        try
+        {
+            OpenLdapAclParser parser = new OpenLdapAclParser();
+            parser.parse( "" );
+
+            fail();
+        }
+        catch ( Exception e )
+        {
+            // Should happen
+        }
+    }
+
+
+    @Test
+    public void testWhatStar() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        assertNotNull( whatClause.getStarClause() );
+    }
+
+
+    @Test
+    public void testWhatStarWithoutAccess() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        assertNotNull( whatClause.getStarClause() );
+    }
+
+
+    @Test
+    public void testWhatStarWithSpaces() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "   access    to     *    by    *    " );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        assertNotNull( whatClause.getStarClause() );
+    }
+
+
+    @Test
+    public void testWhatTwoStars() throws Exception
+    {
+        try
+        {
+            OpenLdapAclParser parser = new OpenLdapAclParser();
+            parser.parse( "to * * by *" );
+
+            fail();
+        }
+        catch ( Exception e )
+        {
+            // Should happen
+        }
+    }
+
+
+    @Test
+    public void testWhatDn() throws Exception
+    {
+        String dnPattern = "dsqdsqdq";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to dn=\"" + dnPattern + "\" by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        AclWhatClauseDn whatClauseDn = whatClause.getDnClause();
+        assertNotNull( whatClauseDn );
+        assertEquals( dnPattern, whatClauseDn.getPattern() );
+    }
+
+
+    @Test
+    public void testWhatDnWithoutAccess() throws Exception
+    {
+        String dnPattern = "dsqdsqdq";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to dn=\"" + dnPattern + "\" by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        AclWhatClauseDn whatClauseDn = whatClause.getDnClause();
+        assertNotNull( whatClauseDn );
+        assertEquals( dnPattern, whatClauseDn.getPattern() );
+    }
+
+
+    @Test
+    public void testWhatDnWithSpaces() throws Exception
+    {
+        String dnPattern = "dsqdsqdq";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "   access    to     dn=\"" + dnPattern + "\"    by    *    " );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        AclWhatClauseDn whatClauseDn = whatClause.getDnClause();
+        assertNotNull( whatClauseDn );
+        assertEquals( dnPattern, whatClauseDn.getPattern() );
+    }
+
+
+    @Test
+    public void testWhatDnDefaultType() throws Exception
+    {
+        String dnPattern = "dsqdsqdq";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to dn=\"" + dnPattern + "\" by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        AclWhatClauseDn whatClauseDn = whatClause.getDnClause();
+        assertNotNull( whatClauseDn );
+        assertEquals( dnPattern, whatClauseDn.getPattern() );
+        assertNull( whatClauseDn.getType() );
+    }
+
+
+    @Test
+    public void testWhatDnDefaultTypeWithoutAccess() throws Exception
+    {
+        String dnPattern = "dsqdsqdq";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to dn=\"" + dnPattern + "\" by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        AclWhatClauseDn whatClauseDn = whatClause.getDnClause();
+        assertNotNull( whatClauseDn );
+        assertEquals( dnPattern, whatClauseDn.getPattern() );
+        assertNull( whatClauseDn.getType() );
+    }
+
+
+    @Test
+    public void testWhatDnRegex() throws Exception
+    {
+        String dnPattern = "dsqdsqdq";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to dn.regex=\"" + dnPattern + "\" by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        AclWhatClauseDn whatClauseDn = whatClause.getDnClause();
+        assertNotNull( whatClauseDn );
+        assertEquals( dnPattern, whatClauseDn.getPattern() );
+        assertEquals( AclWhatClauseDnTypeEnum.REGEX, whatClauseDn.getType() );
+    }
+
+
+    @Test
+    public void testWhatDnRegexWithoutAccess() throws Exception
+    {
+        String dnPattern = "dsqdsqdq";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to dn.regex=\"" + dnPattern + "\" by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        AclWhatClauseDn whatClauseDn = whatClause.getDnClause();
+        assertNotNull( whatClauseDn );
+        assertEquals( dnPattern, whatClauseDn.getPattern() );
+        assertEquals( AclWhatClauseDnTypeEnum.REGEX, whatClauseDn.getType() );
+    }
+
+
+    @Test
+    public void testWhatDnBase() throws Exception
+    {
+        String dnPattern = "dsqdsqdq";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to dn.base=\"" + dnPattern + "\" by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        AclWhatClauseDn whatClauseDn = whatClause.getDnClause();
+        assertNotNull( whatClauseDn );
+        assertEquals( dnPattern, whatClauseDn.getPattern() );
+        assertEquals( AclWhatClauseDnTypeEnum.BASE, whatClauseDn.getType() );
+    }
+
+
+    @Test
+    public void testWhatDnBaseWithoutAccess() throws Exception
+    {
+        String dnPattern = "dsqdsqdq";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to dn.base=\"" + dnPattern + "\" by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        AclWhatClauseDn whatClauseDn = whatClause.getDnClause();
+        assertNotNull( whatClauseDn );
+        assertEquals( dnPattern, whatClauseDn.getPattern() );
+        assertEquals( AclWhatClauseDnTypeEnum.BASE, whatClauseDn.getType() );
+    }
+
+
+    @Test
+    public void testWhatDnExact() throws Exception
+    {
+        String dnPattern = "dsqdsqdq";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to dn.exact=\"" + dnPattern + "\" by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        AclWhatClauseDn whatClauseDn = whatClause.getDnClause();
+        assertNotNull( whatClauseDn );
+        assertEquals( dnPattern, whatClauseDn.getPattern() );
+        assertEquals( AclWhatClauseDnTypeEnum.EXACT, whatClauseDn.getType() );
+    }
+
+
+    @Test
+    public void testWhatDnExactWithoutAccess() throws Exception
+    {
+        String dnPattern = "dsqdsqdq";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to dn.exact=\"" + dnPattern + "\" by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        AclWhatClauseDn whatClauseDn = whatClause.getDnClause();
+        assertNotNull( whatClauseDn );
+        assertEquals( dnPattern, whatClauseDn.getPattern() );
+        assertEquals( AclWhatClauseDnTypeEnum.EXACT, whatClauseDn.getType() );
+    }
+
+
+    @Test
+    public void testWhatDnOne() throws Exception
+    {
+        String dnPattern = "dsqdsqdq";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to dn.one=\"" + dnPattern + "\" by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        AclWhatClauseDn whatClauseDn = whatClause.getDnClause();
+        assertNotNull( whatClauseDn );
+        assertEquals( dnPattern, whatClauseDn.getPattern() );
+        assertEquals( AclWhatClauseDnTypeEnum.ONE, whatClauseDn.getType() );
+    }
+
+
+    @Test
+    public void testWhatDnOneWithoutAccess() throws Exception
+    {
+        String dnPattern = "dsqdsqdq";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to dn.one=\"" + dnPattern + "\" by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        AclWhatClauseDn whatClauseDn = whatClause.getDnClause();
+        assertNotNull( whatClauseDn );
+        assertEquals( dnPattern, whatClauseDn.getPattern() );
+        assertEquals( AclWhatClauseDnTypeEnum.ONE, whatClauseDn.getType() );
+    }
+
+
+    @Test
+    public void testWhatDnSubtree() throws Exception
+    {
+        String dnPattern = "dsqdsqdq";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to dn.subtree=\"" + dnPattern + "\" by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        AclWhatClauseDn whatClauseDn = whatClause.getDnClause();
+        assertNotNull( whatClauseDn );
+        assertEquals( dnPattern, whatClauseDn.getPattern() );
+        assertEquals( AclWhatClauseDnTypeEnum.SUBTREE, whatClauseDn.getType() );
+    }
+
+
+    @Test
+    public void testWhatDnSubtreeWithoutAccess() throws Exception
+    {
+        String dnPattern = "dsqdsqdq";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to dn.subtree=\"" + dnPattern + "\" by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        AclWhatClauseDn whatClauseDn = whatClause.getDnClause();
+        assertNotNull( whatClauseDn );
+        assertEquals( dnPattern, whatClauseDn.getPattern() );
+        assertEquals( AclWhatClauseDnTypeEnum.SUBTREE, whatClauseDn.getType() );
+    }
+
+
+    @Test
+    public void testWhatDnChildren() throws Exception
+    {
+        String dnPattern = "dsqdsqdq";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to dn.children=\"" + dnPattern + "\" by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        AclWhatClauseDn whatClauseDn = whatClause.getDnClause();
+        assertNotNull( whatClauseDn );
+        assertEquals( dnPattern, whatClauseDn.getPattern() );
+        assertEquals( AclWhatClauseDnTypeEnum.CHILDREN, whatClauseDn.getType() );
+    }
+
+
+    @Test
+    public void testWhatDnChildrenWithoutAccess() throws Exception
+    {
+        String dnPattern = "dsqdsqdq";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to dn.children=\"" + dnPattern + "\" by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        AclWhatClauseDn whatClauseDn = whatClause.getDnClause();
+        assertNotNull( whatClauseDn );
+        assertEquals( dnPattern, whatClauseDn.getPattern() );
+        assertEquals( AclWhatClauseDnTypeEnum.CHILDREN, whatClauseDn.getType() );
+    }
+
+
+    @Test
+    public void testWhatTwoDns() throws Exception
+    {
+        try
+        {
+            OpenLdapAclParser parser = new OpenLdapAclParser();
+            parser.parse( "to dn=\"dsdsfsd\" dn=\"dsdsfsd\" by *" );
+
+            fail();
+        }
+        catch ( Exception e )
+        {
+            // Should happen
+        }
+    }
+
+
+    @Test
+    public void testWhatAttributes() throws Exception
+    {
+        String attribute = "userPassword";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to attrs=" + attribute + " by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        AclWhatClauseAttributes whatClauseAttributes = whatClause.getAttributesClause();
+        assertNotNull( whatClauseAttributes );
+        List<String> attributesList = whatClauseAttributes.getAttributes();
+        assertEquals( 1, attributesList.size() );
+        assertTrue( attributesList.contains( attribute ) );
+    }
+
+
+    @Test
+    public void testWhatAttributesWithoutAccess() throws Exception
+    {
+        String attribute = "userPassword";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to attrs=" + attribute + " by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        AclWhatClauseAttributes whatClauseAttributes = whatClause.getAttributesClause();
+        assertNotNull( whatClauseAttributes );
+        List<String> attributesList = whatClauseAttributes.getAttributes();
+        assertEquals( 1, attributesList.size() );
+        assertTrue( attributesList.contains( attribute ) );
+    }
+
+
+    @Test
+    public void testWhatAttributesWithSpaces() throws Exception
+    {
+        String attribute = "userPassword";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "   access    to     attrs=" + attribute + "    by    *    " );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        AclWhatClauseAttributes whatClauseAttributes = whatClause.getAttributesClause();
+        assertNotNull( whatClauseAttributes );
+        List<String> attributesList = whatClauseAttributes.getAttributes();
+        assertEquals( 1, attributesList.size() );
+        assertTrue( attributesList.contains( attribute ) );
+    }
+
+
+    @Test
+    public void testWhatAttributesMultiple() throws Exception
+    {
+        String attribute1 = "userPassword";
+        String attribute2 = "uid";
+        String attribute3 = "cn";
+
+        String attributes = attribute1 + "," + attribute2 + "," + attribute3;
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to attrs=" + attributes + " by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        AclWhatClauseAttributes whatClauseAttributes = whatClause.getAttributesClause();
+        assertNotNull( whatClauseAttributes );
+        List<String> attributesList = whatClauseAttributes.getAttributes();
+        assertEquals( 3, attributesList.size() );
+        assertTrue( attributesList.contains( attribute1 ) );
+        assertTrue( attributesList.contains( attribute2 ) );
+        assertTrue( attributesList.contains( attribute3 ) );
+    }
+
+
+    @Test
+    public void testWhatAttributesMultipleWithoutAccess() throws Exception
+    {
+        String attribute1 = "userPassword";
+        String attribute2 = "uid";
+        String attribute3 = "cn";
+
+        String attributes = attribute1 + "," + attribute2 + "," + attribute3;
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to attrs=" + attributes + " by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        AclWhatClauseAttributes whatClauseAttributes = whatClause.getAttributesClause();
+        assertNotNull( whatClauseAttributes );
+        List<String> attributesList = whatClauseAttributes.getAttributes();
+        assertEquals( 3, attributesList.size() );
+        assertTrue( attributesList.contains( attribute1 ) );
+        assertTrue( attributesList.contains( attribute2 ) );
+        assertTrue( attributesList.contains( attribute3 ) );
+    }
+
+
+    @Test
+    public void testWhatTwoAttributes() throws Exception
+    {
+        try
+        {
+            OpenLdapAclParser parser = new OpenLdapAclParser();
+            parser.parse( "access to attrs=userPassword attrs=userPassword by *" );
+
+            fail();
+        }
+        catch ( Exception e )
+        {
+            // Should happen
+        }
+    }
+
+
+    @Test
+    public void testWhatFilter() throws Exception
+    {
+        String filter = "(objectclass=*)";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to filter=" + filter + " by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        AclWhatClauseFilter whatClauseFilter = whatClause.getFilterClause();
+        assertNotNull( whatClauseFilter );
+        assertEquals( filter, whatClauseFilter.getFilter() );
+    }
+
+
+    @Test
+    public void testWhatFilterWithoutAccess() throws Exception
+    {
+        String filter = "(objectclass=*)";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to filter=" + filter + " by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        AclWhatClauseFilter whatClauseFilter = whatClause.getFilterClause();
+        assertNotNull( whatClauseFilter );
+        assertEquals( filter, whatClauseFilter.getFilter() );
+    }
+
+
+    @Test
+    public void testWhatFilterWithSpaces() throws Exception
+    {
+        String filter = "(objectclass=*)";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "   access    to     filter=" + filter + "    by    *    " );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        AclWhatClauseFilter whatClauseFilter = whatClause.getFilterClause();
+        assertNotNull( whatClauseFilter );
+        assertEquals( filter, whatClauseFilter.getFilter() );
+    }
+
+
+    @Test
+    public void testWhatFilterComplex() throws Exception
+    {
+        String filter = "(&(&(!(cn=jbond))(|(ou=ResearchAndDevelopment)(ou=HumanResources)))(objectclass=Person))";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to filter=" + filter + " by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        AclWhatClauseFilter whatClauseFilter = whatClause.getFilterClause();
+        assertNotNull( whatClauseFilter );
+        assertEquals( filter, whatClauseFilter.getFilter() );
+    }
+
+
+    @Test
+    public void testWhatFilterComplexWithoutAccess() throws Exception
+    {
+        String filter = "(&(&(!(cn=jbond))(|(ou=ResearchAndDevelopment)(ou=HumanResources)))(objectclass=Person))";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to filter=" + filter + " by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        AclWhatClauseFilter whatClauseFilter = whatClause.getFilterClause();
+        assertNotNull( whatClauseFilter );
+        assertEquals( filter, whatClauseFilter.getFilter() );
+    }
+
+
+    @Test
+    public void testWhatTwoFilters() throws Exception
+    {
+        try
+        {
+            OpenLdapAclParser parser = new OpenLdapAclParser();
+            parser.parse( "access to filter=(objectClass=*) filter=(objectClass=*) by *" );
+
+            fail();
+        }
+        catch ( Exception e )
+        {
+            // Should happen
+        }
+    }
+
+
+    @Test
+    public void testWhatDnAndFilter() throws Exception
+    {
+        String dnPattern = "dsqdsqdq";
+        String filter = "(objectclass=*)";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to  dn=\"" + dnPattern + "\" filter=" + filter + " by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        AclWhatClauseDn whatClauseDn = whatClause.getDnClause();
+        assertNotNull( whatClauseDn );
+        assertEquals( dnPattern, whatClauseDn.getPattern() );
+        AclWhatClauseFilter whatClauseFilter = whatClause.getFilterClause();
+        assertNotNull( whatClauseFilter );
+        assertEquals( filter, whatClauseFilter.getFilter() );
+    }
+
+
+    @Test
+    public void testWhatDnAndAttributes() throws Exception
+    {
+        String dnPattern = "dsqdsqdq";
+        String attribute = "userPassword";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to  dn=\"" + dnPattern + "\" attrs=" + attribute + " by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        AclWhatClauseDn whatClauseDn = whatClause.getDnClause();
+        assertNotNull( whatClauseDn );
+        assertEquals( dnPattern, whatClauseDn.getPattern() );
+        AclWhatClauseAttributes whatClauseAttributes = whatClause.getAttributesClause();
+        assertNotNull( whatClauseAttributes );
+        List<String> attributesList = whatClauseAttributes.getAttributes();
+        assertEquals( 1, attributesList.size() );
+        assertTrue( attributesList.contains( attribute ) );
+    }
+
+
+    @Test
+    public void testWhatFilterAndAttributes() throws Exception
+    {
+        String dnPattern = "dsqdsqdq";
+        String filter = "(objectclass=*)";
+        String attribute = "userPassword";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to dn=\"" + dnPattern + "\" filter=" + filter + " attrs=" + attribute
+            + " by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        AclWhatClauseDn whatClauseDn = whatClause.getDnClause();
+        assertNotNull( whatClauseDn );
+        assertEquals( dnPattern, whatClauseDn.getPattern() );
+        AclWhatClauseFilter whatClauseFilter = whatClause.getFilterClause();
+        assertNotNull( whatClauseFilter );
+        assertEquals( filter, whatClauseFilter.getFilter() );
+        AclWhatClauseAttributes whatClauseAttributes = whatClause.getAttributesClause();
+        assertNotNull( whatClauseAttributes );
+        List<String> attributesList = whatClauseAttributes.getAttributes();
+        assertEquals( 1, attributesList.size() );
+        assertTrue( attributesList.contains( attribute ) );
+    }
+
+
+    @Test
+    public void testWhatDnAndFilterAndAttributes() throws Exception
+    {
+        String filter = "(objectclass=*)";
+        String attribute = "userPassword";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to  filter=" + filter + " attrs=" + attribute + " by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'what' clause
+        AclWhatClause whatClause = aclItem.getWhatClause();
+        assertNotNull( whatClause );
+        AclWhatClauseFilter whatClauseFilter = whatClause.getFilterClause();
+        assertNotNull( whatClauseFilter );
+        assertEquals( filter, whatClauseFilter.getFilter() );
+        AclWhatClauseAttributes whatClauseAttributes = whatClause.getAttributesClause();
+        assertNotNull( whatClauseAttributes );
+        List<String> attributesList = whatClauseAttributes.getAttributes();
+        assertEquals( 1, attributesList.size() );
+        assertTrue( attributesList.contains( attribute ) );
+    }
+
+
+    @Test
+    public void testWhoStar() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseStar );
+    }
+
+
+    @Test
+    public void testWhoStarWithoutAccess() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by *" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseStar );
+    }
+
+
+    @Test
+    public void testWhoStarWithSpaces() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "   access    to     *    by    *    " );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseStar );
+    }
+
+
+    @Test
+    public void testWhoAnonymous() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by anonymous" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseAnonymous );
+    }
+
+
+    @Test
+    public void testWhoAnonymousWithoutAccess() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by anonymous" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseAnonymous );
+    }
+
+
+    @Test
+    public void testWhoAnonymousWithSpaces() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "   access    to     *    by    anonymous    " );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseAnonymous );
+    }
+
+
+    @Test
+    public void testWhoUsers() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by users" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseUsers );
+    }
+
+
+    @Test
+    public void testWhoUsersWithoutAccess() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by users" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseUsers );
+    }
+
+
+    @Test
+    public void testWhoUsersWithSpaces() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "   access    to     *    by    users    " );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseUsers );
+    }
+
+
+    @Test
+    public void testWhoSelf() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by self" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseSelf );
+    }
+
+
+    @Test
+    public void testWhoSelfWithoutAccess() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by self" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseSelf );
+    }
+
+
+    @Test
+    public void testWhoSelfWithSpaces() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "   access    to     *    by    self    " );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseSelf );
+    }
+
+
+    @Test
+    public void testWhoDn() throws Exception
+    {
+        String dnPattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by dn=\"" + dnPattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseDn );
+        assertEquals( dnPattern, ( ( AclWhoClauseDn ) whoClause ).getPattern() );
+    }
+
+
+    @Test
+    public void testWhoDnWithoutAccess() throws Exception
+    {
+        String dnPattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by dn=\"" + dnPattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseDn );
+        assertEquals( dnPattern, ( ( AclWhoClauseDn ) whoClause ).getPattern() );
+    }
+
+
+    @Test
+    public void testWhoDnWithSpaces() throws Exception
+    {
+        String dnPattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "   access    to   * by   dn=\"" + dnPattern + "\"   " );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseDn );
+        assertEquals( dnPattern, ( ( AclWhoClauseDn ) whoClause ).getPattern() );
+    }
+
+
+    @Test
+    public void testWhoDnDefaultType() throws Exception
+    {
+        String dnPattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by dn=\"" + dnPattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseDn );
+        AclWhoClauseDn whoClauseDn = ( AclWhoClauseDn ) whoClause;
+        assertEquals( dnPattern, whoClauseDn.getPattern() );
+        assertEquals( AclWhoClauseDnTypeEnum.BASE, whoClauseDn.getType() );
+    }
+
+
+    @Test
+    public void testWhoDnDefaultTypeWithoutAccess() throws Exception
+    {
+        String dnPattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by dn=\"" + dnPattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseDn );
+        AclWhoClauseDn whoClauseDn = ( AclWhoClauseDn ) whoClause;
+        assertEquals( dnPattern, whoClauseDn.getPattern() );
+        assertEquals( AclWhoClauseDnTypeEnum.BASE, whoClauseDn.getType() );
+    }
+
+
+    @Test
+    public void testWhoDnRegex() throws Exception
+    {
+        String dnPattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by dn.regex=\"" + dnPattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseDn );
+        AclWhoClauseDn whoClauseDn = ( AclWhoClauseDn ) whoClause;
+        assertEquals( dnPattern, whoClauseDn.getPattern() );
+        assertEquals( AclWhoClauseDnTypeEnum.REGEX, whoClauseDn.getType() );
+    }
+
+
+    @Test
+    public void testWhoDnRegexWithoutAccess() throws Exception
+    {
+        String dnPattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by dn.regex=\"" + dnPattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseDn );
+        AclWhoClauseDn whoClauseDn = ( AclWhoClauseDn ) whoClause;
+        assertEquals( dnPattern, whoClauseDn.getPattern() );
+        assertEquals( AclWhoClauseDnTypeEnum.REGEX, whoClauseDn.getType() );
+    }
+
+
+    @Test
+    public void testWhoDnBase() throws Exception
+    {
+        String dnPattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by dn.base=\"" + dnPattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseDn );
+        AclWhoClauseDn whoClauseDn = ( AclWhoClauseDn ) whoClause;
+        assertEquals( dnPattern, whoClauseDn.getPattern() );
+        assertEquals( AclWhoClauseDnTypeEnum.BASE, whoClauseDn.getType() );
+    }
+
+
+    @Test
+    public void testWhoDnBaseWithoutAccess() throws Exception
+    {
+        String dnPattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by dn.base=\"" + dnPattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseDn );
+        AclWhoClauseDn whoClauseDn = ( AclWhoClauseDn ) whoClause;
+        assertEquals( dnPattern, whoClauseDn.getPattern() );
+        assertEquals( AclWhoClauseDnTypeEnum.BASE, whoClauseDn.getType() );
+    }
+
+
+    @Test
+    public void testWhoDnExact() throws Exception
+    {
+        String dnPattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by dn.exact=\"" + dnPattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseDn );
+        AclWhoClauseDn whoClauseDn = ( AclWhoClauseDn ) whoClause;
+        assertEquals( dnPattern, whoClauseDn.getPattern() );
+        assertEquals( AclWhoClauseDnTypeEnum.EXACT, whoClauseDn.getType() );
+    }
+
+
+    @Test
+    public void testWhoDnExactWithoutAccess() throws Exception
+    {
+        String dnPattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by dn.exact=\"" + dnPattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseDn );
+        AclWhoClauseDn whoClauseDn = ( AclWhoClauseDn ) whoClause;
+        assertEquals( dnPattern, whoClauseDn.getPattern() );
+        assertEquals( AclWhoClauseDnTypeEnum.EXACT, whoClauseDn.getType() );
+    }
+
+
+    @Test
+    public void testWhoDnOne() throws Exception
+    {
+        String dnPattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by dn.one=\"" + dnPattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseDn );
+        AclWhoClauseDn whoClauseDn = ( AclWhoClauseDn ) whoClause;
+        assertEquals( dnPattern, whoClauseDn.getPattern() );
+        assertEquals( AclWhoClauseDnTypeEnum.ONE, whoClauseDn.getType() );
+    }
+
+
+    @Test
+    public void testWhoDnOneWithoutAccess() throws Exception
+    {
+        String dnPattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by dn.one=\"" + dnPattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseDn );
+        AclWhoClauseDn whoClauseDn = ( AclWhoClauseDn ) whoClause;
+        assertEquals( dnPattern, whoClauseDn.getPattern() );
+        assertEquals( AclWhoClauseDnTypeEnum.ONE, whoClauseDn.getType() );
+    }
+
+
+    @Test
+    public void testWhoDnChildren() throws Exception
+    {
+        String dnPattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by dn.children=\"" + dnPattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseDn );
+        AclWhoClauseDn whoClauseDn = ( AclWhoClauseDn ) whoClause;
+        assertEquals( dnPattern, whoClauseDn.getPattern() );
+        assertEquals( AclWhoClauseDnTypeEnum.CHILDREN, whoClauseDn.getType() );
+    }
+
+
+    @Test
+    public void testWhoDnChildrenWithoutAccess() throws Exception
+    {
+        String dnPattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by dn.children=\"" + dnPattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseDn );
+        AclWhoClauseDn whoClauseDn = ( AclWhoClauseDn ) whoClause;
+        assertEquals( dnPattern, whoClauseDn.getPattern() );
+        assertEquals( AclWhoClauseDnTypeEnum.CHILDREN, whoClauseDn.getType() );
+    }
+
+
+    @Test
+    public void testWhoDnSubtree() throws Exception
+    {
+        String dnPattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by dn.subtree=\"" + dnPattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseDn );
+        AclWhoClauseDn whoClauseDn = ( AclWhoClauseDn ) whoClause;
+        assertEquals( dnPattern, whoClauseDn.getPattern() );
+        assertEquals( AclWhoClauseDnTypeEnum.SUBTREE, whoClauseDn.getType() );
+    }
+
+
+    @Test
+    public void testWhoDnSubtreeWithoutAccess() throws Exception
+    {
+        String dnPattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by dn.subtree=\"" + dnPattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseDn );
+        AclWhoClauseDn whoClauseDn = ( AclWhoClauseDn ) whoClause;
+        assertEquals( dnPattern, whoClauseDn.getPattern() );
+        assertEquals( AclWhoClauseDnTypeEnum.SUBTREE, whoClauseDn.getType() );
+    }
+
+
+    @Test
+    public void testWhoDnLevel() throws Exception
+    {
+        String dnPattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by dn.level{0}=\"" + dnPattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseDn );
+        AclWhoClauseDn whoClauseDn = ( AclWhoClauseDn ) whoClause;
+        assertEquals( dnPattern, whoClauseDn.getPattern() );
+        AclWhoClauseDnTypeEnum whoClauseDnType = whoClauseDn.getType();
+        assertEquals( AclWhoClauseDnTypeEnum.LEVEL, whoClauseDnType );
+        assertEquals( 0, whoClauseDnType.getLevel() );
+    }
+
+
+    @Test
+    public void testWhoDnLevelWithoutAccess() throws Exception
+    {
+        String dnPattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by dn.level{0}=\"" + dnPattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseDn );
+        AclWhoClauseDn whoClauseDn = ( AclWhoClauseDn ) whoClause;
+        assertEquals( dnPattern, whoClauseDn.getPattern() );
+        AclWhoClauseDnTypeEnum whoClauseDnType = whoClauseDn.getType();
+        assertEquals( AclWhoClauseDnTypeEnum.LEVEL, whoClauseDnType );
+        assertEquals( 0, whoClauseDnType.getLevel() );
+    }
+
+
+    @Test
+    public void testWhoDnLevelTwoDigits() throws Exception
+    {
+        String dnPattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by dn.level{12}=\"" + dnPattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseDn );
+        AclWhoClauseDn whoClauseDn = ( AclWhoClauseDn ) whoClause;
+        assertEquals( dnPattern, whoClauseDn.getPattern() );
+        AclWhoClauseDnTypeEnum whoClauseDnType = whoClauseDn.getType();
+        assertEquals( AclWhoClauseDnTypeEnum.LEVEL, whoClauseDnType );
+        assertEquals( 12, whoClauseDnType.getLevel() );
+    }
+
+
+    @Test
+    public void testWhoDnLevelTwoDigitsWithoutAccess() throws Exception
+    {
+        String dnPattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by dn.level{12}=\"" + dnPattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseDn );
+        AclWhoClauseDn whoClauseDn = ( AclWhoClauseDn ) whoClause;
+        assertEquals( dnPattern, whoClauseDn.getPattern() );
+        AclWhoClauseDnTypeEnum whoClauseDnType = whoClauseDn.getType();
+        assertEquals( AclWhoClauseDnTypeEnum.LEVEL, whoClauseDnType );
+        assertEquals( 12, whoClauseDnType.getLevel() );
+    }
+
+
+    @Test
+    public void testWhoDnDefaultModifier() throws Exception
+    {
+        String dnPattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by dn=\"" + dnPattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseDn );
+        AclWhoClauseDn whoClauseDn = ( AclWhoClauseDn ) whoClause;
+        assertEquals( dnPattern, whoClauseDn.getPattern() );
+        assertNull( whoClauseDn.getModifier() );
+    }
+
+
+    @Test
+    public void testWhoDnDefaultModifierWithoutAccess() throws Exception
+    {
+        String dnPattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by dn=\"" + dnPattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseDn );
+        AclWhoClauseDn whoClauseDn = ( AclWhoClauseDn ) whoClause;
+        assertEquals( dnPattern, whoClauseDn.getPattern() );
+        assertNull( whoClauseDn.getModifier() );
+    }
+
+
+    @Test
+    public void testWhoDnExpandModifier() throws Exception
+    {
+        String dnPattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by dn.exact,expand=\"" + dnPattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseDn );
+        AclWhoClauseDn whoClauseDn = ( AclWhoClauseDn ) whoClause;
+        assertEquals( dnPattern, whoClauseDn.getPattern() );
+        assertEquals( AclWhoClauseDnModifierEnum.EXPAND, whoClauseDn.getModifier() );
+    }
+
+
+    @Test
+    public void testWhoDnExpandModifierWithoutAccess() throws Exception
+    {
+        String dnPattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by dn.exact,expand=\"" + dnPattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseDn );
+        AclWhoClauseDn whoClauseDn = ( AclWhoClauseDn ) whoClause;
+        assertEquals( dnPattern, whoClauseDn.getPattern() );
+        assertEquals( AclWhoClauseDnModifierEnum.EXPAND, whoClauseDn.getModifier() );
+    }
+
+
+    @Test
+    public void testWhoDnExpandModifierWrong() throws Exception
+    {
+        try
+        {
+            // Create parser
+            OpenLdapAclParser parser = new OpenLdapAclParser();
+            parser.parse( "access to * by dn,expand=\"dc=example,dc=com\"" );
+
+            fail();
+        }
+        catch ( Exception e )
+        {
+            // Should happen
+        }
+    }
+
+
+    @Test
+    public void testWhoDnAttr() throws Exception
+    {
+        String attribute = "dsqdsqdq";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by dnattr=" + attribute );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseDnAttr );
+        AclWhoClauseDnAttr whoClauseDnAttr = ( AclWhoClauseDnAttr ) whoClause;
+        assertEquals( attribute, whoClauseDnAttr.getAttribute() );
+    }
+
+
+    @Test
+    public void testWhoDnAttrWithoutAccess() throws Exception
+    {
+        String attribute = "dsqdsqdq";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by dnattr=" + attribute );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseDnAttr );
+        AclWhoClauseDnAttr whoClauseDnAttr = ( AclWhoClauseDnAttr ) whoClause;
+        assertEquals( attribute, whoClauseDnAttr.getAttribute() );
+    }
+
+
+    @Test
+    public void testWhoGroupPattern() throws Exception
+    {
+        String pattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by group=\"" + pattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseGroup );
+        AclWhoClauseGroup whoClauseGroup = ( AclWhoClauseGroup ) whoClause;
+        assertNull( whoClauseGroup.getObjectclass() );
+        assertNull( whoClauseGroup.getAttribute() );
+        assertEquals( pattern, whoClauseGroup.getPattern() );
+    }
+
+
+    @Test
+    public void testWhoGroupPatternWithoutAccess() throws Exception
+    {
+        String pattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by group=\"" + pattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseGroup );
+        AclWhoClauseGroup whoClauseGroup = ( AclWhoClauseGroup ) whoClause;
+        assertNull( whoClauseGroup.getObjectclass() );
+        assertNull( whoClauseGroup.getAttribute() );
+        assertEquals( pattern, whoClauseGroup.getPattern() );
+    }
+
+
+    @Test
+    public void testWhoGroupObjectclassPattern() throws Exception
+    {
+        String objectclass = "objectclass";
+        String pattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by group/" + objectclass + "=\"" + pattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseGroup );
+        AclWhoClauseGroup whoClauseGroup = ( AclWhoClauseGroup ) whoClause;
+        assertEquals( objectclass, whoClauseGroup.getObjectclass() );
+        assertNull( whoClauseGroup.getAttribute() );
+        assertEquals( pattern, whoClauseGroup.getPattern() );
+    }
+
+
+    @Test
+    public void testWhoGroupObjectclassPatternWithoutAccess() throws Exception
+    {
+        String objectclass = "objectclass";
+        String pattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by group/" + objectclass + "=\"" + pattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseGroup );
+        AclWhoClauseGroup whoClauseGroup = ( AclWhoClauseGroup ) whoClause;
+        assertEquals( objectclass, whoClauseGroup.getObjectclass() );
+        assertNull( whoClauseGroup.getAttribute() );
+        assertEquals( pattern, whoClauseGroup.getPattern() );
+    }
+
+
+    @Test
+    public void testWhoGroupObjectclassAttrnamePattern() throws Exception
+    {
+        String objectclass = "objectclass";
+        String attrname = "attrname";
+        String pattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by group/" + objectclass + "/" + attrname + "=\""
+            + pattern
+            + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseGroup );
+        AclWhoClauseGroup whoClauseGroup = ( AclWhoClauseGroup ) whoClause;
+        assertEquals( objectclass, whoClauseGroup.getObjectclass() );
+        assertEquals( attrname, whoClauseGroup.getAttribute() );
+        assertEquals( pattern, whoClauseGroup.getPattern() );
+    }
+
+
+    @Test
+    public void testWhoGroupObjectclassAttrnamePatternWithoutAccess() throws Exception
+    {
+        String objectclass = "objectclass";
+        String attrname = "attrname";
+        String pattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by group/" + objectclass + "/" + attrname + "=\"" + pattern
+            + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseGroup );
+        AclWhoClauseGroup whoClauseGroup = ( AclWhoClauseGroup ) whoClause;
+        assertEquals( objectclass, whoClauseGroup.getObjectclass() );
+        assertEquals( attrname, whoClauseGroup.getAttribute() );
+        assertEquals( pattern, whoClauseGroup.getPattern() );
+    }
+
+
+    @Test
+    public void testWhoGroupExpandPattern() throws Exception
+    {
+        String type = "expand";
+        String pattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by group" + "." + type + "=\"" + pattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseGroup );
+        AclWhoClauseGroup whoClauseGroup = ( AclWhoClauseGroup ) whoClause;
+        assertNull( whoClauseGroup.getObjectclass() );
+        assertNull( whoClauseGroup.getAttribute() );
+        assertEquals( pattern, whoClauseGroup.getPattern() );
+        assertEquals( AclWhoClauseGroupTypeEnum.EXPAND, whoClauseGroup.getType() );
+    }
+
+
+    @Test
+    public void testWhoGroupExpandPatternWithoutAccess() throws Exception
+    {
+        String type = "expand";
+        String pattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by group" + "." + type + "=\"" + pattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseGroup );
+        AclWhoClauseGroup whoClauseGroup = ( AclWhoClauseGroup ) whoClause;
+        assertNull( whoClauseGroup.getObjectclass() );
+        assertNull( whoClauseGroup.getAttribute() );
+        assertEquals( pattern, whoClauseGroup.getPattern() );
+        assertEquals( AclWhoClauseGroupTypeEnum.EXPAND, whoClauseGroup.getType() );
+    }
+
+
+    @Test
+    public void testWhoGroupObjectclassExpandPattern() throws Exception
+    {
+        String objectclass = "objectclass";
+        String type = "expand";
+        String pattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by group/" + objectclass + "." + type + "=\"" + pattern
+            + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseGroup );
+        AclWhoClauseGroup whoClauseGroup = ( AclWhoClauseGroup ) whoClause;
+        assertEquals( objectclass, whoClauseGroup.getObjectclass() );
+        assertNull( whoClauseGroup.getAttribute() );
+        assertEquals( pattern, whoClauseGroup.getPattern() );
+        assertEquals( AclWhoClauseGroupTypeEnum.EXPAND, whoClauseGroup.getType() );
+    }
+
+
+    @Test
+    public void testWhoGroupObjectclassExpandPatternWithoutAccess() throws Exception
+    {
+        String objectclass = "objectclass";
+        String type = "expand";
+        String pattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by group/" + objectclass + "." + type + "=\"" + pattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseGroup );
+        AclWhoClauseGroup whoClauseGroup = ( AclWhoClauseGroup ) whoClause;
+        assertEquals( objectclass, whoClauseGroup.getObjectclass() );
+        assertNull( whoClauseGroup.getAttribute() );
+        assertEquals( pattern, whoClauseGroup.getPattern() );
+        assertEquals( AclWhoClauseGroupTypeEnum.EXPAND, whoClauseGroup.getType() );
+    }
+
+
+    @Test
+    public void testWhoGroupObjectclassAttrnameExactPattern() throws Exception
+    {
+        String objectclass = "objectclass";
+        String attrname = "attrname";
+        String type = "exact";
+        String pattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by group/" + objectclass + "/" + attrname + "." + type
+            + "=\""
+            + pattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseGroup );
+        AclWhoClauseGroup whoClauseGroup = ( AclWhoClauseGroup ) whoClause;
+        assertEquals( objectclass, whoClauseGroup.getObjectclass() );
+        assertEquals( attrname, whoClauseGroup.getAttribute() );
+        assertEquals( pattern, whoClauseGroup.getPattern() );
+        assertEquals( AclWhoClauseGroupTypeEnum.EXACT, whoClauseGroup.getType() );
+    }
+
+
+    @Test
+    public void testWhoGroupObjectclassAttrnameExactPatternWithoutAccess() throws Exception
+    {
+        String objectclass = "objectclass";
+        String attrname = "attrname";
+        String type = "exact";
+        String pattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by group/" + objectclass + "/" + attrname + "." + type + "=\""
+            + pattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseGroup );
+        AclWhoClauseGroup whoClauseGroup = ( AclWhoClauseGroup ) whoClause;
+        assertEquals( objectclass, whoClauseGroup.getObjectclass() );
+        assertEquals( attrname, whoClauseGroup.getAttribute() );
+        assertEquals( pattern, whoClauseGroup.getPattern() );
+        assertEquals( AclWhoClauseGroupTypeEnum.EXACT, whoClauseGroup.getType() );
+    }
+
+
+    @Test
+    public void testWhoGroupObjectclassAttrnameExpandPattern() throws Exception
+    {
+        String objectclass = "objectclass";
+        String attrname = "attrname";
+        String type = "expand";
+        String pattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by group/" + objectclass + "/" + attrname + "." + type
+            + "=\""
+            + pattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseGroup );
+        AclWhoClauseGroup whoClauseGroup = ( AclWhoClauseGroup ) whoClause;
+        assertEquals( objectclass, whoClauseGroup.getObjectclass() );
+        assertEquals( attrname, whoClauseGroup.getAttribute() );
+        assertEquals( pattern, whoClauseGroup.getPattern() );
+        assertEquals( AclWhoClauseGroupTypeEnum.EXPAND, whoClauseGroup.getType() );
+    }
+
+
+    @Test
+    public void testWhoGroupObjectclassAttrnameExpandPatternWithoutAccess() throws Exception
+    {
+        String objectclass = "objectclass";
+        String attrname = "attrname";
+        String type = "expand";
+        String pattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by group/" + objectclass + "/" + attrname + "." + type + "=\""
+            + pattern + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseGroup );
+        AclWhoClauseGroup whoClauseGroup = ( AclWhoClauseGroup ) whoClause;
+        assertEquals( objectclass, whoClauseGroup.getObjectclass() );
+        assertEquals( attrname, whoClauseGroup.getAttribute() );
+        assertEquals( pattern, whoClauseGroup.getPattern() );
+        assertEquals( AclWhoClauseGroupTypeEnum.EXPAND, whoClauseGroup.getType() );
+    }
+
+
+    @Test
+    public void testWhoGroupObjectclassAttrnameNoTypePattern() throws Exception
+    {
+        String objectclass = "objectclass";
+        String attrname = "attrname";
+        String pattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by group/" + objectclass + "/" + attrname + "=\""
+            + pattern
+            + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseGroup );
+        AclWhoClauseGroup whoClauseGroup = ( AclWhoClauseGroup ) whoClause;
+        assertEquals( objectclass, whoClauseGroup.getObjectclass() );
+        assertEquals( attrname, whoClauseGroup.getAttribute() );
+        assertEquals( pattern, whoClauseGroup.getPattern() );
+        assertNull( whoClauseGroup.getType() );
+    }
+
+
+    @Test
+    public void testWhoGroupObjectclassAttrnameNoTypePatternWithoutAccess() throws Exception
+    {
+        String objectclass = "objectclass";
+        String attrname = "attrname";
+        String pattern = "dc=example,dc=com";
+
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by group/" + objectclass + "/" + attrname + "=\"" + pattern
+            + "\"" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseGroup );
+        AclWhoClauseGroup whoClauseGroup = ( AclWhoClauseGroup ) whoClause;
+        assertEquals( objectclass, whoClauseGroup.getObjectclass() );
+        assertEquals( attrname, whoClauseGroup.getAttribute() );
+        assertEquals( pattern, whoClauseGroup.getPattern() );
+        assertNull( whoClauseGroup.getType() );
+    }
+
+
+    @Test
+    public void testWhoAccessLevelManage() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by * manage" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseStar );
+
+        // Testing the access level
+        AclAccessLevel accessLevel = whoClause.getAccessLevel();
+        assertNotNull( accessLevel );
+        assertFalse( accessLevel.isSelf() );
+        AclAccessLevelLevelEnum level = accessLevel.getLevel();
+        assertNotNull( level );
+        assertEquals( AclAccessLevelLevelEnum.MANAGE, level );
+    }
+
+
+    @Test
+    public void testWhoAccessLevelManageWithoutAccess() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by * manage" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseStar );
+
+        // Testing the access level
+        AclAccessLevel accessLevel = whoClause.getAccessLevel();
+        assertNotNull( accessLevel );
+        assertFalse( accessLevel.isSelf() );
+        AclAccessLevelLevelEnum level = accessLevel.getLevel();
+        assertNotNull( level );
+        assertEquals( AclAccessLevelLevelEnum.MANAGE, level );
+    }
+
+
+    @Test
+    public void testWhoAccessLevelWrite() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by * write" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseStar );
+
+        // Testing the access level
+        AclAccessLevel accessLevel = whoClause.getAccessLevel();
+        assertNotNull( accessLevel );
+        assertFalse( accessLevel.isSelf() );
+        AclAccessLevelLevelEnum level = accessLevel.getLevel();
+        assertNotNull( level );
+        assertEquals( AclAccessLevelLevelEnum.WRITE, level );
+    }
+
+
+    @Test
+    public void testWhoAccessLevelWriteWithoutAccess() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by * write" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseStar );
+
+        // Testing the access level
+        AclAccessLevel accessLevel = whoClause.getAccessLevel();
+        assertNotNull( accessLevel );
+        assertFalse( accessLevel.isSelf() );
+        AclAccessLevelLevelEnum level = accessLevel.getLevel();
+        assertNotNull( level );
+        assertEquals( AclAccessLevelLevelEnum.WRITE, level );
+    }
+
+
+    @Test
+    public void testWhoAccessLevelRead() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by * read" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseStar );
+
+        // Testing the access level
+        AclAccessLevel accessLevel = whoClause.getAccessLevel();
+        assertNotNull( accessLevel );
+        assertFalse( accessLevel.isSelf() );
+        AclAccessLevelLevelEnum level = accessLevel.getLevel();
+        assertNotNull( level );
+        assertEquals( AclAccessLevelLevelEnum.READ, level );
+    }
+
+
+    @Test
+    public void testWhoAccessLevelReadWithoutAccess() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by * read" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseStar );
+
+        // Testing the access level
+        AclAccessLevel accessLevel = whoClause.getAccessLevel();
+        assertNotNull( accessLevel );
+        assertFalse( accessLevel.isSelf() );
+        AclAccessLevelLevelEnum level = accessLevel.getLevel();
+        assertNotNull( level );
+        assertEquals( AclAccessLevelLevelEnum.READ, level );
+    }
+
+
+    @Test
+    public void testWhoAccessLevelSearch() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by * search" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseStar );
+
+        // Testing the access level
+        AclAccessLevel accessLevel = whoClause.getAccessLevel();
+        assertNotNull( accessLevel );
+        assertFalse( accessLevel.isSelf() );
+        AclAccessLevelLevelEnum level = accessLevel.getLevel();
+        assertNotNull( level );
+        assertEquals( AclAccessLevelLevelEnum.SEARCH, level );
+    }
+
+
+    @Test
+    public void testWhoAccessLevelSearchWithoutAccess() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by * search" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseStar );
+
+        // Testing the access level
+        AclAccessLevel accessLevel = whoClause.getAccessLevel();
+        assertNotNull( accessLevel );
+        assertFalse( accessLevel.isSelf() );
+        AclAccessLevelLevelEnum level = accessLevel.getLevel();
+        assertNotNull( level );
+        assertEquals( AclAccessLevelLevelEnum.SEARCH, level );
+    }
+
+
+    @Test
+    public void testWhoAccessLevelCompare() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by * compare" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseStar );
+
+        // Testing the access level
+        AclAccessLevel accessLevel = whoClause.getAccessLevel();
+        assertNotNull( accessLevel );
+        assertFalse( accessLevel.isSelf() );
+        AclAccessLevelLevelEnum level = accessLevel.getLevel();
+        assertNotNull( level );
+        assertEquals( AclAccessLevelLevelEnum.COMPARE, level );
+    }
+
+
+    @Test
+    public void testWhoAccessLevelCompareWithoutAccess() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by * compare" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseStar );
+
+        // Testing the access level
+        AclAccessLevel accessLevel = whoClause.getAccessLevel();
+        assertNotNull( accessLevel );
+        assertFalse( accessLevel.isSelf() );
+        AclAccessLevelLevelEnum level = accessLevel.getLevel();
+        assertNotNull( level );
+        assertEquals( AclAccessLevelLevelEnum.COMPARE, level );
+    }
+
+
+    @Test
+    public void testWhoAccessLevelAuth() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by * auth" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseStar );
+
+        // Testing the access level
+        AclAccessLevel accessLevel = whoClause.getAccessLevel();
+        assertNotNull( accessLevel );
+        assertFalse( accessLevel.isSelf() );
+        AclAccessLevelLevelEnum level = accessLevel.getLevel();
+        assertNotNull( level );
+        assertEquals( AclAccessLevelLevelEnum.AUTH, level );
+    }
+
+
+    @Test
+    public void testWhoAccessLevelAuthWithoutAccess() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by * auth" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseStar );
+
+        // Testing the access level
+        AclAccessLevel accessLevel = whoClause.getAccessLevel();
+        assertNotNull( accessLevel );
+        assertFalse( accessLevel.isSelf() );
+        AclAccessLevelLevelEnum level = accessLevel.getLevel();
+        assertNotNull( level );
+        assertEquals( AclAccessLevelLevelEnum.AUTH, level );
+    }
+
+
+    @Test
+    public void testWhoAccessLevelDisclose() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by * disclose" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseStar );
+
+        // Testing the access level
+        AclAccessLevel accessLevel = whoClause.getAccessLevel();
+        assertNotNull( accessLevel );
+        assertFalse( accessLevel.isSelf() );
+        AclAccessLevelLevelEnum level = accessLevel.getLevel();
+        assertNotNull( level );
+        assertEquals( AclAccessLevelLevelEnum.DISCLOSE, level );
+    }
+
+
+    @Test
+    public void testWhoAccessLevelDiscloseWithoutAccess() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by * disclose" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseStar );
+
+        // Testing the access level
+        AclAccessLevel accessLevel = whoClause.getAccessLevel();
+        assertNotNull( accessLevel );
+        assertFalse( accessLevel.isSelf() );
+        AclAccessLevelLevelEnum level = accessLevel.getLevel();
+        assertNotNull( level );
+        assertEquals( AclAccessLevelLevelEnum.DISCLOSE, level );
+    }
+
+
+    @Test
+    public void testWhoAccessLevelNone() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by * none" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseStar );
+
+        // Testing the access level
+        AclAccessLevel accessLevel = whoClause.getAccessLevel();
+        assertNotNull( accessLevel );
+        assertFalse( accessLevel.isSelf() );
+        AclAccessLevelLevelEnum level = accessLevel.getLevel();
+        assertNotNull( level );
+        assertEquals( AclAccessLevelLevelEnum.NONE, level );
+    }
+
+
+    @Test
+    public void testWhoAccessLevelNoneWithoutAccess() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by * none" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseStar );
+
+        // Testing the access level
+        AclAccessLevel accessLevel = whoClause.getAccessLevel();
+        assertNotNull( accessLevel );
+        assertFalse( accessLevel.isSelf() );
+        AclAccessLevelLevelEnum level = accessLevel.getLevel();
+        assertNotNull( level );
+        assertEquals( AclAccessLevelLevelEnum.NONE, level );
+    }
+
+
+    @Test
+    public void testWhoAccessLevelSelfManage() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "access to * by * self manage" );
+        assertNotNull( aclItem );
+
+        // Testing the 'who' clause
+        AclWhoClause whoClause = aclItem.getWhoClauses().get( 0 );
+        assertNotNull( whoClause );
+        assertTrue( whoClause instanceof AclWhoClauseStar );
+
+        // Testing the access level
+        AclAccessLevel accessLevel = whoClause.getAccessLevel();
+        assertNotNull( accessLevel );
+        assertTrue( accessLevel.isSelf() );
+        AclAccessLevelLevelEnum level = accessLevel.getLevel();
+        assertNotNull( level );
+        assertEquals( AclAccessLevelLevelEnum.MANAGE, level );
+    }
+
+
+    @Test
+    public void testWhoAccessLevelSelfManageWithoutAccess() throws Exception
+    {
+        // Create parser
+        OpenLdapAclParser parser = new OpenLdapAclParser();
+
+        // Testing the ACL item
+        AclItem aclItem = parser.parse( "to * by * self manage" );
+        assertNotNull( aclItem );
+

[... 1910 lines stripped ...]