Examples of AuthIdentity


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

   * 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

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

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

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

    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

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

    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

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

  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

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

  @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

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

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