| Line 33... |
Line 33... |
| 33 |
private static final Logger LOGGER = LoggerFactory.getLogger(RoleInterceptor.class);
|
33 |
private static final Logger LOGGER = LoggerFactory.getLogger(RoleInterceptor.class);
|
| 34 |
|
34 |
|
| 35 |
private static final Set<String> REQUESTED_URI_PATTERNS = new HashSet<>();
|
35 |
private static final Set<String> REQUESTED_URI_PATTERNS = new HashSet<>();
|
| 36 |
static{
|
36 |
static{
|
| 37 |
REQUESTED_URI_PATTERNS.add("/fofo");
|
37 |
REQUESTED_URI_PATTERNS.add("/fofo");
|
| 38 |
REQUESTED_URI_PATTERNS.add("/fofo/[1-9]{1, 6}/edit");
|
38 |
REQUESTED_URI_PATTERNS.add("/fofo/[0-9]{1,6}/edit");
|
| 39 |
REQUESTED_URI_PATTERNS.add("/file-display/[1-9]{1,6}");
|
39 |
REQUESTED_URI_PATTERNS.add("/file-display/[1-9]{1,6}");
|
| 40 |
}
|
40 |
}
|
| 41 |
@Autowired
|
41 |
@Autowired
|
| 42 |
UserRepository userRepository;
|
42 |
UserRepository userRepository;
|
| 43 |
|
43 |
|
| Line 61... |
Line 61... |
| 61 |
LOGGER.info("request is received after : "+request.getRequestURL().toString());
|
61 |
LOGGER.info("request is received after : "+request.getRequestURL().toString());
|
| 62 |
}
|
62 |
}
|
| 63 |
|
63 |
|
| 64 |
@Override
|
64 |
@Override
|
| 65 |
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object object) throws Exception {
|
65 |
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object object) throws Exception {
|
| 66 |
LOGGER.info("request is received before : "+request.getRequestURL().toString());
|
66 |
LOGGER.info("request is received before uri : "+request.getRequestURI());
|
| 67 |
LOGGER.info("Request method {}",request.getMethod());
|
67 |
LOGGER.info("Request method {}",request.getMethod());
|
| 68 |
try {
|
68 |
try {
|
| 69 |
FofoDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
69 |
FofoDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 70 |
User user = userRepository.selectByEmailId(fofoDetails.getEmailId());
|
70 |
User user = userRepository.selectByEmailId(fofoDetails.getEmailId());
|
| 71 |
List<UserRole> userRoles = userRoleRepository.selectByUserId(user.getId());
|
71 |
List<UserRole> userRoles = userRoleRepository.selectByUserId(user.getId());
|
| Line 73... |
Line 73... |
| 73 |
// condition start
|
73 |
// condition start
|
| 74 |
// first condition start
|
74 |
// first condition start
|
| 75 |
REQUESTED_URI_PATTERNS.stream().anyMatch(new Predicate<String>() {
|
75 |
REQUESTED_URI_PATTERNS.stream().anyMatch(new Predicate<String>() {
|
| 76 |
@Override
|
76 |
@Override
|
| 77 |
public boolean test(String regexUriPattern) {
|
77 |
public boolean test(String regexUriPattern) {
|
| 78 |
return request.getRequestURI().matches(regexUriPattern);
|
78 |
return request.getRequestURI().matches(request.getContextPath() + regexUriPattern);
|
| 79 |
};})
|
79 |
};})
|
| 80 |
// first condition end
|
80 |
// first condition end
|
| 81 |
&&
|
81 |
&&
|
| 82 |
// second condition start
|
82 |
// second condition start
|
| 83 |
userRoles.stream().anyMatch(new Predicate<UserRole>() {
|
83 |
userRoles.stream().anyMatch(new Predicate<UserRole>() {
|