Java Code Examples for org.apache.directory.api.ldap.model.schema.AttributeType#setSyntaxOid()

The following examples show how to use org.apache.directory.api.ldap.model.schema.AttributeType#setSyntaxOid() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Try to inject an AttributeType which is Collective, and userApplication AT
 */
@Test
public void testAddAttributeTypeNoSupCollectiveUser() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    AttributeType attributeType = new AttributeType( "1.1.0" );
    attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setOrderingOid( null );
    attributeType.setSubstringOid( null );
    attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
    attributeType.setUsage( UsageEnum.USER_APPLICATIONS );
    attributeType.setCollective( true );

    // It should not fail
    assertTrue( schemaManager.add( attributeType ) );

    assertTrue( isATPresent( schemaManager, "1.1.0" ) );
    assertEquals( atrSize + 1, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize + 1, schemaManager.getGlobalOidRegistry().size() );
}
 
Example 2
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Try to inject an AttributeType which is a NO-USER-MODIFICATION and is operational
 */
@Test
public void testAddAttributeTypeNoSupNoUserModificationOpAttr() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    AttributeType attributeType = new AttributeType( "1.1.0" );
    attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setOrderingOid( null );
    attributeType.setSubstringOid( null );
    attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
    attributeType.setUsage( UsageEnum.DISTRIBUTED_OPERATION );
    attributeType.setUserModifiable( false );

    // It should not fail
    assertTrue( schemaManager.add( attributeType ) );

    assertTrue( isATPresent( schemaManager, "1.1.0" ) );
    assertEquals( atrSize + 1, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize + 1, schemaManager.getGlobalOidRegistry().size() );
}
 
Example 3
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Try to inject an AttributeType without EQUALITY MR
 */
@Test
public void testAddAttributeTypeNoEqualityMR() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    AttributeType attributeType = new AttributeType( "1.1.0" );
    attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.8 " );
    attributeType.setUsage( UsageEnum.USER_APPLICATIONS );

    // It should be OK
    assertTrue( schemaManager.add( attributeType ) );

    List<Throwable> errors = schemaManager.getErrors();
    assertEquals( 0, errors.size() );

    assertTrue( isATPresent( schemaManager, "1.1.0" ) );
    assertEquals( atrSize + 1, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize + 1, schemaManager.getGlobalOidRegistry().size() );
}
 
Example 4
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Try to inject an AttributeType with valid MRs
 */
@Test
public void testAddAttributeTypeNoSupValidMR() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    AttributeType attributeType = new AttributeType( "1.1.0" );
    attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setOrderingOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setSubstringOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
    attributeType.setUsage( UsageEnum.USER_APPLICATIONS );

    // It should not fail
    assertTrue( schemaManager.add( attributeType ) );

    assertTrue( isATPresent( schemaManager, "1.1.0" ) );
    assertEquals( atrSize + 1, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize + 1, schemaManager.getGlobalOidRegistry().size() );
}
 
Example 5
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Try to inject an AttributeType which is Collective, but an operational AT
 */
@Test
public void testAddAttributeTypeNoSupCollectiveOperational() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    AttributeType attributeType = new AttributeType( "1.1.0" );
    attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setOrderingOid( null );
    attributeType.setSubstringOid( null );
    attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
    attributeType.setUsage( UsageEnum.DIRECTORY_OPERATION );
    attributeType.setCollective( true );

    // It should fail
    assertFalse( schemaManager.add( attributeType ) );

    List<Throwable> errors = schemaManager.getErrors();
    assertEquals( 1, errors.size() );
    Throwable error = errors.get( 0 );

    assertTrue( error instanceof LdapSchemaException );

    assertFalse( isATPresent( schemaManager, "1.1.0" ) );
    assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() );
}
 
Example 6
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Try to inject a single valued AttributeType which is Collective
 */
@Test
public void testAddAttributeTypeCollectiveOperationalSigleValue() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    AttributeType attributeType = new AttributeType( "1.1.0" );
    attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setOrderingOid( null );
    attributeType.setSubstringOid( null );
    attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
    attributeType.setUsage( UsageEnum.USER_APPLICATIONS );
    attributeType.setCollective( true );
    attributeType.setSingleValued( true );

    // It should fail
    assertFalse( schemaManager.add( attributeType ) );

    List<Throwable> errors = schemaManager.getErrors();
    assertEquals( 1, errors.size() );
    Throwable error = errors.get( 0 );

    assertTrue( error instanceof LdapSchemaException );

    assertFalse( isATPresent( schemaManager, "1.1.0" ) );
    assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() );
}
 
Example 7
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Try to inject an AttributeType which is a NO-USER-MODIFICATION and userApplication
 */
@Test
public void testAddAttributeTypeNoSupNoUserModificationUserAplication() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    AttributeType attributeType = new AttributeType( "1.1.0" );
    attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setOrderingOid( null );
    attributeType.setSubstringOid( null );
    attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
    attributeType.setUsage( UsageEnum.USER_APPLICATIONS );
    attributeType.setUserModifiable( false );

    // It should fail
    assertFalse( schemaManager.add( attributeType ) );

    List<Throwable> errors = schemaManager.getErrors();
    assertEquals( 1, errors.size() );
    Throwable error = errors.get( 0 );

    assertTrue( error instanceof LdapSchemaException );

    assertFalse( isATPresent( schemaManager, "1.1.0" ) );
    assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() );
}
 
Example 8
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Try to inject an AttributeType with an invalid EQUALITY MR
 */
@Test
public void testAddAttributeTypeNoSupInvalidEqualityMR() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    AttributeType attributeType = new AttributeType( "1.1.0" );
    attributeType.setEqualityOid( "0.0" );
    attributeType.setOrderingOid( null );
    attributeType.setSubstringOid( null );
    attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
    attributeType.setUsage( UsageEnum.USER_APPLICATIONS );

    // It should fail
    assertFalse( schemaManager.add( attributeType ) );

    List<Throwable> errors = schemaManager.getErrors();
    assertEquals( 1, errors.size() );
    Throwable error = errors.get( 0 );

    assertTrue( error instanceof LdapSchemaException );

    assertFalse( isATPresent( schemaManager, "1.1.0" ) );
    assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() );
}
 
Example 9
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Try to inject an AttributeType with an invalid ORDERING MR
 */
@Test
public void testAddAttributeTypeNoSupInvalidOrderingMR() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    AttributeType attributeType = new AttributeType( "1.1.0" );
    attributeType.setEqualityOid( null );
    attributeType.setOrderingOid( "0.0" );
    attributeType.setSubstringOid( null );
    attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
    attributeType.setUsage( UsageEnum.USER_APPLICATIONS );

    // It should fail
    assertFalse( schemaManager.add( attributeType ) );

    List<Throwable> errors = schemaManager.getErrors();
    assertEquals( 1, errors.size() );
    Throwable error = errors.get( 0 );

    assertTrue( error instanceof LdapSchemaException );

    assertFalse( isATPresent( schemaManager, "1.1.0" ) );
    assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() );
}
 
Example 10
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Try to inject an AttributeType with an invalid SUBSTR MR
 */
@Test
public void testAddAttributeTypeNoSupInvalidSubstringMR() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    AttributeType attributeType = new AttributeType( "1.1.0" );
    attributeType.setEqualityOid( null );
    attributeType.setOrderingOid( null );
    attributeType.setSubstringOid( "0.0" );
    attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
    attributeType.setUsage( UsageEnum.USER_APPLICATIONS );

    // It should fail
    assertFalse( schemaManager.add( attributeType ) );

    List<Throwable> errors = schemaManager.getErrors();
    assertEquals( 1, errors.size() );
    Throwable error = errors.get( 0 );

    assertTrue( error instanceof LdapSchemaException );

    assertFalse( isATPresent( schemaManager, "1.1.0" ) );
    assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() );
}
 
Example 11
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Try to inject an AttributeType with an already attributed name
 */
@Test
public void testAddAttributeTypeNameAlreadyExist() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    AttributeType attributeType = new AttributeType( "1.1.1.0" );
    attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setOrderingOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setSubstringOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
    attributeType.setNames( "Test", "cn" );

    // It should fail
    assertFalse( schemaManager.add( attributeType ) );

    List<Throwable> errors = schemaManager.getErrors();
    assertEquals( 1, errors.size() );
    Throwable error = errors.get( 0 );

    assertTrue( error instanceof LdapSchemaException );

    // The AT must not be there
    assertFalse( isATPresent( schemaManager, "1.1.1.0" ) );

    assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() );
}
 
Example 12
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Try to inject an AttributeType with an ObjectClass name
 */
@Test
public void testAddAttributeTypeNameOfAnObjectClass() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    AttributeType attributeType = new AttributeType( "1.1.1.0" );
    attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setOrderingOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setSubstringOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
    attributeType.setNames( "Test", "referral" );

    // It should be ok
    assertTrue( schemaManager.add( attributeType ) );

    List<Throwable> errors = schemaManager.getErrors();
    assertEquals( 0, errors.size() );

    // The AT must be present
    assertTrue( isATPresent( schemaManager, "1.1.1.0" ) );

    assertEquals( atrSize + 1, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize + 1, schemaManager.getGlobalOidRegistry().size() );

    AttributeType added = schemaManager.lookupAttributeTypeRegistry( "referral" );
    assertNotNull( added );
    assertEquals( "1.1.1.0", added.getOid() );
    assertTrue( added.getNames().contains( "referral" ) );
}
 
Example 13
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 4 votes vote down vote up
/**
 * Try to inject an AttributeType which is a subtype of a Collective AT
 */
@Test
public void testAddAttributeTypeSupCollectiveUser() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    // Create the collective attribute first
    AttributeType attributeType = new AttributeType( "1.1.0" );
    attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    attributeType.setOrderingOid( null );
    attributeType.setSubstringOid( null );
    attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
    attributeType.setUsage( UsageEnum.USER_APPLICATIONS );
    attributeType.setCollective( true );

    // It should not fail
    assertTrue( schemaManager.add( attributeType ) );

    assertTrue( isATPresent( schemaManager, "1.1.0" ) );
    assertEquals( atrSize + 1, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize + 1, schemaManager.getGlobalOidRegistry().size() );

    // Now try to create an AT which is a subtype of teh create collective attribute
    AttributeType subType = new AttributeType( "1.1.1" );
    subType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
    subType.setOrderingOid( null );
    subType.setSubstringOid( null );
    subType.setSuperiorOid( "1.1.0" );
    subType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
    subType.setUsage( UsageEnum.USER_APPLICATIONS );
    subType.setCollective( false );

    // It should fail
    assertFalse( schemaManager.add( subType ) );

    assertFalse( isATPresent( schemaManager, "1.1.1" ) );
    assertEquals( atrSize + 1, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( goidSize + 1, schemaManager.getGlobalOidRegistry().size() );
}