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(); } }
/** * Creates a new getDecoratedMessage() of AuthRequestDsml. * * @param codec The LDAP Service to use */ public BindRequestDsml( LdapApiService codec ) { super( codec, new BindRequestImpl() ); }
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(); } }
/** * {@inheritDoc} */ @Override public void anonymousBind() throws LdapException { BindRequest bindRequest = new BindRequestImpl(); bindRequest.setName( "" ); bindRequest.setCredentials( ( byte[] ) null ); BindResponse bindResponse = bind( bindRequest ); processResponse( bindResponse ); }
/** * {@inheritDoc} */ @Override public void bind( Dn name ) throws LdapException { byte[] credBytes = Strings.EMPTY_BYTES; BindRequest bindRequest = new BindRequestImpl(); bindRequest.setDn( name ); bindRequest.setCredentials( credBytes ); BindResponse bindResponse = bind( bindRequest ); processResponse( bindResponse ); }
/** * {@inheritDoc} */ @Override public void bind( Dn name ) throws LdapException { byte[] credBytes = Strings.EMPTY_BYTES; BindRequest bindRequest = new BindRequestImpl(); bindRequest.setDn( name ); bindRequest.setCredentials( credBytes ); BindResponse bindResponse = bind( bindRequest ); processResponse( bindResponse ); }
/** * {@inheritDoc} */ @Override public void bind( Dn name ) throws LdapException { byte[] credBytes = Strings.EMPTY_BYTES; BindRequest bindRequest = new BindRequestImpl(); bindRequest.setDn( name ); bindRequest.setCredentials( credBytes ); BindResponse bindResponse = bind( bindRequest ); processResponse( bindResponse ); }
/** * {@inheritDoc} */ @Override public void bind( Dn name, String credentials ) throws LdapException { byte[] credBytes = credentials == null ? Strings.EMPTY_BYTES : Strings.getBytesUtf8( credentials ); BindRequest bindRequest = new BindRequestImpl(); bindRequest.setDn( name ); bindRequest.setCredentials( credBytes ); BindResponse bindResponse = bind( bindRequest ); processResponse( bindResponse ); }
/** * {@inheritDoc} */ @Override public void bind( Dn name, String credentials ) throws LdapException { byte[] credBytes = credentials == null ? Strings.EMPTY_BYTES : Strings.getBytesUtf8( credentials ); BindRequest bindRequest = new BindRequestImpl(); bindRequest.setDn( name ); bindRequest.setCredentials( credBytes ); BindResponse bindResponse = bind( bindRequest ); processResponse( bindResponse ); }
/** * {@inheritDoc} */ @Override public void bind( Dn name, String credentials ) throws LdapException { byte[] credBytes = credentials == null ? Strings.EMPTY_BYTES : Strings.getBytesUtf8( credentials ); BindRequest bindRequest = new BindRequestImpl(); bindRequest.setDn( name ); bindRequest.setCredentials( credBytes ); BindResponse bindResponse = bind( bindRequest ); processResponse( bindResponse ); }
@Override public ResultResponse process() throws LdapException { MemoryClearingBuffer passwordBuffer = MemoryClearingBuffer.newInstance( password ); try { BindRequest bindRequest = new BindRequestImpl() .setDn( userDn ) .setCredentials( passwordBuffer.getBytes() ) .addControl( passwordPolicyRequestControl ); return connection.bind( bindRequest ); } finally { passwordBuffer.clear(); } } } );
/** * Calls the PoolMgr to perform an LDAP bind for a user/password combination. This function is valid * if and only if the user entity is a member of the USERS data set. * * @param connection connection to ldap server. * @param szUserDn contains the LDAP dn to the user entry in String format. * @param password contains the password in clear text. * @return bindResponse contains the result of the operation. * @throws LdapException in the event of LDAP error. */ protected BindResponse bind( LdapConnection connection, String szUserDn, String password ) throws LdapException { COUNTERS.incrementBind(); Dn userDn = new Dn( szUserDn ); BindRequest bindReq = new BindRequestImpl(); bindReq.setDn( userDn ); bindReq.setCredentials( password ); bindReq.addControl( PP_REQ_CTRL ); return connection.bind( bindReq ); }
@Override public ResultResponse process() throws LdapException { MemoryClearingBuffer passwordBuffer = MemoryClearingBuffer.newInstance( password ); try { BindRequest bindRequest = new BindRequestImpl() .setDn( userDn ) .setCredentials( passwordBuffer.getBytes() ) .addControl( passwordPolicyRequestControl ); return connection.bind( bindRequest ); } finally { passwordBuffer.clear(); } } } );
@Override public ResultResponse process() throws LdapException { MemoryClearingBuffer passwordBuffer = MemoryClearingBuffer.newInstance( password ); try { BindRequest bindRequest = new BindRequestImpl() .setDn( userDn ) .setCredentials( passwordBuffer.getBytes() ) .addControl( passwordPolicyRequestControl ); return connection.bind( bindRequest ); } finally { passwordBuffer.clear(); } } } );
/** * {@inheritDoc} */ @Override public void action( LdapMessageContainer<BindRequestDecorator> container ) throws DecoderException { // Create the BindRequest LdapMessage instance and store it in the container BindRequest internalBindRequest = new BindRequestImpl(); internalBindRequest.setMessageId( container.getMessageId() ); BindRequestDecorator bindRequest = new BindRequestDecorator( container.getLdapCodecService(), internalBindRequest ); container.setMessage( bindRequest ); // We will check that the request is not null TLV tlv = container.getCurrentTLV(); if ( tlv.getLength() == 0 ) { String msg = I18n.err( I18n.ERR_05144_NULL_BIND_REQUEST ); LOG.error( msg ); // This will generate a PROTOCOL_ERROR throw new DecoderException( msg ); } } }
/** * {@inheritDoc} */ @Override public void action( LdapMessageContainer<BindRequestDecorator> container ) throws DecoderException { // Create the BindRequest LdapMessage instance and store it in the container BindRequest internalBindRequest = new BindRequestImpl(); internalBindRequest.setMessageId( container.getMessageId() ); BindRequestDecorator bindRequest = new BindRequestDecorator( container.getLdapCodecService(), internalBindRequest ); container.setMessage( bindRequest ); // We will check that the request is not null TLV tlv = container.getCurrentTLV(); if ( tlv.getLength() == 0 ) { String msg = I18n.err( I18n.ERR_05144_NULL_BIND_REQUEST ); LOG.error( msg ); // This will generate a PROTOCOL_ERROR throw new DecoderException( msg ); } } }
/** * {@inheritDoc} */ @Override public void action( LdapMessageContainer<BindRequestDecorator> container ) throws DecoderException { // Create the BindRequest LdapMessage instance and store it in the container BindRequest internalBindRequest = new BindRequestImpl(); internalBindRequest.setMessageId( container.getMessageId() ); BindRequestDecorator bindRequest = new BindRequestDecorator( container.getLdapCodecService(), internalBindRequest ); container.setMessage( bindRequest ); // We will check that the request is not null TLV tlv = container.getCurrentTLV(); if ( tlv.getLength() == 0 ) { String msg = I18n.err( I18n.ERR_05144_NULL_BIND_REQUEST ); LOG.error( msg ); // This will generate a PROTOCOL_ERROR throw new DecoderException( msg ); } } }
BindRequest bindRequest = new BindRequestImpl(); bindRequest.setSimple( true ); bindRequest.setCredentials( Strings.getBytesUtf8( password ) );
/** * 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; }
final BindRequestImpl bri = new BindRequestImpl(); if (request.getControls() != null) { bri.addAllControls(config.getControlProcessor().processRequestControls(request.getControls()));