Пример #1
0
  public void init(FilterConfig config) throws ServletException {
    this.context = config.getServletContext();

    // get input and output dirs
    this.inDirName = config.getInitParameter(P_INPUT_DIRNAME);
    if (this.inDirName == null) this.inDirName = DEFAULT_INPUT_DIRNAME;
    this.outDirName = config.getInitParameter(P_OUTPUT_DIRNAME);
    if (this.outDirName == null) this.outDirName = DEFAULT_OUTPUT_DIRNAME;
    if (ZimbraLog.webclient.isDebugEnabled()) {
      ZimbraLog.webclient.debug("### indir:  " + this.inDirName);
      ZimbraLog.webclient.debug("### outdir: " + this.outDirName);
    }
  }
Пример #2
0
  public void init(FilterConfig filterConfig) throws ServletException {
    this.filterConfig = filterConfig;
    String configFile = System.getProperty("jboss.server.config.dir") + "/picketlink.xml";
    if (new File(configFile).exists()) this.configFile = configFile;

    this.servletContext = filterConfig.getServletContext();
    processConfiguration(filterConfig);
  }
Пример #3
0
 public void init(FilterConfig filterConfig) {
   this.config = filterConfig;
   this.encoding = config.getInitParameter("encoding");
   if (encoding == null || encoding.length() == 0) {
     encoding = "GBK";
   }
   expiresMap = new HashMap();
   Enumeration names = config.getInitParameterNames();
   while (names.hasMoreElements()) {
     String paramName = (String) names.nextElement();
     if (!"encoding".equals(paramName)) {
       String paramValue = config.getInitParameter(paramName);
       try {
         Integer expires = Integer.valueOf(config.getInitParameter(paramName));
         expiresMap.put(paramName, expires);
       } catch (Exception ex) {
         // LogUtil.logError( "Filter."+paramValue+"="+paramValue);
       }
     }
   }
 }
Пример #4
0
  protected void processConfiguration(FilterConfig filterConfig) {
    InputStream is;

    if (isNullOrEmpty(this.configFile)) {
      is = servletContext.getResourceAsStream(CONFIG_FILE_LOCATION);
    } else {
      try {
        is = new FileInputStream(this.configFile);
      } catch (FileNotFoundException e) {
        throw logger.samlIDPConfigurationError(e);
      }
    }

    PicketLinkType picketLinkType;

    String configurationProviderName = filterConfig.getInitParameter(CONFIGURATION_PROVIDER);

    if (configurationProviderName != null) {
      try {
        Class<?> clazz = SecurityActions.loadClass(getClass(), configurationProviderName);

        if (clazz == null) {
          throw new ClassNotFoundException(ErrorCodes.CLASS_NOT_LOADED + configurationProviderName);
        }

        this.configProvider = (SAMLConfigurationProvider) clazz.newInstance();
      } catch (Exception e) {
        throw new RuntimeException(
            "Could not create configuration provider [" + configurationProviderName + "].", e);
      }
    }

    try {
      // Work on the IDP Configuration
      if (configProvider != null) {
        try {
          if (is == null) {
            // Try the older version
            is =
                servletContext.getResourceAsStream(
                    GeneralConstants.DEPRECATED_CONFIG_FILE_LOCATION);

            // Additionally parse the deprecated config file
            if (is != null && configProvider instanceof AbstractSAMLConfigurationProvider) {
              ((AbstractSAMLConfigurationProvider) configProvider).setConfigFile(is);
            }
          } else {
            // Additionally parse the consolidated config file
            if (is != null && configProvider instanceof AbstractSAMLConfigurationProvider) {
              ((AbstractSAMLConfigurationProvider) configProvider).setConsolidatedConfigFile(is);
            }
          }

          picketLinkType = configProvider.getPicketLinkConfiguration();
          picketLinkType.setIdpOrSP(configProvider.getSPConfiguration());
        } catch (ProcessingException e) {
          throw logger.samlSPConfigurationError(e);
        } catch (ParsingException e) {
          throw logger.samlSPConfigurationError(e);
        }
      } else {
        if (is != null) {
          try {
            picketLinkType = ConfigurationUtil.getConfiguration(is);
          } catch (ParsingException e) {
            logger.trace(e);
            throw logger.samlSPConfigurationError(e);
          }
        } else {
          is = servletContext.getResourceAsStream(GeneralConstants.DEPRECATED_CONFIG_FILE_LOCATION);
          if (is == null) {
            throw logger.configurationFileMissing(configFile);
          }

          picketLinkType = new PicketLinkType();

          picketLinkType.setIdpOrSP(ConfigurationUtil.getSPConfiguration(is));
        }
      }

      // Close the InputStream as we no longer need it
      if (is != null) {
        try {
          is.close();
        } catch (IOException e) {
          // ignore
        }
      }

      Boolean enableAudit = picketLinkType.isEnableAudit();

      // See if we have the system property enabled
      if (!enableAudit) {
        String sysProp = SecurityActions.getSystemProperty(GeneralConstants.AUDIT_ENABLE, "NULL");
        if (!"NULL".equals(sysProp)) {
          enableAudit = Boolean.parseBoolean(sysProp);
        }
      }

      if (enableAudit) {
        if (auditHelper == null) {
          String securityDomainName = PicketLinkAuditHelper.getSecurityDomainName(servletContext);

          auditHelper = new PicketLinkAuditHelper(securityDomainName);
        }
      }

      SPType spConfiguration = (SPType) picketLinkType.getIdpOrSP();
      processIdPMetadata(spConfiguration);

      this.serviceURL = spConfiguration.getServiceURL();
      this.canonicalizationMethod = spConfiguration.getCanonicalizationMethod();
      this.picketLinkConfiguration = picketLinkType;

      this.issuerID = filterConfig.getInitParameter(ISSUER_ID);
      this.characterEncoding = filterConfig.getInitParameter(CHARACTER_ENCODING);
      this.samlHandlerChainClass = filterConfig.getInitParameter(SAML_HANDLER_CHAIN_CLASS);

      logger.samlSPSettingCanonicalizationMethod(canonicalizationMethod);
      XMLSignatureUtil.setCanonicalizationMethodType(canonicalizationMethod);

      try {
        this.initKeyProvider();
        this.initializeHandlerChain(picketLinkType);
      } catch (Exception e) {
        throw new RuntimeException(e);
      }

      logger.trace("Identity Provider URL=" + getConfiguration().getIdentityURL());
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
 public void init(FilterConfig config) throws ServletException {
   encoding = config.getInitParameter(ENCODING_INIT_PARAM_NAME);
   if (encoding == null) encoding = ENCODING_DEFAULT;
 }
  public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
      throws IOException, ServletException {
    if (filterConfig == null) return;
    StringWriter sw = new StringWriter();
    PrintWriter writer = new PrintWriter(sw);
    writer.println(
        (new StringBuilder("Request Received at "))
            .append(new Timestamp(System.currentTimeMillis()))
            .toString());
    writer.println(
        (new StringBuilder(" characterEncoding="))
            .append(request.getCharacterEncoding())
            .toString());
    writer.println(
        (new StringBuilder("     contentLength=")).append(request.getContentLength()).toString());
    writer.println(
        (new StringBuilder("       contentType=")).append(request.getContentType()).toString());
    writer.println(
        (new StringBuilder("            locale=")).append(request.getLocale()).toString());
    writer.print("           locales=");
    Enumeration locales = request.getLocales();
    boolean first = true;
    Locale locale;
    for (; locales.hasMoreElements(); writer.print(locale.toString())) {
      locale = (Locale) locales.nextElement();
      if (first) first = false;
      else writer.print(", ");
    }

    writer.println();
    for (Enumeration names = request.getParameterNames();
        names.hasMoreElements();
        writer.println()) {
      String name = (String) names.nextElement();
      writer.print((new StringBuilder("         parameter=")).append(name).append("=").toString());
      String values[] = request.getParameterValues(name);
      for (int i = 0; i < values.length; i++) {
        if (i > 0) writer.print(", ");
        writer.print(values[i]);
      }
    }

    writer.println(
        (new StringBuilder("          protocol=")).append(request.getProtocol()).toString());
    writer.println(
        (new StringBuilder("        remoteAddr=")).append(request.getRemoteAddr()).toString());
    writer.println(
        (new StringBuilder("        remoteHost=")).append(request.getRemoteHost()).toString());
    writer.println(
        (new StringBuilder("            scheme=")).append(request.getScheme()).toString());
    writer.println(
        (new StringBuilder("        serverName=")).append(request.getServerName()).toString());
    writer.println(
        (new StringBuilder("        serverPort=")).append(request.getServerPort()).toString());
    writer.println(
        (new StringBuilder("          isSecure=")).append(request.isSecure()).toString());
    if (request instanceof HttpServletRequest) {
      writer.println("---------------------------------------------");
      HttpServletRequest hrequest = (HttpServletRequest) request;
      writer.println(
          (new StringBuilder("       contextPath=")).append(hrequest.getContextPath()).toString());
      Cookie cookies[] = hrequest.getCookies();
      if (cookies == null) cookies = new Cookie[0];
      for (int i = 0; i < cookies.length; i++)
        writer.println(
            (new StringBuilder("            cookie="))
                .append(cookies[i].getName())
                .append("=")
                .append(cookies[i].getValue())
                .toString());

      String name;
      String value;
      for (Enumeration names = hrequest.getHeaderNames();
          names.hasMoreElements();
          writer.println(
              (new StringBuilder("            header="))
                  .append(name)
                  .append("=")
                  .append(value)
                  .toString())) {
        name = (String) names.nextElement();
        value = hrequest.getHeader(name);
      }

      writer.println(
          (new StringBuilder("            method=")).append(hrequest.getMethod()).toString());
      writer.println(
          (new StringBuilder("          pathInfo=")).append(hrequest.getPathInfo()).toString());
      writer.println(
          (new StringBuilder("       queryString=")).append(hrequest.getQueryString()).toString());
      writer.println(
          (new StringBuilder("        remoteUser="******"requestedSessionId="))
              .append(hrequest.getRequestedSessionId())
              .toString());
      writer.println(
          (new StringBuilder("        requestURI=")).append(hrequest.getRequestURI()).toString());
      writer.println(
          (new StringBuilder("       servletPath=")).append(hrequest.getServletPath()).toString());
    }
    writer.println("=============================================");
    writer.flush();
    filterConfig.getServletContext().log(sw.getBuffer().toString());
    chain.doFilter(request, response);
  }