Examples of CallDescriptor


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

    Map<String, String> props = new HashMap<String,String>();

    props.putAll(identity.getApi().getProperties());
    Iterator<CallDescriptor> it = identity.getCallDescriptors().iterator();
    while(it.hasNext()){
      CallDescriptor cd = it.next();
      Policy policy = cd.getPolicy();
      if(policy != null){
        props.putAll(policy.getProperties());
      }
    }
View Full Code Here

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

        processTdrGenerationRuleDynamic(api.getTdrGenerationRule(), exchange, properties, efType);

    // Next add all of the tdr values for the Policies
    Iterator<CallDescriptor> it = identity.getCallDescriptors().iterator();
    while(it.hasNext()){
      CallDescriptor cd = it.next();
      Policy policy = cd.getPolicy();
      if(policy != null){
        if(doStatic)
          processTdrGenerationRuleStatic(policy.getTdrGenerationRule(), exchange, properties);
        else
          processTdrGenerationRuleDynamic(policy.getTdrGenerationRule(), exchange, properties, efType);
View Full Code Here

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

    AuthIdentity id = new AuthIdentity();
    Api api = new Api();
    Policy policy1 = new Policy();
    Auth auth = new Auth();
    CallDescriptor cd = new CallDescriptor(policy1, 0, 0);

    id.setApi(api);
    id.setAuth(auth);
    id.getCallDescriptors().add(cd);
View Full Code Here

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

    Policy p1 = new Policy();
    p1.setId("abcd");

   
    // same cd
    CallDescriptor cd_p1 = new CallDescriptor(p1, -1, -1);
    assertThat(cd_p1, is(cd_p1));
   
    // different cd with same non-null policy
    CallDescriptor cd2_p1 = new CallDescriptor(p1, -1, -1);
    assertThat(cd2_p1, is(cd_p1));
   
    // same non-null policy, different bucket id
    CallDescriptor cd_p1_bucket = new CallDescriptor(p1, 0, -1);
    assertThat(cd_p1_bucket, is(not(cd_p1)));
   
    // same non-null policy, different context id
    CallDescriptor cd_p1_context = new CallDescriptor(p1, -1, 0);
    assertThat(cd_p1_context, is(not(cd_p1)));
   
    // same non-null policy, different bucket & bucket id
    CallDescriptor cd_p1_ctx_buck = new CallDescriptor(p1, 0, 0);
    assertThat(cd_p1, is(not(cd_p1_ctx_buck)));
   
    // comparing with non null policy but null policy id
    Policy p_idn = new Policy();
    CallDescriptor cd_pn_idn = new CallDescriptor(p_idn, -1, -1);
    assertThat(cd_p1, is(not(cd_pn_idn)));
   
    // comparing with non null policy but null policy id
    CallDescriptor cd_pn_idn_bucket = new CallDescriptor(p_idn, 0, -1);
    assertThat(cd_p1, is(not(cd_pn_idn_bucket)));
   
    // comparing with non null policy but null policy id
    CallDescriptor cd_pn_idn_context = new CallDescriptor(p_idn, -1, 0);
    assertThat(cd_p1, is(not(cd_pn_idn_context)));

    // comparing with null policy
    CallDescriptor cd_pn = new CallDescriptor(null, -1, -1);
    assertThat(cd_p1, is(not(cd_pn)));
    assertThat(cd_pn, is(not(cd_p1)));
   
    // comparing 2 null policies
    CallDescriptor cd2_pn = new CallDescriptor(null, -1, -1);
    assertThat(cd_pn, is(cd2_pn));

   
    // comparing with different policy but same policy id
    Policy p2 = new Policy();
    p2.setId("abcd");
   
    // different policy with same id
    CallDescriptor cd2_p2 = new CallDescriptor(p2, -1, -1);
    assertThat(cd2_p2, is(cd_p1));
   
    // different policy with same id + different bucket id
    CallDescriptor cd2_p2_bucket = new CallDescriptor(p1, 0, -1);
    assertThat(cd2_p2_bucket, is(not(cd2_p2)));
   
    // different policy with same id + different context id
    CallDescriptor cd2_p2_context = new CallDescriptor(p1, -1, 0);
    assertThat(cd2_p2_context, is(not(cd2_p2)));
   
    // different policy with same id + different context & bucket id
    CallDescriptor cd2_p2_ctx_buck = new CallDescriptor(p1, 0, 0);
    assertThat(cd2_p2_ctx_buck, is(not(cd2_p2)));

  }
View Full Code Here

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

    applyHeaderTransforms(api.getHeaderTransformations(), type, properties, exchange);

    // Next add all of the tdr values for the Policies
    Iterator<CallDescriptor> it = identity.getCallDescriptors().iterator();
    while(it.hasNext()){
      CallDescriptor cd = it.next();
      Policy policy = cd.getPolicy();
      if(policy != null){
        HeaderTransHelper.applyHeaderTransforms(policy.getHeaderTransformations(), type, properties, exchange);
      }
    }
View Full Code Here

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

            int policyIdx = -1;
            if (policy != null && policy.getContextIds().size() > 0) {
              policyIdx = policy.getContextIds().get(0);
            }
           
            result.add(new CallDescriptor(policy, policyIdx , -1));

          }
        }

        // Now, add the CallDescriptor of the "default" context
        if (api.getContextIds().isEmpty() == false) {
          if (result == null)
            result = new ArrayList<CallDescriptor>();

          // Looking for default context, placed at index 0 by addApi
          ApiIds ctx = api.getContextIds().get(0);
          if (ctx.isStatusActive()) {
            if (logger.isDebugEnabled()) {
              logger.debug("Adding CallDescriptor({}, {}, {})", new String[] {
                  null,
                  ""+ctx.getApiContextId(),
                  ""+ctx.getApiBucketId()
                  });
            }
            result.add(new CallDescriptor(null, ctx.getApiContextId(), ctx.getApiBucketId()));
          }
        }
      }
    } else {

      // We have an Auth and an API, check matching policies
      for (AuthIds authCtx : auth.getPolicyContexts()) {

        String policyIdInAuth = authCtx.getPolicyId();

        boolean policyAdded = false;

        // API may be null if Auth is for "Company"
        if (api != null) {
          for (String policyIdInApi : api.getPolicyIds()) {

            // Matching means that the policy is in Auth and API
            if (policyIdInApi.equals(policyIdInAuth)) {
              Policy policy = getPolicyById(policyIdInAuth);
              if (result == null)
                result = new ArrayList<CallDescriptor>();
              if (authCtx.isStatusActive()) {
                if (logger.isDebugEnabled()) {
                  logger.debug("Adding CallDescriptor({}, {}, {})", new String[] {
                      policy.getId(),
                      ""+authCtx.getPolicyContextId(),
                      ""+authCtx.getPolicyBucketId()
                      });
                }
                result.add(new CallDescriptor(policy, authCtx.getPolicyContextId(), authCtx.getPolicyBucketId()));
              }
              policyAdded = true;
            }
          }
        }

        // If the policy wasn't added...
        if (!policyAdded) {
          // Slow, but need to check if that policy has some API attached
          Policy policy = getPolicyById(policyIdInAuth, false);
          if ((policy.getApiIds() == null) || policy.getApiIds().isEmpty()) {
            if (result == null)
              result = new ArrayList<CallDescriptor>();
            if (authCtx.isStatusActive()) {
              result.add(new CallDescriptor(policy, authCtx.getPolicyContextId(), authCtx.getPolicyBucketId()));
            }
          }
        }
      }

      // Now check the apiContext on the auth which is in the list of API
      if (api != null) {
        for (ApiIds ctx : api.getContextIds()) {
          if (ctx.getApiContextName().equals(auth.getApiContext())) {
            if (result == null)
              result = new ArrayList<CallDescriptor>();
            if (ctx.isStatusActive()) {
              if (logger.isDebugEnabled()) {
                logger.debug("Adding CallDescriptor({}, {}, {})", new String[] {
                    null,
                    ""+ctx.getApiContextId(),
                    ""+ctx.getApiBucketId()
                    });
              }
              result.add(new CallDescriptor(null, ctx.getApiContextId(), ctx.getApiBucketId()));
            }
          }
        }
      }
    }
View Full Code Here

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

    Api api = new Api();
    api.setStatus(StatusType.ACTIVE);
    this.setApi(api);   
    if(isAlwaysHappy) {
      this.setAuth(new Auth());
      this.getCallDescriptors().add(new CallDescriptor(new Policy(), 1, 2));
    }
  }
View Full Code Here

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

   
    // No policy found for the API
    // assertNull(dataAccess.isAllowed("api"));
   
    Policy policy = new Policy();
    mockDataManager.getCallDescriptors().add(new CallDescriptor(policy, 1, 2));
   
   
    AuthReport authReport = dataAccess.checkAllowed(api);
    AuthIdentity authIdentity = authReport.getAuthIdentity();
    assertNotNull(authIdentity);
View Full Code Here

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

    assertNull(dataAccess.checkAllowed(api, "authKey").getAuthIdentity());
    assertNull(dataAccess.checkAllowed(api, "username", "password").getAuthIdentity());
    assertNull(dataAccess.checkAllowed(api, new CanonicalizedIpAddress("127.0.0.1")).getAuthIdentity());
   
    Policy policy = new Policy();
    mockDataManager.getCallDescriptors().add(new CallDescriptor(policy, 1, 2));
   
    AuthIdentity authIdentity = dataAccess.checkAllowed(api, "authKey").getAuthIdentity();
    assertNotNull(authIdentity);   
    assertNotNull(authIdentity.getApi() == api); // compare memory reference
    assertNotNull(authIdentity.getAuth() == auth); // compare memory reference
View Full Code Here

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

    id = new AuthIdentity();
    api = new Api();
    policy1 = new Policy();
    auth = new Auth();
    CallDescriptor cd = new CallDescriptor(policy1, 0, 0);

    id.setApi(api);
    id.setAuth(auth);
    id.getCallDescriptors().add(cd);
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.