use of org.keycloak.representations.idm.LDAPCapabilityRepresentation.CapabilityType in project keycloak by keycloak.
the class LDAPCapabilityTest method testCapabilityTypeFromAttributeName.
@Test
public void testCapabilityTypeFromAttributeName() {
CapabilityType extension = CapabilityType.fromRootDseAttributeName("supportedExtension");
assertEquals(CapabilityType.EXTENSION, extension);
CapabilityType control = CapabilityType.fromRootDseAttributeName("supportedControl");
assertEquals(CapabilityType.CONTROL, control);
CapabilityType feature = CapabilityType.fromRootDseAttributeName("supportedFeatures");
assertEquals(CapabilityType.FEATURE, feature);
CapabilityType unknown = CapabilityType.fromRootDseAttributeName("foo");
assertEquals(CapabilityType.UNKNOWN, unknown);
}
use of org.keycloak.representations.idm.LDAPCapabilityRepresentation.CapabilityType in project keycloak by keycloak.
the class LDAPIdentityStore method queryServerCapabilities.
@Override
public Set<LDAPCapabilityRepresentation> queryServerCapabilities() {
Set<LDAPCapabilityRepresentation> result = new LinkedHashSet<>();
try {
List<String> attrs = new ArrayList<>();
attrs.add("supportedControl");
attrs.add("supportedExtension");
attrs.add("supportedFeatures");
List<SearchResult> searchResults = operationManager.search("", "(objectClass=*)", Collections.unmodifiableCollection(attrs), SearchControls.OBJECT_SCOPE);
if (searchResults.size() != 1) {
throw new ModelException("Could not query root DSE: unexpected result size");
}
SearchResult rootDse = searchResults.get(0);
Attributes attributes = rootDse.getAttributes();
for (String attr : attrs) {
Attribute attribute = attributes.get(attr);
if (null != attribute) {
CapabilityType capabilityType = CapabilityType.fromRootDseAttributeName(attr);
NamingEnumeration<?> values = attribute.getAll();
while (values.hasMoreElements()) {
Object o = values.nextElement();
LDAPCapabilityRepresentation capability = new LDAPCapabilityRepresentation(o, capabilityType);
logger.info("rootDSE query: " + capability);
result.add(capability);
}
}
}
return result;
} catch (NamingException e) {
throw new ModelException("Failed to query root DSE: " + e.getMessage(), e);
}
}
Aggregations