use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef in project jackrabbit-oak by apache.
the class LdapIdentityProvider method createGroup.
@Nonnull
private ExternalGroup createGroup(@Nonnull Entry entry, @CheckForNull String name) throws LdapInvalidAttributeValueException {
ExternalIdentityRef ref = new ExternalIdentityRef(entry.getDn().getName(), this.getName());
if (name == null) {
String idAttribute = config.getGroupConfig().getIdAttribute();
Attribute attr = entry.get(idAttribute);
if (attr == null) {
throw new LdapInvalidAttributeValueException(ResultCodeEnum.CONSTRAINT_VIOLATION, "no value found for attribute '" + idAttribute + "' for entry " + entry);
}
name = attr.getString();
}
String path = config.getGroupConfig().makeDnPath() ? createDNPath(entry.getDn()) : null;
LdapGroup group = new LdapGroup(this, ref, name, path);
Map<String, Object> props = group.getProperties();
applyAttributes(props, entry);
return group;
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef in project jackrabbit-oak by apache.
the class LdapProviderTest method testGetUserByForeignRef.
@Test
public void testGetUserByForeignRef() throws Exception {
ExternalIdentityRef ref = new ExternalIdentityRef(TEST_USER1_DN, "foobar");
ExternalIdentity id = idp.getIdentity(ref);
assertNull("Foreign ref must be null", id);
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef in project jackrabbit-oak by apache.
the class LdapProviderTest method testGetGroups2.
@Test
public void testGetGroups2() throws Exception {
ExternalIdentityRef ref = new ExternalIdentityRef(TEST_USER0_DN, IDP_NAME);
ExternalIdentity id = idp.getIdentity(ref);
assertTrue("User instance", id instanceof ExternalUser);
assertIfEquals("Groups", TEST_USER0_GROUPS, id.getDeclaredGroups());
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef in project jackrabbit-oak by apache.
the class LdapProviderTest method assertIfEquals.
public static void assertIfEquals(String message, String[] expected, Iterable<ExternalIdentityRef> result) {
List<String> dns = new LinkedList<String>();
for (ExternalIdentityRef ref : result) {
dns.add(ref.getId());
}
Collections.sort(dns);
Arrays.sort(expected);
String exp = Text.implode(expected, ",\n");
String res = Text.implode(dns.toArray(new String[dns.size()]), ",\n");
assertEquals(message, exp, res);
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef in project jackrabbit-oak by apache.
the class LdapProviderTest method testGetUnknownUserByRef.
@Test
public void testGetUnknownUserByRef() throws Exception {
ExternalIdentityRef ref = new ExternalIdentityRef("bla=foo," + TEST_USER1_DN, IDP_NAME);
ExternalIdentity id = idp.getIdentity(ref);
assertNull("Unknown user must return null", id);
}
Aggregations