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(); } }
ResultCodeEnum rc = getResultCode( t ); if ( rc != null )
/** * {@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 instance of NoticeOfDisconnect. * * @param rcode The {@link ResultCodeEnum} value to wrap */ private CompareNoDResponse( ResultCodeEnum rcode ) { super(); switch ( rcode ) { case UNAVAILABLE: break; case PROTOCOL_ERROR: break; case STRONG_AUTH_REQUIRED: break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13503_RESULT_CODE_SHOULD_BE_IN, ResultCodeEnum.UNAVAILABLE, ResultCodeEnum.PROTOCOL_ERROR, ResultCodeEnum.STRONG_AUTH_REQUIRED ) ); } super.getLdapResult().setDiagnosticMessage( rcode.toString() + ": The server will disconnect!" ); super.getLdapResult().setMatchedDn( null ); super.getLdapResult().setResultCode( rcode ); }
if ( ResultCodeEnum.NOT_ALLOWED_ON_NON_LEAF.equals( ldapResult.getResultCode() ) ) else if ( ResultCodeEnum.ENTRY_ALREADY_EXISTS.equals( ldapResult.getResultCode() ) ) else if ( !ResultCodeEnum.SUCCESS.equals( ldapResult.getResultCode() ) ) int code = ldapResult.getResultCode().getResultCode(); String message = ldapResult.getDiagnosticMessage();
BerValue.encodeEnumerated( buffer, getResultCode().getValue() );
resultCodeElement.addAttribute( "code", Integer.toString( result.getResultCode().getResultCode() ) ); resultCodeElement.addAttribute( "descr", result.getResultCode().getMessage() );
Set<ResultCodeEnum> set = getResultCodes( t ); candidates = intersection( set, ADD_CODES ); break; candidates = intersection( set, BIND_CODES ); break; candidates = intersection( set, COMPARE_CODES ); break; candidates = intersection( set, DELETE_CODES ); break; candidates = intersection( set, EXTENDED_CODES ); break; candidates = intersection( set, MODIFYDN_CODES ); break; candidates = intersection( set, MODIFY_CODES ); break; case SEARCH_RESULT_REFERENCE: case INTERMEDIATE_RESPONSE: candidates = intersection( set, SEARCH_CODES ); break;
code = ResultCodeEnum.getBestEstimate( cause, req.getType() ); String msg = code.toString() + ": failed for " + req + ": " + cause.getLocalizedMessage();
/** * @see Object#hashCode() * @return the instance's hash code */ @Override public int hashCode() { int hash = 37; if ( referral != null ) { hash = hash * 17 + referral.hashCode(); } hash = hash * 17 + resultCode.hashCode(); if ( diagnosticMessage != null ) { hash = hash * 17 + diagnosticMessage.hashCode(); } if ( matchedDn != null ) { hash = hash * 17 + matchedDn.hashCode(); } return hash; }
ResultCodeEnum rc = getResultCode( t ); if ( rc != null )
/** * {@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 instance of NoticeOfDisconnect. * * @param rcode The {@link ResultCodeEnum} value to wrap */ private BindNoDResponse( ResultCodeEnum rcode ) { super(); switch ( rcode ) { case UNAVAILABLE: break; case PROTOCOL_ERROR: break; case STRONG_AUTH_REQUIRED: break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13503_RESULT_CODE_SHOULD_BE_IN, ResultCodeEnum.UNAVAILABLE, ResultCodeEnum.PROTOCOL_ERROR, ResultCodeEnum.STRONG_AUTH_REQUIRED ) ); } super.getLdapResult().setDiagnosticMessage( rcode.toString() + ": The server will disconnect!" ); super.getLdapResult().setMatchedDn( null ); super.getLdapResult().setResultCode( rcode ); }
BerValue.encodeEnumerated( buffer, getResultCode().getValue() );
Set<ResultCodeEnum> set = getResultCodes( t ); candidates = intersection( set, ADD_CODES ); break; candidates = intersection( set, BIND_CODES ); break; candidates = intersection( set, COMPARE_CODES ); break; candidates = intersection( set, DELETE_CODES ); break; candidates = intersection( set, EXTENDED_CODES ); break; candidates = intersection( set, MODIFYDN_CODES ); break; candidates = intersection( set, MODIFY_CODES ); break; case SEARCH_RESULT_REFERENCE: case INTERMEDIATE_RESPONSE: candidates = intersection( set, SEARCH_CODES ); break;
/** * @see Object#hashCode() * @return the instance's hash code */ @Override public int hashCode() { int hash = 37; if ( referral != null ) { hash = hash * 17 + referral.hashCode(); } hash = hash * 17 + resultCode.hashCode(); if ( diagnosticMessage != null ) { hash = hash * 17 + diagnosticMessage.hashCode(); } if ( matchedDn != null ) { hash = hash * 17 + matchedDn.hashCode(); } return hash; }
ResultCodeEnum rc = getResultCode( t ); if ( rc != null )
/** * {@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 instance of NoticeOfDisconnect. * * @param rcode The {@link ResultCodeEnum} value to wrap */ private ExtendedNoDResponse( ResultCodeEnum rcode ) { super( EXTENSION_OID ); switch ( rcode ) { case UNAVAILABLE: break; case PROTOCOL_ERROR: break; case STRONG_AUTH_REQUIRED: break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13503_RESULT_CODE_SHOULD_BE_IN, ResultCodeEnum.UNAVAILABLE, ResultCodeEnum.PROTOCOL_ERROR, ResultCodeEnum.STRONG_AUTH_REQUIRED ) ); } super.getLdapResult().setDiagnosticMessage( rcode.toString() + ": The server will disconnect!" ); super.getLdapResult().setMatchedDn( null ); super.getLdapResult().setResultCode( rcode ); }
BerValue.encodeEnumerated( buffer, getResultCode().getValue() );