@Override public ResultCode getResultCode() { return getResponse().getResultCode(); }
@Override public ResultCode getResultCode() { return getResponse().getResultCode(); }
@Override public ResultCode getResultCode() { return getResponse().getResultCode(); }
@Override public boolean passivate(final Connection c) { boolean success = false; if (c != null) { try { final BindOperation bind = new BindOperation(c); final Response<Void> response = bind.execute(bindRequest); success = ResultCode.SUCCESS == response.getResultCode(); } catch (Exception e) { logger.debug("passivation failed for bind request {}", bindRequest, e); } } return success; }
@Override public boolean passivate(final Connection c) { boolean success = false; if (c != null) { try { final BindOperation bind = new BindOperation(c); final Response<Void> response = bind.execute(bindRequest); success = ResultCode.SUCCESS == response.getResultCode(); } catch (Exception e) { logger.debug("passivation failed for bind request {}", bindRequest, e); } } return success; }
@Override public boolean passivate(final Connection c) { boolean success = false; if (c != null) { try { final BindOperation bind = new BindOperation(c); final Response<Void> response = bind.execute(bindRequest); success = ResultCode.SUCCESS == response.getResultCode(); } catch (Exception e) { logger.debug("passivation failed for bind request {}", bindRequest, e); } } return success; }
/** * Downloads a CRL from given LDAP url. * * @param r the resource that is the ldap url. * @return the x 509 cRL * @throws Exception if connection to ldap fails, or attribute to get the revocation list is unavailable */ protected X509CRL fetchCRLFromLdap(final Object r) throws Exception { try { final String ldapURL = r.toString(); logger.debug("Fetching CRL from ldap {}", ldapURL); final Response<SearchResult> result = performLdapSearch(ldapURL); if (result.getResultCode() == ResultCode.SUCCESS) { final LdapEntry entry = result.getResult().getEntry(); final LdapAttribute attribute = entry.getAttribute(); logger.debug("Located entry [{}]. Retrieving first attribute [{}]", entry, attribute); return fetchX509CRLFromAttribute(attribute); } else { 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); } }
/** * Executes the ldap search operation. * * @param cf connection factory * @param request search request * * @return status code * * @throws Exception on any LDAP search error */ protected int search(final ConnectionFactory cf, final SearchRequest request) throws Exception { final Connection conn = cf.getConnection(); conn.open(); final SearchOperation op = new SearchOperation(conn); final Response<SearchResult> response = op.execute(request); final SearchResult result = response.getResult(); final SearchResultWriter writer; if (outputDsmlv1) { writer = new Dsmlv1Writer(new BufferedWriter(new OutputStreamWriter(System.out))); } else { writer = new LdifWriter(new BufferedWriter(new OutputStreamWriter(System.out))); } writer.write(result); conn.close(); return response.getResultCode().value(); }
@Override public void responseReceived(final Response<Void> response) { searchResponse = new Response<>( searchResult, response.getResultCode(), response.getMessage(), response.getMatchedDn(), response.getControls(), response.getReferralURLs(), response.getMessageId()); responseLock.release(); }
@Override public void responseReceived(final Response<Void> response) { searchResponse = new Response<>( searchResult, response.getResultCode(), response.getMessage(), response.getMatchedDn(), response.getControls(), response.getReferralURLs(), response.getMessageId()); responseLock.release(); }
@Override public void responseReceived(final Response<Void> response) { searchResponse = new Response<>( searchResult, response.getResultCode(), response.getMessage(), response.getMatchedDn(), response.getControls(), response.getReferralURLs(), response.getMessageId()); responseLock.release(); }
/** * Executes the ldap compare operation. * * @param cf connection factory * @param dn to compare attribute on * @param attr attribute to compare * * @return status code * * @throws Exception on any LDAP search error */ protected int compare(final ConnectionFactory cf, final String dn, final LdapAttribute attr) throws Exception { final Connection conn = cf.getConnection(); conn.open(); final CompareOperation op = new CompareOperation(conn); final Response<Boolean> response = op.execute(new CompareRequest(dn, attr)); System.out.println(response.getResult()); conn.close(); return response.getResultCode().value(); }
/** * Execute delete operation boolean. * * @param connectionFactory the connection factory * @param entry the entry * @return the boolean * @throws LdapException the ldap exception */ public static boolean executeDeleteOperation(final ConnectionFactory connectionFactory, final LdapEntry entry) throws LdapException { try (Connection connection = createConnection(connectionFactory)) { final DeleteOperation delete = new DeleteOperation(connection); final DeleteRequest request = new DeleteRequest(entry.getDn()); request.setReferralHandler(new DeleteReferralHandler()); final Response<Void> res = delete.execute(request); return res.getResultCode() == ResultCode.SUCCESS; } catch (final LdapException e) { LOGGER.error(e.getMessage(), e); } return false; } }
/** * Executes the ldap compare operation. * * @param cf connection factory * @param dn to compare attribute on * @param attr attribute to compare * * @return status code * * @throws Exception on any LDAP search error */ protected int compare(final ConnectionFactory cf, final String dn, final LdapAttribute attr) throws Exception { final Connection conn = cf.getConnection(); conn.open(); final CompareOperation op = new CompareOperation(conn); final Response<Boolean> response = op.execute(new CompareRequest(dn, attr)); System.out.println(response.getResult()); conn.close(); return response.getResultCode().value(); }
/** * Executes the ldap compare operation. * * @param cf connection factory * @param dn to compare attribute on * @param attr attribute to compare * * @return status code * * @throws Exception on any LDAP search error */ protected int compare(final ConnectionFactory cf, final String dn, final LdapAttribute attr) throws Exception { final Connection conn = cf.getConnection(); conn.open(); final CompareOperation op = new CompareOperation(conn); final Response<Boolean> response = op.execute(new CompareRequest(dn, attr)); System.out.println(response.getResult()); conn.close(); return response.getResultCode().value(); }
@Override protected AuthenticationHandlerResponse authenticateInternal( final Connection c, final AuthenticationCriteria criteria) throws LdapException { final byte[] hash = digestCredential(criteria.getCredential(), passwordScheme.getAlgorithm()); final LdapAttribute la = new LdapAttribute( passwordAttribute, String.format("{%s}%s", passwordScheme.getLabel(), LdapUtils.base64Encode(hash)).getBytes()); final CompareOperation compare = new CompareOperation(c); final CompareRequest request = new CompareRequest(criteria.getDn(), la); request.setControls(processRequestControls(criteria)); final Response<Boolean> compareResponse = compare.execute(request); return new AuthenticationHandlerResponse( compareResponse.getResult(), compareResponse.getResultCode(), c, compareResponse.getMessage(), compareResponse.getControls(), compareResponse.getMessageId()); }
@Override protected AuthenticationHandlerResponse authenticateInternal( final Connection c, final AuthenticationCriteria criteria) throws LdapException { final byte[] hash = digestCredential(criteria.getCredential(), passwordScheme.getAlgorithm()); final LdapAttribute la = new LdapAttribute( passwordAttribute, String.format("{%s}%s", passwordScheme.getLabel(), LdapUtils.base64Encode(hash)).getBytes()); final CompareOperation compare = new CompareOperation(c); final CompareRequest request = new CompareRequest(criteria.getDn(), la); request.setControls(processRequestControls(criteria)); final Response<Boolean> compareResponse = compare.execute(request); return new AuthenticationHandlerResponse( compareResponse.getResult(), compareResponse.getResultCode(), c, compareResponse.getMessage(), compareResponse.getControls(), compareResponse.getMessageId()); }
/** * Performs the ldap search. * * @param request to invoke search with * * @return ldap response * * @throws LdapException if an error occurs */ protected Response<SearchResult> executeSearch(final SearchRequest request) throws LdapException { final SearchIterator si = getConnection().getProviderConnection().search(request); final SearchResult result = readResult(request, si); final Response<Void> response = si.getResponse(); return new Response<>( result, response.getResultCode(), response.getMessage(), response.getMatchedDn(), response.getControls(), response.getReferralURLs(), response.getMessageId()); }
/** * Performs the ldap search. * * @param request to invoke search with * * @return ldap response * * @throws LdapException if an error occurs */ protected Response<SearchResult> executeSearch(final SearchRequest request) throws LdapException { final SearchIterator si = getConnection().getProviderConnection().search(request); final SearchResult result = readResult(request, si); final Response<Void> response = si.getResponse(); return new Response<>( result, response.getResultCode(), response.getMessage(), response.getMatchedDn(), response.getControls(), response.getReferralURLs(), response.getMessageId()); }
/** * Performs the ldap search. * * @param request to invoke search with * * @return ldap response * * @throws LdapException if an error occurs */ protected Response<SearchResult> executeSearch(final SearchRequest request) throws LdapException { final SearchIterator si = getConnection().getProviderConnection().search(request); final SearchResult result = readResult(request, si); final Response<Void> response = si.getResponse(); return new Response<>( result, response.getResultCode(), response.getMessage(), response.getMatchedDn(), response.getControls(), response.getReferralURLs(), response.getMessageId()); }