Пример #1
0
 @Override
 public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) {
   if (log.isDebugEnabled()) log.debug("begin setup");
   try {
     super.setup(resolver, objectModel, src, par);
     ContextManager cm = (ContextManager) this.manager.lookup(ContextManager.ROLE);
     try {
       if (cm.hasSessionContext()) {
         cm.deleteContext("authentication");
       }
     } catch (Exception exe) {
     }
     userid = par.getParameter("username", null);
     password = par.getParameter("password", null);
     try {
       String jaasRealmTmp = par.getParameter("jaasRealm", null);
       if (jaasRealmTmp != null && !jaasRealmTmp.equalsIgnoreCase("")) {
         jaasRealm = jaasRealmTmp;
       }
     } catch (Exception se) {
     }
     try {
       String toUpper = par.getParameter("toUpperCase", null);
       if (toUpper != null && !toUpper.equalsIgnoreCase("true")) {
         userid = userid.toUpperCase();
       }
     } catch (Exception se) {
     }
     if (log.isDebugEnabled()) log.debug("trying to login as " + userid + " on the webpage");
   } catch (Exception ex) {
     new ProcessingException(ex.getMessage());
   }
   if (log.isDebugEnabled()) log.debug("end setup");
 }
Пример #2
0
  @Override
  public void setup(SourceResolver resolver, Map objectModel, String src, Parameters parameters)
      throws ProcessingException, SAXException, IOException {
    super.setup(resolver, objectModel, src, parameters);
    authorized = true;
    try {
      String stepID = parameters.getParameter("step_id");
      String beanID = parameters.getParameter("bean_id");
      int workspaceID = Integer.valueOf(parameters.getParameter("workspace_item_id").substring(1));
      WorkspaceService wi = WorkspaceService.find(context, workspaceID);
      SubmissionProcess process =
          SubmissionProcessFactory.getSubmissionProcess(context, wi.getCollection());
      SubmissionStep step = process.getStep(context, Integer.parseInt(stepID));
      xmluiActionUI =
          (AbstractXMLUIAction) SubmissionProcessXMLUIFactory.getActionInterface(beanID);
      // authorized = step.getActionConfig(beanID).getProcessingAction().isAuthorized(context,
      // ObjectModelHelper.getRequest(objectModel), wi);

      if (xmluiActionUI != null) xmluiActionUI.setup(resolver, objectModel, src, parameters);
      //            else
      //                throw new ProcessingException("SubmissionStep class is null!  We do not have
      // a valid AbstractStep in " + this.transformerClassName + ". ");
    } catch (Exception e) {
      log.error(
          LogManager.getHeader(context, "error while setting up SubmissionTransformer", ""), e);
      e.printStackTrace();
      throw new ProcessingException("Something went wrong while setting up the workflow");
    }
    // TODO: throw exception !
  }
Пример #3
0
  public Map act(
      Redirector redirector,
      SourceResolver resolver,
      Map objectModel,
      String source,
      Parameters par)
      throws Exception {
    if (this.getLogger().isDebugEnabled()) {
      this.getLogger()
          .debug(
              "BEGIN act resolver="
                  + resolver
                  + ", objectModel="
                  + objectModel
                  + ", source="
                  + source
                  + ", par="
                  + par);
    }

    int mode;
    final String modeString = par.getParameter("mode", "if-not-authenticated");
    if (modeString.equals("if-not-authenticated")) {
      mode = AuthenticationConstants.LOGOUT_MODE_IF_NOT_AUTHENTICATED;
    } else if (modeString.equalsIgnoreCase("if-unused")) {
      mode = AuthenticationConstants.LOGOUT_MODE_IF_UNUSED;
    } else if (modeString.equalsIgnoreCase("immediately")) {
      mode = AuthenticationConstants.LOGOUT_MODE_IMMEDIATELY;
    } else {
      throw new ProcessingException("Unknown mode " + modeString);
    }

    // logout
    AuthenticationManager authManager = null;
    try {
      authManager = (AuthenticationManager) this.manager.lookup(AuthenticationManager.ROLE);
      RequestState state = authManager.getState();

      final String handlerName =
          par.getParameter("handler", (state == null ? null : state.getHandlerName()));
      if (null == handlerName) {
        throw new ProcessingException("LogoutAction requires at least the handler parameter.");
      }
      authManager.logout(handlerName, mode);
    } finally {
      this.manager.release(authManager);
    }

    if (this.getLogger().isDebugEnabled()) {
      this.getLogger().debug("END act map={}");
    }

    return EMPTY_MAP;
  }
Пример #4
0
  public void setup(SourceResolver resolver, Map objectModel, String src, Parameters parameters)
      throws ProcessingException, SAXException, IOException {
    super.setup(resolver, objectModel, src, parameters);

    this.exception = parameters.getParameter("exception", super.source);
    this.code = Integer.parseInt(parameters.getParameter("code", "0"));

    // Throw exception in the setup phase?
    if (parameters.getParameterAsBoolean("setup", false)) {
      ExceptionAction.exception(this.exception, this.code);
    }
  }
Пример #5
0
 public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
     throws ProcessingException, SAXException, IOException {
   this.objectModel = objectModel;
   try {
     this.key = par.getParameter("key");
   } catch (ParameterException e) {
     throw new CascadingRuntimeException("Could not find parameter key", e);
   }
 }
Пример #6
0
  public Object getSelectorContext(Map objectModel, Parameters parameters) {

    String name = parameters.getParameter("parameter-name", this.defaultName);

    if (name == null) {
      getLogger().warn("No parameter name given -- failing.");
      return null;
    }

    return ObjectModelHelper.getRequest(objectModel).getParameter(name);
  }
Пример #7
0
  /**
   * Set the SourceResolver, objectModel Map, the source and sitemap Parameters used to process the
   * request.
   *
   * @param resolver Source resolver
   * @param objectmodel Object model
   * @param src Source
   * @param parameters Parameters
   * @throws IOException
   * @throws ProcessingException
   * @throws SAXException
   */
  public void setup(SourceResolver resolver, Map objectmodel, String src, Parameters parameters)
      throws ProcessingException, SAXException, IOException {
    super.setup(resolver, objectmodel, src, parameters);
    try {
      this.encoding = parameters.getParameter("encoding", null);
      this.inputSource = resolver.resolveURI(src);

      String nXmlCh = parameters.getParameter("nonXmlChars", String.valueOf(initNonXmlChars));
      if (nXmlCh.length() != initNonXmlChars.length)
        throw new ProcessingException(
            "Error during resolving of '" + src + "'.",
            new SourceException(
                "length of attribute string 'nonXmlChars' is "
                    + nXmlCh.length()
                    + " where it should be "
                    + initNonXmlChars.length
                    + "!"));

      this.nonXmlChars = nXmlCh.toCharArray();
    } catch (SourceException se) {
      throw new ProcessingException("Error during resolving of '" + src + "'.", se);
    }
  }
Пример #8
0
 /** Setup this component, passing the tag names to be tidied. */
 public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
     throws ProcessingException, SAXException, IOException {
   super.setup(resolver, objectModel, src, par);
   String tagsParam = par.getParameter("tags", "");
   if (getLogger().isDebugEnabled()) {
     getLogger().debug("tags: " + tagsParam);
   }
   this.tags = new HashMap();
   StringTokenizer tokenizer = new StringTokenizer(tagsParam, ",");
   while (tokenizer.hasMoreElements()) {
     String tok = tokenizer.nextToken().trim();
     this.tags.put(tok, tok);
   }
 }
Пример #9
0
  /**
   * Append parameters to the uri. Each parameter is appended to the uri with "parameter=value", the
   * parameters are separated by "&".
   */
  public static String appendParameters(String uri, Parameters parameters) {
    if (parameters != null) {
      StringBuffer buffer = new StringBuffer(uri);
      String[] keys = parameters.getNames();
      String current;
      char separator = (uri.indexOf("?") == -1 ? '?' : '&');

      if (keys != null) {
        for (int i = 0; i < keys.length; i++) {
          current = keys[i];
          buffer
              .append(separator)
              .append(current)
              .append('=')
              .append(SourceUtil.encode(parameters.getParameter(current, null)));
          separator = '&';
        }
      }
      return buffer.toString();
    }

    return uri;
  }
Пример #10
0
 public Event createEvent(Parameters params) throws ParameterException {
   final String name = params.getParameter(EVENT_NAME_PARAM);
   final String value = params.getParameter(EVENT_VALUE_PARAM);
   return new NameValueEvent(name, value);
 }
Пример #11
0
  /** Get the parameters for the logicsheet */
  protected Map getLogicSheetParameters() {
    if (this.logicSheetParameters != null) {
      return this.logicSheetParameters;
    }
    HashMap map = null;
    if (par != null) {
      String[] params = par.getNames();
      if (params != null) {
        for (int i = 0; i < params.length; i++) {
          String name = params[i];
          if (isValidXSLTParameterName(name)) {
            String value = par.getParameter(name, null);
            if (value != null) {
              if (map == null) {
                map = new HashMap(params.length);
              }
              map.put(name, value);
            }
          }
        }
      }
    }

    if (this._useParameters) {
      Request request = ObjectModelHelper.getRequest(objectModel);

      Enumeration parameters = request.getParameterNames();
      if (parameters != null) {
        while (parameters.hasMoreElements()) {
          String name = (String) parameters.nextElement();
          if (isValidXSLTParameterName(name)) {
            String value = request.getParameter(name);
            if (map == null) {
              map = new HashMap();
            }
            map.put(name, value);
          }
        }
      }
    }

    if (this._useSessionInfo) {
      final Request request = ObjectModelHelper.getRequest(objectModel);
      if (map == null) {
        map = new HashMap(6);
      }

      final Session session = request.getSession(false);
      if (session != null) {
        map.put("session-available", "true");
        map.put("session-is-new", BooleanUtils.toStringTrueFalse(session.isNew()));
        map.put(
            "session-id-from-cookie",
            BooleanUtils.toStringTrueFalse(request.isRequestedSessionIdFromCookie()));
        map.put(
            "session-id-from-url",
            BooleanUtils.toStringTrueFalse(request.isRequestedSessionIdFromURL()));
        map.put(
            "session-valid", BooleanUtils.toStringTrueFalse(request.isRequestedSessionIdValid()));
        map.put("session-id", session.getId());
      } else {
        map.put("session-available", "false");
      }
    }

    if (this._useCookies) {
      Request request = ObjectModelHelper.getRequest(objectModel);
      Cookie cookies[] = request.getCookies();
      if (cookies != null) {
        for (int i = 0; i < cookies.length; i++) {
          String name = cookies[i].getName();
          if (isValidXSLTParameterName(name)) {
            String value = cookies[i].getValue();
            if (map == null) {
              map = new HashMap(cookies.length);
            }
            map.put(name, value);
          }
        }
      }
    }
    this.logicSheetParameters = map;
    return this.logicSheetParameters;
  }
Пример #12
0
 public void parameterize(Parameters params) throws ParameterException {
   this.m_namespace = params.getParameter("namespace", DEFAULT_PROPERTY_NS);
   this.m_propertyname = params.getParameter("name", DEFAULT_PROPERTY_NAME);
   this.m_extension = params.getParameter("extension", ".xml");
   this.m_xpath = params.getParameter("xpath", "/*");
 }