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 String getDiagnosticMessage() { return decoratedLdapResult.getDiagnosticMessage(); }
/** * {@inheritDoc} */ @Override public void setDiagnosticMessage( String diagnosticMessage ) { decoratedLdapResult.setDiagnosticMessage( diagnosticMessage ); }
ldapResult.setMatchedDn( new Dn( attributeValue ) );
pwdModifyResponse.getLdapResult().setResultCode( response.getLdapResult().getResultCode() ); pwdModifyResponse.getLdapResult().setDiagnosticMessage( response.getLdapResult().getDiagnosticMessage() ); pwdModifyResponse.getLdapResult().setMatchedDn( response.getLdapResult().getMatchedDn() ); pwdModifyResponse.getLdapResult().setReferral( response.getLdapResult().getReferral() ); pwdModifyResponse.getLdapResult().setResultCode( response.getLdapResult().getResultCode() ); pwdModifyResponse.getLdapResult().setDiagnosticMessage( response.getLdapResult().getDiagnosticMessage() ); pwdModifyResponse.getLdapResult().setMatchedDn( response.getLdapResult().getMatchedDn() ); pwdModifyResponse.getLdapResult().setReferral( response.getLdapResult().getReferral() );
/** * Determines if the supplied response should result in an operation retry. * * @param request that produced the exception * @param resultResponse provider response * * @throws LdapException wrapping the ldap exception */ protected void throwOperationException(final Request request, final ResultResponse resultResponse) throws LdapException { final LdapResult ldapResult = resultResponse.getLdapResult(); final Referral ref = ldapResult.getReferral(); ProviderUtils.throwOperationException( config.getOperationExceptionResultCodes(), String.format("Ldap returned result code: %s", ldapResult.getResultCode()), ldapResult.getResultCode().getResultCode(), ldapResult.getMatchedDn() != null ? ldapResult.getMatchedDn().getName() : null, processResponseControls(config.getControlProcessor(), request.getControls(), resultResponse), ref != null ? ref.getLdapUrls().toArray(new String[ref.getReferralLength()]) : null, false); }
/** * 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 ); }
SearchRequest searchRequest = new SearchRequestImpl(); searchRequest.addControl(getSearchContinuationControl(srsc.getServerType())); searchRequest.setBase(new Dn(getBaseDn())); searchRequest.setFilter(getFilterAll()); searchRequest.setDerefAliases(getAlias(ldapConn.getDerefAliases())); temporaryMap.put(sre.getObjectName().toString(), convertEntry(sre.getEntry(), true)); return temporaryMap.entrySet().iterator().next(); } else if(searchResponse != null && searchResponse.getType() == MessageTypeEnum.SEARCH_RESULT_DONE){ LdapResult result = ((SearchResultDone)searchResponse).getLdapResult(); if(result.getResultCode() != ResultCodeEnum.SUCCESS) { throw new LscServiceCommunicationException(result.getDiagnosticMessage(), null);
if ( referral == null && result.getReferral() != null ) if ( result.getReferral() == null && referral != null ) if ( referral != null && result.getReferral() != null && !referral.equals( result.getReferral() ) ) if ( !resultCode.equals( result.getResultCode() ) ) String errMsg1 = result.getDiagnosticMessage(); if ( !matchedDn.equals( result.getMatchedDn() ) ) else if ( result.getMatchedDn() != null )
/** * {@inheritDoc} */ @Override public StartTlsResponseDecorator decorate( ExtendedResponse decoratedResponse ) { if ( decoratedResponse instanceof StartTlsResponseDecorator ) { return ( StartTlsResponseDecorator ) decoratedResponse; } if ( decoratedResponse instanceof StartTlsResponse ) { return new StartTlsResponseDecorator( codec, ( StartTlsResponse ) decoratedResponse ); } // It's an opaque extended operation @SuppressWarnings("unchecked") ExtendedResponseDecorator<ExtendedResponse> response = ( ExtendedResponseDecorator<ExtendedResponse> ) decoratedResponse; // Decode the response, as it's an opaque operation StartTlsResponse startTlsResponse = new StartTlsResponseImpl( response.getMessageId() ); startTlsResponse.getLdapResult().setResultCode( response.getLdapResult().getResultCode() ); startTlsResponse.getLdapResult().setDiagnosticMessage( response.getLdapResult().getDiagnosticMessage() ); return new StartTlsResponseDecorator( codec, new StartTlsResponseImpl() ); } }
/** * Create a new instance for the StartTls response * @param messageId The Message ID * @param rcode The result code * @param diagnosticMessage The diagnostic message */ public StartTlsResponseImpl( int messageId, ResultCodeEnum rcode, String diagnosticMessage ) { super( messageId, EXTENSION_OID ); super.getLdapResult().setMatchedDn( null ); super.getLdapResult().setResultCode( rcode ); super.getLdapResult().setDiagnosticMessage( diagnosticMessage ); }
compareRequest.setName( new Dn( dn ) ); compareRequest.setAttributeId( attribute.getId() ); compareRequest.setAssertionValue( attribute.getString() ); compareRequest.addControl( proxiedAuthzControl ); CompareResponse response = connection.compare( compareRequest ); return response.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS;
throw new LdapException( I18n.err( I18n.ERR_04157_CANNOT_USE_TLS_WITH_SSL_FLAG ) ); LOG.debug( I18n.msg( I18n.MSG_04121_LDAP_ALREADY_USING_START_TLS ) ); LdapResult result = resp.getLdapResult(); if ( result.getResultCode() == ResultCodeEnum.SUCCESS ) throw new LdapOperationException( result.getResultCode(), result.getDiagnosticMessage() );
if ( entryDn.isRootDse() ) if ( newDn.isRootDse() ) resp.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS ); modifyDnRequest.setNewRdn( newDn.getRdn() ); modifyDnRequest.setNewSuperior( newDn.getParent() ); modifyDnRequest.setDeleteOldRdn( deleteOldRdn );
/** * Instantiates a new StartTls response. * * @param messageId the message id */ public StartTlsResponseImpl( int messageId ) { super( messageId, EXTENSION_OID ); super.getLdapResult().setMatchedDn( null ); super.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS ); }
/** * {@inheritDoc} */ @Override public void action( LdapMessageContainer<MessageDecorator<? extends Message>> container ) throws DecoderException { TLV tlv = container.getCurrentTLV(); // If we hae a Referrals sequence, then it should not be empty if ( tlv.getLength() == 0 ) { String msg = I18n.err( I18n.ERR_05105_REFERRAL_MUST_NOT_BE_NULL ); LOG.error( msg ); // This will generate a PROTOCOL_ERROR throw new DecoderException( msg ); } ResultResponse response = ( ResultResponse ) container.getMessage(); LdapResult ldapResult = response.getLdapResult(); Referral referral = new ReferralImpl(); ldapResult.setReferral( referral ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_05105_INITIALISNG_REFERRAL_LIST ) ); } } }
/** * Create a new CertGenerationResponseImpl instance * * @param messageId The request's message ID * @param rcode The result code */ public CertGenerationResponseImpl( int messageId, ResultCodeEnum rcode ) { super( messageId, EXTENSION_OID ); switch ( rcode ) { case SUCCESS: case OPERATIONS_ERROR: case INSUFFICIENT_ACCESS_RIGHTS: break; default: throw new IllegalArgumentException( I18n.err( I18n.ERR_13503_RESULT_CODE_SHOULD_BE_IN, ResultCodeEnum.SUCCESS, ResultCodeEnum.OPERATIONS_ERROR, ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS ) ); } super.getLdapResult().setMatchedDn( null ); super.getLdapResult().setResultCode( rcode ); }
result.setReferral( referral ); result.setResultCode( ResultCodeEnum.REFERRAL ); result.setDiagnosticMessage( "Encountered referral attempting to handle request." ); result.setMatchedDn( req.getBase() );
public void rejectWithoutConfidentiality( IoSession session, ResultResponse resp ) { LdapResult result = resp.getLdapResult(); result.setResultCode( ResultCodeEnum.CONFIDENTIALITY_REQUIRED ); result.setDiagnosticMessage( "Confidentiality (TLS secured connection) is required." ); session.write( resp ); }
/** * {@inheritDoc} */ @Override public Referral getReferral() { return decoratedLdapResult.getReferral(); }