Да, наверное, проще всего подключить бин:
@Component
public class MyAuthorizer {
boolean authorize(Authentication authentication) {
// do your custom checking here
}
}
А затем
@Controller
public class MyController {
@PreAuthorize("@myAuthorizer.authorize(authentication)")
// ... request mapping, etc
}
Или, если возможно, уменьшить сложный объект до строки,hasAuthority
будет работать так же, как и с простыми полномочиями:
public class MyCustomAuthority implements GrantedAuthority {
Object all;
Object my;
Object complexity;
public String getAuthority() {
return String.valueOf(this.complexity);
}
}