org.apache.directory.api.ldap.model.entry.DefaultEntry Java Examples

The following examples show how to use org.apache.directory.api.ldap.model.entry.DefaultEntry. 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: MiniKdc.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a principal in the KDC with the specified user and password.
 *
 * @param principal principal name, do not include the domain.
 * @param password password.
 * @throws Exception thrown if the principal could not be created.
 */
public synchronized void createPrincipal(String principal, String password)
        throws Exception {
  String orgName= conf.getProperty(ORG_NAME);
  String orgDomain = conf.getProperty(ORG_DOMAIN);
  String baseDn = "ou=users,dc=" + orgName.toLowerCase(Locale.ENGLISH)
                  + ",dc=" + orgDomain.toLowerCase(Locale.ENGLISH);
  String content = "dn: uid=" + principal + "," + baseDn + "\n" +
          "objectClass: top\n" +
          "objectClass: person\n" +
          "objectClass: inetOrgPerson\n" +
          "objectClass: krb5principal\n" +
          "objectClass: krb5kdcentry\n" +
          "cn: " + principal + "\n" +
          "sn: " + principal + "\n" +
          "uid: " + principal + "\n" +
          "userPassword: " + password + "\n" +
          "krb5PrincipalName: " + principal + "@" + getRealm() + "\n" +
          "krb5KeyVersionNumber: 0";

  for (LdifEntry ldifEntry : new LdifReader(new StringReader(content))) {
    ds.getAdminSession().add(new DefaultEntry(ds.getSchemaManager(),
            ldifEntry.getEntry()));
  }
}
 
Example #2
Source File: SimpleLDAPAuthenticationManagerTest.java    From qpid-broker-j with Apache License 2.0 6 votes vote down vote up
private void createPrincipal(final String sn,
                             final String cn,
                             final String uid,
                             final String userPassword,
                             final String kerberosPrincipalName) throws LdapException
{
    final DirectoryService directoryService = LDAP.getDirectoryService();
    final Entry entry = new DefaultEntry(directoryService.getSchemaManager());
    entry.setDn(String.format("uid=%s,%s", uid, USERS_DN));
    entry.add("objectClass", "top", "person", "inetOrgPerson", "krb5principal", "krb5kdcentry");
    entry.add("cn", cn);
    entry.add("sn", sn);
    entry.add("uid", uid);
    entry.add("userPassword", userPassword);
    entry.add("krb5PrincipalName", kerberosPrincipalName);
    entry.add("krb5KeyVersionNumber", "0");
    directoryService.getAdminSession().add(entry);
}
 
Example #3
Source File: SchemaAwareEntryTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Test method for add( String, String... )
 */
@Test
public void testAddStringStringArray() throws LdapException
{
    Entry entry = new DefaultEntry();

    entry.add( "cn", ( String ) null );
    assertEquals( 1, entry.size() );
    Attribute attributeCN = entry.get( "cn" );
    assertEquals( 1, attributeCN.size() );
    assertNotNull( attributeCN.get() );
    assertNull( attributeCN.get().getString() );

    entry.add( "sn", "test", "test", "TEST" );
    assertEquals( 2, entry.size() );
    Attribute attributeSN = entry.get( "sn" );
    assertEquals( 2, attributeSN.size() );
    assertNotNull( attributeSN.get() );
    assertTrue( attributeSN.contains( "test" ) );
    assertTrue( attributeSN.contains( "TEST" ) );
}
 
Example #4
Source File: SchemaAwareEntryTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Test method for add( String, byte[]... )
 */
@Test
public void testAddStringByteArrayArray() throws LdapException
{
    Entry entry = new DefaultEntry();

    entry.add( "userPassword", ( byte[] ) null );
    assertEquals( 1, entry.size() );
    Attribute attributePWD = entry.get( "userPassword" );
    assertEquals( 1, attributePWD.size() );
    assertNotNull( attributePWD.get() );
    assertNull( attributePWD.get().getBytes() );

    entry.add( "jpegPhoto", BYTES1, BYTES1, BYTES2 );
    assertEquals( 2, entry.size() );
    Attribute attributeJPG = entry.get( "jpegPhoto" );
    assertEquals( 2, attributeJPG.size() );
    assertNotNull( attributeJPG.get() );
    assertTrue( attributeJPG.contains( BYTES1 ) );
    assertTrue( attributeJPG.contains( BYTES2 ) );
}
 
Example #5
Source File: SchemaAwareEntryTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Test method for hasObjectClass( String )
 */
@Test
public void testHasObjectClass() throws LdapException
{
    Entry entry = new DefaultEntry( exampleDn );

    assertFalse( entry.containsAttribute( "objectClass" ) );
    assertFalse( entry.hasObjectClass( "top" ) );

    entry.add( new DefaultAttribute( "objectClass", "top", "person" ) );

    assertTrue( entry.hasObjectClass( "top" ) );
    assertTrue( entry.hasObjectClass( "person" ) );
    assertFalse( entry.hasObjectClass( "inetorgperson" ) );
    assertFalse( entry.hasObjectClass( ( String ) null ) );
    assertFalse( entry.hasObjectClass( "" ) );
}
 
Example #6
Source File: SchemaAwareEntryTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Test method for clear()
 */
@Test
public void testClear() throws LdapException
{
    Entry entry = new DefaultEntry( exampleDn );

    assertEquals( 0, entry.size() );
    assertNull( entry.get( "ObjectClass" ) );
    entry.clear();
    assertEquals( 0, entry.size() );
    assertNull( entry.get( "ObjectClass" ) );

    entry.add( "ObjectClass", "top", "person" );
    assertEquals( 1, entry.size() );
    assertNotNull( entry.get( "ObjectClass" ) );

    entry.clear();
    assertEquals( 0, entry.size() );
    assertNull( entry.get( "ObjectClass" ) );
}
 
Example #7
Source File: SchemaAwareEntryTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Helper method which creates an entry with 4 attributes.
 */
private Entry createEntry()
{
    try
    {
        Entry entry = new DefaultEntry( exampleDn );

        Attribute attrOC = new DefaultAttribute( "objectClass", "top", "person" );
        Attribute attrCN = new DefaultAttribute( "cn", "test1", "test2" );
        Attribute attrSN = new DefaultAttribute( "sn", "Test1", "Test2" );
        Attribute attrPWD = new DefaultAttribute( "userPassword", BYTES1, BYTES2 );

        entry.put( attrOC, attrCN, attrSN, attrPWD );

        return entry;
    }
    catch ( LdapException ne )
    {
        // Do nothing
        return null;
    }
}
 
Example #8
Source File: SchemaAwareEntryTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Test method for contains( EntryAttribute... )
 */
@Test
public void testContainsEntryAttributeArray() throws LdapException
{
    Entry entry = new DefaultEntry( exampleDn );

    Attribute attrOC = new DefaultAttribute( "objectClass", "top", "person" );
    Attribute attrCN = new DefaultAttribute( "cn", "test1", "test2" );
    Attribute attrSN = new DefaultAttribute( "sn", "Test1", "Test2" );
    Attribute attrPWD = new DefaultAttribute( "userPassword", BYTES1, BYTES2 );

    assertFalse( entry.contains( attrOC, attrCN ) );

    entry.add( attrOC, attrCN );

    assertTrue( entry.contains( attrOC, attrCN ) );
    assertFalse( entry.contains( attrOC, attrCN, attrSN ) );

    entry.add( attrSN, attrPWD );

    assertTrue( entry.contains( attrSN, attrPWD ) );
}
 
Example #9
Source File: SchemaAwareEntryTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Test method for contains( String, byte[]... )
 */
@Test
public void testContainsStringByteArray() throws LdapException
{
    Entry entry = new DefaultEntry( exampleDn );

    assertFalse( entry.containsAttribute( "objectClass" ) );

    Attribute attrPWD = new DefaultAttribute( "userPassword", BYTES1, ( byte[] ) null, BYTES2 );

    entry.add( attrPWD );

    assertTrue( entry.contains( "  userPASSWORD  ", BYTES1, BYTES2 ) );
    assertTrue( entry.contains( "  userPASSWORD  ", ( byte[] ) null ) );

    // We can search for byte[] using Strings. the strings will be converted to byte[]
    assertTrue( entry.contains( "  userPASSWORD  ", "ab", "b" ) );

    assertFalse( entry.contains( "  userPASSWORD  ", "ab", "b", "d" ) );
}
 
Example #10
Source File: SchemaAwareEntryTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Test method for contains( String, String... )
 */
@Test
public void testContainsStringStringArray() throws LdapException
{
    Entry entry = new DefaultEntry( exampleDn );

    assertFalse( entry.containsAttribute( "objectClass" ) );

    Attribute attrOC = new DefaultAttribute( "objectClass", "top", "person" );
    Attribute attrCN = new DefaultAttribute( "cn", "test1", "test2" );
    Attribute attrSN = new DefaultAttribute( "sn", "Test1", "Test2", ( String ) null );
    Attribute attrPWD = new DefaultAttribute( "userPassword", BYTES1, BYTES2 );

    entry.add( attrOC, attrCN, attrSN, attrPWD );

    assertTrue( entry.contains( "OBJECTCLASS", "top", "person" ) );
    assertTrue( entry.contains( " cn ", "test1", "test2" ) );
    assertTrue( entry.contains( "Sn", "Test1", "Test2", ( String ) null ) );
    assertTrue( entry.contains( "  userPASSWORD  ", "ab", "b" ) );

    assertFalse( entry.contains( "OBJECTCLASS", "PERSON" ) );
    assertFalse( entry.contains( " cn ", "test1", "test3" ) );
    assertFalse( entry.contains( "Sn", "Test" ) );
    assertFalse( entry.contains( "  userPASSWORD  ", ( String ) null ) );
}
 
Example #11
Source File: SchemaAwareEntryTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Test method for DefaultEntry()
 */
@Test
public void testDefaultClientEntryLdif() throws Exception
{
    Entry entry = new DefaultEntry(
        "ou=example, dc=com",
        "ObjectClass: top",
        "ObjectClass: person",
        "cn: test",
        "sn: test" );

    assertNotNull( entry );
    assertEquals( "ou=example, dc=com", entry.getDn().toString() );
    assertEquals( 3, entry.size() );
    assertTrue( entry.contains( "objectClass", "top", "person" ) );
    assertTrue( entry.contains( "cn", "test" ) );
    assertTrue( entry.contains( "sn", "test" ) );
}
 
Example #12
Source File: SchemaAwareEntryTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Test method for removeAttributes( String... )
 */
@Test
public void testRemoveAttributesStringArray() throws LdapException
{
    Entry entry = new DefaultEntry( exampleDn );

    Attribute attrOC = new DefaultAttribute( "objectClass", "top", "person" );
    Attribute attrCN = new DefaultAttribute( "cn", "test1", "test2" );
    Attribute attrSN = new DefaultAttribute( "sn", "Test1", "Test2" );
    Attribute attrPWD = new DefaultAttribute( "userPassword", BYTES1, BYTES2 );

    entry.put( attrOC, attrCN, attrSN, attrPWD );

    entry.removeAttributes( "CN", "SN" );

    assertFalse( entry.containsAttribute( "cn", "sn" ) );
    assertTrue( entry.containsAttribute( "objectclass", "userpassword" ) );

    entry.removeAttributes( "badId" );

    entry.removeAttributes( ( String ) null );
}
 
Example #13
Source File: SchemaAwareEntryTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Test method for remove(String, byte[]... )
 */
@Test
public void testRemoveStringByteArrayArray() throws LdapException
{
    Entry entry = new DefaultEntry( exampleDn );

    Attribute attrPWD = new DefaultAttribute( "userPassword", BYTES1, ( byte[] ) null, BYTES2 );

    entry.put( attrPWD );
    assertTrue( entry.remove( "userPassword", ( byte[] ) null ) );
    assertTrue( entry.remove( "userPassword", BYTES1, BYTES2 ) );
    assertFalse( entry.containsAttribute( "userPassword" ) );

    entry.add( "userPassword", BYTES1, ( byte[] ) null, BYTES2 );
    assertTrue( entry.remove( "userPassword", ( byte[] ) null ) );
    assertEquals( 2, entry.get( "userPassword" ).size() );
    assertTrue( entry.remove( "userPassword", BYTES1, BYTES3 ) );
    assertEquals( 1, entry.get( "userPassword" ).size() );
    assertTrue( Arrays.equals( BYTES2, entry.get( "userPassword" ).getBytes() ) );

    assertFalse( entry.remove( "userPassword", BYTES3 ) );
    assertFalse( entry.remove( "void", "whatever" ) );
}
 
Example #14
Source File: SchemaAwareEntryTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Test method for size()
 */
@Test
public void testSize() throws LdapException
{
    Entry entry = new DefaultEntry( exampleDn );

    assertEquals( 0, entry.size() );
    entry.add( "ObjectClass", "top", "person" );
    entry.add( "cn", "test" );
    entry.add( "sn", "Test" );

    assertEquals( 3, entry.size() );

    entry.clear();
    assertEquals( 0, entry.size() );
}
 
Example #15
Source File: SchemaAwareEntryTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Test the serialization of a complete entry
 */
@Test
public void testSerializeCompleteEntry() throws LdapException, IOException, ClassNotFoundException
{
    Dn dn = new Dn( schemaManager,  "ou=system" );

    byte[] password = Strings.getBytesUtf8( "secret" );
    Entry entry = new DefaultEntry( dn );
    entry.add( "ObjectClass", "top", "person" );
    entry.add( "cn", "test1" );
    entry.add( "userPassword", password );

    Entry entrySer = deserializeValue( serializeValue( entry ) );

    assertEquals( entry, entrySer );
}
 
Example #16
Source File: ApiLdapModelOsgiTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
@Override
protected void useBundleClasses() throws Exception
{
    new Dn( "dc=example,dc=com" ); // uses FastDnParser
    new Dn( "cn=a+sn=b,dc=example,dc=com" ); // uses ComplexDnparser (antlr based)
    new Value( "foo" );
    new DefaultAttribute( "cn" );
    new DefaultEntry();

    AttributeUtils.toJndiAttribute( new DefaultAttribute( "cn" ) );
    
    new BindRequestImpl();

    new EqualityNode<String>( "cn", "foo" );

    new LdapUrl( "ldap://ldap.example.com:10389/dc=example,dc=com?objectclass" );

    new ObjectClassDescriptionSchemaParser()
        .parse( "( 2.5.6.0 NAME 'top' DESC 'top of the superclass chain' ABSTRACT MUST objectClass )" );
    
    SchemaObject schemaObject = new LdapSyntax( "1.2.3" );
    new Registries().getGlobalOidRegistry().register( schemaObject );
    new Registries().getLoadedSchemas();
}
 
Example #17
Source File: SchemaAwareEntryTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Test method for userCertificate;binary AT
 */
@Test
public void testUserCertificateBinary() throws LdapException
{
    Entry entry = new DefaultEntry( schemaManager );
    entry.add( "objectClass", "top", "person", "inetorgPerson" );
    entry.add( "cn", "test1", "test2" );
    entry.add( "sn", "Test1", "Test2" );
    entry.add( "userPassword", BYTES1, BYTES2 );

    entry.add( "userCertificate;binary", Strings.getBytesUtf8( "secret" ) );
    assertTrue( entry.containsAttribute( "userCertificate;binary" ) );
    assertTrue( entry.containsAttribute( "userCertificate" ) );

    entry.removeAttributes( "userCertificate;binary" );
    assertFalse( entry.containsAttribute( "userCertificate;binary" ) );
    assertFalse( entry.containsAttribute( "userCertificate" ) );

    entry.add( "userCertificate", Strings.getBytesUtf8( "secret" ) );
    assertTrue( entry.containsAttribute( "userCertificate;binary" ) );
    assertTrue( entry.containsAttribute( "userCertificate" ) );
}
 
Example #18
Source File: AttributeUtilsTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Test a addModification applied to an entry 
 */
@Test
public void testApplyAddModificationToEntry() throws LdapException
{
    Entry entry = new DefaultEntry();
    entry.add( "dc", "apache" );
    assertEquals( 1, entry.size() );

    Attribute attr = new DefaultAttribute( "cn", "test" );
    Modification modification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attr );

    AttributeUtils.applyModification( entry, modification );
    assertNotNull( entry.get( "cn" ) );
    assertEquals( 2, entry.size() );
    assertEquals( attr, entry.get( "cn" ) );
}
 
Example #19
Source File: AttributeUtilsTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Test the deletion of an attribute into an entry which does not contain the attribute
 */
@Test
public void testApplyRemoveModificationFromEntryAttributeNotPresent() throws LdapException
{
    Entry entry = new DefaultEntry();

    Attribute dc = new DefaultAttribute( "dc", "apache" );
    entry.put( dc );

    Attribute cn = new DefaultAttribute( "cn", "test" );

    Modification modification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, cn );

    AttributeUtils.applyModification( entry, modification );

    assertNull( entry.get( "cn" ) );
    assertNotNull( entry.get( "dc" ) );
    assertEquals( 1, entry.size() );
    assertEquals( dc, entry.get( "dc" ) );
}
 
Example #20
Source File: AttributeUtilsTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Test the deletion of an attribute into an entry which contains the attribute
 * but without the value to be deleted
 */
@Test
public void testApplyRemoveModificationFromEntryAttributeNotSameValue() throws LdapException
{
    Entry entry = new DefaultEntry();

    Attribute cn = new DefaultAttribute( "cn", "apache" );
    entry.put( cn );

    Attribute attr = new DefaultAttribute( "cn", "test" );

    Modification modification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, attr );

    AttributeUtils.applyModification( entry, modification );

    assertNotNull( entry.get( "cn" ) );
    assertEquals( 1, entry.size() );
    assertEquals( cn, entry.get( "cn" ) );
}
 
Example #21
Source File: AttributeUtilsTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Test the deletion of an attribute into an entry which contains the attribute.
 * 
 * The entry should not contain the attribute after the operation
 */
@Test
public void testApplyRemoveModificationFromEntrySameAttributeSameValue() throws LdapException
{
    Entry entry = new DefaultEntry();
    entry.put( "cn", "test" );

    Attribute attr = new DefaultAttribute( "cn", "test" );

    Modification modification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, attr );

    AttributeUtils.applyModification( entry, modification );

    assertNull( entry.get( "cn" ) );
    assertEquals( 0, entry.size() );
}
 
Example #22
Source File: AttributeUtilsTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Test the removing by modification of an existing attribute in an .
 * 
 * @throws LdapException
 */
@Test
public void testApplyModifyModificationRemoveAttribute() throws LdapException
{
    Entry entry = new DefaultEntry();
    entry.put( "cn", "test" );
    entry.put( "ou", "apache", "acme corp" );

    Attribute newOu = new DefaultAttribute( "ou" );

    Modification modification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, newOu );

    AttributeUtils.applyModification( entry, modification );

    assertEquals( 1, entry.size() );

    assertNotNull( entry.get( "cn" ) );
    assertNull( entry.get( "ou" ) );
}
 
Example #23
Source File: AddRequestImplTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Creates and populates a LockableAttributes object
 * 
 * @return
 */
private Entry getEntry()
{
    Entry entry = new DefaultEntry();

    try
    {
        entry.put( getAttribute( "attr0" ) );
        entry.put( getAttribute( "attr1" ) );
        entry.put( getAttribute( "attr2" ) );
    }
    catch ( LdapException ne )
    {
        // Do nothing
    }

    return entry;
}
 
Example #24
Source File: DefaultSchemaLoader.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
private Entry getEntry( LdapComparatorDescription comparatorDescription )
{
    Entry entry = new DefaultEntry();

    entry.put( SchemaConstants.OBJECT_CLASS_AT,
        SchemaConstants.TOP_OC,
        MetaSchemaConstants.META_TOP_OC,
        MetaSchemaConstants.META_COMPARATOR_OC );

    entry.put( MetaSchemaConstants.M_OID_AT, comparatorDescription.getOid() );
    entry.put( MetaSchemaConstants.M_FQCN_AT, comparatorDescription.getFqcn() );

    if ( comparatorDescription.getBytecode() != null )
    {
        entry.put( MetaSchemaConstants.M_BYTECODE_AT,
            Base64.decode( comparatorDescription.getBytecode().toCharArray() ) );
    }

    if ( comparatorDescription.getDescription() != null )
    {
        entry.put( MetaSchemaConstants.M_DESCRIPTION_AT, comparatorDescription.getDescription() );
    }

    return entry;
}
 
Example #25
Source File: DefaultSchemaLoader.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
private Entry getEntry( SyntaxCheckerDescription syntaxCheckerDescription )
{
    Entry entry = new DefaultEntry();

    entry.put( SchemaConstants.OBJECT_CLASS_AT,
        SchemaConstants.TOP_OC,
        MetaSchemaConstants.META_TOP_OC,
        MetaSchemaConstants.META_SYNTAX_CHECKER_OC );

    entry.put( MetaSchemaConstants.M_OID_AT, syntaxCheckerDescription.getOid() );
    entry.put( MetaSchemaConstants.M_FQCN_AT, syntaxCheckerDescription.getFqcn() );

    if ( syntaxCheckerDescription.getBytecode() != null )
    {
        entry.put( MetaSchemaConstants.M_BYTECODE_AT,
            Base64.decode( syntaxCheckerDescription.getBytecode().toCharArray() ) );
    }

    if ( syntaxCheckerDescription.getDescription() != null )
    {
        entry.put( MetaSchemaConstants.M_DESCRIPTION_AT, syntaxCheckerDescription.getDescription() );
    }

    return entry;
}
 
Example #26
Source File: DefaultSchemaLoader.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
private Entry getEntry( NormalizerDescription normalizerDescription )
{
    Entry entry = new DefaultEntry();

    entry.put( SchemaConstants.OBJECT_CLASS_AT,
        SchemaConstants.TOP_OC,
        MetaSchemaConstants.META_TOP_OC,
        MetaSchemaConstants.META_NORMALIZER_OC );

    entry.put( MetaSchemaConstants.M_OID_AT, normalizerDescription.getOid() );
    entry.put( MetaSchemaConstants.M_FQCN_AT, normalizerDescription.getFqcn() );

    if ( normalizerDescription.getBytecode() != null )
    {
        entry.put( MetaSchemaConstants.M_BYTECODE_AT,
            Base64.decode( normalizerDescription.getBytecode().toCharArray() ) );
    }

    if ( normalizerDescription.getDescription() != null )
    {
        entry.put( MetaSchemaConstants.M_DESCRIPTION_AT, normalizerDescription.getDescription() );
    }

    return entry;
}
 
Example #27
Source File: LdapNetworkConnection.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Process the SearchResultEntry received from the server
 * 
 * @param searchResultEntry The SearchResultEntry to process
 * @param searchFuture The SearchFuture to feed
 * @throws InterruptedException If the Future is interrupted
 * @throws LdapException If we weren't able to create a new Entry
 */
private void searchResultEntryReceived( SearchResultEntry searchResultEntry, SearchFuture searchFuture ) 
    throws InterruptedException, LdapException
{
    if ( schemaManager != null )
    {
        searchResultEntry.setEntry( new DefaultEntry( schemaManager, searchResultEntry.getEntry() ) );
    }

    if ( LOG.isDebugEnabled() )
    {
        LOG.debug( I18n.msg( I18n.MSG_04128_SEARCH_ENTRY_FOUND, searchResultEntry ) );
    }

    // Store the response into the future
    searchFuture.set( searchResultEntry );
}
 
Example #28
Source File: SchemaElementImpl.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * @return the Names as Ldif lines
 * @throws org.apache.directory.api.ldap.model.exception.LdapException If the conversion goes wrong
 */
private String nameToLdif() throws LdapException
{
    if ( names.isEmpty() )
    {
        return "";
    }
    else
    {
        Entry entry = new DefaultEntry();
        Attribute attribute = new DefaultAttribute( "m-name" );

        for ( String name : names )
        {
            attribute.add( name );
        }

        entry.put( attribute );

        return LdifUtils.convertAttributesToLdif( entry );
    }
}
 
Example #29
Source File: SchemaElementImpl.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * @return The description as a ldif line
 * @throws org.apache.directory.api.ldap.model.exception.LdapException If the conversion goes wrong
 */
private String descToLdif() throws LdapException
{
    if ( Strings.isEmpty( description ) )
    {
        return "";
    }
    else
    {
        Entry entry = new DefaultEntry();
        Attribute attribute = new DefaultAttribute( "m-description", description );

        entry.put( attribute );

        return LdifUtils.convertAttributesToLdif( entry );
    }
}
 
Example #30
Source File: SchemaElementImpl.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * Return the extensions formated as Ldif lines
 *
 * @param id The attributeId : can be m-objectClassExtension or
 * m-attributeTypeExtension
 * @return The extensions formated as ldif lines
 * @throws org.apache.directory.api.ldap.model.exception.LdapException If the conversion goes wrong
 */
protected String extensionsToLdif( String id ) throws LdapException
{
    StringBuilder sb = new StringBuilder();

    Entry entry = new DefaultEntry();
    Attribute attribute = new DefaultAttribute( id );

    for ( String extension : extensions.keySet() )
    {
        attribute.add( extension );
    }

    sb.append( LdifUtils.convertAttributesToLdif( entry ) );

    return sb.toString();
}