/** * Send back an INVALID-CREDENTIAL error message to the user. If we have an exception * as a third argument, then send back the associated message to the client. */ private void sendInvalidCredentials( LdapSession ldapSession, BindRequest bindRequest, Exception e ) { LdapResult result = bindRequest.getResultResponse().getLdapResult(); String message = ""; if ( e != null ) { message = ResultCodeEnum.INVALID_CREDENTIALS + ": " + e.getLocalizedMessage(); } else { message = ResultCodeEnum.INVALID_CREDENTIALS.toString(); } LOG.error( message ); result.setResultCode( ResultCodeEnum.INVALID_CREDENTIALS ); result.setDiagnosticMessage( message ); // Reinitialize the state to Anonymous and clear the sasl properties ldapSession.clearSaslProperties(); ldapSession.setAnonymous(); // Write back the error response ldapSession.getIoSession().write( bindRequest.getResultResponse() ); }
/** * Send back an AUTH-METH-NOT-SUPPORTED error message to the client */ private void sendAuthMethNotSupported( LdapSession ldapSession, BindRequest bindRequest ) { // First, r-einit the state to Anonymous, and clear the // saslProperty map ldapSession.clearSaslProperties(); ldapSession.setAnonymous(); // And send the response to the client LdapResult bindResult = bindRequest.getResultResponse().getLdapResult(); bindResult.setResultCode( ResultCodeEnum.AUTH_METHOD_NOT_SUPPORTED ); bindResult.setDiagnosticMessage( ResultCodeEnum.AUTH_METHOD_NOT_SUPPORTED.toString() + ": " + bindRequest.getSaslMechanism() + " is not a supported mechanism." ); // Write back the error ldapSession.getIoSession().write( bindRequest.getResultResponse() ); }
LdapResult bindResult = bindRequest.getResultResponse().getLdapResult(); bindResult.setResultCode( ResultCodeEnum.PROTOCOL_ERROR ); bindResult.setDiagnosticMessage( I18n.err( I18n.ERR_163 ) ); ldapSession.getIoSession().write( bindRequest.getResultResponse() ); return;
LdapResult result = bindRequest.getResultResponse().getLdapResult(); session.write( bindRequest.getResultResponse() ); ctx = null;
/** * Send a SUCCESS message back to the client. */ private void sendBindSuccess( LdapSession ldapSession, BindRequest bindRequest, byte[] tokenBytes ) { // Return the successful response BindResponse response = ( BindResponse ) bindRequest.getResultResponse(); response.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS ); response.setServerSaslCreds( tokenBytes ); if ( !ldapSession.getCoreSession().isAnonymous() ) { // If we have not been asked to authenticate as Anonymous, authenticate the user ldapSession.setAuthenticated(); } else { // Otherwise, switch back to Anonymous ldapSession.setAnonymous(); } // Clean the SaslProperties, we don't need them anymore MechanismHandler handler = ( MechanismHandler ) ldapSession.getSaslProperty( SaslConstants.SASL_MECH_HANDLER ); if ( handler != null ) { handler.cleanup( ldapSession ); } ldapSession.getIoSession().write( response ); LOG.debug( "Returned SUCCESS message: {}.", response ); }
BindResponse response = ( BindResponse ) bindRequest.getResultResponse(); response.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS ); LdapProtocolUtils.setResponseControls( bindContext, response ); LdapResult result = bindRequest.getResultResponse().getLdapResult(); ldapSession.getIoSession().write( bindRequest.getResultResponse() );
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() );
BindRequest bindRequest ) throws Exception LdapResult result = bindRequest.getResultResponse().getLdapResult(); BindResponse resp = ( BindResponse ) bindRequest.getResultResponse();