当前位置: 首页>>代码示例>>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;未经允许,请勿转载。