hi, spring security team: I'm developing authorization part of my project by implementing AuthorizationManager,Sometime i need compose multiple implementation with 'or' and 'and' relation to check authority . I think these two implementations are very commonly used, so they should be implemented in spring-security-core repo.
public class OrAuthorizationManager<T> implements AuthorizationManager<T> {
private List<AuthorizationManager<T>> authorizationManagers;
public OrAuthorizationManager(List<AuthorizationManager<T>> authorizationManagers) {
this.authorizationManagers = authorizationManagers;
}
@Override
public AuthorizationDecision check(Supplier<Authentication> authentication,
T object) {
boolean granted = false;
for(AuthorizationManager<T> am : authorizationManagers) {
AuthorizationDecision authorizationDecision = am.check(authentication, object);
if(authorizationDecision != null && authorizationDecision.isGranted()) {
granted = true;
break;
}
}
return new AuthorizationDecision(granted);
}
}