/** * Creates a new LDAP exception using the information contained in the * provided LDAP exception. * * @param e The LDAP exception to use to create this exception. */ public LDAPException(final LDAPException e) { super(e.getMessage(), e.getCause()); resultCode = e.getResultCode(); matchedDN = e.getMatchedDN(); diagnosticMessage = e.getDiagnosticMessage(); referralURLs = e.getReferralURLs(); responseControls = e.getResponseControls(); }
/** * {@inheritDoc} */ @Override() public ASN1OctetString normalizeSubstring(final ASN1OctetString value, final byte substringType) throws LDAPException { throw new LDAPException(ResultCode.INAPPROPRIATE_MATCHING, ERR_GENERALIZED_TIME_SUBSTRING_MATCHING_NOT_SUPPORTED.get()); } }
/** * {@inheritDoc} */ @Override() public String getExceptionMessage() { return ldapException.getExceptionMessage(); } }
/** * Creates a new instance of this {@code LDAPRuntimeException} using the * provided {@code LDAPException}. * * @param ldapException The {@code LDAPException} object wrapped by this * runtime exception. */ public LDAPRuntimeException(final LDAPException ldapException) { super(ldapException.getMessage(), ldapException.getCause()); this.ldapException = ldapException; }
/** * Creates a new instance of this notice of disconnection extended result from * the provided LDAP exception. * * @param ldapException The LDAP exception to use to create this notice of * disconnection extended result. */ public NoticeOfDisconnectionExtendedResult(final LDAPException ldapException) { this(0, ldapException.getResultCode(), ldapException.getDiagnosticMessage(), ldapException.getMatchedDN(), ldapException.getReferralURLs(), ldapException.getResponseControls()); }
public void connect(final IAsyncResultHandler<ILdapResult> handler) { try { connection = LDAPConnectionFactory.build(socketFactory, config); BindResult bindResponse = connection.bind(config.getBindDn(), config.getBindPassword()); evalBindReturn(bindResponse.getResultCode(), bindResponse.getDiagnosticMessage(), null, handler); } catch (LDAPException e) { evalBindReturn(e.getResultCode(), e.getMessage(), e, handler); } catch (Exception e) { LDAPConnectionFactory.releaseDefunct(connection); handler.handle(AsyncResultImpl.<ILdapResult>create(e)); } }
/** * Creates a new LDAP search exception from the provided exception. * * @param ldapException The LDAP exception with the information to include * in this LDAP search exception. */ public LDAPSearchException(final LDAPException ldapException) { super(ldapException.getResultCode(), ldapException.getMessage(), ldapException.getMatchedDN(), ldapException.getReferralURLs(), ldapException.getResponseControls(), ldapException); if (ldapException instanceof LDAPSearchException) { final LDAPSearchException lse = (LDAPSearchException) ldapException; searchResult = lse.searchResult; } else { searchResult = new SearchResult(-1, ldapException.getResultCode(), ldapException.getMessage(), ldapException.getMatchedDN(), ldapException.getReferralURLs(), 0, 0, ldapException.getResponseControls()); } }
dn = new DN(entry.getDN()); } catch (LDAPException e) { throw new PersistenceException(e.getMessage(), e); if (e.getResultCode().equals(ResultCode.NO_SUCH_OBJECT)) { return false; throw new PersistenceException("LDAP modify for " + modifyRequest.getDN() + " failed: " + e.getResultString(), e); } finally { timerCtx.stop();
throw new LDAPException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, le.getMessage(), le); throw new LDAPException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, le.getMessage(), le);
/** * Creates a new {@code LDAPResult} object from this exception. * * @return The {@code LDAPResult} object created from this exception. */ public LDAPResult toLDAPResult() { if ((diagnosticMessage == null) && (getMessage() != null)) { return new LDAPResult(-1, resultCode, getMessage(), matchedDN, referralURLs, responseControls); } else { return new LDAPResult(-1, resultCode, diagnosticMessage, matchedDN, referralURLs, responseControls); } }
/** * Creates a new LDAP exception from the provided * {@link com.unboundid.ldap.sdk.LDAPException} object. * * @param ldapException The {@code LDAPException} object to use to create * this LDAP exception. */ public LDAPException(final com.unboundid.ldap.sdk.LDAPException ldapException) { this(ldapException.getMessage(), ldapException.getResultCode().intValue(), ldapException.getMessage(), ldapException.getMatchedDN()); }
/** * Retrieves the result code for this LDAP exception. * * @return The result code for this LDAP exception. */ public ResultCode getResultCode() { return ldapException.getResultCode(); }
ResultCode resultCode = e.getResultCode(); throw new PersistenceException("LDAP delete of " + dn + " failed: " + e.getResultString(), e); } finally { timerCtx.stop();
final Throwable t = le.getCause(); throw new LDAPException(ResultCode.TIMEOUT, le.getMessage(), le); le.getMessage(), t); message = le.getMessage(); debugLevel = Level.WARNING; le.getMessage(), t); message = ERR_READER_CLOSING_DUE_TO_IO_EXCEPTION.get( connection.getHostPort(), getExceptionMessage(t)); le.getMessage(), t); message = ERR_READER_CLOSING_DUE_TO_ASN1_EXCEPTION.get( connection.getHostPort(), getExceptionMessage(t)); le.getMessage(), t); message = ERR_READER_CLOSING_DUE_TO_EXCEPTION.get( connection.getHostPort(), getExceptionMessage(t)); throw new LDAPException(ResultCode.SERVER_DOWN, message, e);
throws LDAPException if (! ResultCode.isConnectionUsable(exception.getResultCode())) throw new LDAPException(ResultCode.SERVER_DOWN, ERR_POOL_HEALTH_CHECK_CONN_INVALID_AFTER_EXCEPTION.get( getExceptionMessage(exception)),
/** * Convert from {@link LDAPException} to apiman's {@link LdapException} * * @param e the LDAP Exception * @return a new LdapException */ public static LdapException create(LDAPException e) { return new LdapException(DefaultLdapResultCodeFactory.convertResultCode(e.getResultCode()), e.getDiagnosticMessage(), e); }
if (e.getResultCode().intValue() == LDAPException.INVALID_CREDENTIALS) { log.info("authenticateUser(): invalid credentials [userLogin = {}]", userLogin); return false; throw new RuntimeException( "authenticateUser(): LDAPException during authentication attempt [userLogin = " + userLogin + "][result code = " + e.getResultCode().toString() + "][error message = "+ e.getExceptionMessage() + "]", e);
throw new LDAPException(ResultCode.LOCAL_ERROR, "", e); throw new LDAPException(ResultCode.LOCAL_ERROR, "", e); throw new LDAPException(ResultCode.LOCAL_ERROR, "", e); tool.wrapErr(0, wrapColumn, ERR_INTERACTIVE_LDAP_CANNOT_CONNECT.get(hostname, port, le.getResultString())); if (promptForBoolean( INFO_INTERACTIVE_LDAP_RETRY_PROMPT.get(), true, true)) throw new LDAPException(le.getResultCode(), "", le); throw new LDAPException(startTLSResult); msg = ((LDAPException) e).getResultString(); throw new LDAPException(ResultCode.LOCAL_ERROR, "", e); tool.wrapErr(0, wrapColumn, ERR_INTERACTIVE_LDAP_CANNOT_AUTHENTICATE.get( le.getResultString())); if (promptForBoolean( INFO_INTERACTIVE_LDAP_RETRY_PROMPT.get(), true, true)) throw new LDAPException(le.getResultCode(), "", le);
/** * Retrieves the diagnostic message returned by the directory server. * * @return The diagnostic message returned by the directory server, or * {@code null} if there is none. */ public String getDiagnosticMessage() { return ldapException.getDiagnosticMessage(); }
public static void loadLdif(InMemoryDirectoryServer directoryServer, Resource ldifFile) throws IOException { File tempFile = File.createTempFile("spring_ldap_test", ".ldif"); try { InputStream inputStream = ldifFile.getInputStream(); IOUtils.copy(inputStream, new FileOutputStream(tempFile)); directoryServer.importFromLDIF(true, new LDIFReader(tempFile)); directoryServer.restartServer(); } catch (LDAPException e) { e.printStackTrace(); } finally { try { tempFile.delete(); } catch (Exception e) { // Ignore this } } } }