Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Multi basic auth with spring security

@Component
@RequiredArgsConstructor
public class TypeFilter extends OncePerRequestFilter {
   private final TypeService typeService;
   private final ObjectMapper mapper;

@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
        throws ServletException, IOException {
    String uri = request.getRequestURI();
    if (!uri.contains("/login") && !uri.contains("/password")) {
        chain.doFilter(request, response);
        return;
    }

    String headerValue = request.getHeader(TYPE);

    if (StringUtils.isBlank(headerValue)) {
       response.setStatus(HttpStatus.BAD_REQUEST.value());
        return;
    }

    try {
        Type type = type Service.findByValue(headerValue);
        TypeContext.setCurrentType(type);
        chain.doFilter(request, response);
    } catch (MyException e) {
       response.setStatus(HttpStatus.BAD_REQUEST.value());
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: java exception handling 
Java :: program Pr115_3; var k, n : integer; suma : real; begin readln(n); suma := 0; for k := 1 to n do suma := suma + 1 / sqr(2*k+1); writeln(suma); readln; end. 
Java :: preset arraylist java 
Java :: start hadoop and yarn with java 
Java :: factorial recursion java 
Java :: empty map entry java 
Java :: create variables in java 
Java :: actionlistener 
Java :: Write a Java Program to check if any number is a magic number or not. 
Java :: Java extends and implements clause 
Java :: key caracter from code java 
Java :: influx cli with docker container 
Java :: gson to class 
Java :: layout focus from recycleview not from top in fragment inside nestedScrollview in android xml 
Java :: destroy fragent after navigating 
Java :: Betrag absolute abs java 
Java :: validate list of objects in javax validation 
Java :: i have use tried catch but still prints exception java 
Java :: mysqld always running 
Java :: ExpandableLayout in android 
Java :: how to set up basic java workspace 
Java :: how get most comon element in map java 
Java :: install the app from assest of other app 
Java :: lcm 
Java :: spigot deal damage 
Java :: hello world in bukkit 
Java :: Simple java questionnaire using json 
Java :: import java.util.* 
Java :: who was the mother of thomas elva edison 
Java :: collapsingtoolbarlayout collapse listener 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =