Exemplo n.º 1
0
  private void processResponse(HttpServletRequest request, OpenSSOHttpServletResponse response)
      throws IOException, ServletException {
    ISystemAccess sysAccess = AmFilterManager.getSystemAccess();
    if (getWsResponseProcessor() != null) {
      String respContent = response.getContents();
      sysAccess.logMessage("AmAgentBaseFilter: response content= " + respContent);
      String processedRespContent =
          getWsResponseProcessor().process(request.getRequestURL().toString(), respContent);
      PrintWriter out = response.getWriter();

      sysAccess.logMessage(
          "AmAgentBaseFilter: processed response content= " + processedRespContent);
      out.println(processedRespContent);
    }
  }
Exemplo n.º 2
0
  private synchronized void initializeFilter(HttpServletRequest request) throws AgentException {
    if (!isInitialized()) {
      ISystemAccess sysAccess = AmFilterManager.getSystemAccess();
      if (sysAccess != null) {
        String applicationName = null;
        String contextPath = request.getContextPath();

        if (contextPath.trim().length() == 0 || contextPath.trim().equals("/")) {
          applicationName = AgentConfiguration.DEFAULT_WEB_APPLICATION_NAME;
        } else {
          applicationName = contextPath.substring(1);
        }

        setApplicationName(applicationName);

        Map modeMap =
            sysAccess.getConfigurationMap(IFilterConfigurationConstants.CONFIG_FILTER_MODE);
        String modeString = (String) modeMap.get(applicationName);
        AmFilterMode suggestedMode = null;
        if (modeString != null && modeString.trim().length() >= 0) {
          suggestedMode = AmFilterMode.get(modeString);
          if (suggestedMode == null) {
            sysAccess.logWarning(
                "AmAgentFilter: Unknown filter mode for "
                    + applicationName
                    + ". Using configured mode");
          }
          sysAccess.logMessage(
              "AmAgentFilter: mode specified for: "
                  + applicationName
                  + " is: "
                  + modeString
                  + ", instance: "
                  + suggestedMode);
        } else {
          sysAccess.logMessage("AmAgentFilter: no mode specified for " + applicationName);
        }

        AmFilterMode actualMode = verifyFilterMode(suggestedMode, getGlobalFilterMode(sysAccess));

        sysAccess.logMessage(
            "AmAgentFilter: Filter mode for "
                + applicationName
                + " set to: "
                + ((actualMode == null) ? "Configured" : actualMode.toString()));

        setFilterMode(actualMode);

        boolean wsEnabled =
            sysAccess.getConfigurationBoolean(
                IFilterConfigurationConstants.CONFIG_WEBSERVICE_ENABLE_FLAG,
                IFilterConfigurationConstants.DEFAULT_WEBSERVICE_ENABLE_FLAG);
        if (wsEnabled) {
          IWebServiceResponseProcessor wsResponseProcessor = null;
          String wsResponseProcessorImpl =
              sysAccess.getConfiguration(
                  IFilterConfigurationConstants.CONFIG_WEBSERVICE_RESPONSEPROCESSOR_IMPL,
                  AgentConfiguration.getServiceResolver()
                      .getDefaultWebServiceResponseProcessorImpl());
          if (wsResponseProcessorImpl != null && wsResponseProcessorImpl.trim().length() > 0) {
            sysAccess.logMessage(
                "AmAgentFilter: web service response processor=" + wsResponseProcessorImpl);
            try {
              wsResponseProcessor =
                  (IWebServiceResponseProcessor)
                      Class.forName(wsResponseProcessorImpl).newInstance();
            } catch (Exception e) {
              sysAccess.logError(
                  "AmAgentFilter: not able to instantiate " + wsResponseProcessorImpl);
            }

            setWsResponseProcessor(wsResponseProcessor);

          } else {
            throw new AgentException("No WebServiceAuthenticator found");
          }
        }
        markInitialized();
      } else {
        throw new AgentException("AmAgentFilter: Unable to obtain system access");
      }
    }
  }