本文整理汇总了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;
}
示例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;
}
示例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\\ \\ ");
}
示例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) {}
}
示例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) {}
}
示例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) {}
}