/** * Retrieves the result code for this LDAP exception. * * @return The result code for this LDAP exception. */ public ResultCode getResultCode() { return ldapException.getResultCode(); }
/** * Retrieves the result code for this LDAP exception. * * @return The result code for this LDAP exception. */ public ResultCode getResultCode() { return ldapException.getResultCode(); }
/** * Checks if the specified LDAP exception is caused by the LDAP server * being unavailable, disconnected or timing out. * * @param e The LDAP exception. Must not be {@code null}. * * @return {@code true} if the LDAP exception is caused by the LDAP * server being unavailable, disconnected or timing out, else * {@code false}. */ protected static boolean indicatesConnectionException(final LDAPException e) { return indicatesConnectionException(e.getResultCode()); }
/** * Checks if the specified LDAP exception is caused by the LDAP server * being unavailable, disconnected or timing out. * * @param e The LDAP exception. Must not be {@code null}. * * @return {@code true} if the LDAP exception is caused by the LDAP * server being unavailable, disconnected or timing out, else * {@code false}. */ protected static boolean indicatesConnectionException(final LDAPException e) { return indicatesConnectionException(e.getResultCode()); }
private SessionId mergeWithRetry(final SessionId sessionId, int maxAttempts) { EntryPersistenceException lastException = null; for (int i = 1; i <= maxAttempts; i++) { try { putInCache(sessionId); return sessionId; } catch (EntryPersistenceException ex) { lastException = ex; if (ex.getCause() instanceof LDAPException) { LDAPException parentEx = ((LDAPException) ex.getCause()); log.debug("LDAP exception resultCode: '{}'", parentEx.getResultCode().intValue()); if ((parentEx.getResultCode().intValue() == ResultCode.NO_SUCH_ATTRIBUTE_INT_VALUE) || (parentEx.getResultCode().intValue() == ResultCode.ATTRIBUTE_OR_VALUE_EXISTS_INT_VALUE)) { log.warn("Session entry update attempt '{}' was unsuccessfull", i); continue; } } throw ex; } } log.error("Session entry update attempt was unsuccessfull after '{}' attempts", maxAttempts); throw lastException; }
final ResultCode ldapCode = ldapException.getResultCode();
/** * 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); }
/** * 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); }
/** * 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()); }
/** * 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()); }
/** * 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()); }
/** * 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()); } }
/** * 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()); } }
/** * 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(); }
/** * 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(); }
@Override public AuthenticationInfo getAuthenticationInfo(AuthenticationToken token) throws AuthenticationException { if (!(token instanceof UsernamePasswordToken)) { throw new UnsupportedTokenException("LDAPRealm only supports UsernamePasswordToken"); } UsernamePasswordToken userNamePasswordToken = (UsernamePasswordToken) token; try { LDAPUserContext userContext = ldapSupport.findUser(userNamePasswordToken.getUsername()); ldapSupport.authenticate(userContext, new String(userNamePasswordToken.getPassword())); AuthenticationInfo authcInfo = new AuthenticationInfo(userNamePasswordToken.getUsername(), userNamePasswordToken.getPassword()); authcInfo.getOtherPrincipals().add(new SimplePrincipalProvider("dn", userContext.getDn())); authcInfo.getOtherPrincipals().add(Principals.fullNamePrincipal(ldapSupport.getAttributeValue(userContext, "cn"))); authcInfo.getOtherPrincipals().add(new LDAPUserContextPrincipalProvider(userContext)); return authcInfo; } catch (org.seedstack.seed.security.ldap.api.LDAPException ex) { LDAPException e = (LDAPException) ex.getCause(); switch (e.getResultCode().intValue()) { case ResultCode.INVALID_CREDENTIALS_INT_VALUE: throw new IncorrectCredentialsException(e.getMessage()); default: throw new AuthenticationException(e.getMessage()); } } }
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)); } }
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)); } }
public static void bind(SSLSocketFactory socketFactory, LdapConfigBean config, IAsyncResultHandler<ILdapResult> handler) { LDAPConnection connection = null; try { connection = LDAPConnectionFactory.build(socketFactory, config); BindResult bindResponse = connection.bind(config.getBindDn(), config.getBindPassword()); evalBindReturn(bindResponse.getResultCode(), bindResponse.getDiagnosticMessage(), null, handler); LDAPConnectionFactory.releaseConnection(connection); } catch (LDAPException e) { // generally errors as an exception, also potentially normal return(!). evalBindReturn(e.getResultCode(), e.getMessage(), e, handler); LDAPConnectionFactory.releaseConnectionAfterException(connection, e); } catch (Exception e) { LDAPConnectionFactory.releaseDefunct(connection); handler.handle(AsyncResultImpl.<ILdapResult>create(e)); } }
public static void bind(SSLSocketFactory socketFactory, LdapConfigBean config, IAsyncResultHandler<ILdapResult> handler) { LDAPConnection connection = null; try { connection = LDAPConnectionFactory.build(socketFactory, config); BindResult bindResponse = connection.bind(config.getBindDn(), config.getBindPassword()); evalBindReturn(bindResponse.getResultCode(), bindResponse.getDiagnosticMessage(), null, handler); LDAPConnectionFactory.releaseConnection(connection); } catch (LDAPException e) { // generally errors as an exception, also potentially normal return(!). evalBindReturn(e.getResultCode(), e.getMessage(), e, handler); LDAPConnectionFactory.releaseConnectionAfterException(connection, e); } catch (Exception e) { LDAPConnectionFactory.releaseDefunct(connection); handler.handle(AsyncResultImpl.<ILdapResult>create(e)); } }