javax.naming.NoPermissionException#org.apache.directory.api.ldap.model.exception.LdapInvalidDnException源码实例Demo

下面列出了javax.naming.NoPermissionException#org.apache.directory.api.ldap.model.exception.LdapInvalidDnException 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: directory-ldap-api   文件: AvaTest.java
@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] );
}
 
源代码2 项目: MyVirtualDirectory   文件: DefaultEntry.java
/**
 * <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();
}
 
源代码3 项目: directory-ldap-api   文件: UserClass_NameTest.java
/**
 * Initialize name instances
 */
@BeforeEach
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 );
}
 
源代码4 项目: directory-ldap-api   文件: Dn.java
/**
 * 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();
}
 
源代码5 项目: directory-ldap-api   文件: Dn.java
/**
 * Creates a Schema aware Dn from a list of Rdns.
 *
 * @param schemaManager The SchemaManager to use
 * @param rdns the list of Rdns to be used for the Dn
 * @throws LdapInvalidDnException If the resulting Dn is invalid
 */
public Dn( SchemaManager schemaManager, Rdn... rdns ) throws LdapInvalidDnException
{
    this.schemaManager = schemaManager;

    if ( rdns == null )
    {
        return;
    }

    for ( Rdn rdn : rdns )
    {
        if ( rdn.isSchemaAware() )
        {
            this.rdns.add( rdn );
        }
        else
        {
            this.rdns.add( new Rdn( schemaManager, rdn ) );
        }
    }

    toUpName();
}
 
源代码6 项目: directory-ldap-api   文件: Dn.java
/**
 * 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;
}
 
源代码7 项目: directory-ldap-api   文件: Rdn.java
/**
 * Validate a NameComponent : <br>
 * <p>
 * &lt;name-component&gt; ::= &lt;attributeType&gt; &lt;spaces&gt; '='
 * &lt;spaces&gt; &lt;attributeValue&gt; &lt;nameComponents&gt;
 * </p>
 *
 * @param schemaManager The Schemamanager to use
 * @param dn The string to parse
 * @return <code>true</code> if the Rdn is valid
 */
public static boolean isValid( SchemaManager schemaManager, String dn )
{
    Rdn rdn = new Rdn( schemaManager );

    try
    {
        parse( schemaManager, dn, rdn );

        return true;
    }
    catch ( LdapInvalidDnException e )
    {
        return false;
    }
}
 
/**
 * Tests for equality using different stub implementations.
 * @throws LdapInvalidDnException 
 */
@Test
public void testEqualsDiffImpl() throws LdapInvalidDnException
{
    ExtendedResponse resp0 = createStub();
    ExtendedResponse resp1 = new OpaqueExtendedResponse( 45, "1.1.1.1" );
    resp1.getLdapResult().setMatchedDn( new Dn( "dc=example,dc=com" ) );
    resp1.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
    ReferralImpl refs = new ReferralImpl();
    refs.addLdapUrl( "ldap://someserver.com" );
    refs.addLdapUrl( "ldap://apache.org" );
    refs.addLdapUrl( "ldap://another.net" );
    resp1.getLdapResult().setReferral( refs );

    assertTrue( resp0.equals( resp1 ) );
    assertTrue( resp1.equals( resp0 ) );
}
 
源代码9 项目: directory-ldap-api   文件: LdapUrlTest.java
/**
 * 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() );
}
 
源代码10 项目: directory-ldap-api   文件: LdapUrlTest.java
/**
 * 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() );
}
 
源代码11 项目: directory-ldap-api   文件: RdnTest.java
/**
 * test that a RDN with an attributeType used twice with the same value
 * throws an exception
 */
@Test
public void testWrongRdnAtUsedTwiceSameValue() throws LdapException
{
    assertThrows( LdapInvalidDnException.class, () ->
    {
        new Rdn( schemaManager, " cn = b + cn = b " );
    } );
}
 
源代码12 项目: directory-ldap-api   文件: DnTest.java
/**
 * Get the prefix out of bound
 */
@Test
public void testDnGetPrefixPos4() throws LdapException
{
    Dn dn = new Dn( "a=b, c=d,e = f" );

    assertThrows( LdapInvalidDnException.class, () ->
    {
        dn.getAncestorOf( "a=z" );
    } );
}
 
/**
 * {@inheritDoc}
 */
public void action( LdapMessageContainer<SearchResultEntry> container ) throws DecoderException
{
    SearchResultEntry searchResultEntry = container.getMessage();

    TLV tlv = container.getCurrentTLV();

    // Store the value.
    if ( tlv.getLength() == 0 )
    {
        searchResultEntry.setObjectName( Dn.EMPTY_DN );
    }
    else
    {
        byte[] dnBytes = tlv.getValue().getData();
        String dnStr = Strings.utf8ToString( dnBytes );

        try
        {
            Dn objectName = new Dn( dnStr );
            searchResultEntry.setObjectName( objectName );
        }
        catch ( LdapInvalidDnException ine )
        {
            // This is for the client side. We will never decode LdapResult on the server
            String msg = I18n.err( I18n.ERR_05157_INVALID_DN, Strings.dumpBytes( dnBytes ), ine.getMessage() );
            LOG.error( I18n.err( I18n.ERR_05114_ERROR_MESSAGE, msg, ine.getMessage() ) );
            throw new DecoderException( msg, ine );
        }
    }

    if ( LOG.isDebugEnabled() )
    {
        LOG.debug( I18n.msg( I18n.MSG_05182_SEARCH_RESULT_ENTRY_DN, searchResultEntry.getObjectName() ) );
    }
}
 
源代码14 项目: directory-ldap-api   文件: DnTest.java
@Test
@Disabled
public void testDnParsingOneRdnPerf() throws LdapInvalidDnException
{
    long t0 = System.currentTimeMillis();
    
    for ( int i = 0; i < 1000000; i++ )
    {
        new Dn( "dc=example" + i );
    }
    
    long t1 = System.currentTimeMillis();
    System.out.println( "delta new 1 RDN : " + ( t1 - t0 ) );
}
 
源代码15 项目: directory-ldap-api   文件: AvaTest.java
@Test
public void testCompareToSameAva() throws LdapInvalidDnException
{
    Ava atav1 = new Ava( schemaManager, "cn", "b" );
    Ava atav2 = new Ava( schemaManager, "cn", "b" );
    Ava atav3 = new Ava( schemaManager, "commonName", "b" );
    Ava atav4 = new Ava( schemaManager, "2.5.4.3", "  B  " );

    // 1 with others
    assertEquals( 0, atav1.compareTo( atav1 ) );
    assertEquals( 0, atav1.compareTo( atav2 ) );
    assertEquals( 0, atav1.compareTo( atav3 ) );
    assertEquals( 0, atav1.compareTo( atav4 ) );
    
    // 2 with others
    assertEquals( 0, atav2.compareTo( atav1 ) );
    assertEquals( 0, atav2.compareTo( atav2 ) );
    assertEquals( 0, atav2.compareTo( atav3 ) );
    assertEquals( 0, atav2.compareTo( atav4 ) );
    
    // 3 with others
    assertEquals( 0, atav3.compareTo( atav1 ) );
    assertEquals( 0, atav3.compareTo( atav2 ) );
    assertEquals( 0, atav3.compareTo( atav3 ) );
    assertEquals( 0, atav3.compareTo( atav4 ) );
    
    // 4 with others
    assertEquals( 0, atav4.compareTo( atav1 ) );
    assertEquals( 0, atav4.compareTo( atav2 ) );
    assertEquals( 0, atav4.compareTo( atav3 ) );
    assertEquals( 0, atav4.compareTo( atav4 ) );
}
 
源代码16 项目: directory-ldap-api   文件: DnNode.java
/**
 * update the children's Dn based on the new parent Dn created
 * after a rename or move operation
 * 
 * @param newParentDn The new parent's Dn
 * @throws LdapInvalidDnException The parent DN is invalid
 */
private synchronized void updateAfterModDn( Dn newParentDn ) throws LdapInvalidDnException
{
    if ( children != null )
    {
        for ( DnNode<N> child : children.values() )
        {
            child.nodeDn = newParentDn.add( child.nodeRdn );
            child.updateAfterModDn( child.nodeDn );
        }
    }
}
 
源代码17 项目: directory-ldap-api   文件: Dsmlv2ResponseGrammar.java
/**
 * {@inheritDoc}
 */
@Override
public void action( Dsmlv2Container container ) throws XmlPullParserException
{
    AddResponseDsml addResponse = new AddResponseDsml(
        container.getLdapCodecService(), new AddResponseImpl() );
    container.getBatchResponse().addResponse( addResponse );

    LdapResult ldapResult = addResponse.getLdapResult();

    XmlPullParser xpp = container.getParser();

    // Checking and adding the batchRequest's attributes
    String attributeValue;
    // requestID
    attributeValue = xpp.getAttributeValue( "", "requestID" );

    if ( attributeValue != null )
    {
        addResponse.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
    }

    // MatchedDN
    attributeValue = xpp.getAttributeValue( "", "matchedDN" );

    if ( attributeValue != null )
    {
        try
        {
            ldapResult.setMatchedDn( new Dn( attributeValue ) );
        }
        catch ( LdapInvalidDnException lide )
        {
            throw new XmlPullParserException( lide.getMessage(), xpp, lide );
        }
    }
}
 
源代码18 项目: directory-ldap-api   文件: Dsmlv2ResponseGrammar.java
/**
 * {@inheritDoc}
 */
@Override
public void action( Dsmlv2Container container ) throws XmlPullParserException
{
    BindResponseDsml bindResponse = new BindResponseDsml(
        container.getLdapCodecService(), new BindResponseImpl() );
    container.getBatchResponse().addResponse( bindResponse );

    LdapResult ldapResult = bindResponse.getLdapResult();

    XmlPullParser xpp = container.getParser();

    // Checking and adding the batchRequest's attributes
    String attributeValue;
    // requestID
    attributeValue = xpp.getAttributeValue( "", "requestID" );

    if ( attributeValue != null )
    {
        bindResponse.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );

    }

    // MatchedDN
    attributeValue = xpp.getAttributeValue( "", "matchedDN" );

    if ( attributeValue != null )
    {
        try
        {
            ldapResult.setMatchedDn( new Dn( attributeValue ) );
        }
        catch ( LdapInvalidDnException lide )
        {
            throw new XmlPullParserException( lide.getMessage(), xpp, lide );
        }
    }
}
 
源代码19 项目: directory-ldap-api   文件: Dsmlv2ResponseGrammar.java
/**
 * {@inheritDoc}
 */
@Override
public void action( Dsmlv2Container container ) throws XmlPullParserException
{
    ModifyResponseDsml modifyResponse = new ModifyResponseDsml(
        container.getLdapCodecService(), new ModifyResponseImpl() );
    container.getBatchResponse().addResponse( modifyResponse );

    LdapResult ldapResult = modifyResponse.getLdapResult();

    XmlPullParser xpp = container.getParser();

    // Checking and adding the batchRequest's attributes
    String attributeValue;
    // requestID
    attributeValue = xpp.getAttributeValue( "", "requestID" );

    if ( attributeValue != null )
    {
        modifyResponse.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
    }

    // MatchedDN
    attributeValue = xpp.getAttributeValue( "", "matchedDN" );

    if ( attributeValue != null )
    {
        try
        {
            ldapResult.setMatchedDn( new Dn( attributeValue ) );
        }
        catch ( LdapInvalidDnException lide )
        {
            throw new XmlPullParserException( lide.getMessage(), xpp, lide );
        }
    }
}
 
源代码20 项目: directory-ldap-api   文件: Dsmlv2ResponseGrammar.java
/**
 * {@inheritDoc}
 */
@Override
public void action( Dsmlv2Container container ) throws XmlPullParserException
{
    ModDNResponseDsml modDNResponse = new ModDNResponseDsml(
        container.getLdapCodecService(), new ModifyDnResponseImpl() );
    container.getBatchResponse().addResponse( modDNResponse );

    LdapResult ldapResult = modDNResponse.getLdapResult();

    XmlPullParser xpp = container.getParser();

    // Checking and adding the batchRequest's attributes
    String attributeValue;
    // requestID
    attributeValue = xpp.getAttributeValue( "", "requestID" );

    if ( attributeValue != null )
    {
        modDNResponse.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
    }

    // MatchedDN
    attributeValue = xpp.getAttributeValue( "", "matchedDN" );

    if ( attributeValue != null )
    {
        try
        {
            ldapResult.setMatchedDn( new Dn( attributeValue ) );
        }
        catch ( LdapInvalidDnException lide )
        {
            throw new XmlPullParserException( lide.getMessage(), xpp, lide );
        }
    }
}
 
源代码21 项目: directory-ldap-api   文件: Dsmlv2ResponseGrammar.java
/**
 * {@inheritDoc}
 */
@Override
public void action( Dsmlv2Container container ) throws XmlPullParserException
{
    SearchResultDoneDsml searchResultDone =
        new SearchResultDoneDsml( container.getLdapCodecService(),
            new SearchResultDoneImpl() );

    SearchResponseDsml searchResponseDsml = ( SearchResponseDsml )
        container.getBatchResponse().getCurrentResponse();
    searchResponseDsml.addResponse( searchResultDone );

    XmlPullParser xpp = container.getParser();

    // Checking and adding the batchRequest's attributes
    String attributeValue;
    // requestID
    attributeValue = xpp.getAttributeValue( "", "requestID" );

    if ( attributeValue != null )
    {
        searchResultDone.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
    }

    // MatchedDN
    attributeValue = xpp.getAttributeValue( "", "matchedDN" );

    if ( attributeValue != null )
    {
        try
        {
            searchResultDone.getLdapResult().setMatchedDn( new Dn( attributeValue ) );
        }
        catch ( LdapInvalidDnException lide )
        {
            throw new XmlPullParserException( lide.getMessage(), xpp, lide );
        }
    }
}
 
源代码22 项目: directory-fortress-core   文件: LdapDataProvider.java
/**
 * Method will retrieve the relative distinguished name from a distinguished name variable.
 *
 * @param dn contains ldap distinguished name.
 * @return rDn as string.
 */
protected String getRdn( String dn )
{
    try
    {
        return new Dn( dn ).getRdn().getName();
    }
    catch ( LdapInvalidDnException lide )
    {
        return null;
    }
}
 
源代码23 项目: directory-ldap-api   文件: ImmutableEntry.java
/**
 * {@inheritDoc}
 */
@Override
public void setDn( String dn ) throws LdapInvalidDnException
{
    new Exception().printStackTrace();
    throw new NotImplementedException( I18n.err( I18n.ERR_13239_ENTRY_IMMUTABLE_CANT_RENAME_ENTRY, entry.getDn() ) );
}
 
源代码24 项目: directory-ldap-api   文件: LdifRevertor.java
/**
 * A small helper class to compute the simple revert.
 * 
 * @param entry The entry to revert
 * @param newDn The new Dn
 * @param newSuperior The new superior, if it has changed (null otherwise)
 * @param oldRdn The old Rdn
 * @param newRdn The new RDN if the RDN has changed
 * @return The reverted entry
 * @throws LdapInvalidDnException If the Dn is invalid
 */
private static LdifEntry revertEntry( Entry entry, Dn newDn, Dn newSuperior, Rdn oldRdn, Rdn newRdn )
    throws LdapInvalidDnException
{
    LdifEntry reverted = new LdifEntry();

    // We have a composite old Rdn, something like A=a+B=b
    // It does not matter if the RDNs overlap
    reverted.setChangeType( ChangeType.ModRdn );

    if ( newSuperior != null )
    {
        Dn restoredDn = newSuperior.add( newRdn );
        reverted.setDn( restoredDn );
    }
    else
    {
        reverted.setDn( newDn );
    }

    reverted.setNewRdn( oldRdn.getName() );

    // Is the newRdn's value present in the entry ?
    // ( case 3, 4 and 5)
    // If keepOldRdn = true, we cover case 4 and 5
    boolean keepOldRdn = entry.contains( newRdn.getNormType(), newRdn.getValue() );

    reverted.setDeleteOldRdn( !keepOldRdn );

    if ( newSuperior != null )
    {
        Dn oldSuperior = entry.getDn();

        oldSuperior = oldSuperior.getParent();
        reverted.setNewSuperior( oldSuperior.getName() );
    }

    return reverted;
}
 
源代码25 项目: directory-ldap-api   文件: LdapNetworkConnection.java
/**
 * deletes the entry with the given Dn, and all its children
 *
 * @param dn the target entry's Dn as a String
 * @throws LdapException If the Dn is not valid or if the deletion failed
 */
public void deleteTree( String dn ) throws LdapException
{
    try
    {
        String treeDeleteOid = "1.2.840.113556.1.4.805";
        Dn newDn = new Dn( dn );

        if ( isControlSupported( treeDeleteOid ) )
        {
            DeleteRequest deleteRequest = new DeleteRequestImpl();
            deleteRequest.setName( newDn );
            deleteRequest.addControl( new OpaqueControl( treeDeleteOid ) );
            DeleteResponse deleteResponse = delete( deleteRequest );

            processResponse( deleteResponse );
        }
        else
        {
            String msg = I18n.err( I18n.ERR_04148_SUBTREE_CONTROL_NOT_SUPPORTED );
            LOG.error( msg );
            throw new LdapException( msg );
        }
    }
    catch ( LdapInvalidDnException e )
    {
        LOG.error( e.getMessage(), e );
        throw new LdapException( e.getMessage(), e );
    }
}
 
源代码26 项目: directory-ldap-api   文件: DnParserTest.java
/**
 * test exception from illegal hexString attribute value : a=#zz.
 */
@Test
public void testBadLdapDNHexStringAttributeValue() throws LdapException
{
    try
    {
        new Dn( "a=#zz" );
        fail();
    }
    catch ( LdapInvalidDnException ine )
    {
        assertTrue( true );
    }
}
 
源代码27 项目: directory-ldap-api   文件: Ava.java
/**
 * Construct an Ava. The type and value are normalized :
 * <ul>
 *   <li> the type is trimmed and lowercased </li>
 *   <li> the value is trimmed </li>
 * </ul>
 * <p>
 * Note that the upValue should <b>not</b> be null or empty, or resolved
 * to an empty string after having trimmed it.
 *
 * @param schemaManager The SchemaManager
 * @param upType The User Provided type
 * @param normType The normalized type
 * @param value The value
 * 
 * @throws LdapInvalidDnException If the given type or value are invalid
 */
// WARNING : The protection level is left unspecified intentionally.
// We need this method to be visible from the DnParser class, but not
// from outside this package.
/* Unspecified protection */Ava( SchemaManager schemaManager, String upType, String normType, Value value )
    throws LdapInvalidDnException
{
    StringBuilder sb = new StringBuilder();

    this.upType = upType;
    this.normType = normType;
    this.value = value;
    
    sb.append( upType );
    sb.append( '=' );
    
    if ( ( value != null ) && ( value.getString() != null ) )
    {
        sb.append( value.getString() );
    }
    
    upName = sb.toString();

    if ( schemaManager != null )
    {
        apply( schemaManager );
    }

    hashCode();
}
 
源代码28 项目: directory-ldap-api   文件: Dn.java
/**
 * Creates a Dn from a list of Rdns.
 *
 * @param rdns the list of Rdns to be used for the Dn
 * @throws LdapInvalidDnException If the resulting Dn is invalid
 */
public Dn( Rdn... rdns ) throws LdapInvalidDnException
{
    if ( rdns == null )
    {
        return;
    }

    for ( Rdn rdn : rdns )
    {
        this.rdns.add( rdn );
    }

    toUpName();
}
 
源代码29 项目: directory-ldap-api   文件: RdnTest.java
@Test
public void testAvaConstructor() throws LdapInvalidDnException
{
    Rdn rdn = new Rdn( new Ava( "CN", "\u00E4" ), new Ava( "A", "d" ) );
    assertEquals( "CN=\u00E4+A=d", rdn.getName() );
    assertEquals( "\u00E4", rdn.getValue( "CN" ) );
    assertEquals( "\u00E4", rdn.getValue() );
    assertEquals( "CN", rdn.getType() );
    assertEquals( "cn", rdn.getNormType() );
}
 
源代码30 项目: directory-ldap-api   文件: Dn.java
/**
 * Tells if the current Dn is a parent of another Dn.<br>
 * For instance, <b>dc=com</b> is a ancestor
 * of <b>dc=example, dc=com</b>
 *
 * @param dn The child
 * @return true if the current Dn is a parent of the given Dn
 */
public boolean isAncestorOf( String dn )
{
    try
    {
        return isAncestorOf( new Dn( dn ) );
    }
    catch ( LdapInvalidDnException lide )
    {
        return false;
    }
}