本文整理匯總了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) {}
}