Package com.alu.e3.data.model

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


    this.apiId = apiId;
  }
 
  @Override
  public void process(Exchange exchange) throws Exception {
    Api api = this.dataManager.getApiById(apiId, false);
    HttpServletRequest request = (HttpServletRequest) exchange.getIn().getHeader(Exchange.HTTP_SERVLET_REQUEST);
    //retrieve the real IP adress from the request
    String remoteAddr = CommonTools.remoteAddr(request);
    CanonicalizedIpAddress ip = new CanonicalizedIpAddress(remoteAddr);
    if(this.dataManager.isIpAllowed(api, ip.getIp())) {
View Full Code Here



  protected List<CallDescriptor> checkSubscriberIdAuth(String subscriberId, AuthIdentity authIdentity) throws GatewayException {

    // 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

    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

    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());
      }
    }

    if(identity.getAuth() != null)
      props.putAll(identity.getAuth().getProperties());
View Full Code Here

    // 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);
      }
    }

    // Finally add the values from the Auth
    Auth auth = identity.getAuth();
View Full Code Here

    auth3.getAuthDetail().getWhiteListedIps().add("12.23.45.56");
    auth3.getAuthDetail().getWhiteListedIps().add("45.45.89.65");
    dataManager.addAuth(auth3);

    // Add a new Policy: Associated to API id1 and Auth id1
    Policy policy = new Policy();
    policy.setId("id31");
    policy.getApiIds().add(api.getId());

    // Create Bucket authIds of auth ids
    QuotaRLBucket authIds = new QuotaRLBucket();
    authIds.setId("bucketId");
    authIds.getAuthIds().add(auth.getId());
    authIds.getAuthIds().add(auth2.getId());
    authIds.getAuthIds().add(auth3.getId());

    // Add bucket authIds to policy
    policy.getAuthIds().add(authIds);

    dataManager.addPolicy(policy);

    Api api_ = dataManager.getApiById(api.getId());
    Auth auth_ = dataManager.getAuthById(auth.getId());

    List<CallDescriptor> list1 = dataManager.getMatchingPolicies(api_, auth_);
    assertEquals("List1 has correct size", 1, list1.size());
    assertEquals("Matching policy is correct", policy.getId(), list1.get(0).getPolicy().getId());

    // cleanup
    dataManager.removePolicy(policy.getId());
    dataManager.removeApi(api.getId());
    dataManager.removeAuth(auth.getId());
    dataManager.removeAuth(auth2.getId());
    dataManager.removeAuth(auth3.getId());
  }
View Full Code Here

  }

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

    Policy p = new Policy();
    p.setId            (policy.getId());
    p.getApiIds().addAll    (policy.getApiIds());
    p.getAuthIds().addAll    (BeanConverterUtil.<QuotaRLBucket, com.alu.e3.prov.restapi.model.AuthIdsType>toDataModels(policy.getAuthIds()));
    p.getContexts().addAll    (BeanConverterUtil.<Context,com.alu.e3.prov.restapi.model.Context>toDataModels(policy.getContexts()));

    p.setTdrGenerationRule    (toDataModel(policy.getTdr()));

    p.setTdrOnLimitReached    (policy.getTdrOnLimitReached());

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

    for(Key prop : policy.getProperties()){
      p.getProperties().put(prop.getName(), prop.getValue());
    }

    return p;

  }
View Full Code Here

  public static Exchange setupExchange(){
    Exchange exchange = new MockExchange();

    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);
View Full Code Here

      throw new InvalidIDException("An API with that ID [" + id + "] doesn't exist");
    }

    // Find the policies associated, and remove this API
    for (String policyId : api.getPolicyIds()) {
      Policy policy = getPolicyById(policyId);
      if (policy != null) {
        policy.getApiIds().remove(api.getId());
        cachingTablePolicy.set(policyId, policy);
      }
    }

    // Remove the contexts
View Full Code Here

    // Find the policies associated, and remove this Auth
    for (AuthIds authCtx : auth.getPolicyContexts()) {
      String policyId = authCtx.getPolicyId();

      Policy policy = getPolicyById(policyId);
      if (policy != null) {
        for(QuotaRLBucket authIds : policy.getAuthIds()) {
          authIds.getAuthIds().remove(auth.getId());
          cachingTablePolicy.set(policyId, policy);
        }
      }
    }
View Full Code Here

TOP

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

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.