@Override public String toString() { return String.format( "[%s@%d::resultCode=%s, matchedDn=%s, responseControls=%s, " + "referralURLs=%s, messageId=%s, message=%s, providerException=%s]", getClass().getName(), hashCode(), resultCode, matchedDn, Arrays.toString(responseControls), Arrays.toString(referralURLs), messageId, getMessage(), getCause()); } }
@Override public void exceptionReceived(final Exception exception) { logger.trace("received exception={}", exception); if (exception instanceof LdapException) { searchException = (LdapException) exception; } else { searchException = new LdapException(exception); } responseLock.release(); }
} catch (LdapException ex) { System.err.println("LDAP Operation failed:"); ex.printStackTrace(System.err); if (ex.getResultCode() != null) { status = ex.getResultCode().value();
public static String format(final Throwable t) { Throwable throwable = t; if (IllegalStateException.class.isInstance(throwable)) { throwable = throwable.getCause(); } final Throwable rootCause = ExceptionUtils.getRootCause(throwable) == null ? throwable : ExceptionUtils.getRootCause(throwable); String exceptionSimpleName = rootCause.getClass().getSimpleName(); String message = rootCause.getMessage(); if (LdapException.class.isInstance(throwable)) { LdapException le = LdapException.class.cast(throwable); // unwrap underlying exception if appropriate exceptionSimpleName = le.getCause() == null ? le.getClass().getSimpleName() : le.getCause().getClass().getSimpleName(); if (LdapReferralException.class.isInstance(le.getCause())) { final LdapReferralException ldapReferralException = LdapReferralException.class.cast(le.getCause()); message = "Referral error, remaining name '" + ldapReferralException.getRemainingName().toString() + "'"; } if (NameNotFoundException.class.isInstance(le.getCause())) { final NameNotFoundException nameNotFoundException = NameNotFoundException.class.cast(le.getCause()); message = "Name not found error, remaining name '" + nameNotFoundException.getRemainingName().toString() + "'"; } final StringBuilder sb = new StringBuilder(); sb.append("[").append(exceptionSimpleName).append("] "); sb.append(message); if (le.getResultCode() != null) { sb.append(" [result code = ").append(le.getResultCode().name()).append("]"); } return sb.toString(); } return "Error occurred: [" + exceptionSimpleName + "] " + message; }
/** * Downloads a CRL from given LDAP url. * * @param r the resource that is the ldap url. * @return the x 509 cRL * @throws IOException the exception thrown if resources cant be fetched * @throws CRLException the exception thrown if resources cant be fetched * @throws CertificateException if connection to ldap fails, or attribute to get the revocation list is unavailable */ protected X509CRL fetchCRLFromLdap(final Object r) throws CertificateException, IOException, CRLException { try { val ldapURL = r.toString(); LOGGER.debug("Fetching CRL from ldap [{}]", ldapURL); val result = performLdapSearch(ldapURL); if (result.getResultCode() == ResultCode.SUCCESS) { val entry = result.getResult().getEntry(); val attribute = entry.getAttribute(this.certificateAttribute); if (attribute.isBinary()) { LOGGER.debug("Located entry [{}]. Retrieving first attribute [{}]", entry, attribute); return fetchX509CRLFromAttribute(attribute); } LOGGER.warn("Found certificate attribute [{}] but it is not marked as a binary attribute", this.certificateAttribute); } LOGGER.debug("Failed to execute the search [{}]", result); throw new CertificateException("Failed to establish a connection ldap and search."); } catch (final LdapException e) { LOGGER.error(e.getMessage(), e); throw new CertificateException(e.getMessage()); } }
connResponse.getMessageId()); } catch (LdapException e) { if (e.getResultCode() != null) { response = new AuthenticationHandlerResponse( false, e.getResultCode(), c, e.getMessage(), e.getControls(), e.getMessageId()); } else { throw e;
SearchRequest.newObjectScopeSearchRequest(sourceEntry.getDn(), request.getSearchAttributes())); } catch (LdapException e) { if (e.getResultCode() != ResultCode.NO_SUCH_OBJECT) { throw e; searchResponse.getResultCode() != ResultCode.SUCCESS && searchResponse.getResultCode() != ResultCode.NO_SUCH_OBJECT) { throw new LdapException( String.format( "Error searching for entry: %s, response did not return success or " +
/** {@inheritDoc} */ @Override @Nullable public StorageRecord read(@Nonnull @NotEmpty final String context, @Nonnull @NotEmpty final String key) throws IOException { SearchResult result = null; try { result = search(context, key).getResult(); } catch (LdapException e) { if (e.getResultCode() != ResultCode.NO_SUCH_OBJECT) { log.error("LDAP search operation failed", e); throw new IOException(e); } } StorageRecord record = null; if (result != null && result.size() > 0) { final LdapEntry entry = result.getEntry(); if (entry != null) { final LdapAttribute attr = entry.getAttribute(key); if (attr != null) { record = new StorageRecord(attr.getStringValue(), null); } } } return record; }
.collect(Collectors.toSet()); } catch (final LdapException e) { e.printStackTrace(); throw new IllegalStateException(); } finally {
@Override public ResponseControl getControl(final String oid) { if (getControls() != null) { for (ResponseControl c : getControls()) { if (c.getOID().equals(oid)) { return c; } } } return null; }
logger.debug("Error occurred attempting DN lookup", e); loginSuccess = false; throw new LoginException(e != null ? e.getMessage() : "DN resolution error");
connResponse.getMessageId()); } catch (LdapException e) { if (e.getResultCode() != null) { response = new AuthenticationHandlerResponse( false, e.getResultCode(), c, e.getMessage(), e.getControls(), e.getMessageId()); } else { throw e;
SearchRequest.newObjectScopeSearchRequest(sourceEntry.getDn(), request.getSearchAttributes())); } catch (LdapException e) { if (e.getResultCode() != ResultCode.NO_SUCH_OBJECT) { throw e; searchResponse.getResultCode() != ResultCode.SUCCESS && searchResponse.getResultCode() != ResultCode.NO_SUCH_OBJECT) { throw new LdapException( String.format( "Error searching for entry: %s, response did not return success or " +
} catch (LdapException e) { logger.warn("Could not follow referral to " + url, e); if (e.getResultCode() == ResultCode.REFERRAL_LIMIT_EXCEEDED) { throw e;
}).collect(Collectors.toList()); } catch (final LdapException e) { e.printStackTrace(); throw new IllegalStateException(e); } finally {
@Override public ResponseControl getControl(final String oid) { if (getControls() != null) { for (ResponseControl c : getControls()) { if (c.getOID().equals(oid)) { return c; } } } return null; }
logger.debug("Error occurred attempting DN lookup", e); loginSuccess = false; throw new LoginException(e != null ? e.getMessage() : "DN resolution error");
connResponse.getMessageId()); } catch (LdapException e) { if (e.getResultCode() != null) { response = new AuthenticationHandlerResponse( false, e.getResultCode(), c, e.getMessage(), e.getControls(), e.getMessageId()); } else { throw e;
@Override public void exceptionReceived(final Exception exception) { logger.trace("received exception={}", exception); if (exception instanceof LdapException) { searchException = (LdapException) exception; } else { searchException = new LdapException(exception); } responseLock.release(); }
@Override public String toString() { return String.format( "[%s@%d::resultCode=%s, matchedDn=%s, responseControls=%s, " + "referralURLs=%s, messageId=%s, message=%s, providerException=%s]", getClass().getName(), hashCode(), resultCode, matchedDn, Arrays.toString(responseControls), Arrays.toString(referralURLs), messageId, getMessage(), getCause()); } }