當前位置: 首頁>>代碼示例>>Java>>正文


Java LdapName.getRdn方法代碼示例

本文整理匯總了Java中javax.naming.ldap.LdapName.getRdn方法的典型用法代碼示例。如果您正苦於以下問題:Java LdapName.getRdn方法的具體用法?Java LdapName.getRdn怎麽用?Java LdapName.getRdn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.naming.ldap.LdapName的用法示例。


在下文中一共展示了LdapName.getRdn方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getACLs

import javax.naming.ldap.LdapName; //導入方法依賴的package包/類
protected Set<GroupPrincipal> getACLs(String destinationBase, SearchControls constraints, String roleBase, String roleAttribute) {
    try {
        Set<GroupPrincipal> roles = new HashSet<GroupPrincipal>();
        Set<String> acls = new HashSet<String>();
        NamingEnumeration<?> results = context.search(destinationBase, roleBase, constraints);
        while (results.hasMore()) {
            SearchResult result = (SearchResult)results.next();
            Attributes attrs = result.getAttributes();
            if (attrs == null) {
                continue;
            }
            acls = addAttributeValues(roleAttribute, attrs, acls);
        }
        for (Iterator<String> iter = acls.iterator(); iter.hasNext();) {
            String roleName = iter.next();
            LdapName ldapname = new LdapName(roleName);
            Rdn rdn = ldapname.getRdn(ldapname.size() - 1);
            LOG.debug("Found role: [" + rdn.getValue().toString() + "]");
            roles.add(new GroupPrincipal(rdn.getValue().toString()));
        }
        return roles;
    } catch (NamingException e) {
        LOG.error(e.toString());
        return new HashSet<GroupPrincipal>();
    }
}
 
開發者ID:DiamondLightSource,項目名稱:daq-eclipse,代碼行數:27,代碼來源:LDAPAuthorizationMap.java

示例2: rename

import javax.naming.ldap.LdapName; //導入方法依賴的package包/類
public void rename(Name nOld, Name nNew) throws NamingException {
    checkName(nOld);
    checkName(nNew);

    if (!isInSameNamespace(nOld, nNew)) {
        throw new InvalidNameException(Messages.getString("ldap.2A")); //$NON-NLS-1$
    }

    if (hasMultiNamingSpace(nOld) && hasMultiNamingSpace(nNew)) {
        Context context = findNnsContext(nOld);
        context.rename(nOld.getSuffix(1), nNew.getSuffix(1));
        return;
    }

    // get absolute dn name
    String oldTargetDN = getTargetDN(nOld, contextDn);
    String newTargetDN = getTargetDN(nNew, contextDn);
    LdapName name = new LdapName(newTargetDN);
    Rdn rdn = name.getRdn(name.size() - 1);
    String value = (String) env.get(LDAP_DELETE_RDN);
    // true is default value
    boolean isDeleteRdn = true;
    if (value != null) {
        isDeleteRdn = Boolean.getBoolean(value);
    }

    ModifyDNOp op = new ModifyDNOp(oldTargetDN, rdn.toString(),
            isDeleteRdn, name.getPrefix(name.size() - 1).toString());

    try {
        doBasicOperation(op);
    } catch (ReferralException e) {
        if (isFollowReferral(e)) {
            DirContext referralContext = getReferralContext(e);
            referralContext.rename(nOld, nNew);
            return;
        }
        throw e;
    }
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:41,代碼來源:LdapContextImpl.java

示例3: testGetRdn002

import javax.naming.ldap.LdapName; //導入方法依賴的package包/類
/**
 * <p>
 * Test method for 'javax.naming.ldap.LdapName.getRdn(int)'
 * </p>
 * <p>
 * Here we are testing if this method correctly returns the RDN contained in
 * the LdapName that is at the specified index.
 * </p>
 * <p>
 * The expected result is an exception like IndexOutOfBounds.
 * </p>
 */
public void testGetRdn002() throws Exception {
    try {
        LinkedList<Rdn> test = new LinkedList<Rdn>();
        test.add(new Rdn("t=test"));
        LdapName ln = new LdapName(test);
        ln.getRdn(-1);
        fail("IndexOutOfBoundsException expected");
    } catch (IndexOutOfBoundsException e) {}
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:22,代碼來源:LdapNameTest.java

示例4: testGetRdn003

import javax.naming.ldap.LdapName; //導入方法依賴的package包/類
/**
 * <p>
 * Test method for 'javax.naming.ldap.LdapName.getRdn(int)'
 * </p>
 * <p>
 * Here we are testing if this method correctly returns the RDN contained in
 * the LdapName that is at the specified index.
 * </p>
 * <p>
 * The expected result is an exception like IndexOutOfBounds.
 * </p>
 */
public void testGetRdn003() throws Exception {
    try {
        LinkedList<Rdn> test = new LinkedList<Rdn>();
        test.add(new Rdn("t=test"));
        LdapName ln = new LdapName(test);
        ln.getRdn(1);
        fail("IndexOutOfBoundsException expected");
    } catch (IndexOutOfBoundsException e) {}
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:22,代碼來源:LdapNameTest.java

示例5: testGetRdn004

import javax.naming.ldap.LdapName; //導入方法依賴的package包/類
/**
 * <p>
 * Test method for 'javax.naming.ldap.LdapName.getRdn(int)'
 * </p>
 * <p>
 * Here we are testing if this method correctly returns the RDN contained in
 * the LdapName that is at the specified index.
 * </p>
 * <p>
 * The expected result is an IndexOutOfBoundsException.
 * </p>
 */
public void testGetRdn004() throws Exception {
    try {
        LdapName ln = new LdapName("");
        ln.getRdn(0);
        fail("IndexOutOfBoundsException expected");
    } catch (IndexOutOfBoundsException e) {}
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:20,代碼來源:LdapNameTest.java


注:本文中的javax.naming.ldap.LdapName.getRdn方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。