本文整理汇总了Java中org.apache.directory.api.ldap.model.exception.LdapInvalidDnException类的典型用法代码示例。如果您正苦于以下问题:Java LdapInvalidDnException类的具体用法?Java LdapInvalidDnException怎么用?Java LdapInvalidDnException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LdapInvalidDnException类属于org.apache.directory.api.ldap.model.exception包,在下文中一共展示了LdapInvalidDnException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCompareAvaOrder
import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; //导入依赖的package包/类
@Test
public void testCompareAvaOrder() throws LdapInvalidDnException
{
Ava atav1 = new Ava( schemaManager, "cn", " B " );
Ava atav2 = new Ava( schemaManager, "sn", " c" );
// atav1 should be before atav2
assertEquals( -1, atav1.compareTo( atav2 ) );
assertEquals( 1, atav2.compareTo( atav1 ) );
Ava atav3 = new Ava( schemaManager, "2.5.4.3", "A " );
// Atav1 shoud be after atav3
assertEquals( 1, atav1.compareTo( atav3 ) );
assertEquals( -1, atav3.compareTo( atav1 ) );
}
示例2: testSortAva
import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; //导入依赖的package包/类
@Test
public void testSortAva() throws LdapInvalidDnException
{
Ava atav1 = new Ava( schemaManager, "cn", " B " );
Ava atav2 = new Ava( schemaManager, "sn", " c" );
Ava atav3 = new Ava( schemaManager, "2.5.4.3", "A " );
Ava atav4 = new Ava( schemaManager, "2.5.4.11", " C " );
Ava atav5 = new Ava( schemaManager, "ou", "B " );
Ava atav6 = new Ava( schemaManager, "ou", "D " );
Ava atav7 = new Ava( schemaManager, "CN", " " );
Ava[] avas = new Ava[] { atav1, atav2, atav3, atav4, atav5, atav6, atav7 };
Arrays.sort( avas );
assertEquals( atav5, avas[0] );
assertEquals( atav4, avas[1] );
assertEquals( atav6, avas[2] );
assertEquals( atav7, avas[3] );
assertEquals( atav3, avas[4] );
assertEquals( atav1, avas[5] );
assertEquals( atav2, avas[6] );
}
示例3: DefaultEntry
import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; //导入依赖的package包/类
/**
* <p>
* Creates a new instance of DefaultEntry, schema aware.
* </p>
* <p>
* No attributes will be created.
* </p>
*
* @param schemaManager The reference to the schemaManager
* @param dn The String Dn for this serverEntry. Can be null.
* @throws LdapInvalidDnException If the Dn is invalid
*/
public DefaultEntry( SchemaManager schemaManager, String dn ) throws LdapInvalidDnException
{
this.schemaManager = schemaManager;
if ( Strings.isEmpty( dn ) )
{
this.dn = Dn.EMPTY_DN;
}
else
{
this.dn = new Dn( schemaManager, dn );
}
// Initialize the ObjectClass object
initObjectClassAT();
}
示例4: parseDN
import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; //导入依赖的package包/类
/**
* Parse a string and check that it complies with RFC 2253. Here, we will
* just call the Dn parser to do the job.
*
* @param chars The char array to be checked
* @param pos the starting position
* @return -1 if the char array does not contains a Dn
*/
private int parseDN( char[] chars, int pos )
{
int end = pos;
for ( int i = pos; ( i < chars.length ) && ( chars[i] != '?' ); i++ )
{
end++;
}
try
{
String dnStr = new String( chars, pos, end - pos );
dn = new Dn( decode( dnStr ) );
}
catch ( LdapUriException | LdapInvalidDnException e )
{
return -1;
}
return end;
}
示例5: createAva
import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; //导入依赖的package包/类
/**
* Construct a schema aware Ava. The AttributeType and value will be checked accordingly
* to the SchemaManager.
* <p>
* Note that the upValue should <b>not</b> be null or empty, or resolve
* to an empty string after having trimmed it.
*
* @param schemaManager The SchemaManager instance
* @param upType The User Provided type
* @param value The value
*
* @throws LdapInvalidDnException If the given type or value are invalid
*/
private void createAva( SchemaManager schemaManager, String upType, Value value )
throws LdapInvalidDnException
{
StringBuilder sb = new StringBuilder();
normType = attributeType.getOid();
this.upType = upType;
this.value = value;
sb.append( upType );
sb.append( '=' );
if ( value != null )
{
sb.append( Rdn.escapeValue( value.getValue() ) );
}
upName = sb.toString();
hashCode();
}
示例6: Dn
import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; //导入依赖的package包/类
/**
* Construct an empty Schema aware Dn object
*
* @param schemaManager The SchemaManager to use
* @param dn The Dn to use
* @throws LdapInvalidDnException If the Dn is invalid
*/
public Dn( SchemaManager schemaManager, Dn dn ) throws LdapInvalidDnException
{
this.schemaManager = schemaManager;
if ( dn == null )
{
return;
}
for ( Rdn rdn : dn.rdns )
{
this.rdns.add( new Rdn( schemaManager, rdn ) );
}
toUpName();
}
示例7: add
import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; //导入依赖的package包/类
/**
* Add a suffix to the Dn. For instance, if the current Dn is "ou=people",
* and the suffix "dc=example,dc=com", then the resulting Dn will be
* "ou=people,dc=example,dc=com"
*
* @param comp the suffix to add
* @return The resulting Dn with the additional suffix
* @throws LdapInvalidDnException If the resulting Dn is not valid
*/
public Dn add( String comp ) throws LdapInvalidDnException
{
if ( comp.length() == 0 )
{
return this;
}
Dn clonedDn = copy();
// We have to parse the nameComponent which is given as an argument
Rdn newRdn = new Rdn( schemaManager, comp );
clonedDn.rdns.add( 0, newRdn );
clonedDn.toUpName();
return clonedDn;
}
示例8: Rdn
import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; //导入依赖的package包/类
/**
* A constructor that parse a String representing a schema aware Rdn.
*
* @param schemaManager the schema manager
* @param rdn the String containing the Rdn to parse
* @throws LdapInvalidDnException if the Rdn is invalid
*/
public Rdn( SchemaManager schemaManager, String rdn ) throws LdapInvalidDnException
{
if ( Strings.isNotEmpty( rdn ) )
{
// Parse the string. The Rdn will be updated.
parse( schemaManager, rdn, this );
if ( upName.length() < rdn.length() )
{
throw new LdapInvalidDnException( "Invalid RDN" );
}
upName = rdn;
}
else
{
upName = "";
normName = "";
normalized = true;
}
hashCode();
}
示例9: isValid
import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; //导入依赖的package包/类
/**
* Validate a NameComponent : <br>
* <p>
* <name-component> ::= <attributeType> <spaces> '='
* <spaces> <attributeValue> <nameComponents>
* </p>
*
* @param dn The string to parse
* @return <code>true</code> if the Rdn is valid
*/
public static boolean isValid( String dn )
{
Rdn rdn = new Rdn();
try
{
parse( null, dn, rdn );
return true;
}
catch ( LdapInvalidDnException e )
{
return false;
}
}
示例10: testDnSetDn
import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; //导入依赖的package包/类
/**
* test the setDn() method
*/
@Test
public void testDnSetDn() throws LdapURLEncodingException, LdapInvalidDnException
{
LdapUrl url = new LdapUrl();
assertNull( url.getDn() );
Dn dn = new Dn( "dc=example,dc=com" );
url.setDn( dn );
assertEquals( dn, url.getDn() );
assertEquals( "ldap:///dc=example,dc=com", url.toString() );
url.setDn( null );
assertNull( url.getDn() );
assertEquals( "ldap:///", url.toString() );
}
示例11: testDnSetScope
import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; //导入依赖的package包/类
/**
* test the setScope() method
*/
@Test
public void testDnSetScope() throws LdapURLEncodingException, LdapInvalidDnException
{
LdapUrl url = new LdapUrl();
assertEquals( SearchScope.OBJECT, url.getScope() );
url.setDn( new Dn( "dc=example,dc=com" ) );
url.setScope( SearchScope.ONELEVEL );
assertEquals( SearchScope.ONELEVEL, url.getScope() );
assertEquals( "ldap:///dc=example,dc=com??one", url.toString() );
url.setScope( SearchScope.SUBTREE );
assertEquals( SearchScope.SUBTREE, url.getScope() );
assertEquals( "ldap:///dc=example,dc=com??sub", url.toString() );
url.setScope( -1 );
assertEquals( SearchScope.OBJECT, url.getScope() );
assertEquals( "ldap:///dc=example,dc=com", url.toString() );
}
示例12: testDnSetFilter
import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; //导入依赖的package包/类
/**
* test the setFilter() method
*/
@Test
public void testDnSetFilter() throws LdapURLEncodingException, LdapInvalidDnException
{
LdapUrl url = new LdapUrl();
assertNull( url.getFilter() );
url.setDn( new Dn( "dc=example,dc=com" ) );
url.setFilter( "(objectClass=person)" );
assertEquals( "(objectClass=person)", url.getFilter() );
assertEquals( "ldap:///dc=example,dc=com???(objectClass=person)", url.toString() );
url.setFilter( "(cn=Babs Jensen)" );
assertEquals( "(cn=Babs Jensen)", url.getFilter() );
assertEquals( "ldap:///dc=example,dc=com???(cn=Babs%20Jensen)", url.toString() );
url.setFilter( null );
assertNull( url.getFilter() );
assertEquals( "ldap:///dc=example,dc=com", url.toString() );
}
示例13: initNames
import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; //导入依赖的package包/类
/**
* Initialize name instances
*/
@Before
public void initNames() throws LdapInvalidDnException
{
Set<String> dnSetA = new HashSet<>();
dnSetA.add( new Dn( "a=aa" ).getNormName() );
dnSetA.add( new Dn( "b=bb" ).getNormName() );
Set<String> dnSetB = new HashSet<>();
dnSetB.add( new Dn( "b=bb" ).getNormName() );
dnSetB.add( new Dn( "a=aa" ).getNormName() );
Set<String> dnSetC = new HashSet<>();
dnSetC.add( new Dn( "a=aa" ).getNormName() );
dnSetC.add( new Dn( "b=bb" ).getNormName() );
Set<String> dnSetD = new HashSet<>();
dnSetD.add( new Dn( "b=bb" ).getNormName() );
dnSetD.add( new Dn( "c=cc" ).getNormName() );
nameA = new Name( dnSetA );
nameACopy = new Name( dnSetB );
nameB = new Name( dnSetC );
nameC = new Name( dnSetD );
}
示例14: DefaultEntry
import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; //导入依赖的package包/类
/**
* <p>
* Creates a new instance of DefaultEntry, schema aware.
* </p>
* <p>
* No attributes will be created.
* </p>
*
* @param schemaManager The reference to the schemaManager
* @param dn The String Dn for this serverEntry. Can be null.
* @throws LdapInvalidDnException If the Dn is invalid
*/
public DefaultEntry( SchemaManager schemaManager, String dn ) throws LdapInvalidDnException
{
this.schemaManager = schemaManager;
if ( Strings.isEmpty( dn ) )
{
this.dn = Dn.EMPTY_DN;
}
else
{
this.dn = new Dn( dn );
normalizeDN( this.dn );
}
// Initialize the ObjectClass object
initObjectClassAT();
}
示例15: createDefaultDefinition
import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; //导入依赖的package包/类
public static ServerDefinition createDefaultDefinition(AbstractLdapConfiguration configuration) {
ServerDefinition def = new ServerDefinition();
def.host = configuration.getHost();
def.port = configuration.getPort();
def.connectionSecurity = configuration.getConnectionSecurity();
def.sslProtocol = configuration.getSslProtocol();
def.enabledSecurityProtocols = configuration.getEnabledSecurityProtocols();
def.enabledCipherSuites = configuration.getEnabledCipherSuites();
def.authenticationType = configuration.getAuthenticationType();
def.bindDn = configuration.getBindDn();
def.bindPassword = configuration.getBindPassword();
def.connectTimeout = configuration.getConnectTimeout();
try {
def.baseContext = new Dn(configuration.getBaseContext());
} catch (LdapInvalidDnException e) {
throw new ConfigurationException("Wrong DN format in baseContext: "+e.getMessage(), e);
}
def.origin = Origin.CONFIGURATION;
return def;
}