bindRequest.setVersion3( true ); bindRequest.setName( name ); bindRequest.setSimple( true ); bindRequest.setCredentials( credentials ); bindRequest.setSimple( false ); bindRequest.setCredentials( credentials ); bindRequest.setSaslMechanism( saslMechanism ); bindRequest.addAllControls( controls );
/** * {@inheritDoc} */ @Override public String getName() { return getDecorated().getName(); }
/** * {@inheritDoc} */ @Override public boolean isSimple() { return getDecorated().isSimple(); }
IntermediateResponseHandler intermediateResponseHandler) throws UnsupportedOperationException { if (request.getAuthenticationType() != -128) { logger.warn("LDAP BIND: unsupported authentication type: " + request.getAuthenticationType()); resultHandler.handleResult(Responses.newBindResult(ResultCode.AUTH_METHOD_NOT_SUPPORTED)); return; String bindName = request.getName(); if (bindName.length() > 0) { if (request instanceof GenericBindRequest) {
/** * {@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 ); }
bindRequest.setMessageId( newId ); { bindRequest.getSaslMechanism() }, saslRequest.getAuthorizationId(), "ldap", String message = I18n.err( I18n.ERR_04158_CANNOT_FIND_SASL_FACTORY_FOR_MECH, bindRequest.getSaslMechanism() ); LOG.error( message ); throw new LdapException( message ); bindRequest.setCredentials( challengeResponse ); writeRequest( bindRequest ); bindRequestCopy.setMessageId( newId ); bindRequestCopy.setName( bindRequest.getName() ); bindRequestCopy.setSaslMechanism( bindRequest.getSaslMechanism() ); bindRequestCopy.setSimple( bindRequest.isSimple() ); bindRequestCopy.setVersion3( bindRequest.getVersion3() ); bindRequestCopy.addAllControls( bindRequest.getControls().values().toArray( new Control[0] ) ); bindRequest.setMessageId( newId ); bindRequest.setCredentials( response );
if ( req.isSimple() != isSimple() ) if ( req.isVersion3() != isVersion3() ) String name1 = req.getName(); String name2 = getName(); Dn dn1 = req.getDn(); Dn dn2 = getDn(); return Arrays.equals( req.getCredentials(), getCredentials() );
bindContext.setCredentials( bindRequest.getCredentials() ); Dn bindDn = bindRequest.getDn(); bindContext.setInterceptors( directoryService.getInterceptors( OperationEnum.BIND ) ); for ( Control control : bindRequest.getControls().values() ) if ( !bindRequest.isSimple() ) bindContext.setSaslMechanism( bindRequest.getSaslMechanism() );
bindRequest.setSimple( true ); bindRequest.setCredentials( Strings.getBytesUtf8( password ) ); bindRequest.setName( user ); bindRequest.setVersion3( true ); bindRequest.setMessageId( messageId );
Dn bindDn = bindRequest.getDn(); String name = bindRequest.getName(); bindRequest.setDn( bindDn ); bindContext.setDn( bindRequest.getDn() ); bindContext.setCredentials( bindRequest.getCredentials() ); bindContext.setIoSession( ldapSession.getIoSession() ); bindContext.setInterceptors( directoryService.getInterceptors( OperationEnum.BIND ) ); principalEntry = directoryService.getAdminSession().lookup( bindRequest.getDn() ); LOG.info( "The {} principalDN cannot be found in the server : bind failure.", bindRequest.getName() ); LdapResult result = bindRequest.getResultResponse().getLdapResult(); result.setDiagnosticMessage( "Bind principalDn points to referral." ); result.setResultCode( ResultCodeEnum.INVALID_CREDENTIALS ); ldapSession.getIoSession().write( bindRequest.getResultResponse() ); bindRequest.getResultResponse().addAllControls( bindContext.getResponseControls() ); sendBindSuccess( ldapSession, bindRequest, null ); LdapResult result = bindRequest.getResultResponse().getLdapResult(); bindRequest.getResultResponse().addAllControls( bindContext.getResponseControls() ); ldapSession.getIoSession().write( bindRequest.getResultResponse() );
/** * {@inheritDoc} */ @Override public BindRequest setCredentials( String credentials ) { getDecorated().setCredentials( credentials ); return this; }
BindRequest bindRequest ) throws Exception LdapResult result = bindRequest.getResultResponse().getLdapResult(); if ( bindRequest.getCredentials() == null ) bindRequest.setCredentials( Strings.EMPTY_BYTES ); byte[] tokenBytes = ss.evaluateResponse( bindRequest.getCredentials() ); String saslMechanism = bindRequest.getSaslMechanism(); byte[] password = null; BindResponse resp = ( BindResponse ) bindRequest.getResultResponse();
/** * 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 ); }
/** * {@inheritDoc} */ @Override public void action( LdapMessageContainer<BindRequestDecorator> container ) throws DecoderException { BindRequest bindRequestMessage = container.getMessage(); TLV tlv = container.getCurrentTLV(); // We will check that the sasl is not null if ( tlv.getLength() == 0 ) { String msg = I18n.err( I18n.ERR_05116_SASL_CREDS_CANT_BE_NULL ); LOG.error( msg ); BindResponseImpl response = new BindResponseImpl( bindRequestMessage.getMessageId() ); throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_CREDENTIALS, bindRequestMessage.getDn(), null ); } bindRequestMessage.setSimple( false ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_05115_SASL_CREDS_CREATED ) ); } } }
/** * {@inheritDoc} */ @Override public void action( LdapMessageContainer<BindRequestDecorator> container ) { BindRequest bindRequestMessage = container.getMessage(); // Get the Value and store it in the BindRequest TLV tlv = container.getCurrentTLV(); // We have to handle the special case of a 0 length name if ( tlv.getLength() == 0 ) { bindRequestMessage.setName( "" ); } else { byte[] nameBytes = tlv.getValue().getData(); String nameStr = Strings.utf8ToString( nameBytes ); bindRequestMessage.setName( nameStr ); } if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_05116_BIND_NAME_IS, bindRequestMessage.getName() ) ); } } }
@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(); } } } );
bindRequestMessage.setSimple( true ); bindRequestMessage.setCredentials( Strings.EMPTY_BYTES ); bindRequestMessage.setCredentials( tlv.getValue().getData() );
/** * {@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 Element toDsml( Element root ) { Element element = super.toDsml( root ); BindRequest request = getDecorated(); // Principal Dn dn = request.getDn(); if ( !Dn.isNullOrEmpty( dn ) ) { // A DN has been provided element.addAttribute( "principal", dn.getName() ); } else { // No DN has been provided, let's use the name as a string instead String name = request.getName(); element.addAttribute( "principal", name ); } return element; }
/** * {@inheritDoc} */ @Override public void action( LdapMessageContainer<BindRequestDecorator> container ) { BindRequest bindRequestMessage = container.getMessage(); TLV tlv = container.getCurrentTLV(); // We have to handle the special case of a 0 length // mechanism if ( tlv.getLength() == 0 ) { bindRequestMessage.setSaslMechanism( "" ); } else { bindRequestMessage.setSaslMechanism( Strings.utf8ToString( tlv.getValue().getData() ) ); } // We can have an END transition container.setGrammarEndAllowed( true ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_05118_THE_SASL_MECHANISM_IS, bindRequestMessage.getSaslMechanism() ) ); } } }