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


Java LdapName.get方法代碼示例

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


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

示例1: cnFor

import javax.naming.ldap.LdapName; //導入方法依賴的package包/類
private static String cnFor(String dn) {
  try {
    LdapName name = new LdapName(dn);
    if (!name.isEmpty()) {
      String cn = name.get(name.size() - 1);
      int index = cn.indexOf('=');
      if (index >= 0) {
        cn = cn.substring(index + 1);
      }
      return cn;
    }
  } catch (InvalidNameException e) {
    log.warn("Cannot parse LDAP dn for cn", e);
  }
  return dn;
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:17,代碼來源:LdapGroupBackend.java

示例2: parseRole

import javax.naming.ldap.LdapName; //導入方法依賴的package包/類
private LdapEntry parseRole(String dn, String groupNameAttribute, URI groupReferralAddress) {

            try {
                LdapName ldapName = new LdapName(Rdn.unescapeValue(dn).toString());
                for (int i = ldapName.size() - 1; i >= 0; i--) {
                    String rdnString = ldapName.get(i);
                    Rdn rdn = new Rdn(rdnString);
                    Attribute attr = rdn.toAttributes().get(groupNameAttribute);
                    if (attr != null) {
                        Object value = attr.get();
                        if (value != null) {
                            return new LdapEntry( (value instanceof byte[]) ? new String((byte[]) value, StandardCharsets.UTF_8) : value.toString(), dn, groupReferralAddress);
                        }
                    }
                }
            } catch (NamingException e) {
                SECURITY_LOGGER.tracef("Unable to parse role from DN (%s): %s", dn, e.getMessage());
            }
            return null;
        }
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:21,代碼來源:LdapGroupSearcherFactory.java

示例3: testLdapNameString002

import javax.naming.ldap.LdapName; //導入方法依賴的package包/類
/**
 * <p>
 * Test method for 'javax.naming.ldap.LdapName(String)'
 * </p>
 */
public void testLdapNameString002() throws Exception {
    String str = "t=\\20\\ te\\ s\\20t\\20\\20 + t2 = test1\\20\\ ";
    LdapName ln = new LdapName(str);
    assertEquals(ln.toString(), str);
    ln.get(0);
    assertEquals(ln.toString(), str);
    ln.add("t=test");
    assertEquals(ln.toString(), "t=test,t=\\ \\ te s t\\ +t2=test1\\ \\ ");
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:15,代碼來源:LdapNameTest.java

示例4: testGet002

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

示例5: testGet003

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

示例6: testGet004

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


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