Examples of LimitCheckResult


Examples of com.alu.e3.rate.model.LimitCheckResult

    RateLimitProcessor rateProcessor = new RateLimitProcessor();
    rateProcessor.setGatewayRateMger(new IGatewayRateManager() {

      @Override
      public LimitCheckResult isAllowed(AuthIdentity authIdentity, boolean isTDREnabled) {
        LimitCheckResult result = new LimitCheckResult();
        return result;
      }

    });
View Full Code Here

Examples of com.alu.e3.rate.model.LimitCheckResult

    RateLimitProcessor rateProcessor = new RateLimitProcessor();
    rateProcessor.setGatewayRateMger(new IGatewayRateManager() {

      @Override
      public LimitCheckResult isAllowed(AuthIdentity authIdentity, boolean isTDREnabled) {
        LimitCheckResult result = new LimitCheckResult();
        result.setActionType(ActionType.REJECT);
        return result;
      }
    });

    checkRate.whenAnyExchangeReceived(rateProcessor);
View Full Code Here

Examples of com.alu.e3.rate.model.LimitCheckResult

  class AlwaysAllowed implements IGatewayRateManager {

    @Override
    public LimitCheckResult isAllowed(AuthIdentity authIdentity, boolean isTDREnabled) {
      LimitCheckResult result = new LimitCheckResult();
      return result;
    }
View Full Code Here

Examples of com.alu.e3.rate.model.LimitCheckResult

  class NeverAllowed implements IGatewayRateManager {

    @Override

    public LimitCheckResult isAllowed(AuthIdentity authIdentity, boolean isTDREnabled) {
      LimitCheckResult result = new LimitCheckResult();
      result.setActionType(ActionType.REJECT);
      return result;
    }
View Full Code Here

Examples of com.alu.e3.rate.model.LimitCheckResult

    apiCallStatus.apiCallIsSuccess = true;
    apiCallStatus.apiCallAction = null;
   
    RateLimitParams params = new RateLimitParams();
    params.isTDREnabled = isTDREnabled;
    params.result = new LimitCheckResult();
    params.authIdentity = authIdentity;
   
    boolean mustResetRateLimit = gatewayRateValidator.isRateLimitInvalid(currentTime);
   
    // contain the id of the lock to unlocks locks in case of throw exception
View Full Code Here

Examples of com.alu.e3.rate.model.LimitCheckResult

      throw new GatewayException(GatewayExceptionCode.RATEORQUOTA, "The property " + ExchangeConstantKeys.E3_AUTH_IDENTITY.toString() + " is required to check the rate limits.");
    }

    boolean isTDREnabled = exchange.getProperty(ExchangeConstantKeys.E3_TDR_ENABLED.toString(), boolean.class);
    AuthIdentity authIdentity = (AuthIdentity) property;
    LimitCheckResult limitCheckResult = rateManager.isAllowed(authIdentity, isTDREnabled);

    if(isTDREnabled){
      /**
       * Put some TDR data into into service
       */
      TDRDataService.addTxTDRProperty(exchange, TDRConstant.OVER_QUOTA, limitCheckResult.isOverQuota());
      TDRDataService.addTxTDRProperty(exchange, TDRConstant.OVER_QUOTA_SEC, limitCheckResult.isOverSecond());
      TDRDataService.addTxTDRProperty(exchange, TDRConstant.OVER_QUOTA_MIN, limitCheckResult.isOverMinute());
      TDRDataService.addTxTDRProperty(exchange, TDRConstant.OVER_QUOTA_DAY, limitCheckResult.isOverDay());
      TDRDataService.addTxTDRProperty(exchange, TDRConstant.OVER_QUOTA_WEEK, limitCheckResult.isOverWeek());
      TDRDataService.addTxTDRProperty(exchange, TDRConstant.OVER_QUOTA_MONTH, limitCheckResult.isOverMonth());

      for(String tdrName : limitCheckResult.getTdrValues().keySet()){
        List<TdrGenerationRule> genRules = limitCheckResult.getTdrValues().get(tdrName);
        for(TdrGenerationRule genRule : genRules){
          TDRDataService.addNewTdrGenerationRule(exchange, genRule, tdrName);
        }
      }
    }


    // Route allowed if null - no action error defined
    if (limitCheckResult != null && limitCheckResult.getActionType() != null) {
      if(isTDREnabled) {
        exchange.setProperty(ExchangeConstantKeys.E3_RATELIMIT_ACTION.toString(), limitCheckResult.getActionType().toString());
        TDRDataService.addTxTDRProperty(exchange, TDRConstant.OVER_QUOTA_ACTION, limitCheckResult.getActionType().toString());
      }

      // Log - Will be based on the Logging Framework developed internally
      //log.debug("Route rate limit for API " + (authIdentity.getApi()==null ? "(no API)" : authIdentity.getApi().getId()) + " exeeded" + ((authIdentity.getAuth()==null) ? "": "by " + authIdentity.getAuth().getId()));
      // TDR Notification - not yet implemented
      // HTTP Status Code 429 - to be return by the error processor of the route

      if(limitCheckResult.getActionType().equals(ActionType.REJECT)) {
        throw new GatewayException(GatewayExceptionCode.RATEORQUOTA, "Rate limit exceeded. " + limitCheckResult.getActionTypeMessage(), limitCheckResult.getActionType().toString());
      }
    }

  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.