| Line 15... |
Line 15... |
| 15 |
import org.springframework.stereotype.Component;
|
15 |
import org.springframework.stereotype.Component;
|
| 16 |
import org.springframework.web.servlet.HandlerInterceptor;
|
16 |
import org.springframework.web.servlet.HandlerInterceptor;
|
| 17 |
import org.springframework.web.servlet.ModelAndView;
|
17 |
import org.springframework.web.servlet.ModelAndView;
|
| 18 |
|
18 |
|
| 19 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
19 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| - |
|
20 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 20 |
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
|
21 |
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
|
| 21 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
22 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
| 22 |
import com.spice.profitmandi.dao.repository.dtr.UserRoleRepository;
|
23 |
import com.spice.profitmandi.dao.repository.dtr.UserRoleRepository;
|
| 23 |
import com.spice.profitmandi.web.model.LoginDetails;
|
24 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 24 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
25 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| Line 33... |
Line 34... |
| 33 |
static{
|
34 |
static{
|
| 34 |
REQUESTED_URI_PATTERNS.add("/fofo");
|
35 |
REQUESTED_URI_PATTERNS.add("/fofo");
|
| 35 |
REQUESTED_URI_PATTERNS.add("/fofo/");
|
36 |
REQUESTED_URI_PATTERNS.add("/fofo/");
|
| 36 |
REQUESTED_URI_PATTERNS.add("/fofo/-?[0-9]{1,10}/edit");
|
37 |
REQUESTED_URI_PATTERNS.add("/fofo/-?[0-9]{1,10}/edit");
|
| 37 |
REQUESTED_URI_PATTERNS.add("/fofo/-?[0-9]{1,10}/edit/");
|
38 |
REQUESTED_URI_PATTERNS.add("/fofo/-?[0-9]{1,10}/edit/");
|
| 38 |
REQUESTED_URI_PATTERNS.add("/file-display/-?[1-9]{1,10}");
|
39 |
REQUESTED_URI_PATTERNS.add("/fofo/-?[0-9]{1,10}/file-display");
|
| 39 |
REQUESTED_URI_PATTERNS.add("/file-display/-?[1-9]{1,10}/");
|
40 |
REQUESTED_URI_PATTERNS.add("/fofo/-?[0-9]{1,10}/file-display/");
|
| 40 |
}
|
41 |
}
|
| 41 |
@Autowired
|
42 |
@Autowired
|
| 42 |
UserRepository userRepository;
|
43 |
UserRepository userRepository;
|
| 43 |
|
44 |
|
| 44 |
@Autowired
|
45 |
@Autowired
|
| Line 48... |
Line 49... |
| 48 |
MVCResponseSender mvcResponseSender;
|
49 |
MVCResponseSender mvcResponseSender;
|
| 49 |
|
50 |
|
| 50 |
@Autowired
|
51 |
@Autowired
|
| 51 |
CookiesProcessor cookiesProcessor;
|
52 |
CookiesProcessor cookiesProcessor;
|
| 52 |
|
53 |
|
| - |
|
54 |
@Autowired
|
| - |
|
55 |
ResponseSender<?> responseSender;
|
| - |
|
56 |
|
| 53 |
@Override
|
57 |
@Override
|
| 54 |
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object arg2, Exception arg3)
|
58 |
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object arg2, Exception arg3)
|
| 55 |
throws Exception {
|
59 |
throws Exception {
|
| 56 |
}
|
60 |
}
|
| 57 |
|
61 |
|
| Line 72... |
Line 76... |
| 72 |
// condition start
|
76 |
// condition start
|
| 73 |
// first condition start
|
77 |
// first condition start
|
| 74 |
(REQUESTED_URI_PATTERNS.stream().anyMatch(new Predicate<String>() {
|
78 |
(REQUESTED_URI_PATTERNS.stream().anyMatch(new Predicate<String>() {
|
| 75 |
@Override
|
79 |
@Override
|
| 76 |
public boolean test(String regexUriPattern) {
|
80 |
public boolean test(String regexUriPattern) {
|
| 77 |
LOGGER.info("requestedUri == predefinedPattern {}=={} => {}", request.getRequestURI(), regexUriPattern, request.getRequestURI().matches(request.getContextPath() + regexUriPattern));
|
81 |
LOGGER.info("requestedUri {} == predefinedPattern {} => {}", request.getRequestURI(), request.getContextPath() + regexUriPattern, request.getRequestURI().matches(request.getContextPath() + regexUriPattern));
|
| 78 |
return request.getRequestURI().matches(request.getContextPath() + regexUriPattern);
|
82 |
return request.getRequestURI().matches(request.getContextPath() + regexUriPattern);
|
| 79 |
};
|
83 |
};
|
| 80 |
})
|
84 |
})
|
| 81 |
// first condition end
|
85 |
// first condition end
|
| 82 |
&&
|
86 |
&&
|
| Line 94... |
Line 98... |
| 94 |
public boolean test(String regexUriPattern) {
|
98 |
public boolean test(String regexUriPattern) {
|
| 95 |
return request.getRequestURI().matches(request.getContextPath() + regexUriPattern);
|
99 |
return request.getRequestURI().matches(request.getContextPath() + regexUriPattern);
|
| 96 |
};
|
100 |
};
|
| 97 |
}))
|
101 |
}))
|
| 98 |
&&
|
102 |
&&
|
| 99 |
fofoDetails.isFofo()
|
103 |
fofoDetails.getRoleTypes().contains(RoleType.FOFO)
|
| 100 |
)
|
104 |
)
|
| 101 |
) {
|
105 |
) {
|
| 102 |
return true;
|
106 |
return true;
|
| 103 |
} else {
|
107 |
} else {
|
| 104 |
LOGGER.error("Accessed Uri {} is forbidden", request.getRequestURI());
|
108 |
LOGGER.error("Accessed Uri {} is forbidden", request.getRequestURI());
|