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


Java LdifEntry类代码示例

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


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

示例1: testReverseDel

import org.apache.directory.api.ldap.model.ldif.LdifEntry; //导入依赖的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

示例2: testReverseModifyDNMove

import org.apache.directory.api.ldap.model.ldif.LdifEntry; //导入依赖的package包/类
/**
 * Test a reversed move ModifyDN
 *
 * @throws LdapException on error
 */
@Test
public void testReverseModifyDNMove() throws LdapException
{
    Dn dn = new Dn( "cn=john doe, dc=example, dc=com" );
    Dn newSuperior = new Dn( "ou=system" );
    Rdn rdn = new Rdn( "cn=john doe" );

    LdifEntry reversed = LdifRevertor.reverseMove( newSuperior, dn );

    assertNotNull( reversed );

    assertEquals( "cn=john doe,ou=system", reversed.getDn().getName() );
    assertEquals( ChangeType.ModDn, reversed.getChangeType() );
    assertFalse( reversed.isDeleteOldRdn() );
    assertEquals( rdn.getName(), reversed.getNewRdn() );
    assertEquals( "dc=example, dc=com", Strings.trim( reversed.getNewSuperior() ) );
    assertNull( reversed.getEntry() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:24,代码来源:LdifRevertorTest.java

示例3: test21ReverseRenameSimpleSimpleNotOverlappingDeleteOldRdnDontExistInEntry

import org.apache.directory.api.ldap.model.ldif.LdifEntry; //导入依赖的package包/类
/**
 * Test a reversed rename ModifyDN, where the Rdn are both simple, not overlapping,
 * with deleteOldRdn = true, and the Ava not present in the initial entry
 * 
 * Covers case 2.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 test21ReverseRenameSimpleSimpleNotOverlappingDeleteOldRdnDontExistInEntry() 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.DELETE_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

示例4: createPrincipal

import org.apache.directory.api.ldap.model.ldif.LdifEntry; //导入依赖的package包/类
/**
 * Creates a principal in the KDC with the specified user and password.
 *
 * @param principal principal name, do not include the domain.
 * @param password password.
 * @throws Exception thrown if the principal could not be created.
 */
public synchronized void createPrincipal(String principal, String password) throws Exception {
    String orgName = conf.getProperty(ORG_NAME);
    String orgDomain = conf.getProperty(ORG_DOMAIN);
    String baseDn = "ou=users,dc=" + orgName.toLowerCase(Locale.ENGLISH) + ",dc="
            + orgDomain.toLowerCase(Locale.ENGLISH);
    String content = "dn: uid=" + principal + "," + baseDn + "\n" + "objectClass: top\n" + "objectClass: person\n"
            + "objectClass: inetOrgPerson\n" + "objectClass: krb5principal\n" + "objectClass: krb5kdcentry\n"
            + "cn: " + principal + "\n" + "sn: " + principal + "\n" + "uid: " + principal + "\n" + "userPassword: "
            + password + "\n" + "krb5PrincipalName: " + principal + "@" + getRealm() + "\n"
            + "krb5KeyVersionNumber: 0";

    for (LdifEntry ldifEntry : new LdifReader(new StringReader(content))) {
        ds.getAdminSession().add(new DefaultEntry(ds.getSchemaManager(), ldifEntry.getEntry()));
    }
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:23,代码来源:MiniKdc.java

示例5: testSimpleLdifEntry

import org.apache.directory.api.ldap.model.ldif.LdifEntry; //导入依赖的package包/类
/**
 * Test a simple LdifEntry
 * @throws Exception
 */
@Test
public void testSimpleLdifEntry() throws Exception
{
    String cn = "app1";

    LdifEntry ldifEntry = new LdifEntry( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org",
        "cn", cn,
        "objectClass: top",
        "objectClass: apApplication",
        "displayName:   app1   ",
        "dependencies:",
        "envVars:" );

    assertNotNull( ldifEntry );
    assertTrue( ldifEntry.isLdifContent() );
    assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", ldifEntry.getDn().getName() );

    Attribute attr = ldifEntry.get( "displayname" );
    assertTrue( attr.contains( "app1" ) );

    Attribute cnAttr = ldifEntry.get( "cn" );
    assertTrue( cnAttr.contains( "app1" ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:28,代码来源:LdifEntryTest.java

示例6: testLdifParserChangeTypeDeleteNoControl

import org.apache.directory.api.ldap.model.ldif.LdifEntry; //导入依赖的package包/类
/**
 * Test a Delete changeType LdifEntry with no control
 * 
 * @throws Exception
 */
@Test
public void testLdifParserChangeTypeDeleteNoControl() throws Exception
{
    String ldif =
        "# Delete an entry. The operation will attach the LDAPv3\n" +
            "# Tree Delete Control defined in [9]. The criticality\n" +
            "# field is \"true\" and the controlValue field is\n" +
            "# absent, as required by [9].\n" +
            "changetype: delete\n";

    LdifEntry ldifEntry = new LdifEntry( "ou=Product Development, dc=airius, dc=com", ldif );

    assertNotNull( ldifEntry );
    assertEquals( ChangeType.Delete, ldifEntry.getChangeType() );
    assertNull( ldifEntry.getEntry() );
    assertEquals( "ou=Product Development, dc=airius, dc=com", ldifEntry.getDn().getName() );
    assertFalse( ldifEntry.hasControls() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:24,代码来源:LdifEntryTest.java

示例7: testLdifParserChangeTypeDeleteWithControl

import org.apache.directory.api.ldap.model.ldif.LdifEntry; //导入依赖的package包/类
/**
 * Test a Delete changeType LdifEntry with one control
 * 
 * @throws Exception
 */
@Test
public void testLdifParserChangeTypeDeleteWithControl() throws Exception
{
    String ldif =
        "# Delete an entry. The operation will attach the LDAPv3\n" +
            "# Tree Delete Control defined in [9]. The criticality\n" +
            "# field is \"true\" and the controlValue field is\n" +
            "# absent, as required by [9].\n" +
            "control: 1.2.840.113556.1.4.805 true\n" +
            "changetype: delete\n";

    LdifEntry ldifEntry = new LdifEntry( "ou=Product Development, dc=airius, dc=com", ldif );

    assertNotNull( ldifEntry );
    assertEquals( ChangeType.Delete, ldifEntry.getChangeType() );
    assertNull( ldifEntry.getEntry() );
    assertEquals( "ou=Product Development, dc=airius, dc=com", ldifEntry.getDn().getName() );
    assertTrue( ldifEntry.hasControls() );

    LdifControl ldifControl = ldifEntry.getControl( "1.2.840.113556.1.4.805" );
    assertNotNull( ldifControl );
    assertEquals( "1.2.840.113556.1.4.805", ldifControl.getOid() );
    assertTrue( ldifControl.isCritical() );
    assertNull( ldifControl.getValue() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:31,代码来源:LdifEntryTest.java

示例8: testLdifEntryChangeTypeAddNoControl

import org.apache.directory.api.ldap.model.ldif.LdifEntry; //导入依赖的package包/类
/**
 * Test a Add changeType LdifEntry with no control
 * @throws Exception
 */
@Test
public void testLdifEntryChangeTypeAddNoControl() throws Exception
{
    String ldif =
        "changetype: add\n" +
            "cn: app1\n" +
            "objectClass: top\n" +
            "objectClass: apApplication\n" +
            "displayName:   app1   \n" +
            "dependencies:\n" +
            "envVars:";

    LdifEntry ldifEntry = new LdifEntry( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", ldif );

    assertNotNull( ldifEntry );
    assertEquals( ChangeType.Add, ldifEntry.getChangeType() );
    assertNotNull( ldifEntry.getEntry() );
    assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", ldifEntry.getDn().getName() );
    assertFalse( ldifEntry.hasControls() );
    assertTrue( ldifEntry.isLdifChange() );

    Attribute attr = ldifEntry.get( "displayname" );
    assertTrue( attr.contains( "app1" ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:29,代码来源:LdifEntryTest.java

示例9: testLdifEntryChangeTypeModDnNoControl

import org.apache.directory.api.ldap.model.ldif.LdifEntry; //导入依赖的package包/类
/**
 * Test a ModDn changeType LdifEntry with no control
 */
@Test
public void testLdifEntryChangeTypeModDnNoControl() throws Exception
{
    String ldif =
        "changetype: moddn\n" +
            "newrdn: cn=app2\n" +
            "deleteoldrdn: 1\n";

    LdifEntry ldifEntry = new LdifEntry( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", ldif );

    assertNotNull( ldifEntry );
    assertEquals( ChangeType.ModDn, ldifEntry.getChangeType() );
    assertNull( ldifEntry.getEntry() );
    assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", ldifEntry.getDn().getName() );
    assertFalse( ldifEntry.hasControls() );
    assertTrue( ldifEntry.isLdifChange() );
    assertEquals( "cn=app2", ldifEntry.getNewRdn() );
    assertTrue( ldifEntry.isDeleteOldRdn() );
    assertNull( ldifEntry.getNewSuperior() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:24,代码来源:LdifEntryTest.java

示例10: testLdifEntryChangeTypeModDnRenameNoControlNewSuperior

import org.apache.directory.api.ldap.model.ldif.LdifEntry; //导入依赖的package包/类
/**
 * Test a ModDn changeType LdifEntry with no control and a newSuperior
 */
@Test
public void testLdifEntryChangeTypeModDnRenameNoControlNewSuperior() throws Exception
{
    String ldif =
        "changetype: moddn\n" +
            "newrdn: cn=app2\n" +
            "deleteoldrdn: 1\n" +
            "newsuperior: dc=example, dc=com";

    LdifEntry ldifEntry = new LdifEntry( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", ldif );

    assertNotNull( ldifEntry );
    assertEquals( ChangeType.ModDn, ldifEntry.getChangeType() );
    assertNull( ldifEntry.getEntry() );
    assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", ldifEntry.getDn().getName() );
    assertFalse( ldifEntry.hasControls() );
    assertTrue( ldifEntry.isLdifChange() );
    assertEquals( "cn=app2", ldifEntry.getNewRdn() );
    assertTrue( ldifEntry.isDeleteOldRdn() );
    assertEquals( "dc=example, dc=com", ldifEntry.getNewSuperior() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:25,代码来源:LdifEntryTest.java

示例11: createPrincipal

import org.apache.directory.api.ldap.model.ldif.LdifEntry; //导入依赖的package包/类
/**
 * Creates a principal in the KDC with the specified user and password.
 *
 * @param principal principal name, do not include the domain.
 * @param password password.
 * @throws Exception thrown if the principal could not be created.
 */
public synchronized void createPrincipal(String principal, String password)
        throws Exception {
  String orgName= conf.getProperty(ORG_NAME);
  String orgDomain = conf.getProperty(ORG_DOMAIN);
  String baseDn = "ou=users,dc=" + orgName.toLowerCase(Locale.ENGLISH)
                  + ",dc=" + orgDomain.toLowerCase(Locale.ENGLISH);
  String content = "dn: uid=" + principal + "," + baseDn + "\n" +
          "objectClass: top\n" +
          "objectClass: person\n" +
          "objectClass: inetOrgPerson\n" +
          "objectClass: krb5principal\n" +
          "objectClass: krb5kdcentry\n" +
          "cn: " + principal + "\n" +
          "sn: " + principal + "\n" +
          "uid: " + principal + "\n" +
          "userPassword: " + password + "\n" +
          "krb5PrincipalName: " + principal + "@" + getRealm() + "\n" +
          "krb5KeyVersionNumber: 0";

  for (LdifEntry ldifEntry : new LdifReader(new StringReader(content))) {
    ds.getAdminSession().add(new DefaultEntry(ds.getSchemaManager(),
            ldifEntry.getEntry()));
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:32,代码来源:MiniKdc.java

示例12: testConvertToLdif

import org.apache.directory.api.ldap.model.ldif.LdifEntry; //导入依赖的package包/类
/**
 * Test a conversion of an entry from a LDIF file
 */
@Test
public void testConvertToLdif() throws LdapException
{
    LdifEntry entry = new LdifEntry();
    entry.setDn( "cn=Saarbr\u00FCcken, dc=example, dc=com" );
    entry.setChangeType( ChangeType.Add );

    entry.addAttribute( "objectClass", "top", "person", "inetorgPerson" );
    entry.addAttribute( "cn", "Saarbr\u00FCcken" );
    entry.addAttribute( "sn", "test" );

    LdifUtils.convertToLdif( entry, 15 );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:17,代码来源:LdifUtilsTest.java

示例13: testReverseModifyDNSuperior

import org.apache.directory.api.ldap.model.ldif.LdifEntry; //导入依赖的package包/类
/**
 * Check that the correct reverse LDIF is produced for a modifyDn
 * operation that moves and renames the entry while preserving the
 * old rdn.
 *
 * @throws NamingException on error
 */
@Test
public void testReverseModifyDNSuperior() throws LdapException
{
    Dn dn = new Dn( "cn=john doe, dc=example, dc=com" );
    Dn newSuperior = new Dn( "ou=system" );

    Entry entry = new DefaultEntry( dn );
    entry.add( "objectClass", "person", "uidObject" );
    entry.add( "cn", "john doe", "jack doe" );
    entry.add( "sn", "doe" );
    entry.add( "uid", "jdoe" );

    List<LdifEntry> reverseds = LdifRevertor.reverseMoveAndRename( entry, newSuperior, new Rdn( "cn=jack doe" ),
        false );

    assertNotNull( reverseds );
    assertEquals( 1, reverseds.size() );

    LdifEntry reversed = reverseds.get( 0 );
    assertEquals( "cn=jack doe,ou=system", reversed.getDn().getName() );
    assertEquals( ChangeType.ModRdn, reversed.getChangeType() );
    assertFalse( reversed.isDeleteOldRdn() );
    assertEquals( "cn=john doe", reversed.getNewRdn() );
    assertEquals( "dc=example, dc=com", Strings.trim( reversed.getNewSuperior() ) );
    assertNull( reversed.getEntry() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:34,代码来源:LdifUtilsTest.java

示例14: testReverseModifyDNDeleteOldRdnSuperior

import org.apache.directory.api.ldap.model.ldif.LdifEntry; //导入依赖的package包/类
/**
 * Test a reversed ModifyDN with a deleteOldRdn, rdn change, and a superior
 *
 * @throws NamingException on error
 */
@Test
public void testReverseModifyDNDeleteOldRdnSuperior() throws LdapException
{
    Dn dn = new Dn( "cn=john doe, dc=example, dc=com" );
    Dn newSuperior = new Dn( "ou=system" );

    Entry entry = new DefaultEntry( dn );
    entry.add( "objectClass", "person", "uidObject" );
    entry.add( "cn", "john doe" );
    entry.add( "sn", "doe" );
    entry.add( "uid", "jdoe" );

    List<LdifEntry> reverseds = LdifRevertor.reverseMoveAndRename( entry, newSuperior, new Rdn( "cn=jack doe" ),
        false );

    assertNotNull( reverseds );
    assertEquals( 1, reverseds.size() );

    LdifEntry reversed = reverseds.get( 0 );
    assertEquals( "cn=jack doe,ou=system", reversed.getDn().getName() );
    assertEquals( ChangeType.ModRdn, reversed.getChangeType() );
    assertTrue( reversed.isDeleteOldRdn() );
    assertEquals( "cn=john doe", reversed.getNewRdn() );
    assertEquals( "dc=example, dc=com", Strings.trim( reversed.getNewSuperior() ) );
    assertNull( reversed.getEntry() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:32,代码来源:LdifUtilsTest.java

示例15: testConvertEntryNoControls

import org.apache.directory.api.ldap.model.ldif.LdifEntry; //导入依赖的package包/类
@Test
public void testConvertEntryNoControls() throws Exception
{
    LdifReader reader = new LdifReader();

    String expected =
        "dn: ou=test\n" +
            "ObjectClass: top\n" +
            "ObjectClass: metaTop\n" +
            "ObjectClass: metaSyntax\n" +
            "m-oid: 1.2.3.4\n" +
            "m-description: description\n\n";

    List<LdifEntry> entries = reader.parseLdif( expected );
    LdifEntry expectedEntry = entries.get( 0 );

    LdifEntry entry = new LdifEntry();

    entry.setDn( "ou=test" );
    entry.addAttribute( "ObjectClass", "top", "metaTop", "metaSyntax" );
    entry.addAttribute( "m-oid", "1.2.3.4" );
    entry.addAttribute( "m-description", "description" );

    String converted = LdifUtils.convertToLdif( entry );

    assertNotNull( converted );

    entries = reader.parseLdif( converted );
    LdifEntry convertedEntry = entries.get( 0 );

    assertEquals( expectedEntry, convertedEntry );
    
    reader.close();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:35,代码来源:LdifUtilsTest.java


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