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


Java DirContextAdapter.getStringAttribute方法代码示例

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


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

示例1: mapFromContext

import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
public DirContextAdapter mapFromContext(Object ctx) {
    DirContextAdapter adapter = (DirContextAdapter) ctx;
    Assert.assertEquals("Values and attributes need to have the same length ",
            expectedAttributes.length, expectedValues.length);
    for (int i = 0; i < expectedAttributes.length; i++) {
        String attributeValue = adapter
                .getStringAttribute(expectedAttributes[i]);
        Assert.assertNotNull("Attribute " + expectedAttributes[i]
                + " was not present", attributeValue);
        Assert.assertEquals(expectedValues[i], attributeValue);
    }

    for (String absentAttribute : absentAttributes) {
        Assert.assertNull(adapter.getStringAttribute(absentAttribute));
    }

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

示例2: findAllNoCache

import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
/**
 * Fetch and return all normalized groups. Note the result use cache, so does not reflect the current state of LDAP.
 * LDAP.
 * 
 * @return the groups. Key is the normalized name, Value is the corresponding LDAP group containing real CN, DN and
 *         normalized UID members.
 */
public Map<String, GroupOrg> findAllNoCache() {
	final Map<String, GroupOrg> groups = new HashMap<>();
	final Map<String, Set<String>> subGroupsDn = new HashMap<>();
	final Map<String, GroupOrg> dnToGroups = new HashMap<>();

	// First pass, collect the groups and dirty relationships
	for (final DirContextAdapter groupRaw : template.search(groupsBaseDn, new EqualsFilter("objectClass", GROUP_OF_UNIQUE_NAMES).encode(),
			(Object ctx) -> (DirContextAdapter) ctx)) {
		final Set<String> members = new HashSet<>();
		final String dn = Normalizer.normalize(groupRaw.getDn().toString());
		final String name = groupRaw.getStringAttribute("cn");
		final HashSet<String> subGroups = new HashSet<>();
		for (final String memberDN : ArrayUtils.nullToEmpty(groupRaw.getStringAttributes(UNIQUE_MEMBER))) {
			if (memberDN.startsWith("uid")) {
				// User membership
				members.add(memberDN);
			} else {
				// Group (or whatever) membership
				subGroups.add(memberDN);
			}
		}
		final GroupOrg group = new GroupOrg(dn, name, members);
		subGroupsDn.put(group.getId(), subGroups);
		groups.put(group.getId(), group);
		dnToGroups.put(dn, group);
	}

	// Second pass to validate the sub-groups and complete the opposite relation
	updateSubGroups(groups, subGroupsDn, dnToGroups);

	return groups;
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:40,代码来源:GroupLdapRepository.java

示例3: mapFromContext

import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
@Override
public Object mapFromContext(Object ctx) {
    DirContextAdapter context = (DirContextAdapter) ctx;
    User user = new User();
    user.setSn(context.getStringAttribute("sn"));
    user.setGivenName(context.getStringAttribute("givenName"));
    user.setUid(context.getStringAttribute("uid"));
    user.setEmail(context.getStringAttribute("mail"));
    user.setHomeDir(context.getStringAttribute("homeDirectory"));
    user.setCreateTime(ldapStringToDate(context.getStringAttribute(LdapService.CREATE_TIMESTAMP)));
    user.setModifyTime(ldapStringToDate(context.getStringAttribute(LdapService.MODIFY_TIMESTAMP)));
    user.setPassword("**********");
    user.setCn(context.getStringAttribute("cn"));
    user.setStatus(User.Status.getFromString(context.getStringAttribute("destinationindicator")));

    String description = context.getStringAttribute("description");
    if (description != null && description.length() > 0) {
        String[] pairs;
        if (description.indexOf("\n") > 0) {
            pairs = description.split("\n");
        } else if (description.indexOf(",") > 0) {
            pairs = description.split(",");
        } else {
            pairs = description.split(" ");
        }
        for (String pair : pairs) {
            String[] pairArray = pair.trim().split("=", 2);
            if (pairArray.length == 2) {
                String key = pairArray[0].trim();
                String value = pairArray[1].trim();
                if (key.toLowerCase().indexOf("tenant") >= 0) {
                    user.setTenant(value);
                } else if (key.toLowerCase().indexOf("edorg") >= 0) {
                    user.setEdorg(value);
                }
            }
        }
    }
    return user;
}
 
开发者ID:inbloom,项目名称:secure-data-service,代码行数:41,代码来源:UserContextMapper.java

示例4: mapFromContext

import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
@Override
public Object mapFromContext(Object ctx) {
    DirContextAdapter context = (DirContextAdapter) ctx;
    User user = new User();
    Map<String, String> attributes = new HashMap<String, String>();

    attributes.put("userName", context.getStringAttribute("cn"));
    attributes.put("vendor", context.getStringAttribute("o"));
    attributes.put("givenName", context.getStringAttribute("givenName"));
    attributes.put("sn", context.getStringAttribute("sn"));

    if (needAdditionalAttributes) {
        attributes.put("uid", context.getStringAttribute("uid"));
        attributes.put("uidNumber", context.getStringAttribute("uidNumber"));
        attributes.put("gidNumber", context.getStringAttribute("gidNumber"));
        attributes.put("homeDirectory", context.getStringAttribute("homeDirectory"));
        attributes.put("mail", context.getStringAttribute("mail"));

        String emailToken = context.getStringAttribute("displayName");
        if (emailToken == null || emailToken.trim().length() == 0) {
            emailToken = "";
        }
        attributes.put("emailToken", emailToken);
    }

    String description = context.getStringAttribute("description");
    if (description != null && description.length() > 0) {
        String[] pairs;
        if (description.indexOf("\n") > 0) {
            pairs = description.split("\n");
        } else if (description.indexOf(",") > 0) {
            pairs = description.split(",");
        } else {
            pairs = description.split(" ");
        }
        for (String pair : pairs) {
            pair = pair.trim();
            String[] pairArray = pair.split("=", 2);
            if (pairArray.length == 2) {
                String value = pairArray[1].trim();
                if (value.length() > 0) {
                    attributes.put(pairArray[0].trim(), value);
                }
            }
        }
    }

    String employeeNumber = context.getStringAttribute("employeeNumber");
    if (employeeNumber != null && employeeNumber.length() > 0) {
        attributes.put("employeeNumber", employeeNumber);
    }
    user.setUserId(context.getStringAttribute("uid"));
    user.attributes = attributes;
    return user;
}
 
开发者ID:inbloom,项目名称:secure-data-service,代码行数:56,代码来源:UserService.java

示例5: mapFromContext

import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
public String mapFromContext(Object ctx) {
	DirContextAdapter adapter = (DirContextAdapter) ctx;

	return adapter.getStringAttribute("cn");
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:6,代码来源:SimpleLdapTemplateITest.java


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