当前位置: 首页>>代码示例>>Java>>正文


Java Entry类代码示例

本文整理汇总了Java中org.apache.directory.api.ldap.model.entry.Entry的典型用法代码示例。如果您正苦于以下问题:Java Entry类的具体用法?Java Entry怎么用?Java Entry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Entry类属于org.apache.directory.api.ldap.model.entry包,在下文中一共展示了Entry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testAddStringByteArrayArray

import org.apache.directory.api.ldap.model.entry.Entry; //导入依赖的package包/类
/**
 * 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 ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:24,代码来源:SchemaAwareEntryTest.java

示例2: testLdifVersionStart

import org.apache.directory.api.ldap.model.entry.Entry; //导入依赖的package包/类
@Test
public void testLdifVersionStart() throws LdapLdifException, IOException
{
    String ldif = 
          "cn: app1\n" 
        + "objectClass: top\n" 
        + "objectClass: apApplication\n" 
        + "displayName:   app1   \n"
        + "dependencies:\n" 
        + "envVars:";

    LdifAttributesReader reader = new LdifAttributesReader();
    Entry entry = reader.parseEntry( ldif );

    assertEquals( 1, reader.getVersion() );
    assertNotNull( entry );

    Attribute attr = entry.get( "displayname" );
    assertTrue( attr.contains( "app1" ) );
    reader.close();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:22,代码来源:LdifAttributesReaderTest.java

示例3: testContainsEntryAttributeArray

import org.apache.directory.api.ldap.model.entry.Entry; //导入依赖的package包/类
/**
 * 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 ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:25,代码来源:SchemaAwareEntryTest.java

示例4: testContainsStringStringArray

import org.apache.directory.api.ldap.model.entry.Entry; //导入依赖的package包/类
/**
 * 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 ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:28,代码来源:SchemaAwareEntryTest.java

示例5: getEntry

import org.apache.directory.api.ldap.model.entry.Entry; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Entry getEntry() throws LdapException
{
    if ( isEntry() )
    {
        return ( ( SearchResultEntry ) response ).getEntry();
    }
    
    if ( isReferral() )
    {
        Referral referral = ( ( SearchResultReference ) response ).getReferral();
        throw new LdapReferralException( referral.getLdapUrls() );
    }

    throw new LdapException();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:20,代码来源:SearchCursorImpl.java

示例6: exists

import org.apache.directory.api.ldap.model.entry.Entry; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public boolean exists( Dn dn ) throws LdapException
{
    try
    {
        Entry entry = lookup( dn, SchemaConstants.NO_ATTRIBUTE_ARRAY );

        return entry != null;
    }
    catch ( LdapNoPermissionException lnpe )
    {
        // Special case to deal with insufficient permissions
        return false;
    }
    catch ( LdapException le )
    {
        throw le;
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:23,代码来源:LdapNetworkConnection.java

示例7: SingleLdifSchemaLoader

import org.apache.directory.api.ldap.model.entry.Entry; //导入依赖的package包/类
/**
 * Instantiates a new single LDIF schema loader.
 * 
 * @param schemaUrl The URL of the schema to load
 */
public SingleLdifSchemaLoader( URL schemaUrl )
{
    try
    {
        for ( String s : schemaObjectTypeRdns )
        {
            scObjEntryMap.put( s, new HashMap<String, List<Entry>>() );
        }

        InputStream in = schemaUrl.openStream();

        initializeSchemas( in );
    }
    catch ( LdapException | IOException e )
    {
        throw new RuntimeException( e );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:24,代码来源:SingleLdifSchemaLoader.java

示例8: testLdifParserEndSpaces

import org.apache.directory.api.ldap.model.entry.Entry; //导入依赖的package包/类
/**
 * Spaces at the end of values should not be included into values.
 * 
 * @throws NamingException
 */
@Test
public void testLdifParserEndSpaces() throws LdapLdifException, IOException
{
    String ldif = 
          "cn: app1\n" 
        + "objectClass: top\n" 
        + "objectClass: apApplication\n" 
        + "displayName:   app1   \n"
        + "dependencies:\n" 
        + "envVars:";

    LdifAttributesReader reader = new LdifAttributesReader();

    Entry entry = reader.parseEntry( ldif );
    assertNotNull( entry );

    Attribute attr = entry.get( "displayname" );
    assertTrue( attr.contains( "app1" ) );
    reader.close();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:26,代码来源:LdifAttributesReaderTest.java

示例9: testRemoveAttributesStringArray

import org.apache.directory.api.ldap.model.entry.Entry; //导入依赖的package包/类
/**
 * 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 );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:25,代码来源:SchemaAwareEntryTest.java

示例10: loadSchemaObjects

import org.apache.directory.api.ldap.model.entry.Entry; //导入依赖的package包/类
private List<Entry> loadSchemaObjects( String schemaObjectType, Schema... schemas ) throws LdapException,
    IOException
{
    Map<String, List<Entry>> m = scObjEntryMap.get( schemaObjectType );
    List<Entry> atList = new ArrayList<>();

    for ( Schema s : schemas )
    {
        List<Entry> preLoaded = m.get( s.getSchemaName() );
        
        if ( preLoaded != null )
        {
            atList.addAll( preLoaded );
        }
    }

    return atList;
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:19,代码来源:SingleLdifSchemaLoader.java

示例11: testRemoveStringStringArray

import org.apache.directory.api.ldap.model.entry.Entry; //导入依赖的package包/类
/**
 * Test method for remove( String, String... )
 */
@Test
public void testRemoveStringStringArray() throws LdapException
{
    Entry entry = createEntry();

    assertTrue( entry.remove( "cn", "test1" ) );
    assertTrue( entry.remove( "cn", "test2" ) );
    assertFalse( entry.containsAttribute( "cn" ) );

    entry.add( "cn", "test1", ( String ) null, "test2" );
    assertTrue( entry.remove( "cn", ( String ) null ) );
    assertEquals( 2, entry.get( "cn" ).size() );
    assertTrue( entry.remove( "cn", "test1", "test3" ) );
    assertEquals( 1, entry.get( "cn" ).size() );
    assertEquals( "test2", entry.get( "cn" ).get().getValue() );

    assertFalse( entry.remove( "cn", "test3" ) );
    assertFalse( entry.remove( "void", "whatever" ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:23,代码来源:SchemaAwareEntryTest.java

示例12: testSerializeCompleteEntry

import org.apache.directory.api.ldap.model.entry.Entry; //导入依赖的package包/类
/**
 * 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 );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:19,代码来源:SchemaAwareEntryTest.java

示例13: testApplyRemoveModificationFromEntryAttributeNotSameValue

import org.apache.directory.api.ldap.model.entry.Entry; //导入依赖的package包/类
/**
 * 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" ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:23,代码来源:AttributeUtilsTest.java

示例14: getAttributes

import org.apache.directory.api.ldap.model.entry.Entry; //导入依赖的package包/类
public List<String> getAttributes(Entry entry, String attName) {
    List<String> values = new ArrayList<>();
    javax.naming.directory.Attribute att = AttributeUtils.toAttributes(entry).get(attName);
    if (att == null) {
        return values;
    }

    try {
        NamingEnumeration<?> list = att.getAll();
        while (list.hasMore()) {
            values.add(list.next().toString());
        }
    } catch (NamingException e) {
        log.warn("Error while processing LDAP attribute {}, result could be incomplete!", attName, e);
    }
    return values;
}
 
开发者ID:kamax-io,项目名称:mxisd,代码行数:18,代码来源:LdapGenericBackend.java

示例15: testApplyAddModificationToEntry

import org.apache.directory.api.ldap.model.entry.Entry; //导入依赖的package包/类
/**
 * 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" ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:19,代码来源:AttributeUtilsTest.java


注:本文中的org.apache.directory.api.ldap.model.entry.Entry类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。