Package com.alu.e3.data.model

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


    }
  }
 
  @Test
  public void localProxySet() {
    Api api = newApi(null);
   
    ForwardProxy localProxy = new ForwardProxy();
    localProxy.setProxyHost("host1");
    localProxy.setProxyPass("pass1");
    localProxy.setProxyPort("port1");
    localProxy.setProxyUser("user1");
    api.setForwardProxy(localProxy);
   
    dataManager.addApi(api);
    targetHostManager.registerAPI(api.getId());
   
    for(APIContext context : api.getApiDetail().getContexts()) {
      List<TargetReference> references = targetHostManager.getTargetReferences(api.getId(), context.getId());
     
      IForwardProxy refProxy;
      for(TargetReference target : references) {
       
        refProxy = target.getTargetHost().getForwardProxy();
View Full Code Here


  public void globalProxyPreSetThenUpdated() {
    dataManager.addGlobalProxyListener3(targetHostManager.getGlobalForwardProxy());
   
    dataManager.addProxy("host2#port2#user2#pass2");

    Api api = newApi(null);
    api.setUseGlobalProxy(true);
   
    dataManager.addApi(api);
    targetHostManager.registerAPI(api.getId());
   
    for(APIContext context : api.getApiDetail().getContexts()) {
      List<TargetReference> references = targetHostManager.getTargetReferences(api.getId(), context.getId());
     
      IForwardProxy refProxy;
      for(TargetReference target : references) {
       
        refProxy = target.getTargetHost().getForwardProxy();
        assertEquals("host2", refProxy.getProxyHost());
        assertEquals("pass2", refProxy.getProxyPass());
        assertEquals("port2", refProxy.getProxyPort());
        assertEquals("user2", refProxy.getProxyUser());
      }
    }
   
    dataManager.addProxy("host3#port3#user3#pass3");

    for(APIContext context : api.getApiDetail().getContexts()) {
      List<TargetReference> references = targetHostManager.getTargetReferences(api.getId(), context.getId());
     
      IForwardProxy refProxy;
      for(TargetReference target : references) {
       
        refProxy = target.getTargetHost().getForwardProxy();
View Full Code Here

    healthCheckService.init();
   
    // imic Spring instantiation of THManager
    targetHostManager.registerHealthCheckService(healthCheckService);
   
    Api api = newApi(healthCheckService);
   
    // Provision the API
    dataManager.addApi(api);
   
    // Register the APi on the THMgr: all targets should be monitored by the healthcheck service too
    targetHostManager.registerAPI(api.getId());
   
    for(APIContext context : api.getApiDetail().getContexts()) {
      // These are targetReferences returned by the THMgr to the LoadBalancer
      List<TargetReference> references = targetHostManager.getTargetReferences(api.getId(), context.getId());
       
      // We have same as many targetreference as targethost in the context
      assertTrue("Number of target references == than number of target hosts", references.size() == context.getTargetHosts().size());

      for(TargetReference target : references) {
View Full Code Here

   * Sets the API
   * @param apiId
   */
  public void setApi(String apiId) {
   
    Api api = new Api();
    api.setId(apiId);
   
    this.authIdentity.setApi(api);
  }
View Full Code Here

   
    if(logger.isDebugEnabled()) {
      logger.debug("Authentication Processor is excuted");
    }

    Api api = (Api)exchange.getProperty(ExchangeConstantKeys.E3_API.toString());
    if(api == null) {
      api = dataManager.getApiById(apiId);
    }

    AuthType authType = AuthType.NO_AUTH;
View Full Code Here

  public void setUp() throws Exception {
  }

  @Test
  public void test1() throws Exception {
    Api api = new Api();
    api.setId("test");

    fileData = new FileData("/notAValidFile.db");
    assertNotNull(fileData);
    assertNull(fileData.checkAllowed(api, "test").getAuthIdentity());
  }
View Full Code Here

  }
 
  @Test
  public void testIsAssociated() throws Exception {
   
    Api api = new Api();
    api.setId("api1234");

    URL fileURL = getClass().getResource(DB_PATH);
   
    fileData = new FileData(fileURL.getPath());
   
    assertNotNull(fileData.checkAllowed(api, "appKey1234").getAuthIdentity());
    assertNotNull(fileData.checkAllowed(api, "user", "pass").getAuthIdentity());
    assertNotNull(fileData.checkAllowed(api, new CanonicalizedIpAddress("127.0.0.1")).getAuthIdentity());
    assertNotNull(fileData.checkAllowed(api).getAuthIdentity());
   
    api.setId("apiASDF");
   
    assertNull(fileData.checkAllowed(api, "badbad").getAuthIdentity());
    assertNull(fileData.checkAllowed(api, "bad", "bad").getAuthIdentity());
    assertNull(fileData.checkAllowed(api, new CanonicalizedIpAddress("10.0.0.1")).getAuthIdentity());
    assertNull(fileData.checkAllowed(api, "badbad", "badbad").getAuthIdentity());
View Full Code Here

    context2.getTargetHosts().add(targetHostWithUrlAndSite("http://www.apple.co.uk", "UK"));
   
    if(targetHealthCheck != null)
      context2.getLoadBalancing().setTargetHealthCheck(targetHealthCheck);
   
    Api api = new Api();
    api.setApiDetail(new ApiDetail());
    api.getApiDetail().setEndpoint("/endpoint");
    api.getApiDetail().getContexts().add(context1);
    api.getApiDetail().getContexts().add(context2);
    return api;
  }
View Full Code Here

    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("Registering API {}", apiId);
    }
   
    // Gets the API
    Api api = dataManager.getApiById(apiId, true);

    // Get context Ids (because apis are incomplete on Gateway only machines)
    List<ApiIds> ids = api.getContextIds();
    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("Browsing {} contexts for API #{}", ids.size(), apiId);
    }
   
    // Get or create the Api Context map for this API
    Map<String, List<TargetReference>> map = getApiMap(apiId);
    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("Size of api context map for api id {}: {}", apiId, map.size());
    }
   
    // Browsing API Contexts
    for(ApiIds id : ids) {
      // Get the ApiContext by its ID (this map is populated on all gateways)
      if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Getting api context for api id {}", apiId);
      }
      APIContext context = dataManager.getApiContextById(id.getApiContextId());
     
      // Shouldn't be null...
      if(context != null) {
        // Prepare the list of TargetReference
        List<TargetReference> targetReferences = new ArrayList<TargetReference>();
        if (LOGGER.isDebugEnabled()) {
          LOGGER.debug("Registering Context {} ({} TargetHosts)", context.getId(), context.getTargetHosts().size());
        }
       
        // Store requested HealthCheck service for later use
        ITargetHealthCheckService healthCheckService = null;
        String healthCheckServiceName = null;
       
        LoadBalancing lbConfig = context.getLoadBalancing();
        if(lbConfig.getTargetHealthCheck() != null) {
          healthCheckServiceName = lbConfig.getTargetHealthCheck().getType();
        }
       
        if(healthCheckServiceName != null) {
          if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Will use HealthCheck service ", healthCheckServiceName);
          }
           
          // Getting corresponding HealthCheck Service
          healthCheckService = targetHealthCheckServices.get(healthCheckServiceName);
          if(healthCheckService != null) {
            if (LOGGER.isDebugEnabled()) {
              LOGGER.debug("Found a HealthCheckService ({}) for this name: {}", healthCheckService.getClass().getName(), healthCheckServiceName);
            }
          } else {
            if (LOGGER.isDebugEnabled()) {
              LOGGER.debug("No HealthCheckService found for this name: {}", healthCheckServiceName);
            }
          }
        } else {
          if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Will NOT use HealthCheck service for following targets");
          }
        }
       
       
        // For each TargetHost, check if there is already a corresponding ManagedTargetHost
        for(TargetHost targetHost : context.getTargetHosts()) {
         
          /*
           * If the api has its own proxy settings, they were automatically set by the DataManager while loading the api. Nothing to do.
           * If the api uses global proxy settings,  we have to retrieve a reference on this shared instance
           */
         
          targetHost.setForwardProxy( api.isUseGlobalProxy() ? globalForwardProxy : api.getForwardProxy() );
         
          // Using a "hash differentiation string":
          // We need to take into account the HealthCheckService associated to a TargetHost
          // Ex: API #1 (http://www.apple.com|Ping), API #2 (http://www.apple.com|Telnet), API #3 (http://www.apple.com|Ping)
          // API #1 and #3 must have the same "Managed target" and #2 another one
View Full Code Here

  }

  public static final Api toDataModel(com.alu.e3.prov.restapi.model.Api provisionData) {
    if (provisionData==null) throw new IllegalArgumentException("provisionData must not be null");

    Api api = new Api();

    api.setId                (provisionData.getId());
    api.setTdrGenerationRule        (toDataModel(provisionData.getTdr()));
    //Not populated to WS
    //api.setPolicyIds            (null);
    api.setTdrOnUse(provisionData.getTdrOnUse());
    api.setTdrOnLimitReached(provisionData.getTdrOnLimitReached());

    for(Key prop : provisionData.getProperties()){
      api.getProperties().put(prop.getName(), prop.getValue());
    }

    api.setHeaderTransformation             (BeanConverterUtil.<HeaderTransformation, com.alu.e3.prov.restapi.model.HeaderTransformation>toDataModels(provisionData.getHeaderTransformations()));

    ApiDetail apiDetail = new ApiDetail();
    api.setApiDetail            (apiDetail);

    apiDetail.setDisplayName        (provisionData.getDisplayName());
    apiDetail.setEndpoint          (provisionData.getEndpoint());
    apiDetail.setHttps            (toDataModel(provisionData.getHttps()));
    apiDetail.setType            (toDataModel(provisionData.getType()));
    apiDetail.setSubscriptionStep      (toDataModel(provisionData.getSubscriptionStep()));
    apiDetail.setNotificationFormat      (toDataModel(provisionData.getNotificationFormat()));
    apiDetail.setVersion          (provisionData.getVersion());
    if(provisionData.getIpWhiteList() != null) {
      api.getWhiteListedIps().addAll(provisionData.getIpWhiteList().getIp());
    }
    apiDetail.getContexts().addAll      (BeanConverterUtil.<APIContext, com.alu.e3.prov.restapi.model.ApiContext>toDataModels(provisionData.getContexts()));
    apiDetail.setTdrEnabled          (toDataModel(provisionData.getTdrEnabled()));
    if (provisionData.getAuthentication() != null && provisionData.getAuthentication().getAuthKey() != null) {
      apiDetail.setAuthKeyName      (provisionData.getAuthentication().getAuthKey().getKeyName());
      apiDetail.setAuthHeaderName      (provisionData.getAuthentication().getAuthKey().getHeaderName());
    }
    if (provisionData.getAuthentication() != null)
      apiDetail.getEnabledAuthType().addAll  (BeanConverterUtil.<NBAuthType, AuthType>toDataModels(provisionData.getAuthentication().getAuths()));

    apiDetail.setStatus            (toDataModel(provisionData.getStatus()));

    // FIXME: The current WS API model does not support notification (true|false) attributes.
    apiDetail.setNotification      (null);

    apiDetail.setAllowedMethods(provisionData.getAllowedHttpMethodsAsString());

    api.setValidation(toDataModel(provisionData.getValidation()));   
    api.setHeaderTransEnabled(provisionData.getHeaderTransEnabled());
    api.setInternal(provisionData.getInternal());
   
    if(provisionData.getProxySettings() != null){
      if(provisionData.getProxySettings().getGlobalProxy() != null){
        api.setUseGlobalProxy(true);
      }else if (provisionData.getProxySettings().getLocalProxy() != null){
        api.setForwardProxy( toDataModel(provisionData.getProxySettings().getLocalProxy()) );
      }
    } // else no proxy
   
   
    return api;
View Full Code Here

TOP

Related Classes of com.alu.e3.data.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.