Further simplified the vote method.
This commit is contained in:
parent
a22daf9513
commit
709b24257f
|
@ -23,16 +23,13 @@ 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
|
return authentication
|
||||||
.getAuthorities()
|
.getAuthorities()
|
||||||
.stream().map(GrantedAuthority::getAuthority)
|
.stream()
|
||||||
.collect(Collectors.toList());
|
.map(GrantedAuthority::getAuthority)
|
||||||
|
.filter(r -> "ROLE_USER".equals(r) && LocalDateTime.now().getMinute() % 2 != 0)
|
||||||
for (String role: roles) {
|
.findAny()
|
||||||
if ("ROLE_USER".equals(role) && LocalDateTime.now().getMinute() % 2 != 0) {
|
.map(s -> ACCESS_DENIED)
|
||||||
return ACCESS_DENIED;
|
.orElseGet(() -> ACCESS_ABSTAIN);
|
||||||
}
|
|
||||||
}
|
|
||||||
return ACCESS_ABSTAIN;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue