Example usage for javax.servlet Filter getClass

List of usage examples for javax.servlet Filter getClass

Introduction

In this page you can find the example usage for javax.servlet Filter getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.nuxeo.ecm.core.opencmis.impl.CmisFeatureSessionHttp.java

protected void addFilter(org.apache.catalina.Context context, String servletName, String filterName,
        Filter filter) {
    FilterDef filterDef = new FilterDef();
    filterDef.setFilterName(filterName);
    filterDef.setFilterClass(filter.getClass().getName());
    context.addFilterDef(filterDef);/*from w w  w  .  j  a  v  a 2 s.c  om*/
    FilterMap filterMap = new FilterMap();
    filterMap.setFilterName(filterName);
    filterMap.addServletName(servletName);
    context.addFilterMap(filterMap);
}

From source file:org.nuxeo.ecm.core.opencmis.impl.NuxeoSessionClientServerTestCase.java

protected void setUpTomcat() throws Exception {
    Tomcat tomcat = new Tomcat();
    tomcat.setBaseDir("."); // for tmp dir
    tomcat.setHostname(HOST);//from  ww w.  j  ava  2s.  c  o m
    tomcat.setPort(PORT);
    ProtocolHandler p = tomcat.getConnector().getProtocolHandler();
    JIoEndpoint endpoint = (JIoEndpoint) getFieldValue(p, "endpoint");
    // ServerSocketFactory factory = new
    // ReuseAddrServerSocketFactory(endpoint);
    // endpoint.setServerSocketFactory(factory);
    // endpoint.getSocketProperties().setSoReuseAddress(true);
    endpoint.setMaxKeepAliveRequests(1); // vital for clean shutdown

    URL url = getResource(BASE_RESOURCE);
    File docBase = new File(url.getPath());
    org.apache.catalina.Context context = tomcat.addContext("/", docBase.getAbsolutePath());
    String SERVLET_NAME = "testServlet";
    Wrapper servlet = tomcat.addServlet("/", SERVLET_NAME, getServlet());
    servlet.addInitParameter(CmisAtomPubServlet.PARAM_CALL_CONTEXT_HANDLER,
            BasicAuthCallContextHandler.class.getName());
    context.addServletMapping("/*", SERVLET_NAME);
    context.setApplicationLifecycleListeners(getEventListeners());
    Filter filter = getFilter();
    if (filter != null) {
        String FILTER_NAME = "NuxeoAuthenticationFilter";
        FilterDef filterDef = new FilterDef();
        filterDef.setFilterName(FILTER_NAME);
        filterDef.setFilterClass(filter.getClass().getName());
        context.addFilterDef(filterDef);
        FilterMap filterMap = new FilterMap();
        filterMap.setFilterName(FILTER_NAME);
        filterMap.addServletName(SERVLET_NAME);
        context.addFilterMap(filterMap);
    }

    serverURI = new URI("http://" + HOST + ':' + PORT + '/');
    tomcat.start();
    this.tomcat = tomcat;
}

From source file:org.springframework.boot.context.embedded.netty.NettyEmbeddedContext.java

@Override
public javax.servlet.FilterRegistration.Dynamic addFilter(String filterName, Filter filter) {
    return addFilter(filterName, filter.getClass().getName(), filter);
}

From source file:org.springframework.cloud.dataflow.server.config.security.OAuthSecurityConfiguration.java

@Override
protected void configure(HttpSecurity http) throws Exception {

    final RequestMatcher textHtmlMatcher = new MediaTypeRequestMatcher(
            new BrowserDetectingContentNegotiationStrategy(), MediaType.TEXT_HTML);

    final BasicAuthenticationEntryPoint basicAuthenticationEntryPoint = new BasicAuthenticationEntryPoint();
    basicAuthenticationEntryPoint.setRealmName(securityProperties.getBasic().getRealm());
    basicAuthenticationEntryPoint.afterPropertiesSet();

    final Filter oauthFilter = oauthFilter();
    BasicAuthenticationFilter basicAuthenticationFilter = new BasicAuthenticationFilter(providerManager(),
            basicAuthenticationEntryPoint);

    http.addFilterAfter(oauthFilter, basicAuthenticationFilter.getClass());
    http.addFilterBefore(basicAuthenticationFilter, oauthFilter.getClass());
    http.addFilterBefore(oAuth2AuthenticationProcessingFilter(), basicAuthenticationFilter.getClass());

    http.authorizeRequests()//w  w w . j  av  a  2 s .  c om
            .antMatchers("/security/info**", "/login**", dashboard("/logout-success-oauth.html"),
                    dashboard("/styles/**"), dashboard("/images/**"), dashboard("/fonts/**"),
                    dashboard("/lib/**"))
            .permitAll().anyRequest().authenticated().and().httpBasic().and().logout()
            .logoutSuccessUrl(dashboard("/logout-success-oauth.html")).and().csrf().disable()
            .exceptionHandling()
            .defaultAuthenticationEntryPointFor(new LoginUrlAuthenticationEntryPoint("/login"), textHtmlMatcher)
            .defaultAuthenticationEntryPointFor(basicAuthenticationEntryPoint, AnyRequestMatcher.INSTANCE);

    securityStateBean.setAuthenticationEnabled(true);
    securityStateBean.setAuthorizationEnabled(false);
}

From source file:org.springframework.security.config.annotation.web.builders.DebugFilter.java

String formatFilters(List<Filter> filters) {
    StringBuilder sb = new StringBuilder();
    sb.append("Security filter chain: ");
    if (filters == null) {
        sb.append("no match");
    } else if (filters.isEmpty()) {
        sb.append("[] empty (bypassed by security='none') ");
    } else {/*  w w w  . j a v  a  2  s. co  m*/
        sb.append("[\n");
        for (Filter f : filters) {
            sb.append("  ").append(f.getClass().getSimpleName()).append("\n");
        }
        sb.append("]");
    }

    return sb.toString();
}

From source file:org.springframework.security.config.http.DefaultFilterChainValidator.java

@SuppressWarnings({ "unchecked" })
private <F extends Filter> F getFilter(Class<F> type, List<Filter> filters) {
    for (Filter f : filters) {
        if (type.isAssignableFrom(f.getClass())) {
            return (F) f;
        }// w  w  w  .jav  a2 s. c  o  m
    }

    return null;
}

From source file:org.springframework.security.config.http.DefaultFilterChainValidator.java

private void checkForDuplicates(Class<? extends Filter> clazz, List<Filter> filters) {
    for (int i = 0; i < filters.size(); i++) {
        Filter f1 = filters.get(i);
        if (clazz.isAssignableFrom(f1.getClass())) {
            // Found the first one, check remaining for another
            for (int j = i + 1; j < filters.size(); j++) {
                Filter f2 = filters.get(j);
                if (clazz.isAssignableFrom(f2.getClass())) {
                    logger.warn("Possible error: Filters at position " + i + " and " + j + " are both "
                            + "instances of " + clazz.getName());
                    return;
                }/*from  w  w  w.  j a v a  2s. c  om*/
            }
        }
    }
}

From source file:org.springframework.web.socket.TomcatWebSocketTestServer.java

@Override
public void deployConfig(WebApplicationContext wac, Filter... filters) {
    Assert.state(this.port != -1, "setup() was never called.");
    this.context = this.tomcatServer.addContext("", System.getProperty("java.io.tmpdir"));
    this.context.addApplicationListener(WsContextListener.class.getName());
    Tomcat.addServlet(this.context, "dispatcherServlet", new DispatcherServlet(wac)).setAsyncSupported(true);
    this.context.addServletMappingDecoded("/", "dispatcherServlet");
    for (Filter filter : filters) {
        FilterDef filterDef = new FilterDef();
        filterDef.setFilterName(filter.getClass().getName());
        filterDef.setFilter(filter);//from   w w w  .j av  a  2  s. co m
        filterDef.setAsyncSupported("true");
        this.context.addFilterDef(filterDef);
        FilterMap filterMap = new FilterMap();
        filterMap.setFilterName(filter.getClass().getName());
        filterMap.addURLPattern("/*");
        filterMap.setDispatcher("REQUEST,FORWARD,INCLUDE,ASYNC");
        this.context.addFilterMap(filterMap);
    }
}