use of javax.naming.ldap.LdapName in project directory-ldap-api by apache.
the class DnTest method testName.
/**
* Test for DIRSERVER-191
*/
@Test
public void testName() throws LdapException, InvalidNameException {
LdapName jName = new javax.naming.ldap.LdapName("cn=four,cn=three,cn=two,cn=one");
Dn aName = new Dn("cn=four,cn=three,cn=two,cn=one");
assertEquals(jName.toString(), "cn=four,cn=three,cn=two,cn=one");
assertEquals(aName.toString(), "cn=four,cn=three,cn=two,cn=one");
assertEquals(jName.toString(), aName.toString());
}
use of javax.naming.ldap.LdapName in project directory-ldap-api by apache.
the class DnTest method testAddStringName.
/**
* Test for DIRSERVER-191. The Dn is immutable, thus we can't add a new Rdn
* to a Dn, it simply creates a new one.
*/
@Test
public void testAddStringName() throws LdapException, InvalidNameException {
LdapName jName = new LdapName("cn=four,cn=three,cn=two,cn=one");
Dn aName = new Dn("cn=four,cn=three,cn=two,cn=one");
assertSame(jName, jName.add("cn=five"));
assertNotSame(aName, aName.add("cn=five"));
assertNotSame(jName.toString(), aName.toString());
}
use of javax.naming.ldap.LdapName in project directory-ldap-api by apache.
the class DnTest method testStartsWithName.
/**
* Test for DIRSERVER-191
*/
@Test
public void testStartsWithName() throws LdapException, InvalidNameException {
LdapName jName = new LdapName("cn=four,cn=three,cn=two,cn=one");
Dn aName = new Dn("cn=four,cn=three,cn=two,cn=one");
assertEquals(jName.startsWith(new LdapName("cn=seven,cn=six,cn=five")), aName.isDescendantOf(new Dn("cn=seven,cn=six,cn=five")));
assertEquals(jName.startsWith(new LdapName("cn=three,cn=two,cn=one")), aName.isDescendantOf(new Dn("cn=three,cn=two,cn=one")));
}
use of javax.naming.ldap.LdapName in project Openfire by igniterealtime.
the class CertificateManagerTest method parse.
/**
* @see <a href="https://stackoverflow.com/questions/2914521/how-to-extract-cn-from-x509certificate-in-java>https://stackoverflow.com/questions/2914521/how-to-extract-cn-from-x509certificate-in-java</a>
*/
public static Set<String> parse(String distinguishedName, String identifier) throws Exception {
final Set<String> result = new HashSet<>();
final LdapName ln = new LdapName(distinguishedName);
for (final Rdn rdn : ln.getRdns()) {
if (rdn.getType().equalsIgnoreCase(identifier)) {
result.add(rdn.getValue().toString());
}
}
return result;
}
use of javax.naming.ldap.LdapName in project Openfire by igniterealtime.
the class LdapManagerTest method testGetProviderURLTwoHosts.
/**
* Test if {@link LdapManager#getProviderURL(LdapName)} generates a whitespace-separated value of URLs when
* more than one connect-host is being provided..
*/
@Test
public void testGetProviderURLTwoHosts() throws Exception {
// Setup fixture.
final Map<String, String> properties = new HashMap<>();
properties.put("ldap.host", "localhost example.org");
properties.put("ldap.port", "389");
final LdapManager manager = new LdapManager(properties);
final LdapName name = new LdapName("ou=people,dc=example,dc=org");
// Execute system under test.
final String result = manager.getProviderURL(name);
// Verify result.
assertEquals("ldaps://localhost:389/ou=people,dc=example,dc=org ldaps://example.org:389/ou=people,dc=example,dc=org", result);
}
Aggregations