Package com.alu.e3.data.model

Examples of com.alu.e3.data.model.CallDescriptor


  protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
    if(!parameters.containsKey("apiId"))
      throw new CamelException("apiId parameter is missing");
   
    String apiId = getAndRemoveParameter(parameters, "apiId", String.class);
    return new IpWhiteListEndpoint(uri, this, dataManager, apiId);
  }
View Full Code Here


    CanonicalizedIpAddress ip = new CanonicalizedIpAddress(remoteAddr);
    if(this.dataManager.isIpAllowed(api, ip.getIp())) {
      exchange.setProperty(ExchangeConstantKeys.E3_API.toString(), api);   
    }
    else {
      Exception exception = new GatewayException(GatewayExceptionCode.AUTHORIZATION, "Not Authorized from this IP address");
      exchange.setException(exception);     
    }   
  }
View Full Code Here

    Exception exception = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class);

    if (exception instanceof GatewayException) {

      GatewayException gatewayException = (GatewayException) exception;

      if (gatewayException.getCode() == GatewayExceptionCode.AUTHORIZATION) {
        String body = "Issue: " + gatewayException.getMessage();
        createHttpErrorResponse(exchange, 401, body);
        isNoteSpecialized = false;

      } else if(gatewayException.getCode() == GatewayExceptionCode.AUTHORIZATION_BASIC) {
        exchange.getOut().setHeader("WWW-Authenticate", "Basic realm=\"Secure Service\"");
        String body = "Issue: " + gatewayException.getMessage();
        createHttpErrorResponse(exchange, 401, body);
        isNoteSpecialized = false;
       
      } else if(gatewayException.getCode() == GatewayExceptionCode.API_NOT_ACTIVATED) {       
        String body = "Issue: " + gatewayException.getMessage();
        createHttpErrorResponse(exchange, 403, body);
        isNoteSpecialized = false;   
       
      } else if(gatewayException.getCode() == GatewayExceptionCode.VALIDATION) {
        String body = "Issue: " + gatewayException.getMessage();
        createHttpErrorResponse(exchange, 400, body);
        isNoteSpecialized = false;
     
      if (gatewayException.getCode() == GatewayExceptionCode.RATEORQUOTA) {
        String body = "Issue: " + gatewayException.getMessage();
        // Based on draft "Additional HTTP Status Codes; draft-nottingham-http-new-status-02"
        // http://tools.ietf.org/html/draft-nottingham-http-new-status-02#page-4
        createHttpErrorResponse(exchange, 429, "Too Many Requests", body);
        isNoteSpecialized = false;
      }
      if (gatewayException.getCode() == GatewayExceptionCode.HTTP_METHOD) {
        String body = "Issue: " + gatewayException.getMessage();
        createHttpErrorResponse(exchange, 405, body);
        isNoteSpecialized = false;
      }
    }
View Full Code Here

    // Get subscriber matching CallDescriptors
    Auth auth;
    try {
      auth = dataManager.getAuthById(subscriberId);
    } catch (InvalidIDException e) {
      throw new GatewayException(GatewayExceptionCode.AUTHORIZATION, e.getMessage() );
    }

    if (auth == null || !auth.getStatus().isActive()) {
      throw new GatewayException(GatewayExceptionCode.AUTHORIZATION, "Authorization status is invalid");
    }

    return   dataManager.getMatchingPolicies(authIdentity.getApi(), auth);

  }
View Full Code Here

  public abstract void process(Exchange exchange) throws Exception;
 
  protected void injectUriAndQueryString(String notifyUrl, Exchange exchange) throws GatewayException {
    String[] parts = CommonTools.splitUrl(notifyUrl);
    if(parts == null)
      throw new GatewayException(GatewayExceptionCode.NOTIFY_URL, "Notification URL is invalid");
     
    exchange.getIn().setHeader(Exchange.HTTP_URI, parts[0]);
    exchange.getIn().setHeader(Exchange.HTTP_QUERY, parts[1]);
  }
View Full Code Here

    HttpServletRequest req = exchange.getIn().getBody(HttpServletRequest.class);
    X509Certificate[] cert = (X509Certificate[]) req.getAttribute("javax.servlet.request.X509Certificate");
   
    if ((cert == null) || (cert.length == 0)) {
      // we don't have a client certificate => stop the request
      throw new GatewayException(GatewayExceptionCode.AUTHORIZATION, "Missing certificate");         
    }
  }
View Full Code Here

    if(allowedHttpMethods==null || allowedHttpMethods.isEmpty())
      return;

    Object methodheader = exchange.getIn().getHeader(Exchange.HTTP_METHOD);
    if(methodheader == null){
      throw new GatewayException(GatewayExceptionCode.HTTP_METHOD, "No HTTP Method");
    }
   
    for(String m : allowedHttpMethods){
      if(m.equals(methodheader.toString().toLowerCase())){
        return;
      }
    }
   
    throw new GatewayException(GatewayExceptionCode.HTTP_METHOD, "Method "+methodheader.toString()+" not allowed");
  }
View Full Code Here

    this.apiId = apiId;
  }

  @Override
  public Producer createProducer() throws Exception {
    return new IpWhiteListProducer(this, dataManager, apiId);
  }
View Full Code Here

  {
    ServletContextHandler context = new ServletContextHandler(server, "/",
        ServletContextHandler.NO_SECURITY | ServletContextHandler.NO_SESSIONS);
    context.setConnectorNames(new String[] {connector.getName()});

    DispatchingContinuationServlet servlet = new DispatchingContinuationServlet();
    servlet.setDispatcher(new TreeDispatcher<HttpConsumer>());
    Long timeout = endpoint.getContinuationTimeout() != null ? endpoint
        .getContinuationTimeout() : getContinuationTimeout();
    if (timeout != null) {
      servlet.setContinuationTimeout(timeout);
    }

    ServletHolder holder = new ServletHolder();
    holder.setServlet(servlet);
    context.addServlet(holder, "/*");
 
View Full Code Here

    if (LOG.isDebugEnabled())
      LOG.debug("Update API ID: {}", apiId);

    // check API ID same in Pay-load/URL
    if (api == null || api.getId() == null)
      throw new WebApplicationException(new ProvisionException(ApplicationCodeConstants.API_ID_NOT_PROVIDED, "API ID missing in the body for Update operation"));

    if (!api.getId().equals(apiId))
      throw new WebApplicationException(new ProvisionException(ApplicationCodeConstants.API_ID_MISMATCH, "API ID not the same in URL vs Body for Update operation: +" + apiId + "/" + apiId));

    Action action = new Action() {
      protected Object doAction(Object... params) {
        try {
          apiService.update(api);
View Full Code Here

TOP

Related Classes of com.alu.e3.data.model.CallDescriptor

Copyright © 2018 www.massapicom. 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.