protected Response processFlow(
      String execution,
      ClientSessionModel clientSession,
      String flowPath,
      AuthenticationFlowModel flow,
      String errorMessage) {
    AuthenticationProcessor processor = new AuthenticationProcessor();
    processor
        .setClientSession(clientSession)
        .setFlowPath(flowPath)
        .setFlowId(flow.getId())
        .setConnection(clientConnection)
        .setEventBuilder(event)
        .setProtector(authManager.getProtector())
        .setRealm(realm)
        .setSession(session)
        .setUriInfo(uriInfo)
        .setRequest(request);
    if (errorMessage != null)
      processor.setForwardedErrorMessage(new FormMessage(null, errorMessage));

    try {
      if (execution != null) {
        return processor.authenticationAction(execution);
      } else {
        return processor.authenticate();
      }
    } catch (Exception e) {
      return processor.handleBrowserException(e);
    }
  }