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(); } }
result = bindResponse.getLdapResult().getResultCode(); result = bindResponse.getLdapResult().getResultCode(); && ( ( result == ResultCodeEnum.SASL_BIND_IN_PROGRESS ) || ( result == ResultCodeEnum.SUCCESS ) ) ) response = sc.evaluateChallenge( bindResponse.getServerSaslCreds() ); result = bindResponse.getLdapResult().getResultCode();
/** * {@inheritDoc} */ @Override public byte[] getServerSaslCreds() { return getDecorated().getServerSaslCreds(); }
/** * 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 ); }
/** * {@inheritDoc} */ @Override public void setServerSaslCreds( byte[] serverSaslCreds ) { getDecorated().setServerSaslCreds( serverSaslCreds ); }
bindResp.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS ); session = bindContext.getSession(); bindResp.addAllControls( bindContext.getResponseControls() ); LdapResult res = bindResp.getLdapResult(); res.setDiagnosticMessage( e.getMessage() ); res.setResultCode( e.getResultCode() );
result = bindResponse.getLdapResult().getResultCode(); result = bindResponse.getLdapResult().getResultCode(); && ( ( result == ResultCodeEnum.SASL_BIND_IN_PROGRESS ) || ( result == ResultCodeEnum.SUCCESS ) ) ) response = sc.evaluateChallenge( bindResponse.getServerSaslCreds() ); result = bindResponse.getLdapResult().getResultCode();
/** * {@inheritDoc} */ @Override public byte[] getServerSaslCreds() { return getDecorated().getServerSaslCreds(); }
/** * {@inheritDoc} */ @Override public void setServerSaslCreds( byte[] serverSaslCreds ) { getDecorated().setServerSaslCreds( serverSaslCreds ); }
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(); } }
result = bindResponse.getLdapResult().getResultCode(); result = bindResponse.getLdapResult().getResultCode(); && ( ( result == ResultCodeEnum.SASL_BIND_IN_PROGRESS ) || ( result == ResultCodeEnum.SUCCESS ) ) ) response = sc.evaluateChallenge( bindResponse.getServerSaslCreds() ); result = bindResponse.getLdapResult().getResultCode();
/** * {@inheritDoc} */ @Override public byte[] getServerSaslCreds() { return getDecorated().getServerSaslCreds(); }
/** * {@inheritDoc} */ @Override public void setServerSaslCreds( byte[] serverSaslCreds ) { getDecorated().setServerSaslCreds( serverSaslCreds ); } }
if ( bindResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
/** * {@inheritDoc} */ @Override public byte[] getServerSaslCreds() { return getDecorated().getServerSaslCreds(); }
/** * {@inheritDoc} */ @Override public void setServerSaslCreds( byte[] serverSaslCreds ) { getDecorated().setServerSaslCreds( serverSaslCreds ); }
if ( bindResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
byte[] creds = response.getServerSaslCreds();
response.setServerSaslCreds( serverSaslCreds );
if ( bindResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )