/** * {@inheritDoc} */ @Override public LdapResult getLdapResult() { return getDecorated().getLdapResult(); } }
/** * Makes a AddRequest encodable. * * @param codec The LDAP service instance * @param decoratedMessage the decorated AddRequest */ public ResponseDecorator( LdapApiService codec, M decoratedMessage ) { super( codec, decoratedMessage ); ldapResultDecorator = new LdapResultDecorator( codec, decoratedMessage.getLdapResult() ); }
/** * Makes a AddRequest encodable. * * @param codec The LDAP service instance * @param decoratedMessage the decorated AddRequest */ public ResponseDecorator( LdapApiService codec, M decoratedMessage ) { super( codec, decoratedMessage ); ldapResultDecorator = new LdapResultDecorator( codec, decoratedMessage.getLdapResult() ); }
/** * Makes a AddRequest encodable. * * @param codec The LDAP service instance * @param decoratedMessage the decorated AddRequest */ public ResponseDecorator( LdapApiService codec, M decoratedMessage ) { super( codec, decoratedMessage ); ldapResultDecorator = new LdapResultDecorator( codec, decoratedMessage.getLdapResult() ); }
/** * Creates a DecoderException * * @param message A message with meaning to a human * @param response The response to store * @param code the ResultCode * @param matchedDn The Matched DN * @param cause The Exception which caused the error */ public ResponseCarryingException( String message, ResultResponse response, ResultCodeEnum code, Dn matchedDn, Throwable cause ) { super( message, cause ); response.getLdapResult().setDiagnosticMessage( message ); response.getLdapResult().setResultCode( code ); response.getLdapResult().setMatchedDn( matchedDn ); this.response = response; }
/** * Creates a DecoderException * * @param message A message with meaning to a human * @param response The response to store * @param code the ResultCode * @param matchedDn The Matched DN * @param cause The Exception which caused the error */ public ResponseCarryingException( String message, ResultResponse response, ResultCodeEnum code, Dn matchedDn, Throwable cause ) { super( message, cause ); response.getLdapResult().setDiagnosticMessage( message ); response.getLdapResult().setResultCode( code ); response.getLdapResult().setMatchedDn( matchedDn ); this.response = response; }
/** * Creates a DecoderException * * @param message A message with meaning to a human * @param response The response to store * @param code the ResultCode * @param matchedDn The Matched DN * @param cause The Exception which caused the error */ public ResponseCarryingException( String message, ResultResponse response, ResultCodeEnum code, Dn matchedDn, Throwable cause ) { super( message, cause ); response.getLdapResult().setDiagnosticMessage( message ); response.getLdapResult().setResultCode( code ); response.getLdapResult().setMatchedDn( matchedDn ); this.response = response; }
/** * {@inheritDoc} */ @Override public <T extends ResultResponse> T responseOrException( T response ) { if ( ResultCodeEnum.SUCCESS != response.getLdapResult().getResultCode() ) { throw new LdapRequestUnsuccessfulException( response ); } return response; }
/** * {@inheritDoc} */ @Override public <T extends ResultResponse> T responseOrException( T response ) { if ( ResultCodeEnum.SUCCESS != response.getLdapResult().getResultCode() ) { throw new LdapRequestUnsuccessfulException( response ); } return response; }
/** * {@inheritDoc} */ @Override public <T extends ResultResponse> T responseOrException( T response ) { if ( ResultCodeEnum.SUCCESS != response.getLdapResult().getResultCode() ) { throw new LdapRequestUnsuccessfulException( response ); } return response; }
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 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 ) ); } } }
/** * Handle the replication request. */ private void handleReplication( LdapSession session, SearchRequest searchRequest ) throws LdapException { if ( replicationReqHandler != null ) { replicationReqHandler.handleSyncRequest( session, searchRequest ); } else { // Replication is not allowed on this server. generate a error message LOG.warn( "This server does not allow replication" ); LdapResult result = searchRequest.getResultResponse().getLdapResult(); result.setDiagnosticMessage( "Replication is not allowed on this server" ); result.setResultCode( ResultCodeEnum.OTHER ); session.getIoSession().write( searchRequest.getResultResponse() ); return; } }
/** * {@inheritDoc} */ public void handle( LdapSession session, AddRequest req ) { LOG.debug( "Handling request: {}", req ); LdapResult result = req.getResultResponse().getLdapResult(); try { // Call the underlying layer to inject the new entry CoreSession coreSession = session.getCoreSession(); coreSession.add( req ); // If success, here now, otherwise, we would have an exception. result.setResultCode( ResultCodeEnum.SUCCESS ); // Write the AddResponse message session.getIoSession().write( req.getResultResponse() ); } catch ( Exception e ) { handleException( session, req, e ); } } }
/** * {@inheritDoc} */ public void handle( LdapSession session, DeleteRequest req ) { LOG.debug( "Handling request: {}", req ); LdapResult result = req.getResultResponse().getLdapResult(); try { // Call the underlying layer to delete the entry CoreSession coreSession = session.getCoreSession(); coreSession.delete( req ); // If success, here now, otherwise, we would have an exception. result.setResultCode( ResultCodeEnum.SUCCESS ); // Write the DeleteResponse message session.getIoSession().write( req.getResultResponse() ); } catch ( Exception e ) { handleException( session, req, e ); } } }
/** * {@inheritDoc} */ public void handle( LdapSession session, ModifyRequest req ) { LOG.debug( "Handling request : {}", req ); LdapResult result = req.getResultResponse().getLdapResult(); try { // Call the underlying layer to delete the entry CoreSession coreSession = session.getCoreSession(); coreSession.modify( req ); // If success, here now, otherwise, we would have an exception. result.setResultCode( ResultCodeEnum.SUCCESS ); // Write the DeleteResponse message session.getIoSession().write( req.getResultResponse() ); } catch ( Exception e ) { handleException( session, req, e ); } } }
/** * 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); }
/** * {@inheritDoc} */ public void handle( LdapSession session, CompareRequest req ) { LOG.debug( "Handling compare request while ignoring referrals: {}", req ); LdapResult result = req.getResultResponse().getLdapResult(); try { if ( session.getCoreSession().compare( req ) ) { result.setResultCode( ResultCodeEnum.COMPARE_TRUE ); } else { result.setResultCode( ResultCodeEnum.COMPARE_FALSE ); } result.setMatchedDn( req.getName() ); session.getIoSession().write( req.getResultResponse() ); } catch ( Exception e ) { handleException( session, req, e ); } } }
/** * 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() ); }
/** * Creates an operation response with the supplied response data. * * @param <T> type of response * @param request containing controls * @param result of the operation * @param resultResponse provider response * * @return operation response */ protected <T> Response<T> createResponse(final Request request, final T result, final ResultResponse resultResponse) { final LdapResult ldapResult = resultResponse.getLdapResult(); final Referral ref = ldapResult.getReferral(); return new Response<>( result, ResultCode.valueOf(ldapResult.getResultCode().getValue()), ldapResult.getDiagnosticMessage(), ldapResult.getMatchedDn() != null ? ldapResult.getMatchedDn().getName() : null, processResponseControls(config.getControlProcessor(), request.getControls(), resultResponse), ref != null ? ref.getLdapUrls().toArray(new String[ref.getReferralLength()]) : null, resultResponse.getMessageId()); }