Examples of AuthReport


Examples of com.alu.e3.common.camel.AuthReport

   * @param auth
   * @return authReport instance
   */
  private AuthReport getAuthReport(Api api, Auth auth) {
 
    AuthReport authReport = new AuthReport();
   
    if(api != null) {

      // check if the API is active (status)
      authReport.setApiActive(api.getStatus().isActive());
     
      if(authReport.isApiActive()) {
       
        List<CallDescriptor> descriptors = null;
         
        if(auth != null) {
                 
          authReport.setAuthActive(auth.getStatus().isActive());
         
          // with auth         
          descriptors = this.dataManager.getMatchingPolicies(api, auth);
         
          if (descriptors != null) {
         
            // check if a policy exists
            boolean foundPolicy = false;
            for (CallDescriptor callDescriptor : descriptors) {
              if (callDescriptor.getPolicy() != null) {
                foundPolicy = true;
                break;
              }
            }
           
            if (foundPolicy) {
              authReport.setAuthIdentity(new AuthIdentity());
              authReport.getAuthIdentity().setApi(api);
              authReport.getAuthIdentity().setAuth(auth);
              authReport.getAuthIdentity().getCallDescriptors().addAll(descriptors);
            } else {
              if(logger.isDebugEnabled()) {
                logger.debug("No policy found");
              }
              authReport.setHasNoPolicy(true);
            }
           
          } else {
            if(logger.isDebugEnabled()) {
              logger.debug("Auth does not match with API");
            }
            authReport.setNotAuthorized(true);
          }
        } else {
          if(logger.isDebugEnabled()) {
            logger.debug("No auth found for API");
          }
          authReport.setAuthNotFound(true);
        }
       
      }
           
    } else {
      if(logger.isDebugEnabled()) {
        logger.debug("No api found " + api.getId());
      }
      authReport.setApiNotFound(true);
    }
   
    return authReport;   
  }
View Full Code Here

Examples of com.alu.e3.common.camel.AuthReport

   * check if an auth key and an app id match.
   */
  @Override
  public AuthReport checkAllowed(Api api, String authKey) {

    AuthReport authReport = new AuthReport();
    if(logger.isDebugEnabled()) {
      logger.debug("Lookup if AuthKey:" + authKey + " is associated with appId:" + api.getId());
    }
   
    String appId = findString(api.getId(), authKey);
   
    if(appId != null) {
     
      AuthIdentityHelper authIdentityHelper = new AuthIdentityHelper();
     
      authIdentityHelper.setApi(api.getId());
      authIdentityHelper.setAppId(appId);
      authIdentityHelper.setAuth(authKey);
     
      authReport.setAuthIdentity( authIdentityHelper.getAuthIdentity());
      authReport.setApiActive(true);
     
    } else {
      authReport.setNotAuthorized(true);
    }
   
    return authReport;
  }
View Full Code Here

Examples of com.alu.e3.common.camel.AuthReport

  }
 
  @Override
  public AuthReport checkAllowed(Api api, String username, String password) {
   
    AuthReport authReport  = new AuthReport();
    if(logger.isDebugEnabled()) {
      logger.debug("Lookup if username:password: " + username+":"+password + " is associated with appId:" + api.getId());
    }
   
    String appId = findString(api.getId(), username+":"+password);
   
    if(appId != null) {
     
      AuthIdentityHelper authIdentityHelper = new AuthIdentityHelper();
     
      authIdentityHelper.setApi(api.getId());
      authIdentityHelper.setAppId(appId);
      authIdentityHelper.setAuth(username, password);
     
      authReport.setAuthIdentity( authIdentityHelper.getAuthIdentity());
      authReport.setApiActive(true);
     
    } else {
      authReport.setNotAuthorized(true);
    }
   
    return authReport;
  }
View Full Code Here

Examples of com.alu.e3.common.camel.AuthReport

  }

  @Override
  public AuthReport checkAllowed(Api api, CanonicalizedIpAddress ipCanonicalized) {
   
    AuthReport authReport = new AuthReport();
   
    String ip = ipCanonicalized.getIp();
   
    String appId = findString(api.getId(), ip);
   
    if(appId != null) {
     
      AuthIdentityHelper authIdentityHelper = new AuthIdentityHelper();

      authIdentityHelper.setApi(api.getId());
      authIdentityHelper.setAppId(appId);
      authIdentityHelper.setAuth(ipCanonicalized);
     
      authReport.setAuthIdentity( authIdentityHelper.getAuthIdentity());
      authReport.setApiActive(true);
     
    } else {
      authReport.setNotAuthorized(true);
    }
   
    return authReport;
 
View Full Code Here

Examples of com.alu.e3.common.camel.AuthReport

    AuthType authType = AuthType.NO_AUTH;
   
    boolean isAllowed = false;
    AuthIdentity authIdentity = null;
    AuthReport report = null;
    AuthType reportAuth = null;
   
    Iterator<IAuthExecutor> it = executors.iterator();
    while(!isAllowed && it.hasNext()) {
     
      IAuthExecutor executor = it.next();
      AuthReport authReport = executor.checkAllowed(exchange, api)
      isAllowed = authReport.isAllowed();
     
      if (isAllowed) {
        authIdentity = authReport.getAuthIdentity();
        report = authReport;
      } else {
        if (report == null) {
          report = authReport;
          reportAuth = executor.getType();
View Full Code Here

Examples of com.alu.e3.common.camel.AuthReport

 

  @Override
  public AuthReport checkAllowed(Api api) {
   
    AuthReport authReport = new AuthReport();
    if(logger.isDebugEnabled()) {
      logger.debug("Lookup if noauth is true for appId:" + api.getId());
    }
   
    String appId = findString(api.getId(), "noauth:true");
   
    if(appId != null) {
     
      AuthIdentityHelper authIdentityHelper = new AuthIdentityHelper();

      authIdentityHelper.setApi(api.getId());
      authIdentityHelper.setAppId(appId);
     
      authReport.setAuthIdentity( authIdentityHelper.getAuthIdentity());
      authReport.setApiActive(true);
     
    } else {
      authReport.setNotAuthorized(true);
    }
   
    return authReport;
  }
View Full Code Here

Examples of com.alu.e3.common.camel.AuthReport

  }

  @Override
  public AuthReport checkOAuthAllowed(Api api, String clientId, String clientSecret) {
   
    AuthReport authReport = new AuthReport();
    if(logger.isDebugEnabled()) {
      logger.debug("Lookup if clientId:clientSecret: " + clientId+":"+clientSecret + " is associated with appId:" + api.getId());
    }
   
    String appId = findString(api.getId(), clientId+":"+clientSecret);
   
    if(appId != null) {
     
      AuthIdentityHelper authIdentityHelper = new AuthIdentityHelper();
     
      authIdentityHelper.setApi(api.getId());
      authIdentityHelper.setAppId(appId);
      authIdentityHelper.setOAuth(clientId, clientSecret);
     
      authReport.setAuthIdentity( authIdentityHelper.getAuthIdentity());
      authReport.setApiActive(true);
     
    } else {
      authReport.setNotAuthorized(true);
    }
   
    return authReport;
  }
View Full Code Here

Examples of com.alu.e3.common.camel.AuthReport

  }
 
  @Override
  public AuthReport checkAllowed(Exchange exchange, Api api) {
   
    AuthReport authReport = new AuthReport();
   
    String authHeader = (String) exchange.getIn().getHeader("Authorization");
   
    if(authHeader != null){
      String[] chunks = authHeader.split(" ");
     
      // Only expect two parts: the auth scheme and the user/pass encoding
      if(chunks.length == 2){
        String scheme = chunks[0];
        if("Basic".equalsIgnoreCase(scheme)){
          String base64 = chunks[1];
          String decoded = new String(Base64.decodeBase64(base64.getBytes()));
          chunks = decoded.split(":");
          if(chunks.length >= 2){
            String user = chunks[0];
            String pass = chunks[1];
            // Checks if the user is allowed to use this service
            authReport = dataAccess.checkAllowed(api, user, pass);
          }
          else{
            if(logger.isDebugEnabled()) {
              logger.debug("Unable to decode user/pass");
            }
            authReport.setBadRequest(true);
          }
        }
        else{
          if(logger.isDebugEnabled()) {
            logger.debug("Auth scheme not Basic ("+scheme+"). Cannot authenticate request");
          }
          authReport.setBadRequest(true);
        }
      }
      else{
        if(logger.isDebugEnabled()) {
          logger.debug("Improperly formed authorization header:"+authHeader);
        }
        authReport.setBadRequest(true);
      }
    }
    else{
      if(logger.isDebugEnabled()) {
        logger.debug("Http Basic Authentication Header is missing");
      }
      authReport.setBadRequest(true);
    }
   
    return authReport;
  }
View Full Code Here

Examples of com.alu.e3.common.camel.AuthReport

  }

  @Override
  public AuthReport checkAllowed(Exchange exchange, Api api) {
   
    AuthReport authReport = new AuthReport();
    
    if(logger.isDebugEnabled()) {
      logger.debug("Hit the IpWhitelistExecutor.isAllowed");
    }
   
    // magic Jetty stuff
    HttpServletRequest request = (HttpServletRequest) exchange.getIn().getHeader(Exchange.HTTP_SERVLET_REQUEST);
   
    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);
    }
     
    return authReport;
  }
View Full Code Here

Examples of com.alu.e3.common.camel.AuthReport

  }
 
  @Override
  public AuthReport checkAllowed(Exchange exchange, Api api) {
   
    AuthReport authReport = new AuthReport();
    Object keyObj = null;
   
    Map<?, ?> parameters = exchange.getProperty(ExchangeConstantKeys.E3_REQUEST_PARAMETERS.toString(), Map.class);
    if (parameters == null) {
      if(logger.isDebugEnabled()) {
        logger.debug("Request parameters not set");
      }
      authReport.setBadRequest(true);
    } else {
   
      keyObj = parameters.get(keyName);
      if (keyObj == null) { // No parameter by keyName, checking for a header "headerName"
        keyObj = exchange.getIn().getHeader(headerName, String.class);
        if (keyObj == null) {   
          // Abort
          if(logger.isDebugEnabled()) {
            logger.debug("Unable to find url parameter or header matching the provisioned api key name");
          }
          authReport.setBadRequest(true);
        }
      }
    }
   
    // if not a bad request
    if(!authReport.isBadRequest()) {
   
      String authKey = keyObj.toString();
      if(logger.isDebugEnabled()) {
        logger.debug("authKey= " + authKey);
      }
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.