Package com.alu.e3.common.camel

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


    }

    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();
        } else {
          if (report.compareTo(authReport) > 0) {
            report = authReport;
            reportAuth = executor.getType();
          }
        }
      }
      // The last executor
      authType = executor.getType();
    }
   
    if (isAllowed) {
      if(logger.isDebugEnabled()) {
        logger.debug("Request allowed to use this Api");
      }
    } else {
      if(logger.isDebugEnabled()) {
        logger.debug("Request not allowed to use this Api");
      }
      handleReport(exchange, report, reportAuth);
    }

    // Put this in the exchange for TDRs
    TDRDataService.setTxTDRProperty(TDRConstant.AUTHENTICATION, authType.value(), exchange);
   
    // Set the authentication result in the exchange
    exchange.setProperty(ExchangeConstantKeys.E3_AUTH_METHOD.toString(), authType.value())
   
    //getting apiContext
    String value = null;
    if(authIdentity != null && authIdentity.getAuth() != null){
        value = authIdentity.getAuth().getApiContext();
    }
   
    exchange.setProperty(ExchangeConstantKeys.E3_AUTH_IDENTITY.toString(), authIdentity);
    exchange.setProperty(ExchangeConstantKeys.E3_AUTH_IDENTITY_APICONTEXT.toString(), value)
  }
View Full Code Here


   * Public static function to centralize the functionality of applying the transformations to the request/response
   * @param type
   * @param exchange
   */
  public static void applyHeaderTransforms(HeaderTransformationType type, Exchange exchange){
    AuthIdentity identity = (AuthIdentity) exchange.getProperty(ExchangeConstantKeys.E3_AUTH_IDENTITY.toString());
    @SuppressWarnings("unchecked")
    Map<String, String> properties = (Map<String,String>) exchange.getProperty(ExchangeConstantKeys.E3_MODEL_PROPERTIES.toString());
    if(properties == null)
      properties = new HashMap<String, String>();

    // First add the TDRs from the API
    Api api = identity.getApi();
    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);
      }
    }

    // Finally add the values from the Auth
    Auth auth = identity.getAuth();
    if(auth != null)
      HeaderTransHelper.applyHeaderTransforms(auth.getHeaderTransformations(), type, properties, exchange);
  }
View Full Code Here

import com.alu.e3.data.model.sub.TdrStaticRule;
import com.alu.e3.tdr.TDRDataService;

public class TdrProcessorHelper {
  public static void processTdrRules(Exchange exchange, ExtractFromType efType, boolean doStatic){
    AuthIdentity identity = (AuthIdentity) exchange.getProperty(ExchangeConstantKeys.E3_AUTH_IDENTITY.toString());
    if (identity == null) return;
    @SuppressWarnings("unchecked")
    Map<String, String> properties = (Map<String,String>) exchange.getProperty(ExchangeConstantKeys.E3_MODEL_PROPERTIES.toString());
    if(properties == null)
      properties = new HashMap<String, String>();

    // First add the TDRs from the API
    Api api = identity.getApi();
    if (api != null)
      if(doStatic)
        processTdrGenerationRuleStatic(api.getTdrGenerationRule(), exchange, properties);
      else
        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);
      }
    }

    // Finally add the values from the Auth
    Auth auth = identity.getAuth();
    if(auth != null)
      if(doStatic)
        processTdrGenerationRuleStatic(auth.getTdrGenerationRule(), exchange, properties);
      else
        processTdrGenerationRuleDynamic(auth.getTdrGenerationRule(), exchange, properties, efType);
View Full Code Here

    Policy policy = new Policy();
    mockDataManager.getCallDescriptors().add(new CallDescriptor(policy, 1, 2));
   
   
    AuthReport authReport = dataAccess.checkAllowed(api);
    AuthIdentity authIdentity = authReport.getAuthIdentity();
    assertNotNull(authIdentity);
   
    assertNotNull(authIdentity.getApi() == api); // compare memory reference
    assertNull(authIdentity.getAuth());
    assertNotNull(authIdentity.getCallDescriptors().get(0).getPolicy() == policy); // compare memory reference
   
  }
View Full Code Here

    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

  public AuthReport checkAllowed(Exchange exchange, Api api) {
   
    AuthReport authReport = new AuthReport();
   
    if(exchange.getIn().getHeaders().size() > 0) {
      AuthIdentity authIdentity = new AuthIdentity();
      authIdentity.setAppId("1234");
      authReport.setAuthIdentity(authIdentity);
      authReport.setApiActive(true);
      authReport.setAuthActive(true);
     
    } else {
View Full Code Here

  @Before
  public void setup(){
    exchange = new DefaultExchange(new DefaultCamelContext());
    processor = new PropertyExtractionProcessor();

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

  public void setup(){
    exchange = TestHelper.setupExchange();
    requestProcessor = new HeaderTransRequestProcessor();
    responseProcessor = new HeaderTransResponseProcessor();

    AuthIdentity id = (AuthIdentity) exchange.getProperty(ExchangeConstantKeys.E3_AUTH_IDENTITY.toString());
    auth = id.getAuth();
    api = id.getApi();
    policy1 = id.getCallDescriptors().get(0).getPolicy();

    // Setup some properties to reference
    Map<String, String> properties = new HashMap<String, String>();
    properties.put("PROPERTY1","1234");
    properties.put("PROPERTY2","5678");
View Full Code Here

  private int queueWaitingSize = 2000; // Only default

  private static PerfWatch perfWatch;
  public PerfWatch getPerfWatch() {
    if (perfWatch == null )
      perfWatch = new PerfWatch();
   
    return perfWatch;
  }
View Full Code Here

  private static final int TDR_FILE_AGE = 30 * 1000;   // TDR file age rotation trigger

  private static PerfWatch perfWatch;
  public PerfWatch getPerfWatch() {
    if (perfWatch == null )
      perfWatch = new PerfWatch();
   
    return perfWatch;
  }
View Full Code Here

TOP

Related Classes of com.alu.e3.common.camel.AuthIdentity

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.