Search in sources :

Example 41 with ObjectClass

use of org.apache.directory.api.ldap.model.schema.ObjectClass in project directory-ldap-api by apache.

the class ObjectClassDescriptionSchemaParserTest method testMicrosoftAds2003Msieee.

@Test
public void testMicrosoftAds2003Msieee() throws ParseException, NamingException {
    String value = "( 1.2.840.113556.1.5.240 NAME 'msieee80211-Policy' SUP top STRUCTURAL MAY (msieee80211-Data $ msieee80211-DataType $ msieee80211-ID ) )";
    ObjectClass objectClass = parser.parseObjectClassDescription(value);
    assertEquals("1.2.840.113556.1.5.240", objectClass.getOid());
    assertEquals(1, objectClass.getNames().size());
    assertEquals("msieee80211-Policy", objectClass.getNames().get(0));
    assertNull(objectClass.getDescription());
    assertEquals(1, objectClass.getSuperiorOids().size());
    assertEquals("top", objectClass.getSuperiorOids().get(0));
    assertEquals(ObjectClassTypeEnum.STRUCTURAL, objectClass.getType());
    assertEquals(0, objectClass.getMustAttributeTypeOids().size());
    assertEquals(3, objectClass.getMayAttributeTypeOids().size());
    assertEquals("msieee80211-Data", objectClass.getMayAttributeTypeOids().get(0));
    assertEquals("msieee80211-DataType", objectClass.getMayAttributeTypeOids().get(1));
    assertEquals("msieee80211-ID", objectClass.getMayAttributeTypeOids().get(2));
    assertEquals(0, objectClass.getExtensions().size());
}
Also used : ObjectClass(org.apache.directory.api.ldap.model.schema.ObjectClass) Test(org.junit.Test)

Example 42 with ObjectClass

use of org.apache.directory.api.ldap.model.schema.ObjectClass in project directory-ldap-api by apache.

the class ObjectClassDescriptionSchemaParserTest method testRfcPerson.

@Test
public void testRfcPerson() throws ParseException, NamingException {
    String value = "( 2.5.6.6 NAME 'person' DESC 'RFC2256: a person' SUP top STRUCTURAL MUST ( sn $ cn ) MAY ( userPassword $ telephoneNumber $ seeAlso $ description ) )";
    ObjectClass objectClass = parser.parseObjectClassDescription(value);
    assertEquals("2.5.6.6", objectClass.getOid());
    assertEquals(1, objectClass.getNames().size());
    assertEquals("person", objectClass.getNames().get(0));
    assertEquals("RFC2256: a person", objectClass.getDescription());
    assertEquals(1, objectClass.getSuperiorOids().size());
    assertEquals("top", objectClass.getSuperiorOids().get(0));
    assertEquals(ObjectClassTypeEnum.STRUCTURAL, objectClass.getType());
    assertEquals(2, objectClass.getMustAttributeTypeOids().size());
    assertEquals("sn", objectClass.getMustAttributeTypeOids().get(0));
    assertEquals("cn", objectClass.getMustAttributeTypeOids().get(1));
    assertEquals(4, objectClass.getMayAttributeTypeOids().size());
    assertEquals("userPassword", objectClass.getMayAttributeTypeOids().get(0));
    assertEquals("telephoneNumber", objectClass.getMayAttributeTypeOids().get(1));
    assertEquals("seeAlso", objectClass.getMayAttributeTypeOids().get(2));
    assertEquals("description", objectClass.getMayAttributeTypeOids().get(3));
    assertEquals(0, objectClass.getExtensions().size());
}
Also used : ObjectClass(org.apache.directory.api.ldap.model.schema.ObjectClass) Test(org.junit.Test)

Example 43 with ObjectClass

use of org.apache.directory.api.ldap.model.schema.ObjectClass in project directory-ldap-api by apache.

the class ObjectClassDescriptionSchemaParserTest method testIgnoreElementOrder.

/**
 * Ensure that element order is ignored
 *
 * @throws ParseException
 */
@Test
public void testIgnoreElementOrder() throws ParseException, NamingException {
    String value = "( 2.5.6.6 STRUCTURAL MAY ( userPassword $ telephoneNumber $ seeAlso $ description ) SUP top DESC 'RFC2256: a person' MUST ( sn $ cn ) NAME 'person' )";
    ObjectClass objectClass = parser.parseObjectClassDescription(value);
    assertEquals("2.5.6.6", objectClass.getOid());
    assertEquals(1, objectClass.getNames().size());
    assertEquals("person", objectClass.getNames().get(0));
    assertEquals("RFC2256: a person", objectClass.getDescription());
    assertEquals(1, objectClass.getSuperiorOids().size());
    assertEquals("top", objectClass.getSuperiorOids().get(0));
    assertEquals(ObjectClassTypeEnum.STRUCTURAL, objectClass.getType());
    assertEquals(2, objectClass.getMustAttributeTypeOids().size());
    assertEquals("sn", objectClass.getMustAttributeTypeOids().get(0));
    assertEquals("cn", objectClass.getMustAttributeTypeOids().get(1));
    assertEquals(4, objectClass.getMayAttributeTypeOids().size());
    assertEquals("userPassword", objectClass.getMayAttributeTypeOids().get(0));
    assertEquals("telephoneNumber", objectClass.getMayAttributeTypeOids().get(1));
    assertEquals("seeAlso", objectClass.getMayAttributeTypeOids().get(2));
    assertEquals("description", objectClass.getMayAttributeTypeOids().get(3));
    assertEquals(0, objectClass.getExtensions().size());
}
Also used : ObjectClass(org.apache.directory.api.ldap.model.schema.ObjectClass) Test(org.junit.Test)

Example 44 with ObjectClass

use of org.apache.directory.api.ldap.model.schema.ObjectClass in project directory-ldap-api by apache.

the class OpenLdapSchemaParserTest method testObjectClassMultipleNames.

@Test
public void testObjectClassMultipleNames() throws Exception {
    String objectClassData = "objectclass ( 0.9.2342.19200300.100.4.4\n" + "\tNAME ( 'pilotPerson' 'newPilotPerson' )\n" + "\tSUP person STRUCTURAL\n" + "\tMAY ( userid $ textEncodedORAddress $ rfc822Mailbox $\n" + "\t\tfavouriteDrink $ roomNumber $ userClass $\n" + "\t\thomeTelephoneNumber $ homePostalAddress $ secretary $\n" + "\t\tpersonalTitle $ preferredDeliveryMethod $ businessCategory $\n" + "\t\tjanetMailbox $ otherMailbox $ mobileTelephoneNumber $\n" + "\t\tpagerTelephoneNumber $ organizationalStatus $\n" + "\t\tmailPreferenceOption $ personalSignature )\n" + "\t)";
    parser.parse(objectClassData);
    List<ObjectClass> objectClassesList = parser.getObjectClassTypes();
    Map<String, ObjectClass> objectClasses = mapObjectClasses(objectClassesList);
    ObjectClass objectClass = objectClasses.get("0.9.2342.19200300.100.4.4");
    assertNotNull(objectClass);
    assertEquals("0.9.2342.19200300.100.4.4", objectClass.getOid());
    assertEquals("pilotPerson", objectClass.getName());
    assertEquals("newPilotPerson", objectClass.getNames().get(1));
    assertEquals(ObjectClassTypeEnum.STRUCTURAL, objectClass.getType());
    assertEquals("person", objectClass.getSuperiorOids().get(0));
    assertEquals("userid", objectClass.getMayAttributeTypeOids().get(0));
    assertEquals("textEncodedORAddress", objectClass.getMayAttributeTypeOids().get(1));
    assertEquals("rfc822Mailbox", objectClass.getMayAttributeTypeOids().get(2));
    assertEquals("favouriteDrink", objectClass.getMayAttributeTypeOids().get(3));
    assertEquals("roomNumber", objectClass.getMayAttributeTypeOids().get(4));
    assertEquals("userClass", objectClass.getMayAttributeTypeOids().get(5));
    assertEquals("homeTelephoneNumber", objectClass.getMayAttributeTypeOids().get(6));
    assertEquals("homePostalAddress", objectClass.getMayAttributeTypeOids().get(7));
    assertEquals("secretary", objectClass.getMayAttributeTypeOids().get(8));
    assertEquals("personalTitle", objectClass.getMayAttributeTypeOids().get(9));
    assertEquals("preferredDeliveryMethod", objectClass.getMayAttributeTypeOids().get(10));
    assertEquals("businessCategory", objectClass.getMayAttributeTypeOids().get(11));
    assertEquals("janetMailbox", objectClass.getMayAttributeTypeOids().get(12));
    assertEquals("otherMailbox", objectClass.getMayAttributeTypeOids().get(13));
    assertEquals("mobileTelephoneNumber", objectClass.getMayAttributeTypeOids().get(14));
    assertEquals("pagerTelephoneNumber", objectClass.getMayAttributeTypeOids().get(15));
    assertEquals("organizationalStatus", objectClass.getMayAttributeTypeOids().get(16));
    assertEquals("mailPreferenceOption", objectClass.getMayAttributeTypeOids().get(17));
    assertEquals("personalSignature", objectClass.getMayAttributeTypeOids().get(18));
}
Also used : ObjectClass(org.apache.directory.api.ldap.model.schema.ObjectClass) Test(org.junit.Test)

Example 45 with ObjectClass

use of org.apache.directory.api.ldap.model.schema.ObjectClass in project directory-ldap-api by apache.

the class OpenLdapSchemaParserTest method testParseOpenLdapCoreSchema.

@Test
public void testParseOpenLdapCoreSchema() throws Exception {
    InputStream input = getClass().getResourceAsStream("core.schema");
    parser.parse(input);
    List<MutableAttributeType> attributeTypes = parser.getAttributeTypes();
    List<ObjectClass> objectClassTypes = parser.getObjectClassTypes();
    Map<String, OpenLdapObjectIdentifierMacro> objectIdentifierMacros = parser.getObjectIdentifierMacros();
    assertEquals(52, attributeTypes.size());
    assertEquals(27, objectClassTypes.size());
    assertEquals(0, objectIdentifierMacros.size());
}
Also used : ObjectClass(org.apache.directory.api.ldap.model.schema.ObjectClass) OpenLdapObjectIdentifierMacro(org.apache.directory.api.ldap.model.schema.syntaxCheckers.OpenLdapObjectIdentifierMacro) InputStream(java.io.InputStream) MutableAttributeType(org.apache.directory.api.ldap.model.schema.MutableAttributeType) Test(org.junit.Test)

Aggregations

ObjectClass (org.apache.directory.api.ldap.model.schema.ObjectClass)53 Test (org.junit.Test)34 SchemaManager (org.apache.directory.api.ldap.model.schema.SchemaManager)11 DefaultSchemaManager (org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager)11 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)10 AttributeType (org.apache.directory.api.ldap.model.schema.AttributeType)10 MutableAttributeType (org.apache.directory.api.ldap.model.schema.MutableAttributeType)9 MutableObjectClass (org.apache.directory.api.ldap.model.schema.MutableObjectClass)6 ParseException (java.text.ParseException)5 HashSet (java.util.HashSet)5 LdapSchemaException (org.apache.directory.api.ldap.model.exception.LdapSchemaException)5 SchemaObject (org.apache.directory.api.ldap.model.schema.SchemaObject)5 OpenLdapObjectIdentifierMacro (org.apache.directory.api.ldap.model.schema.syntaxCheckers.OpenLdapObjectIdentifierMacro)5 InputStream (java.io.InputStream)4 LdapNoSuchAttributeException (org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException)4 LdapSyntax (org.apache.directory.api.ldap.model.schema.LdapSyntax)3 MatchingRule (org.apache.directory.api.ldap.model.schema.MatchingRule)3 MutableMatchingRule (org.apache.directory.api.ldap.model.schema.MutableMatchingRule)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2