Esempio n. 1
0
  @Override
  public void doFilter(
      ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
      throws IOException, ServletException {

    HttpServletRequest request = (HttpServletRequest) servletRequest;
    HttpServletResponse response = (HttpServletResponse) servletResponse;

    HttpSession session = request.getSession();
    Object user_login = session.getAttribute(AURORA_USER_LOGIN);
    if (user_login != null) {
      filterChain.doFilter(request, response);
      return;
    }
    SapUserDistil distil = new SapUserDistil();
    try {
      String loginName = distil.execute(request, verifyPseFile, logger);
      if (loginName == null) {
        filterChain.doFilter(request, response);
        return;
      }
      executeLoginProc(request, response, loginName);
    } catch (Exception e) {
      logger.log(Level.SEVERE, "", e);
      return;
    }
    session.setAttribute(AURORA_USER_LOGIN, Boolean.TRUE);
    if (afterLoginRedirectUrl != null) response.sendRedirect(afterLoginRedirectUrl);
  }
Esempio n. 2
0
  public String execute(HttpServletRequest request, String verifyPseFile, ILogger logger)
      throws Exception {
    logger.info("parse sap cookie.");
    int ISSUER_CERT_SUBJECT = 0;
    int ISSUER_CERT_ISSUER = 1;
    int ISSUER_CERT_SERIALNO = 2;

    String sso = "MYSAPSSO2";
    String ticket = "";
    Cookie[] all_Cookies = request.getCookies();
    if (all_Cookies == null) return null;
    for (int i = 0; i < all_Cookies.length; i++) {
      // Get MYSAPSSO2 cookie from request context...
      if (sso.equals(all_Cookies[i].getName())) {
        ticket = all_Cookies[i].getValue();
        break;
      }
    }
    //		if (ticket == null || ticket.equals("")){
    //			ticket =
    // "AjExMDAgAA5wb3J0YWw6YW5ud2FuZ4gAE2Jhc2ljYXV0aGVudGljYXRpb24BAAdBTk5XQU5HAgADMDAwAwADUFAxBAAMMjAxNDA0MzAwNjI1BQAEAAAADQoAB0FOTldBTkf%2FAQUwggEBBgkqhkiG9w0BBwKggfMwgfACAQExCzAJBgUrDgMCGgUAMAsGCSqGSIb3DQEHATGB0DCBzQIBATAiMB0xDDAKBgNVBAMTA1BQMTENMAsGA1UECxMESjJFRQIBADAJBgUrDgMCGgUAoF0wGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMTQwNDMwMDYyNTU3WjAjBgkqhkiG9w0BCQQxFgQUO47rVk2n%2BziiW1BxmsBtk579p5AwCQYHKoZIzjgEAwQvMC0CFHxmhZ4XwG3RvNiZaqwWPy4Gg6s6AhUAwgCWpMt3QlfGOe%2B8xTgDGEIycn8%3D";
    //		}
    // If no ticket present we output an error page
    if (ticket.equals("")) return null;
    Object[] o = null;
    // Validate logon ticket.
    logger.info("ticket:" + ticket);
    o = SSO2Ticket.evalLogonTicket(ticket, verifyPseFile, null);
    String user = (String) o[0]; // First element is the SAP system user
    String Sysid = (String) o[1]; // Second element is the id of the
    // issuing system
    String Client = (String) o[2]; // Third element is the client of
    // the issuing system
    String Subject =
        (String) SSO2Ticket.parseCertificate((byte[]) o[3], ISSUER_CERT_SUBJECT); // Portal user
    String issuer = (String) SSO2Ticket.parseCertificate((byte[]) o[3], ISSUER_CERT_ISSUER);
    String PrtUsr = (String) o[4]; // Portal user
    logger.info("PrtUsr:"******"0")) return null;

    return PrtUsr;
  }
 @Override
 public boolean startup() {
   if (!(databaseServiceFactory instanceof DatabaseServiceFactory))
     throw BuiltinExceptionFactory.createInstanceNotFoundException(
         this, DatabaseServiceFactory.class);
   ((DatabaseServiceFactory) databaseServiceFactory).setGlobalParticipant(this);
   dataSource = (DataSource) objectRegistry.getInstanceOfType(DataSource.class);
   if (dataSource == null)
     throw BuiltinExceptionFactory.createInstanceNotFoundException(this, DataSource.class);
   ILogger logger = LoggingContext.getLogger(this.getClass().getCanonicalName(), objectRegistry);
   String query_dimensions_sql =
       " select d.dimension_code,d.data_query_sql,d.dimension_init_proc,d.dimension_tag "
           + " from sys_bm_config_dimension d where d.enabled_flag='Y' order by d.order_num ";
   logger.config("query_dimensions_sql:" + query_dimensions_sql);
   try {
     custDimensionsRecords = sqlQuery(query_dimensions_sql);
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
   return true;
 }
Esempio n. 4
0
  public void run(ProcedureRunner runner) throws Exception {
    CompositeMap context = runner.getContext();
    logger = LoggingContext.getLogger(context, LOGGING_TOPIC);
    logger.config("jco-invoke");
    logger.config("===================================");
    logger.log(Level.CONFIG, "config:{0}", new Object[] {this});

    ServiceInstance service = (ServiceInstance) ServiceInstance.getInstance(context.getRoot());

    //		HttpServiceInstance service = (HttpServiceInstance) HttpServiceInstance
    //				.getInstance(context.getRoot());
    CompositeMap target = null;
    CompositeMap model = null;
    if (service != null) model = service.getServiceContext().getModel();
    else model = context.getRoot().getChild("model");
    if (model == null) model = context.getRoot().createChild("model");
    if (return_target != null) {
      String t = TextParser.parse(return_target, context);
      target = (CompositeMap) model.getObject(t);
      if (target == null) target = model.createChildByTag(t);
    }
    JCoDestination destination = sapConfig.getJCoDestination(sid);
    String functionName = function;

    JCoFunctionTemplate ftemplate = destination.getRepository().getFunctionTemplate(functionName);
    logger.info("function template:" + functionName);
    if (ftemplate == null) {
      logger.log(Level.SEVERE, "Function '" + function + "' not found in SAP system.");
      throw new IllegalArgumentException("Function '" + function + "' not found in SAP system.");
    }
    // Create a function from the template
    JCoFunction function = ftemplate.getFunction();
    JCoParameterList input = function.getImportParameterList();
    JCoParameterList output = function.getExportParameterList();
    if (parameters != null)
      for (int i = 0; i < parameters.length; i++) {
        Parameter param = parameters[i];
        if (param.Return_field == null) {
          Object o =
              param.Source_field == null ? param.Value : context.getObject(param.Source_field);
          String value = o == null ? "" : o.toString();
          input.setValue(param.Name, value);
          logger.log(Level.CONFIG, "parameter {0} -> {1}", new Object[] {param.Name, value});
        }
      }
    if (structures != null) {
      for (int i = 0; i < structures.length; i++) {
        Structure structure = structures[i];
        structure.setLogger(logger);
        if (structure.isImport()) {
          JCoStructure stc = structure.getJCOStructure(input);
          structure.fillJCOStructure(stc, context);
          input.setValue(structure.Name, stc);
        }
      }
    }
    // Set import table
    if (tables != null) {
      JCoParameterList list = function.getTableParameterList();
      for (int i = 0; i < tables.length; i++) {
        Table table = tables[i];
        table.setLogger(logger);
        if (table.isImport()) {
          JCoTable tbl = table.getJCOTable(list);
          Object o = context.getObject(table.Source_field);
          logger.config(
              "transfer import table " + table.Name + " from '" + table.Source_field + "':" + o);
          if (o instanceof CompositeMap) table.fillJCOTable(tbl, (CompositeMap) context);
        }
      }
    }

    // Call the remote system and retrieve return value
    logger.config("call function " + function);
    function.execute(destination);
    if (parameters != null) {
      for (int i = 0; i < parameters.length; i++) {
        Parameter param = parameters[i];
        if (param.Return_field != null) {
          if (target == null)
            throw new ConfigurationError(
                "<jco-invoke>:must set 'return_target' attribute if there is return field");
          String vl = output.getString(param.Name);
          if (vl == null && !param.Nullable)
            throw new IllegalArgumentException(
                "jco-invoke: return field " + param.Name + " is null");
          String f = TextParser.parse(param.Return_field, context);
          target.putObject(f, vl);
          logger.config("return: " + param.Name + "=" + vl + " -> " + f);
        }
      }
    }
    if (structures != null) {
      for (int i = 0; i < structures.length; i++) {
        Structure structure = structures[i];
        structure.setLogger(logger);
        if (structure.isImport()) continue;
        if (structure.Target == null)
          throw new ConfigurationError(
              "Must set 'target' attribute for Structures " + structure.Name);
        JCoStructure stc = structure.getJCOStructure(output);
        CompositeMap result = (CompositeMap) context.getObject(structure.Target);
        if (result == null) result = context.createChildByTag(structure.Target);
        structure.fillCompositeMap(stc, result);
      }
    }
    // Get export tables
    if (tables != null) {
      JCoParameterList list = function.getTableParameterList();
      if (list == null)
        throw new IllegalArgumentException("Function '" + function + "' doesn't return tables");
      for (int i = 0; i < tables.length; i++) {
        Table table = tables[i];
        if (table.isImport()) continue;
        if (table.Target == null)
          throw new ConfigurationError("Must set 'target' attribute for table " + table.Name);
        table.setLogger(logger);
        JCoTable records = table.getJCOTable(list);
        // Fetch as CompositeMap

        CompositeMap result = (CompositeMap) context.getObject(table.Target);
        if (result == null) result = context.createChildByTag(table.Target);
        table.fillCompositeMap(records, result);
        int rc = 0;
        if (result.getChilds() != null) rc = result.getChilds().size();
        logger.config(
            "loading export table "
                + table.Name
                + " into path '"
                + table.Target
                + "', total "
                + rc
                + " record(s)");
      }
    }
  }
  public void query(CompositeMap context_map) throws Exception {
    super.doPopulate();
    ILogger logger =
        LoggingContext.getLogger(context_map, DatabaseConstant.AURORA_DATABASE_LOGGING_TOPIC);
    SqlServiceContext context =
        (SqlServiceContext) DynamicObject.cast(context_map, SqlServiceContext.class);

    String cache_key = null;
    boolean is_cache = false;
    ICache cache_for_data = null;
    if (cacheKey != null) {
      is_cache = true;
      cache_for_data = CacheUtil.getNamedCache(mObjectReg, KEY_DATA_CACHE_NAME);
      cache_key = TextParser.parse(cacheKey, context_map);
      CompositeMap data = (CompositeMap) cache_for_data.getValue(cache_key);
      if (data != null) {
        logger.config("Cached data found with key " + cache_key);
        // write cache to context
        CompositeMap root_node =
            getMapFromRootPath(
                context.getModel(), TextParser.parse(this.rootPath, context.getObjectContext()));
        root_node.copy(data);
        return;
      } else {
        logger.config(
            "Cached data not found with key " + cache_key + ", doing normal database query");
      }
    }

    prepare(context_map);

    // context.setTrace(trace);
    ServiceOption option = ServiceOption.createInstance();
    option.setQueryMode(mode);
    option.setAutoCount(autoCount);
    option.setConnectionName(connectionName);
    option.setFieldCase(fieldNameCaseValue);
    option.setRecordName(recordName);
    transferServiceOption(option, ServiceOption.KEY_DEFAULT_WHERE_CLAUSE);
    transferServiceOption(option, ServiceOption.KEY_QUERY_ORDER_BY);
    context.setServiceOption(option);

    IResultSetConsumer consumer = null;
    //        CompositeMapCreator compositeCreator = null;
    try {
      // get parameter
      CompositeMap param = context.getCurrentParameter();
      if (parameter != null) {
        Object obj = param.getObject(parameter);
        if (obj != null) {
          if (!(obj instanceof CompositeMap))
            throw new IllegalArgumentException(
                "query parameter should be instance of CompositeMap, but actually got "
                    + obj.getClass().getName());
          param = (CompositeMap) obj;
        }
      }

      // page settings
      FetchDescriptor desc = FetchDescriptor.createFromParameter(context.getParameter());
      desc.setFetchAll(fetchAll);
      if (pageSize != null) desc.setPageSize(pageSize.intValue());

      // ResultSet consumer
      if (this.rsConsummer != null) consumer = this.rsConsummer;
      else {
        consumer = (IResultSetConsumer) context.getInstanceOfType(IResultSetConsumer.class);
        if (consumer == null) {
          consumer = new CompositeMapCreator();
          mOCManager.populateObject(mEntryConfig, consumer);
        }
      }
      if (consumer instanceof IContextAcceptable)
        ((IContextAcceptable) consumer).setContext(context_map);
      // set root path
      if (consumer instanceof IRootMapAcceptable) {
        CompositeMap result =
            getMapFromRootPath(
                context.getModel(), TextParser.parse(this.rootPath, context.getObjectContext()));
        if (result != null) ((IRootMapAcceptable) consumer).setRoot(result);
      }
      context.setResultsetConsumer(consumer);
      doQuery(param, consumer, desc);

      // write data to cache
      if (is_cache) {
        CompositeMap d = (CompositeMap) consumer.getResult();
        CompositeMap copied_data = (CompositeMap) d.clone();
        copied_data.setParent(null);
        cache_for_data.setValue(cache_key, copied_data);
      }
      /*
      if( transform_list != null && consumer instanceof  IRootMapAcceptable){
          CompositeMap root = ((IRootMapAcceptable)consumer).getRoot();
          Transformer.doBatchTransform( root, transform_list );
      }
      */
    } finally {
      context.setServiceOption(null);
      context.setResultsetConsumer(null);
      cleanUp(context_map);
    }
  }