use of org.apache.directory.api.ldap.model.exception.LdapException in project directory-ldap-api by apache.
the class AbstractPasswordPolicyResponder method process.
/**
* {@inheritDoc}
*/
@Override
public final PasswordWarning process(PasswordPolicyOperation operation) throws PasswordException {
try {
ResultResponse response = operation.process();
PasswordPolicy passwordPolicy = getPasswordPolicy(response);
ResultCodeEnum resultCode = response.getLdapResult().getResultCode();
if (resultCode == ResultCodeEnum.SUCCESS) {
return success(passwordPolicy);
} else {
throw fail(response, passwordPolicy, resultCode);
}
} catch (LdapException e) {
throw new PasswordException().setLdapException(e);
}
}
use of org.apache.directory.api.ldap.model.exception.LdapException in project directory-ldap-api by apache.
the class LdapConnectionTemplate method modifyPassword.
/**
* {@inheritDoc}
*/
@Override
public void modifyPassword(Dn userDn, char[] oldPassword, char[] newPassword, boolean asAdmin) throws PasswordException {
LdapConnection connection = null;
try {
connection = connectionPool.getConnection();
if (!asAdmin) {
authenticateConnection(connection, userDn, oldPassword);
}
modifyPassword(connection, userDn, newPassword);
} catch (LdapException e) {
throw new LdapRuntimeException(e);
} finally {
returnLdapConnection(connection);
}
}
use of org.apache.directory.api.ldap.model.exception.LdapException in project directory-ldap-api by apache.
the class SearchCursorImpl method next.
/**
* {@inheritDoc}
*/
@Override
public boolean next() throws LdapException, CursorException {
if (done) {
return false;
}
try {
if (future.isCancelled()) {
response = null;
done = true;
return false;
}
response = future.get(timeout, timeUnit);
} catch (Exception e) {
LdapException ldapException = new LdapException(LdapNetworkConnection.NO_RESPONSE_ERROR, e);
// Send an abandon request
if (!future.isCancelled()) {
future.cancel(true);
}
// close the cursor
try {
close(ldapException);
} catch (IOException ioe) {
throw new LdapException(ioe.getMessage(), ioe);
}
throw ldapException;
}
if (response == null) {
future.cancel(true);
throw new LdapConnectionTimeOutException(LdapNetworkConnection.TIME_OUT_ERROR);
}
done = response instanceof SearchResultDone;
if (done) {
searchDoneResp = (SearchResultDone) response;
response = null;
}
return !done;
}
use of org.apache.directory.api.ldap.model.exception.LdapException in project directory-ldap-api by apache.
the class OidRegistry method getNameSet.
/**
* Gets the names associated with an OID. An OID is unique however it may
* have many names used to refer to it. A good example is the cn and
* commonName attribute names for OID 2.5.4.3. Within a server one name
* within the set must be chosen as the primary name. This is used to
* name certain things within the server internally. If there is more than
* one name then the first name is taken to be the primary.
*
* @param oid the OID for which we return the set of common names
* @return a sorted set of names
* @throws org.apache.directory.api.ldap.model.exception.LdapException if oid does not exist
*/
public List<String> getNameSet(String oid) throws LdapException {
SchemaObject schemaObject = byOid.get(oid);
if (null == schemaObject) {
String msg = I18n.err(I18n.ERR_13741_OID_NOT_FOUND_IN_REGISTRY, oid);
LOG.error(msg);
throw new LdapException(msg);
}
List<String> names = schemaObject.getNames();
if (IS_DEBUG) {
LOG.debug("looked up names '{}' for OID '{}'", ArrayUtils.toString(names), oid);
}
return names;
}
use of org.apache.directory.api.ldap.model.exception.LdapException in project directory-ldap-api by apache.
the class OidRegistry method getPrimaryName.
/**
* Gets the primary name associated with an OID. The primary name is the
* first name specified for the OID.
*
* @param oid the object identifier
* @return the primary name
* @throws LdapException if oid does not exist
*/
public String getPrimaryName(String oid) throws LdapException {
SchemaObject schemaObject = byOid.get(oid);
if (schemaObject != null) {
return schemaObject.getName();
} else {
String msg = I18n.err(I18n.ERR_13741_OID_NOT_FOUND_IN_REGISTRY, oid);
LOG.error(msg);
throw new LdapException(msg);
}
}
Aggregations