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


Java Dn类代码示例

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


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

示例1: modifyEntry

import org.apache.directory.api.ldap.model.name.Dn; //导入依赖的package包/类
/**
 * 修改条目(准确是修改条目的属性)。可包括如下操作。
 *   1. ModificationOperation.ADD_ATTRIBUTE:    添加属性  
 *   2. ModificationOperation.REMOVE_ATTRIBUTE: 删除属性
 *   3. ModificationOperation.REPLACE_ATTRIBUTE:替换属性值
 * 
 * @author      ZhengWei(HY)
 * @createDate  2017-02-16
 * @version     v1.0
 *
 * @param i_Operation       操作类型
 * @param i_DN              DN标识
 * @param i_AttributeName   属性名称
 * @param i_AttributeValue  属性值(可为多个)
 * @return
 */
private boolean modifyEntry(ModificationOperation i_Operation ,String i_DN ,String i_AttributeName ,String ... i_AttributeValue)
{
    LdapConnection v_Conn     = null;
    ModifyRequest  v_Request  = new ModifyRequestImpl();
    ModifyResponse v_Response = null;
    
    try
    {
        v_Request.setName(new Dn(i_DN));
        v_Request.addModification(new DefaultModification(i_Operation ,i_AttributeName ,i_AttributeValue));
        
        v_Conn = this.getConnection();
        v_Response = v_Conn.modify(v_Request);
    }
    catch (Exception exce)
    {
        exce.printStackTrace();
    }
    finally
    {
        this.closeConnection(v_Conn);
    }
    
    return LDAP.isSuccess(v_Response);
}
 
开发者ID:HY-ZhengWei,项目名称:hy.common.ldap,代码行数:42,代码来源:LDAP.java

示例2: testLdapURLExtensionWithRFC3986UnreservedChars

import org.apache.directory.api.ldap.model.name.Dn; //导入依赖的package包/类
/**
 * Test with RFC 3986 unreserved characters in extension value.
 *
 *   unreserved  = ALPHA / DIGIT / "-" / "." / "_" / "~"
 */
@Test
public void testLdapURLExtensionWithRFC3986UnreservedChars() throws Exception
{
    LdapUrl url1 = new LdapUrl();
    url1.setHost( "localhost" );
    url1.setPort( 123 );
    url1.setDn( Dn.EMPTY_DN );
    url1.getExtensions().add(
        new Extension( false, "X-CONNECTION-NAME",
            "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~" ) );
    assertEquals(
        "ldap://localhost:123/????X-CONNECTION-NAME=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",
        url1.toString() );

    LdapUrl url2 = new LdapUrl(
        "ldap://localhost:123/????X-CONNECTION-NAME=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~" );
    assertEquals( "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~", url1
        .getExtensionValue( "X-CONNECTION-NAME" ) );
    assertEquals(
        "ldap://localhost:123/????X-CONNECTION-NAME=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",
        url2.toString() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:28,代码来源:LdapUrlTest.java

示例3: testReverseDel

import org.apache.directory.api.ldap.model.name.Dn; //导入依赖的package包/类
/**
 * Test a DelRequest reverse
 * @throws LdapException
 */
@Test
public void testReverseDel() throws LdapException
{
    Dn dn = new Dn( "dc=apache, dc=com" );

    Entry deletedEntry = new DefaultEntry( dn ,
        "objectClass: top",
        "objectClass: person",
        "cn: test",
        "sn: apache",
        "dc: apache" );

    LdifEntry reversed = LdifRevertor.reverseDel( dn, deletedEntry );

    assertNotNull( reversed );
    assertEquals( dn.getName(), reversed.getDn().getName() );
    assertEquals( ChangeType.Add, reversed.getChangeType() );
    assertNotNull( reversed.getEntry() );
    assertEquals( deletedEntry, reversed.getEntry() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:25,代码来源:LdifRevertorTest.java

示例4: createStub

import org.apache.directory.api.ldap.model.name.Dn; //导入依赖的package包/类
/**
 * Creates and populates a ExtendedResponseImpl stub for testing purposes.
 * 
 * @return a populated ExtendedResponseImpl stub
 */
private ExtendedResponseImpl createStub()
{
    // Construct the Search response to test with results and referrals
    ExtendedResponseImpl response = new ExtendedResponseImpl( 45 );
    response.setResponseName( "1.1.1.1" );
    LdapResult result = response.getLdapResult();

    try
    {
        result.setMatchedDn( new Dn( "dc=example,dc=com" ) );
    }
    catch ( LdapException ine )
    {
        // Do nothing
    }

    result.setResultCode( ResultCodeEnum.SUCCESS );
    ReferralImpl refs = new ReferralImpl();
    refs.addLdapUrl( "ldap://someserver.com" );
    refs.addLdapUrl( "ldap://apache.org" );
    refs.addLdapUrl( "ldap://another.net" );
    result.setReferral( refs );
    return response;
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:30,代码来源:ExtendedResponseImplTest.java

示例5: BaseSubtreeSpecification

import org.apache.directory.api.ldap.model.name.Dn; //导入依赖的package包/类
/**
 * Creates a subtree which may be a refinement filter where all aspects of
 * the specification can be set. If the refinement filter is null this
 * defaults to {@link #BaseSubtreeSpecification(org.apache.directory.api.ldap.model.name.Dn, int, int, Set, Set)}.
 *
 * @param base the base of the subtree relative to the administrative point
 * @param minBaseDistance the minimum distance below base to start including entries
 * @param maxBaseDistance the maximum distance from base past which entries are excluded
 * @param chopAfter the set of subordinates entries whose subordinates are to be
 * excluded
 * @param chopBefore the set of subordinates entries and their subordinates to
 * exclude
 * @param refinement the filter expression only composed of objectClass attribute
 * value assertions
 */
public BaseSubtreeSpecification( Dn base, int minBaseDistance, int maxBaseDistance,
    Set<Dn> chopAfter, Set<Dn> chopBefore, ExprNode refinement )
{
    this.base = base;
    this.minBaseDistance = minBaseDistance;

    if ( maxBaseDistance < 0 )
    {
        this.maxBaseDistance = UNBOUNDED_MAX;
    }
    else
    {
        this.maxBaseDistance = maxBaseDistance;
    }

    this.chopAfter = chopAfter;
    this.chopBefore = chopBefore;
    this.refinement = refinement;
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:35,代码来源:BaseSubtreeSpecification.java

示例6: testSpecWithSpecificExclusions

import org.apache.directory.api.ldap.model.name.Dn; //导入依赖的package包/类
/**
 * Tests the parser with a valid specification with some specific exclusions
 * set.
 */
@Test
public void testSpecWithSpecificExclusions() throws Exception
{
    SubtreeSpecification ss = parser.parse( SPEC_WITH_SPECIFICEXCLUSIONS );
    assertFalse( ss.getChopBeforeExclusions().isEmpty() );
    assertFalse( ss.getChopAfterExclusions().isEmpty() );
    assertTrue( ss.getChopBeforeExclusions().contains( new Dn( schemaManager, "cn=cd" ) ) );
    assertTrue( ss.getChopAfterExclusions().contains( new Dn( schemaManager, "cn=gh" ) ) );

    // try a second time
    ss = parser.parse( SPEC_WITH_SPECIFICEXCLUSIONS );
    assertFalse( ss.getChopBeforeExclusions().isEmpty() );
    assertFalse( ss.getChopAfterExclusions().isEmpty() );
    assertTrue( ss.getChopBeforeExclusions().contains( new Dn( schemaManager, "cn=cd" ) ) );
    assertTrue( ss.getChopAfterExclusions().contains( new Dn( schemaManager, "cn=gh" ) ) );

    // try a third time
    ss = parser.parse( SPEC_WITH_SPECIFICEXCLUSIONS );
    assertFalse( ss.getChopBeforeExclusions().isEmpty() );
    assertFalse( ss.getChopAfterExclusions().isEmpty() );
    assertTrue( ss.getChopBeforeExclusions().contains( new Dn( schemaManager, "cn=cd" ) ) );
    assertTrue( ss.getChopAfterExclusions().contains( new Dn( schemaManager, "cn=gh" ) ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:28,代码来源:SubtreeSpecificationParserTest.java

示例7: testHasParentDN

import org.apache.directory.api.ldap.model.name.Dn; //导入依赖的package包/类
@Test
public void testHasParentDN() throws Exception
{
    DnNode<Dn> tree = new DnNode<Dn>();
    Dn dn1 = new Dn( "dc=c,dc=b,dc=a" );
    tree.add( dn1, dn1 );

    Dn dn2 = new Dn( "dc=e,dc=a" );
    tree.add( dn2, dn2 );

    assertFalse( tree.hasParent( Dn.EMPTY_DN ) );

    DnNode<Dn> child = tree.getChild( new Rdn( "dc=a" ) );
    assertTrue( tree.hasParent( new Dn( "dc=a" ) ) );

    child = child.getChild( new Rdn( "dc=b" ) );
    assertTrue( tree.hasParent( new Dn( "dc=b,dc=a" ) ) );

    child = child.getChild( new Rdn( "dc=c" ) );
    assertTrue( tree.hasParent( new Dn( "dc=c,dc=b,dc=a" ) ) );

    assertTrue( tree.hasParent( new Dn( "dc=f,dc=e,dc=c,dc=b,dc=a" ) ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:24,代码来源:TestDnNode.java

示例8: search

import org.apache.directory.api.ldap.model.name.Dn; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public EntryCursor search( Dn baseDn, String filter, SearchScope scope, String... attributes )
    throws LdapException
{
    if ( baseDn == null )
    {
        LOG.debug( "received a null dn for a search" );
        throw new IllegalArgumentException( "The base Dn cannot be null" );
    }

    // Create a new SearchRequest object
    SearchRequest searchRequest = new SearchRequestImpl();

    searchRequest.setBase( baseDn );
    searchRequest.setFilter( filter );
    searchRequest.setScope( scope );
    searchRequest.addAttributes( attributes );
    searchRequest.setDerefAliases( AliasDerefMode.DEREF_ALWAYS );

    // Process the request in blocking mode
    return new EntryCursorImpl( search( searchRequest ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:26,代码来源:LdapNetworkConnection.java

示例9: testLdapDNSimple

import org.apache.directory.api.ldap.model.name.Dn; //导入依赖的package包/类
/**
 * test a simple Dn : a = b
 */
@Test
public void testLdapDNSimple() throws LdapException
{
    Dn dn = FastDnParser.parse( "a = b" );

    assertEquals( "a = b", dn.getName() );
    assertEquals( "a=b", dn.getEscaped() );
    assertEquals( "a = b", dn.toString() );

    assertEquals( "a = b", dn.getRdn().getName() );
    assertEquals( "a=b", dn.getRdn().getEscaped() );

    assertEquals( "a=b", dn.getRdn().getAva().getName() );
    assertEquals( "a=b", dn.getRdn().getAva().getEscaped() );

    assertEquals( "a", dn.getRdn().getAva().getType() );
    assertEquals( "a", dn.getRdn().getAva().getNormType() );
    assertEquals( "b", dn.getRdn().getAva().getValue().getValue() );
    assertEquals( "b", dn.getRdn().getAva().getValue().getValue() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:24,代码来源:FastDnParserTest.java

示例10: testEqualsExactCopy

import org.apache.directory.api.ldap.model.name.Dn; //导入依赖的package包/类
/**
 * Tests for equality using exact copies.
 */
@Test
public void testEqualsExactCopy() throws LdapException
{
    BindRequestImpl req0 = new BindRequestImpl();
    req0.setMessageId( 5 );
    req0.setCredentials( PASSWORD );
    req0.setDn( new Dn( "cn=admin,dc=example,dc=com" ) );
    req0.setSimple( true );
    req0.setVersion3( true );

    BindRequestImpl req1 = new BindRequestImpl();
    req1.setMessageId( 5 );
    req1.setCredentials( PASSWORD );
    req1.setDn( new Dn( "cn=admin,dc=example,dc=com" ) );
    req1.setSimple( true );
    req1.setVersion3( true );

    assertTrue( req0.equals( req1 ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:23,代码来源:BindRequestImplTest.java

示例11: testSize

import org.apache.directory.api.ldap.model.name.Dn; //导入依赖的package包/类
@Test
public void testSize() throws LdapException
{
    DnNode<Dn> tree = new DnNode<Dn>();
    assertEquals( 1, tree.size() );

    tree.add( new Dn( "dc=b,dc=a" ) );
    assertEquals( 3, tree.size() );

    tree.add( new Dn( "dc=f,dc=a" ) );
    assertEquals( 4, tree.size() );

    tree.add( new Dn( "dc=a,dc=f,dc=a" ) );
    assertEquals( 5, tree.size() );

    tree.add( new Dn( "dc=b,dc=f,dc=a" ) );
    assertEquals( 6, tree.size() );

    tree.add( new Dn( "dc=z,dc=t" ) );
    assertEquals( 8, tree.size() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:22,代码来源:TestDnNode.java

示例12: DefaultSchemaManager

import org.apache.directory.api.ldap.model.name.Dn; //导入依赖的package包/类
/**
 * Creates a new instance of DefaultSchemaManager with the default schema schemaLoader
 * 
 * @param schemas The list of schema to load
 */
public DefaultSchemaManager( Collection<Schema> schemas )
{
    // Default to the the root (one schemaManager for all the entries
    namingContext = Dn.ROOT_DSE;
    
    for ( Schema schema : schemas )
    {
        schemaMap.put( schema.getSchemaName(), schema );
    }
    
    errors = new ArrayList<>();
    registries = new Registries();
    factory = new SchemaEntityFactory();
    isRelaxed = STRICT;
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:21,代码来源:DefaultSchemaManager.java

示例13: testDnSetFilter

import org.apache.directory.api.ldap.model.name.Dn; //导入依赖的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() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:24,代码来源:LdapUrlTest.java

示例14: normalizeDn

import org.apache.directory.api.ldap.model.name.Dn; //导入依赖的package包/类
/**
 * normalizes the given Dn if it was not already normalized
 *
 * @param dn the Dn to be normalized
 */
private Dn normalizeDn( Dn dn )
{
    if ( !dn.isSchemaAware() )
    {
        try
        {
            // The dn must be normalized
            return new Dn( schemaManager, dn );
        }
        catch ( LdapException ne )
        {
            LOG.warn( "The Dn '{}' cannot be normalized", dn );
            
            return dn;
        }
    }
    else
    {
        return dn;
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:27,代码来源:DefaultEntry.java

示例15: test11ReverseRenameSimpleSimpleNotOverlappingKeepOldRdnDontExistInEntry

import org.apache.directory.api.ldap.model.name.Dn; //导入依赖的package包/类
/**
 * Test a reversed rename ModifyDN, where the Rdn are both simple, not overlapping,
 * with deleteOldRdn = false, and the Ava not present in the initial entry?
 * 
 * Covers case 1.1 of http://cwiki.apache.org/confluence/display/DIRxSRVx11/Reverse+LDIF
 * 
 * Initial entry
 * dn: cn=test,ou=system
 * objectclass: top
 * objectclass: person
 * cn: test
 * sn: This is a test
 * 
 * new Rdn : cn=joe
 *
 * @throws LdapException on error
 */
@Test
public void test11ReverseRenameSimpleSimpleNotOverlappingKeepOldRdnDontExistInEntry() throws LdapException
{
    Dn dn = new Dn( "cn=test,ou=system" );
    Rdn oldRdn = new Rdn( "cn=test" );
    Rdn newRdn = new Rdn( "cn=joe" );

    Entry entry = new DefaultEntry( dn,
        "objectClass: top",
        "objectClass: person",
        "cn: test",
        "sn: this is a test" );

    List<LdifEntry> reverseds = LdifRevertor.reverseRename( entry, newRdn, LdifRevertor.KEEP_OLD_RDN );

    assertNotNull( reverseds );
    assertEquals( 1, reverseds.size() );
    LdifEntry reversed = reverseds.get( 0 );

    assertEquals( "cn=joe,ou=system", reversed.getDn().getName() );
    assertEquals( ChangeType.ModRdn, reversed.getChangeType() );
    assertTrue( reversed.isDeleteOldRdn() );
    assertEquals( oldRdn.getName(), reversed.getNewRdn() );
    assertNull( reversed.getNewSuperior() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:43,代码来源:LdifRevertorTest.java


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