Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
package com.example;

import com.aquima.interactions.portal.IApplication;
import com.aquima.interactions.portal.IPortalSession;
import com.aquima.interactions.portal.IWebServiceOperationDefinition;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

@Component
public class CustomBaasFlowStarter extends DefaultBaasFlowStarter {


  private final HttpServletRequest httpRequest;
  public CustomBaasFlowStarter (IAuthorisationManager authManager, HttpServletRequest httpRequest) {

    // wrap the auth manager in a custom implementation that is also aware of the current HTTP request
    super(new CustomAuthorisationManager(authManager, httpRequest);


    this.httpRequest = httpRequest;
  }
  
  @Override
  public IPortalSession createSession(IApplication application) {
    IPortalSession result = super.createSession(application);
    // custom logic, for example execute an action handler to modify the profile before the request is mapped
    return result;
  }
  
  @Override
  public void startFlow(IApplication application, IWebServiceOperationDefinition operation, IPortalSession session) {
    // custom logic before the flow is started, for example:
    // - setting session scoped attributes
    // - modify the profile after the request is mapped
    super.startFlow(application, operation, session);
  }
  
  @Override
  protected Map<String, Serializable> getFlowParameters() {
    Map<String, Serializable> parameters = new HashMap<>();
    parameters.put("example.custom_parameter", httpRequest.getHeader("X-Custom-Header"));
    
    return parameters;
  }
}

...