本文整理汇总了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 ) );
}
示例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();
}
示例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 ) );
}
示例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 ) );
}
示例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();
}
示例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;
}
}
示例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 );
}
}
示例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();
}
示例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 );
}
示例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;
}
示例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" ) );
}
示例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 );
}
示例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" ) );
}
示例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;
}
示例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" ) );
}