本文整理汇总了Java中org.apache.directory.api.ldap.model.exception.LdapException类的典型用法代码示例。如果您正苦于以下问题:Java LdapException类的具体用法?Java LdapException怎么用?Java LdapException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LdapException类属于org.apache.directory.api.ldap.model.exception包,在下文中一共展示了LdapException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: descToLdif
import org.apache.directory.api.ldap.model.exception.LdapException; //导入依赖的package包/类
/**
* @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 );
}
}
示例2: testUnregister
import org.apache.directory.api.ldap.model.exception.LdapException; //导入依赖的package包/类
@Test
public void testUnregister() throws LdapException
{
MutableAttributeType at0 = new MutableAttributeType( "1.1" );
at0.addName( "t", "test", "Test", "T" );
atRegistry.register( at0 );
atRegistry.unregister( "1.1" );
assertFalse( atRegistry.contains( "1.1" ) );
assertFalse( atRegistry.contains( "t" ) );
assertFalse( atRegistry.contains( "T" ) );
assertFalse( atRegistry.contains( "tEsT" ) );
try
{
atRegistry.getOidByName( "T" );
fail();
}
catch ( LdapException ne )
{
assertTrue( true );
}
}
示例3: testCopyConstructorClientAttribute
import org.apache.directory.api.ldap.model.exception.LdapException; //导入依赖的package包/类
/**
* Test the copy constructor of a ClientAttribute
*/
@Test
public void testCopyConstructorClientAttribute() throws LdapException
{
Attribute attribute = new DefaultAttribute( "commonName" );
attribute.add( "test" );
Attribute copy = new DefaultAttribute( atCN, attribute );
assertEquals( atCN, copy.getAttributeType() );
assertEquals( "test", copy.getString() );
assertTrue( copy.isHumanReadable() );
attribute.add( "test2" );
assertFalse( copy.contains( "test2" ) );
}
示例4: testToClientAttribute
import org.apache.directory.api.ldap.model.exception.LdapException; //导入依赖的package包/类
/**
* Test the conversion method
*/
@Test
public void testToClientAttribute() throws LdapException
{
Attribute attribute = new DefaultAttribute( atCN, "test", "test2" );
Attribute clientAttribute = attribute.clone();
assertTrue( clientAttribute instanceof Attribute );
assertTrue( clientAttribute.contains( "test", "test2" ) );
assertEquals( "2.5.4.3", clientAttribute.getId() );
attribute.remove( "test", "test2" );
assertTrue( clientAttribute.contains( "test", "test2" ) );
}
示例5: testApply
import org.apache.directory.api.ldap.model.exception.LdapException; //导入依赖的package包/类
/**
* Test the normalize method
*/
@Test
public void testApply() throws LdapException
{
AttributeType attribute = EntryUtils.getIA5StringAttributeType();
Value sv = Value.createValue( attribute );
sv = new Value( at, sv );
assertEquals( 0, sv.compareTo( ( String ) null ) );
sv = new Value( attribute, "" );
sv = new Value( at, sv );
assertEquals( 0, sv.compareTo( " " ) );
sv = new Value( attribute, " A TEST " );
assertEquals( 0, sv.compareTo( " a test " ) );
}
示例6: testSerializeAttributeBinaryValue
import org.apache.directory.api.ldap.model.exception.LdapException; //导入依赖的package包/类
/**
* Test the serialization of a server attribute with a binary value
*/
@Test
public void testSerializeAttributeBinaryValue() throws LdapException, IOException, ClassNotFoundException
{
DefaultAttribute dsa = new DefaultAttribute( atPwd );
byte[] password = Strings.getBytesUtf8( "secret" );
dsa.add( password );
DefaultAttribute dsaSer = deserializeValue( serializeValue( dsa ), atPwd );
assertEquals( dsa.toString(), dsaSer.toString() );
assertEquals( "2.5.4.35", dsaSer.getId() );
assertEquals( "userPassword", dsaSer.getUpId() );
assertTrue( Arrays.equals( dsa.getBytes(), dsaSer.getBytes() ) );
assertEquals( 1, dsaSer.size() );
assertTrue( dsaSer.contains( password ) );
assertFalse( dsaSer.isHumanReadable() );
}
示例7: testCreateServerModification
import org.apache.directory.api.ldap.model.exception.LdapException; //导入依赖的package包/类
@Test
public void testCreateServerModification() throws LdapException
{
Attribute attribute = new DefaultAttribute( "cn", cnAT );
attribute.add( "test1", "test2" );
Modification mod = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attribute );
Modification clone = mod.clone();
attribute.remove( "test2" );
Attribute clonedAttribute = clone.getAttribute();
assertEquals( 1, mod.getAttribute().size() );
assertTrue( mod.getAttribute().contains( "TEST1" ) );
assertEquals( 2, clonedAttribute.size() );
assertTrue( clone.getAttribute().contains( "test1" ) );
assertTrue( clone.getAttribute().contains( "test2" ) );
}
示例8: execute
import org.apache.directory.api.ldap.model.exception.LdapException; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public <T> T execute( ConnectionCallback<T> connectionCallback )
{
LdapConnection connection = null;
try
{
connection = connectionPool.getConnection();
return connectionCallback.doWithConnection( connection );
}
catch ( LdapException e )
{
throw new LdapRuntimeException( e );
}
finally
{
returnLdapConnection( connection );
}
}
示例9: bindAsync
import org.apache.directory.api.ldap.model.exception.LdapException; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public BindFuture bindAsync( Dn name, String credentials ) throws LdapException
{
LOG.debug( "Bind request : {}", name );
// The password must not be empty or null
if ( Strings.isEmpty( credentials ) && ( !Dn.EMPTY_DN.equals( name ) ) )
{
LOG.debug( "The password is missing" );
throw new LdapAuthenticationException( "The password is missing" );
}
// Create the BindRequest
BindRequest bindRequest = createBindRequest( name, Strings.getBytesUtf8( credentials ) );
return bindAsync( bindRequest );
}
示例10: testHashCodeExactCopy
import org.apache.directory.api.ldap.model.exception.LdapException; //导入依赖的package包/类
/**
* Tests for equal hashCode using exact copies.
*/
@Test
public void testHashCodeExactCopy() throws LdapException
{
CompareRequestImpl req0 = new CompareRequestImpl();
req0.setMessageId( 5 );
req0.setName( new Dn( "cn=admin,dc=example,dc=com" ) );
req0.setAttributeId( "objectClass" );
req0.setAssertionValue( "top" );
CompareRequestImpl req1 = new CompareRequestImpl();
req1.setMessageId( 5 );
req1.setName( new Dn( "cn=admin,dc=example,dc=com" ) );
req1.setAttributeId( "objectClass" );
req1.setAssertionValue( "top" );
assertTrue( req0.hashCode() == req1.hashCode() );
}
示例11: testRemoveStringStringArray
import org.apache.directory.api.ldap.model.exception.LdapException; //导入依赖的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: getEntry
import org.apache.directory.api.ldap.model.exception.LdapException; //导入依赖的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();
}
示例13: testNullUpValueSerialization
import org.apache.directory.api.ldap.model.exception.LdapException; //导入依赖的package包/类
@Test
public void testNullUpValueSerialization() throws LdapException, IOException, ClassNotFoundException
{
Ava atav = new Ava( schemaManager, "DC", ( String ) null );
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream( baos );
try
{
atav.writeExternal( out );
fail();
}
catch ( IOException ioe )
{
String message = ioe.getMessage();
assertEquals( "Cannot serialize a wrong ATAV, the value should not be null", message );
}
}
示例14: testNullUpValueStaticSerialization
import org.apache.directory.api.ldap.model.exception.LdapException; //导入依赖的package包/类
@Test
public void testNullUpValueStaticSerialization() throws LdapException, IOException, ClassNotFoundException
{
Ava atav = new Ava( schemaManager, "CN", ( String ) null );
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream( baos );
try
{
atav.writeExternal( out );
fail();
}
catch ( IOException ioe )
{
String message = ioe.getMessage();
assertEquals( "Cannot serialize a wrong ATAV, the value should not be null", message );
}
}
示例15: removeMappingFor
import org.apache.directory.api.ldap.model.exception.LdapException; //导入依赖的package包/类
/**
* Remove the AttributeType normalizer from the OidNormalizer map
*/
@Override
public void removeMappingFor( AttributeType attributeType ) throws LdapException
{
if ( attributeType == null )
{
return;
}
oidNormalizerMap.remove( attributeType.getOid() );
// We also have to remove all the short names for this attribute
for ( String name : attributeType.getNames() )
{
oidNormalizerMap.remove( Strings.toLowerCaseAscii( name ) );
}
}