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


Java LdapUtils.newLdapName方法代码示例

本文整理汇总了Java中org.springframework.ldap.support.LdapUtils.newLdapName方法的典型用法代码示例。如果您正苦于以下问题:Java LdapUtils.newLdapName方法的具体用法?Java LdapUtils.newLdapName怎么用?Java LdapUtils.newLdapName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.ldap.support.LdapUtils的用法示例。


在下文中一共展示了LdapUtils.newLdapName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testLookup_String_ReturnAttributes_ContextMapper

import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
@Test
public void testLookup_String_ReturnAttributes_ContextMapper()
        throws Exception {
    expectGetReadOnlyContext();

    String[] attributeNames = new String[] { "cn" };

    BasicAttributes expectedAttributes = new BasicAttributes();
    expectedAttributes.put("cn", "Some Name");

    when(dirContextMock.getAttributes(DEFAULT_BASE_STRING, attributeNames)).thenReturn(expectedAttributes);

    LdapName name = LdapUtils.newLdapName(DEFAULT_BASE_STRING);
    DirContextAdapter adapter = new DirContextAdapter(expectedAttributes,
            name);

    Object transformed = new Object();
    when(contextMapperMock.mapFromContext(adapter)).thenReturn(transformed);

    Object actual = tested.lookup(DEFAULT_BASE_STRING, attributeNames,
            contextMapperMock);

    verify(dirContextMock).close();

    assertThat(actual).isSameAs(transformed);
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:27,代码来源:LdapTemplateLookupTest.java

示例2: testRemoveDnAttributeSyntacticallyEqual

import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
@Test
public void testRemoveDnAttributeSyntacticallyEqual() throws NamingException {
    BasicAttributes attributes = new BasicAttributes();
    attributes.put("uniqueMember", "cn=john doe,OU=company");

    DirContextAdapter tested = new DirContextAdapter(attributes, LdapUtils.newLdapName("cn=administrators, ou=groups"));
    tested.setUpdateMode(true);

    tested.removeAttributeValue("uniqueMember", LdapUtils.newLdapName("cn=john doe, ou=company"));
    ModificationItem[] modificationItems = tested.getModificationItems();
    assertThat(modificationItems.length).isEqualTo(1);

    ModificationItem modificationItem = modificationItems[0];
    assertThat(modificationItem.getModificationOp()).isEqualTo(DirContext.REMOVE_ATTRIBUTE);
    assertThat(modificationItem.getAttribute().getID()).isEqualTo("uniqueMember");
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:17,代码来源:DirContextAdapterTest.java

示例3: testCreateWithIdSpecified

import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
@Test
public void testCreateWithIdSpecified() throws NamingException {
    expectGetReadWriteContext();

    Object expectedObject = new Object();
    LdapName expectedName = LdapUtils.newLdapName("ou=someOu");
    when(odmMock.getId(expectedObject)).thenReturn(expectedName);

    ArgumentCaptor<DirContextAdapter> ctxCaptor = ArgumentCaptor.forClass(DirContextAdapter.class);
    doNothing().when(odmMock).mapToLdapDataEntry(eq(expectedObject), ctxCaptor.capture());

    tested.create(expectedObject);

    verify(odmMock, never()).setId(expectedObject, expectedName);
    verify(dirContextMock).bind(expectedName, ctxCaptor.getValue(), null);
    verify(dirContextMock).close();
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:18,代码来源:LdapTemplateTest.java

示例4: testAuthenticateWithSingleUserFoundShouldBeSuccessful

import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
@Test
public void testAuthenticateWithSingleUserFoundShouldBeSuccessful() throws Exception {
	when(contextSourceMock.getReadOnlyContext()).thenReturn(dirContextMock);

	Object expectedObject = new DirContextAdapter(new BasicAttributes(), LdapUtils.newLdapName("cn=john doe"),
               LdapUtils.newLdapName("dc=jayway, dc=se"));
	SearchResult searchResult = new SearchResult("", expectedObject, new BasicAttributes());

	singleSearchResult(searchControlsRecursive(), searchResult);

	when(contextSourceMock.getContext("cn=john doe,dc=jayway,dc=se", "password"))
               .thenReturn(authenticatedContextMock);
	entryContextCallbackMock.executeWithContext(authenticatedContextMock, new LdapEntryIdentification(
               LdapUtils.newLdapName("cn=john doe,dc=jayway,dc=se"), LdapUtils.newLdapName("cn=john doe")));

	boolean result = tested.authenticate(nameMock, "(ou=somevalue)", "password", entryContextCallbackMock);

       verify(authenticatedContextMock).close();
       verify(dirContextMock).close();

	assertThat(result).isTrue();
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:23,代码来源:LdapTemplateTest.java

示例5: testUpdateWithIdChanged

import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
@Test
public void testUpdateWithIdChanged() throws NamingException {
    Object expectedObject = new Object();

    when(contextSourceMock.getReadWriteContext()).thenReturn(dirContextMock, dirContextMock);
    LdapName expectedOriginalName = LdapUtils.newLdapName("ou=someOu");
    LdapName expectedNewName = LdapUtils.newLdapName("ou=someOtherOu");

    ArgumentCaptor<DirContextAdapter> ctxCaptor = ArgumentCaptor.forClass(DirContextAdapter.class);
    doNothing().when(odmMock).mapToLdapDataEntry(eq(expectedObject), ctxCaptor.capture());

    when(odmMock.getId(expectedObject)).thenReturn(expectedOriginalName);
    when(odmMock.getCalculatedId(expectedObject)).thenReturn(expectedNewName);

    tested.update(expectedObject);

    verify(odmMock).setId(expectedObject, expectedNewName);
    verify(dirContextMock).unbind(expectedOriginalName);
    verify(dirContextMock).bind(expectedNewName, ctxCaptor.getValue(), null);
    verify(dirContextMock, times(2)).close();
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:22,代码来源:LdapTemplateTest.java

示例6: testLookup_GetNameInNamespace_Plain

import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
@Test
public void testLookup_GetNameInNamespace_Plain() {
       String expectedDn = "cn=Some Person2, ou=company1,ou=Sweden";
       DirContextAdapter result = (DirContextAdapter) tested.lookup(expectedDn);

       LdapName expectedName = LdapUtils.newLdapName(expectedDn);
       assertThat(result.getDn()).isEqualTo(expectedName);
	assertThat(result.getNameInNamespace()).isEqualTo("cn=Some Person2,ou=company1,ou=Sweden," + base);
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:10,代码来源:LdapTemplateLookupITest.java

示例7: testSetDnAttributeValueIdentical

import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
@Test
public void testSetDnAttributeValueIdentical() {
    BasicAttributes attributes = new BasicAttributes();
    attributes.put("uniqueMember", "cn=john doe, ou=company");

    DirContextAdapter tested = new DirContextAdapter(attributes, LdapUtils.newLdapName("cn=administrators, ou=groups"));
    tested.setUpdateMode(true);

    tested.setAttributeValue("uniqueMember", LdapUtils.newLdapName("cn=john doe, ou=company"));
    ModificationItem[] modificationItems = tested.getModificationItems();
    assertThat(modificationItems.length).isEqualTo(0);
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:13,代码来源:DirContextAdapterTest.java

示例8: testLookup_Plain

import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
/**
 * This method depends on a DirObjectFactory ({@link org.springframework.ldap.core.support.DefaultDirObjectFactory})
 * being set in the ContextSource.
 */
@Test
public void testLookup_Plain() {
       String expectedDn = "cn=Some Person2, ou=company1, ou=Sweden," + base;
       DirContextAdapter result = (DirContextAdapter) tested.lookup(expectedDn);

	assertThat(result.getStringAttribute("cn")).isEqualTo("Some Person2");
	assertThat(result.getStringAttribute("sn")).isEqualTo("Person2");
	assertThat(result.getStringAttribute("description")).isEqualTo("Sweden, Company1, Some Person2");

       LdapName expectedName = LdapUtils.newLdapName(expectedDn);
       assertThat(result.getDn()).isEqualTo(expectedName);
	assertThat(result.getNameInNamespace()).isEqualTo(expectedDn);
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:18,代码来源:LdapTemplateNoBaseSuffixITest.java

示例9: testListBindings_ContextMapper_Name

import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
@Test
public void testListBindings_ContextMapper_Name() {
	contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
	contextMapper.setExpectedValues(ALL_VALUES);
	LdapName dn = LdapUtils.newLdapName("ou=company2,ou=Sweden");
	List list = tested.listBindings(dn, contextMapper);
	assertThat(list).hasSize(1);
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:9,代码来源:LdapTemplateListITest.java

示例10: testBindGroupOfUniqueNamesWithNameValues

import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
@Test
public void testBindGroupOfUniqueNamesWithNameValues() {
    DirContextAdapter ctx = new DirContextAdapter(LdapUtils.newLdapName("cn=TEST,ou=groups"));
    ctx.addAttributeValue("cn", "TEST");
    ctx.addAttributeValue("objectclass", "top");
    ctx.addAttributeValue("objectclass", "groupOfUniqueNames");
    ctx.addAttributeValue("uniqueMember", LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Sweden," + base));
    tested.bind(ctx);
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:10,代码来源:LdapTemplateBindUnbindITest.java

示例11: testGetTemporaryDN_MultivalueDN

import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
@Test
public void testGetTemporaryDN_MultivalueDN() {
    LdapName expectedOriginalName = LdapUtils.newLdapName(
            "cn=john doe+sn=doe, ou=somecompany, c=SE");
    DefaultTempEntryRenamingStrategy tested = new DefaultTempEntryRenamingStrategy();

    Name result = tested.getTemporaryName(expectedOriginalName);
    assertThat(result.toString()).isEqualTo("cn=john doe+sn=doe_temp,ou=somecompany,c=SE");
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:10,代码来源:DefaultTempEntryRenamingStrategyTest.java

示例12: testRollback

import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
@Test
public void testRollback() {
    LdapName expectedOldName = LdapUtils.newLdapName("cn=oldDn");
    LdapName expectedTempName = LdapUtils.newLdapName("cn=newDn");
    UnbindOperationExecutor tested = new UnbindOperationExecutor(
            ldapOperationsMock, expectedOldName, expectedTempName);



    // Perform test
    tested.rollback();
    verify(ldapOperationsMock).rename(expectedTempName, expectedOldName);
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:14,代码来源:UnbindOperationExecutorTest.java

示例13: doMapFromContext

import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
@Override
public Person doMapFromContext(DirContextOperations context) {
	Person person = new Person();

          LdapName dn = LdapUtils.newLdapName(context.getDn());
	person.setCountry(LdapUtils.getStringValue(dn, 0));
	person.setCompany(LdapUtils.getStringValue(dn, 1));
	person.setFullName(context.getStringAttribute("cn"));
	person.setLastName(context.getStringAttribute("sn"));
	person.setDescription(context.getStringAttribute("description"));
	person.setPhone(context.getStringAttribute("telephoneNumber"));

	return person;
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:15,代码来源:PersonDaoImpl.java

示例14: getTemporaryName

import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
public Name getTemporaryName(Name originalName) {
    LdapName temporaryName = LdapUtils.newLdapName(originalName);

    // Add tempSuffix to the leaf node name.
    try {
        String leafNode = (String) temporaryName.remove(temporaryName.size() - 1);
        temporaryName.add(new Rdn(leafNode  + tempSuffix));
    } catch (InvalidNameException e) {
        throw new org.springframework.ldap.InvalidNameException(e);
    }

    return temporaryName;
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:14,代码来源:DefaultTempEntryRenamingStrategy.java

示例15: getDn

import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
/**
    * {@inheritDoc}
    */
   @Override
public Name getDn() {
	return LdapUtils.newLdapName(dn);
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:8,代码来源:DirContextAdapter.java


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