use of org.springframework.ldap.core.DirContextOperations in project perun by CESNET.
the class AbstractPerunEntry method entryAttributeExists.
@Override
public Boolean entryAttributeExists(T bean, String ldapAttributeName) {
DirContextOperations entry = findByDN(buildDN(bean));
String value = entry.getStringAttribute(ldapAttributeName);
return (value != null);
}
use of org.springframework.ldap.core.DirContextOperations in project perun by CESNET.
the class AbstractPerunEntry method modifyEntry.
@Override
public void modifyEntry(T bean, AttributeDefinition attr) {
DirContextOperations entry = findByDN(buildDN(bean));
List<PerunAttribute<T>> attrDefs = findAttributeDescriptionsByPerunAttr(getAttributeDescriptions(), attr);
if (attrDefs.isEmpty()) {
// this is not exceptional situation
// throw new InternalErrorException("Attribute description for attribute " + attr.getName() + " not found");
log.info("Attribute description for attribute {} not found, not modifying entry.", attr.getName());
return;
}
for (PerunAttribute<T> attrDef : attrDefs) {
mapToContext(bean, entry, attrDef, attr);
}
ldapTemplate.modifyAttributes(entry);
}
use of org.springframework.ldap.core.DirContextOperations in project perun by CESNET.
the class AbstractPerunEntry method removeAllAttributes.
@Override
public void removeAllAttributes(T bean) {
DirContextOperations entry = findByDN(buildDN(bean));
/* we have to find all existing entry attributes to resolve all the present options in names */
NamingEnumeration<String> attrNames = entry.getAttributes().getIDs();
while (attrNames.hasMoreElements()) {
String attrName = attrNames.nextElement();
Iterable<PerunAttribute<T>> attrDefs = findAttributeDescriptionsByLdapName(getAttributeDescriptions(), Arrays.asList(attrName));
for (PerunAttribute<T> attrDef : attrDefs) {
if (attrDef.requiresAttributeBean() && !attrDef.isRequired()) {
entry.setAttributeValues(attrName, null);
}
}
}
if (entry.getModificationItems().length > 0) {
ldapTemplate.modifyAttributes(entry);
}
}
use of org.springframework.ldap.core.DirContextOperations in project perun by CESNET.
the class AbstractPerunEntry method modifyEntry.
@Override
public void modifyEntry(T bean, PerunAttribute<T> attrDef, AttributeDefinition attr) {
DirContextOperations entry = findByDN(buildDN(bean));
mapToContext(bean, entry, attrDef, attr);
ldapTemplate.modifyAttributes(entry);
}
use of org.springframework.ldap.core.DirContextOperations in project perun by CESNET.
the class AbstractPerunEntry method modifyEntry.
@Override
public void modifyEntry(T bean, Iterable<Pair<PerunAttribute<T>, AttributeDefinition>> attrs) {
DirContextOperations entry = findByDN(buildDN(bean));
for (Pair<PerunAttribute<T>, AttributeDefinition> pair : attrs) {
mapToContext(bean, entry, pair.getLeft(), pair.getRight());
}
ldapTemplate.modifyAttributes(entry);
}
Aggregations