Examples of CanonicalizedIpAddress


Examples of com.alu.e3.common.tools.CanonicalizedIpAddress

  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())) {
      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

Examples of com.alu.e3.common.tools.CanonicalizedIpAddress

   
    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());
    assertNull(fileData.checkAllowed(api).getAuthIdentity());
  }
View Full Code Here

Examples of com.alu.e3.common.tools.CanonicalizedIpAddress

   
    if(request != null) {
      //retrieve the real IP adress from the request
      String remoteAddr = CommonTools.remoteAddr(request);
         
          CanonicalizedIpAddress ip = new CanonicalizedIpAddress(remoteAddr);
      authReport = dataAccess.checkAllowed(api, ip);
    } else {
      authReport.setBadRequest(true);
    }
     
View Full Code Here

Examples of com.alu.e3.common.tools.CanonicalizedIpAddress

    mockDataManager.setApi(api);
   
    // no auth found
    assertNull(dataAccess.checkAllowed(api, "authKey").getAuthIdentity());
    assertNull(dataAccess.checkAllowed(api, "username", "password").getAuthIdentity());
    assertNull(dataAccess.checkAllowed(api, new CanonicalizedIpAddress("127.0.0.1")).getAuthIdentity());
   
    Auth auth = new Auth();
    auth.setStatus(StatusType.ACTIVE);
    mockDataManager.setAuth(auth);
   
    // No policy found
    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
    assertNotNull(authIdentity.getCallDescriptors().get(0).getPolicy() == policy); // compare memory reference

    authIdentity = dataAccess.checkAllowed(api, "username", "password").getAuthIdentity();
    assertNotNull(authIdentity);   
    assertNotNull(authIdentity.getApi() == api); // compare memory reference
    assertNotNull(authIdentity.getAuth() == auth); // compare memory reference
    assertNotNull(authIdentity.getCallDescriptors().get(0).getPolicy() == policy); // compare memory reference
   
   
    authIdentity = dataAccess.checkAllowed(api, new CanonicalizedIpAddress("127.0.0.1")).getAuthIdentity();
    assertNotNull(authIdentity)
    assertNotNull(authIdentity.getApi() == api); // compare memory reference
    assertNotNull(authIdentity.getAuth() == auth); // compare memory reference
    assertNotNull(authIdentity.getCallDescriptors().get(0).getPolicy() == policy); // compare memory reference
   
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.