public boolean authenticate(LdapNetworkConnection connection, String principal, String credentials) throws LdapException { checkArgument(!isNullOrEmpty(principal), "Binding with empty principal is forbidden."); checkArgument(!isNullOrEmpty(credentials), "Binding with empty credentials is forbidden."); final BindRequestImpl bindRequest = new BindRequestImpl(); bindRequest.setName(principal); bindRequest.setCredentials(credentials); LOG.trace("Re-binding with DN {} using password", principal); final BindResponse bind = connection.bind(bindRequest); if (!bind.getLdapResult().getResultCode().equals(ResultCodeEnum.SUCCESS)) { LOG.trace("Re-binding DN {} failed", principal); throw new RuntimeException(bind.toString()); } LOG.trace("Binding DN {} did not throw, connection authenticated: {}", principal, connection.isAuthenticated()); return connection.isAuthenticated(); } }
connection.bind();
/** * {@inheritDoc} */ @Override public void anonymousBind() throws LdapException { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_04109_ANONYMOUS_BIND ) ); } // Create the BindRequest BindRequest bindRequest = createBindRequest( StringConstants.EMPTY, Strings.EMPTY_BYTES ); BindResponse bindResponse = bind( bindRequest ); processResponse( bindResponse ); }
/** * Creates a new {@link LdapNetworkConnection} and authenticates as admin user. * The caller is responsible for closing the connection, use closeConnection(). * * @param ldapServer the LDAP server instance, used to obtain the port used * @return the created connection * @throws LdapException the LDAP exception */ public static LdapNetworkConnection createAdminConnection( LdapServer ldapServer ) throws LdapException { LdapNetworkConnection conn = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, ldapServer.getPort() ); conn.bind( DEFAULT_ADMIN, DEFAULT_PASSWORD ); return conn; }
/** * {@inheritDoc} */ @Override public void anonymousBind() throws LdapException { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_04109_ANONYMOUS_BIND ) ); } // Create the BindRequest BindRequest bindRequest = createBindRequest( StringConstants.EMPTY, Strings.EMPTY_BYTES ); BindResponse bindResponse = bind( bindRequest ); processResponse( bindResponse ); }
/** * {@inheritDoc} */ @Override public void anonymousBind() throws LdapException { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_04109_ANONYMOUS_BIND ) ); } // Create the BindRequest BindRequest bindRequest = createBindRequest( StringConstants.EMPTY, Strings.EMPTY_BYTES ); BindResponse bindResponse = bind( bindRequest ); processResponse( bindResponse ); }
public boolean authenticate(LdapNetworkConnection connection, String principal, String credentials) throws LdapException { checkArgument(!isNullOrEmpty(principal), "Binding with empty principal is forbidden."); checkArgument(!isNullOrEmpty(credentials), "Binding with empty credentials is forbidden."); final BindRequestImpl bindRequest = new BindRequestImpl(); bindRequest.setName(principal); bindRequest.setCredentials(credentials); LOG.trace("Re-binding with DN {} using password", principal); final BindResponse bind = connection.bind(bindRequest); if (!bind.getLdapResult().getResultCode().equals(ResultCodeEnum.SUCCESS)) { LOG.trace("Re-binding DN {} failed", principal); throw new RuntimeException(bind.toString()); } LOG.trace("Binding DN {} did not throw, connection authenticated: {}", principal, connection.isAuthenticated()); return connection.isAuthenticated(); } }
/** * Bind to the server using the SASL DIGEST-MD5 mechanism. * * @param userName The user name * @param credentials The user credentials * @return A LdapResponse containing the result * @throws LdapException if some error occurred */ public BindResponse bindSaslDigestMd5( String userName, String credentials ) throws LdapException { SaslDigestMd5Request request = new SaslDigestMd5Request(); request.setUsername( userName ); request.setCredentials( "secret" ); return bind( request ); }
/** * Bind to the server using the SASL CRAM-MD5 mechanism. * * @param userName The user name * @param credentials The user credentials * @return A LdapResponse containing the result * @throws LdapException if some error occurred */ public BindResponse bindSaslCramMd5( String userName, String credentials ) throws LdapException { SaslCramMd5Request request = new SaslCramMd5Request(); request.setUsername( userName ); request.setCredentials( "secret" ); return bind( request ); }
/** * Bind to the server using the SASL DIGEST-MD5 mechanism. * * @param userName The user name * @param credentials The user credentials * @return A LdapResponse containing the result * @throws LdapException if some error occurred */ public BindResponse bindSaslDigestMd5( String userName, String credentials ) throws LdapException { SaslDigestMd5Request request = new SaslDigestMd5Request(); request.setUsername( userName ); request.setCredentials( "secret" ); return bind( request ); }
/** * Bind to the server using the SASL CRAM-MD5 mechanism. * * @param userName The user name * @param credentials The user credentials * @return A LdapResponse containing the result * @throws LdapException if some error occurred */ public BindResponse bindSaslCramMd5( String userName, String credentials ) throws LdapException { SaslCramMd5Request request = new SaslCramMd5Request(); request.setUsername( userName ); request.setCredentials( "secret" ); return bind( request ); }
/** * Bind to the server using the SASL CRAM-MD5 mechanism. * * @param userName The user name * @param credentials The user credentials * @return A LdapResponse containing the result * @throws LdapException if some error occurred */ public BindResponse bindSaslCramMd5( String userName, String credentials ) throws LdapException { SaslCramMd5Request request = new SaslCramMd5Request(); request.setUsername( userName ); request.setCredentials( "secret" ); return bind( request ); }
/** * Bind to the server using the SASL DIGEST-MD5 mechanism. * * @param userName The user name * @param credentials The user credentials * @return A LdapResponse containing the result * @throws LdapException if some error occurred */ public BindResponse bindSaslDigestMd5( String userName, String credentials ) throws LdapException { SaslDigestMd5Request request = new SaslDigestMd5Request(); request.setUsername( userName ); request.setCredentials( "secret" ); return bind( request ); }
/** * {@inheritDoc} */ @Override public void bind() throws LdapException { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_04112_BIND ) ); } // Create the BindRequest BindRequest bindRequest = createBindRequest( config.getName(), Strings.getBytesUtf8( config.getCredentials() ) ); BindResponse bindResponse = bind( bindRequest ); processResponse( bindResponse ); }
/** * {@inheritDoc} */ @Override public void bind() throws LdapException { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_04112_BIND ) ); } // Create the BindRequest BindRequest bindRequest = createBindRequest( config.getName(), Strings.getBytesUtf8( config.getCredentials() ) ); BindResponse bindResponse = bind( bindRequest ); processResponse( bindResponse ); }
/** * {@inheritDoc} */ @Override public void bind() throws LdapException { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_04112_BIND ) ); } // Create the BindRequest BindRequest bindRequest = createBindRequest( config.getName(), Strings.getBytesUtf8( config.getCredentials() ) ); BindResponse bindResponse = bind( bindRequest ); processResponse( bindResponse ); }
connection.bind();
connection.bind(); } catch (Exception e) { throw new DataRetrievalException("LDAP connnection could not be bind", e);
/** * Performs an anonymous bind. * * @param request to bind with * * @return bind response * * @throws LdapException if an error occurs */ protected Response<Void> anonymousBind(final BindRequest request) throws LdapException { Response<Void> response = null; try { final BindRequestImpl bri = new BindRequestImpl(); if (request.getControls() != null) { bri.addAllControls(config.getControlProcessor().processRequestControls(request.getControls())); } final BindResponse br = connection.bind(bri); throwOperationException(request, br); response = createResponse(request, null, br); } catch (LdapOperationException e) { processLdapOperationException(e); } catch (org.apache.directory.api.ldap.model.exception.LdapException e) { processLdapException(e); } return response; }
bri.setCredentials(request.getCredential().getBytes()); final BindResponse br = connection.bind(bri); throwOperationException(request, br); response = createResponse(request, null, br);