use of org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException in project directory-fortress-core by apache.
the class UserDAO method unlock.
/**
* @param user
* @throws UpdateException
*/
void unlock(User user) throws UpdateException {
LdapConnection ld = null;
String userDn = getDn(user.getUserId(), user.getContextId());
try {
// ld = getAdminConnection();
List<Modification> mods = new ArrayList<Modification>();
mods.add(new DefaultModification(ModificationOperation.REMOVE_ATTRIBUTE, OPENLDAP_PW_LOCKED_TIME));
ld = getAdminConnection();
modify(ld, userDn, mods, user);
} catch (LdapNoSuchAttributeException e) {
LOG.info("unlock user [" + user.getUserId() + "] no such attribute:" + OPENLDAP_ACCOUNT_LOCKED_TIME);
} catch (LdapException e) {
String error = "unlock user [" + user.getUserId() + "] caught LDAPException= " + e.getMessage();
throw new UpdateException(GlobalErrIds.USER_PW_UNLOCK_FAILED, error, e);
} finally {
closeAdminConnection(ld);
}
}
use of org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException in project directory-ldap-api by apache.
the class DefaultObjectClassRegistry method registerDescendants.
/**
* {@inheritDoc}
*/
@Override
public void registerDescendants(ObjectClass objectClass, List<ObjectClass> ancestors) throws LdapException {
// add this attribute to descendant list of other attributes in superior chain
if ((ancestors == null) || ancestors.isEmpty()) {
return;
}
for (ObjectClass ancestor : ancestors) {
// Get the ancestor's descendant, if any
Set<ObjectClass> descendants = oidToDescendants.get(ancestor.getOid());
// Initialize the descendant Set to store the descendants for the attributeType
if (descendants == null) {
descendants = new HashSet<>(1);
oidToDescendants.put(ancestor.getOid(), descendants);
}
// Add the current ObjectClass as a descendant
descendants.add(objectClass);
try {
// And recurse until we reach the top of the hierarchy
registerDescendants(objectClass, ancestor.getSuperiors());
} catch (LdapException ne) {
throw new LdapNoSuchAttributeException(ne.getMessage(), ne);
}
}
}
use of org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException in project directory-ldap-api by apache.
the class DefaultObjectClassRegistry method unregister.
/**
* {@inheritDoc}
*/
@Override
public ObjectClass unregister(String numericOid) throws LdapException {
try {
ObjectClass removed = super.unregister(numericOid);
// Deleting an ObjectClass which might be used as a superior means we have
// to recursively update the descendant map. We also have to remove
// the at.oid -> descendant relation
oidToDescendants.remove(numericOid);
// Now recurse if needed
unregisterDescendants(removed, removed.getSuperiors());
return removed;
} catch (LdapException ne) {
throw new LdapNoSuchAttributeException(ne.getMessage(), ne);
}
}
use of org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException in project directory-ldap-api by apache.
the class DefaultObjectClassRegistry method hasDescendants.
/**
* {@inheritDoc}
*/
@Override
public boolean hasDescendants(String ancestorId) throws LdapException {
try {
String oid = getOidByName(ancestorId);
Set<ObjectClass> descendants = oidToDescendants.get(oid);
return (descendants != null) && !descendants.isEmpty();
} catch (LdapException ne) {
throw new LdapNoSuchAttributeException(ne.getMessage(), ne);
}
}
use of org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException in project directory-ldap-api by apache.
the class DefaultAttributeTypeRegistry method descendants.
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public Iterator<AttributeType> descendants(String ancestorId) throws LdapException {
try {
String oid = getOidByName(ancestorId);
Set<AttributeType> descendants = oidToDescendantSet.get(oid);
if (descendants == null) {
return Collections.EMPTY_SET.iterator();
}
return descendants.iterator();
} catch (LdapException ne) {
throw new LdapNoSuchAttributeException(ne.getMessage(), ne);
}
}
Aggregations