本文整理汇总了Java中org.springframework.ldap.core.DirContextAdapter.setAttributeValues方法的典型用法代码示例。如果您正苦于以下问题:Java DirContextAdapter.setAttributeValues方法的具体用法?Java DirContextAdapter.setAttributeValues怎么用?Java DirContextAdapter.setAttributeValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.ldap.core.DirContextAdapter
的用法示例。
在下文中一共展示了DirContextAdapter.setAttributeValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
@Override
public UserOrg create(final UserOrg entry) {
// Build the DN
final Name dn = buildDn(entry);
// Create the LDAP entry
entry.setDn(dn.toString());
final DirContextAdapter context = new DirContextAdapter(dn);
context.setAttributeValues(OBJECT_CLASS, new String[] { peopleClass });
mapToContext(entry, context);
template.bind(context);
// Also, update the cache
ldapCacheRepository.create(entry);
// Return the original entry with updated DN
return entry;
}
示例2: create
import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
public void create(OrgPerson person) {
DistinguishedName dn = new DistinguishedName();
dn.add("ou", person.getCountry());
dn.add("ou", person.getCompany());
dn.add("cn", person.getFullname());
DirContextAdapter ctx = new DirContextAdapter();
ctx.setAttributeValues("objectclass", new String[] { "top", "person" });
ctx.setAttributeValue("cn", person.getFullname());
ctx.setAttributeValue("sn", person.getLastname());
ctx.setAttributeValue("description", person.getDescription());
ldapTemplate.bind(dn, ctx, null);
this.getHibernateTemplate().saveOrUpdate(person);
}
示例3: testBindAndUnbind_Plain
import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
@Test
public void testBindAndUnbind_Plain() {
DirContextAdapter adapter = new DirContextAdapter();
adapter.setAttributeValues("objectclass", new String[] { "top", "person" });
adapter.setAttributeValue("cn", "Some Person4");
adapter.setAttributeValue("sn", "Person4");
tested.bind("cn=Some Person4, ou=company1, ou=Sweden," + base, adapter, null);
DirContextAdapter result = (DirContextAdapter) tested
.lookup("cn=Some Person4, ou=company1, ou=Sweden," + base);
assertThat(result.getStringAttribute("cn")).isEqualTo("Some Person4");
assertThat(result.getStringAttribute("sn")).isEqualTo("Person4");
assertThat(result.getDn()).isEqualTo(LdapUtils.newLdapName("cn=Some Person4,ou=company1,ou=Sweden," + base));
tested.unbind("cn=Some Person4,ou=company1,ou=Sweden," + base);
try {
tested.lookup("cn=Some Person4, ou=company1, ou=Sweden," + base);
fail("NameNotFoundException expected");
}
catch (NameNotFoundException expected) {
assertThat(true).isTrue();
}
}
示例4: testBindAndRebindWithDirContextAdapterOnly
import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
@Test
public void testBindAndRebindWithDirContextAdapterOnly() {
DirContextAdapter adapter = new DirContextAdapter(LdapUtils.newLdapName(DN));
adapter.setAttributeValues("objectclass", new String[] { "top",
"person" });
adapter.setAttributeValue("cn", "Some Person4");
adapter.setAttributeValue("sn", "Person4");
tested.bind(adapter);
verifyBoundCorrectData();
adapter.setAttributeValue("sn", "Person4.Changed");
tested.rebind(adapter);
verifyReboundCorrectData();
tested.unbind(DN);
verifyCleanup();
}
示例5: create
import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
/**
* Create a new group. There is no synchronized block, so error could occur; this is assumed for performance
* purpose.
*
* @param dn
* The DN of new customer. Must ends with the OU.
* @param ou
* The formatted OU.
*/
public void create(final String dn, final String ou) {
// First create the LDAP entry
log.info("Customer (OU) {} will be created as {}", ou, dn);
final DirContextAdapter context = new DirContextAdapter(dn);
context.setAttributeValues("objectClass", new String[] { CUSTOMER_OF_PROJECT });
mapToContext(ou, context);
getUser().getTemplate().bind(context);
}
示例6: create
import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
@Override
public T create(final String dn, final String cn) {
final T container = newContainer(dn, cn);
// First create the LDAP entry
log.info("{} {} will be created as {}", type.name(), container.getName(), dn);
final DirContextAdapter context = new DirContextAdapter(dn);
context.setAttributeValues("objectClass", new String[] { className });
mapToContext(container, context);
template.bind(context);
// Return the new container
return container;
}
示例7: mapToContext
import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
/**
* The WriteableLdapUserServiceImpl implementation is overwritted because
* it doest not allow to remove attribute.
* @param ldapUser
* @param context
*/
protected void mapToContext(final LdapUser ldapUser, final DirContextAdapter context) {
List<String> attributesNames = ldapUser.getAttributeNames();
for (String ldapAttributeName : attributesNames) {
List<String> listAttr = new ArrayList<>();
listAttr = ldapUser.getAttributes(ldapAttributeName);
// The attribute exists
if (listAttr != null && listAttr.size() != 0) {
context.setAttributeValues(ldapAttributeName, listAttr.toArray());
} else {
// manage the attributes erasing
context.setAttributeValues(ldapAttributeName, null);
}
}
}
示例8: mapUserToContext
import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
private void mapUserToContext(DirContextAdapter context, User user) {
context.setAttributeValues("objectclass", new String[] { "inetOrgPerson", "posixAccount", "top" });
context.setAttributeValue("givenName", user.getAttributes().get("givenName"));
context.setAttributeValue("sn", user.getAttributes().get("sn"));
context.setAttributeValue("uid", user.getAttributes().get("uid"));
context.setAttributeValue("uidNumber", user.getAttributes().get("uidNumber"));
context.setAttributeValue("gidNumber", user.getAttributes().get("gidNumber"));
context.setAttributeValue("cn", user.getAttributes().get("userName"));
context.setAttributeValue("mail", user.getAttributes().get("mail"));
context.setAttributeValue("homeDirectory", user.getAttributes().get("homeDirectory"));
context.setAttributeValue("gecos", user.getAttributes().get("resetKey"));
context.setAttributeValue("userPassword", user.getAttributes().get("userPassword"));
String description = "";
if (user.getAttributes().get("tenant") != null) {
description += "tenant=" + user.getAttributes().get("tenant");
}
if (user.getAttributes().get("edOrg") != null) {
description += ",edOrg=" + user.getAttributes().get("edOrg");
}
if (!"".equals(description)) {
context.setAttributeValue("description", "tenant=" + user.getAttributes().get("tenant") + "," + "edOrg="
+ user.getAttributes().get("edOrg"));
}
if (user.getAttributes().containsKey("employeeNumber")) {
context.setAttributeValue("employeeNumber", user.getAttributes().get("employeeNumber"));
}
}
示例9: create
import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
public void create(String country, String company, String fullname,
String lastname, String description) {
DistinguishedName dn = new DistinguishedName();
dn.add("ou", country);
dn.add("ou", company);
dn.add("cn", fullname);
DirContextAdapter ctx = new DirContextAdapter();
ctx.setAttributeValues("objectclass", new String[] { "top", "person" });
ctx.setAttributeValue("cn", fullname);
ctx.setAttributeValue("sn", lastname);
ctx.setAttributeValue("description", description);
ldapTemplate.bind(dn, ctx, null);
}
示例10: createRecursivelyAndUnbindSubnode
import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
@Override
public void createRecursivelyAndUnbindSubnode() {
DirContextAdapter ctx = new DirContextAdapter();
ctx.setAttributeValues("objectclass", new String[]{"top", "organizationalUnit"});
ctx.setAttributeValue("ou", "dummy");
ctx.setAttributeValue("description", "dummy description");
ldapTemplate.bind("ou=dummy", ctx, null);
ldapTemplate.bind("ou=dummy,ou=dummy", ctx, null);
ldapTemplate.unbind("ou=dummy,ou=dummy");
ldapTemplate.unbind("ou=dummy");
}
示例11: create
import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
public void create(String country, String company, String fullname, String lastname, String description) {
DistinguishedName dn = new DistinguishedName();
dn.add("ou", country);
dn.add("ou", company);
dn.add("cn", fullname);
DirContextAdapter ctx = new DirContextAdapter();
ctx.setAttributeValues("objectclass", new String[] { "top", "person" });
ctx.setAttributeValue("cn", fullname);
ctx.setAttributeValue("sn", lastname);
ctx.setAttributeValue("description", description);
ldapTemplate.bind(dn, ctx, null);
jdbcTemplate.update("insert into PERSON values(?, ?, ?)", new Object[] { fullname, lastname, description });
}
示例12: prepareTestedInstance
import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
@Before
public void prepareTestedInstance() throws Exception {
DirContextAdapter adapter = new DirContextAdapter();
adapter.setAttributeValues("objectclass", new String[] { "top", "person" });
adapter.setAttributeValue("cn", "Some Person6");
adapter.setAttributeValue("sn", "Person6");
adapter.setAttributeValue("description", "Some description");
tested.bind(DN, adapter, null);
}
示例13: prepareTestedInstance
import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
@Before
public void prepareTestedInstance() throws Exception {
DirContextAdapter adapter = new DirContextAdapter();
adapter.setAttributeValues("objectclass", new String[] { "top", "person" });
adapter.setAttributeValue("cn", "Some\\Person6");
adapter.setAttributeValue("sn", "Person6");
adapter.setAttributeValue("description", "Some description");
tested.unbind(DN);
tested.bind(DN, adapter, null);
}
示例14: testBindAndUnbindWithDirContextAdapter
import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
@Test
public void testBindAndUnbindWithDirContextAdapter() {
DirContextAdapter adapter = new DirContextAdapter();
adapter.setAttributeValues("objectclass", new String[] { "top",
"person" });
adapter.setAttributeValue("cn", "Some Person4");
adapter.setAttributeValue("sn", "Person4");
tested.bind(DN, adapter, null);
verifyBoundCorrectData();
tested.unbind(DN);
verifyCleanup();
}
示例15: testBindAndUnbindWithDirContextAdapterUsingLdapName
import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
@Test
public void testBindAndUnbindWithDirContextAdapterUsingLdapName() {
DirContextAdapter adapter = new DirContextAdapter();
adapter.setAttributeValues("objectclass", new String[] { "top",
"person" });
adapter.setAttributeValue("cn", "Some Person4");
adapter.setAttributeValue("sn", "Person4");
tested.bind(LdapUtils.newLdapName(DN), adapter, null);
verifyBoundCorrectData();
tested.unbind(LdapUtils.newLdapName(DN));
verifyCleanup();
}