removed the previous version

This commit is contained in:
Andrew Tobilko 2016-10-25 02:16:14 +03:00
parent 05ba4f173e
commit be290bf9b8
5 changed files with 0 additions and 99 deletions

View File

@ -8,5 +8,4 @@ The "Learn Spring Security" Classes: http://github.learnspringsecurity.com
### Relevant Articles:
- [RestTemplate with Basic Authentication in Spring](http://www.baeldung.com/2012/04/16/how-to-use-resttemplate-with-basic-authentication-in-spring-3-1)
- [HttpClient Timeout](http://www.baeldung.com/httpclient-timeout)
- [Writing a Custom Filter in Spring Security](http://www.baeldung.com/writing-custom-filter-spring-security)
- [HttpClient with SSL](http://www.baeldung.com/httpclient-ssl)

View File

@ -1,32 +0,0 @@
package org.baeldung.security.filter;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@Component
@Order(Ordered.LOWEST_PRECEDENCE)
public class CustomHttpFilter extends GenericCustomHttpFilter {
@Override
public void init(FilterConfig config) throws ServletException {
System.out.println(config.getInitParameter("first-init-param") +
config.getInitParameter("second-init-param"));
}
@Override
public void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain
chain) throws IOException, ServletException {
System.out.println("CustomHttpFilter is in action [the request is going to the server].");
chain.doFilter(request, response);
System.out.println("CustomHttpFilter is in action [the request has come from the server].");
}
}

View File

@ -1,28 +0,0 @@
package org.baeldung.security.filter;
import org.springframework.boot.context.embedded.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.HashMap;
import static java.util.Collections.singletonList;
@Configuration
public class FilterConfiguration {
@Bean
public FilterRegistrationBean getCustomFilterRegistrationBean() {
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setFilter(new CustomHttpFilter());
registration.setInitParameters(new HashMap<String, String>() {{
put("first-init-param", "Hello from ");
put("second-init-param", "Filter!");
}});
registration.setUrlPatterns(singletonList("/user/registration"));
return registration;
}
}

View File

@ -1,16 +0,0 @@
package org.baeldung.security.filter;
import javax.servlet.Filter;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
public abstract class GenericCustomFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {}
@Override
public void destroy() {}
}

View File

@ -1,22 +0,0 @@
package org.baeldung.security.filter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public abstract class GenericCustomHttpFilter extends GenericCustomFilter {
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
doFilter((HttpServletRequest) request, (HttpServletResponse) response, chain);
}
public abstract void doFilter(HttpServletRequest request, HttpServletResponse response,
FilterChain chain) throws IOException, ServletException;
}