Package com.alu.e3.prov.restapi.model

Examples of com.alu.e3.prov.restapi.model.Api


  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

    Action action = new Action() {

      protected Object doAction(Object... params) {
        try {
          Api api = apiService.get(apiId);
          return new ApiResponse(ApiResponse.SUCCESS, api);

        } catch (ProvisionException e) {
          throw new WebApplicationException(e);
        }
View Full Code Here

      throw new ProvisionException(ApplicationCodeConstants.API_ID_NOT_PROVIDED, "Missing API ID in the get request");
    }

    com.alu.e3.data.model.Api api = dataManager.getApiById(apiId, true);

    Api apiWs = BeanConverterUtil.fromDataModel(api);

    ExchangeData exchange = createExchange(apiId);
    LogUtil.log(LOG, exchange, LogUtil.Phase.GET, "N/A");

    return apiWs;
View Full Code Here

    testMessage.assertIsSatisfied();
  }

  private void setupExchange(Exchange exchange, ProvisionAuthentication auth){
    Api api = new Api();

    ApiContext env = new ApiContext();
    env.setId("test");

    api.setType(ApiType.PASS_THROUGH);
    api.setContexts(Arrays.asList(env));

    List<TargetHost> targetList = new ArrayList<TargetHost>();

    api.setEndpoint("www.yahoo.fr");

    TargetHost to1 = new TargetHost();
    to1.setUrl("http://www.google.com");
    targetList.add(to1);

    TargetHost to2 = new TargetHost();
    to2.setUrl("http://www.google.com?toto=tutu");
    targetList.add(to2);

    TargetHost to3 = new TargetHost();
    to3.setUrl("http://www.google.com?toto=tutu&tata=tete&titi=toto");
    targetList.add(to3);

    env.setTargetHosts(targetList);

    TdrEnabled tdr = new TdrEnabled();
    tdr.setEnabled("true");
    api.setTdrEnabled(tdr);

    api.setAuthentication(auth);

    TdrData tdrData = new TdrData();

    TdrType tdrType = new TdrType();
    tdrType.getType().add("apiRateLimit");

    DynamicTdr dt = new DynamicTdr();
    dt.setHttpHeaderName("HTTP_HEADER");
    dt.setTdrPropName("propname");
    dt.setTypes(tdrType);

    tdrData.getDynamic().add(dt);

    StaticTdr st = new StaticTdr();
    st.setValue("staticValue");
    st.setTdrPropName("staticName");

    st.setTypes(tdrType);

    tdrData.getStatic().add(st);

    api.setTdr(tdrData);

    HTTPSType httpsType = new HTTPSType();
    httpsType.setEnabled(true);
    httpsType.setTlsMode(TLSMode.ONE_WAY);
    api.setHttps(httpsType);

    exchange.setProperty(ExchangeConstantKeys.E3_REQUEST_PAYLOAD.toString(), api);
    exchange.setProperty(ExchangeConstantKeys.E3_API_ID.toString(), "MyApiID");
    exchange.setProperty(ExchangeConstantKeys.E3_API_ID_ENCODED.toString(), "MonApiIDEncoded");
    exchange.setProperty(ExchangeConstantKeys.E3_PROVISION_ID.toString(), "MyProvId");
View Full Code Here

  }


  @Test
  public void testApiService() throws Exception {
    Api api = newApi();
    try {
      apiService.create(api);
      apiService.update(api);
      Api getApi  = apiService.get(api.getId());
      assertNotNull(getApi);

      List<String> ids = apiService.getAll();
      assertNotNull(ids);
      assertFalse(ids.isEmpty());
View Full Code Here

TOP

Related Classes of com.alu.e3.prov.restapi.model.Api

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.