Changed collect, forEach call to filter, findAny, orElseGet
This commit is contained in:
parent
a22daf9513
commit
1e53355b13
@ -23,16 +23,17 @@ public class MinuteBasedVoter implements AccessDecisionVoter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int vote(Authentication authentication, Object object, Collection collection) {
|
public int vote(Authentication authentication, Object object, Collection collection) {
|
||||||
List<String> roles = authentication
|
String role = authentication
|
||||||
.getAuthorities()
|
.getAuthorities()
|
||||||
.stream().map(GrantedAuthority::getAuthority)
|
.stream().map(GrantedAuthority::getAuthority)
|
||||||
.collect(Collectors.toList());
|
.filter("ROLE_USER"::equals)
|
||||||
|
.findAny()
|
||||||
|
.orElseGet(() -> "ROLE_ADMIN");
|
||||||
|
|
||||||
for (String role: roles) {
|
if ("ROLE_USER".equals(role) && LocalDateTime.now().getMinute() % 2 != 0) {
|
||||||
if ("ROLE_USER".equals(role) && LocalDateTime.now().getMinute() % 2 != 0) {
|
|
||||||
return ACCESS_DENIED;
|
return ACCESS_DENIED;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ACCESS_ABSTAIN;
|
return ACCESS_ABSTAIN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user