MethodSecurityService add additional methods

Fixes: gh-5016
This commit is contained in:
Rob Winch 2018-02-12 14:44:45 -06:00
parent ca5fb78ee1
commit 6c52eb6ee1
2 changed files with 15 additions and 1 deletions

View File

@ -17,10 +17,10 @@
package org.springframework.security.config.annotation.method.configuration; package org.springframework.security.config.annotation.method.configuration;
import org.springframework.security.access.annotation.Secured; import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.method.P;
import org.springframework.security.access.prepost.PostAuthorize; import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
import org.springframework.security.core.parameters.P;
import javax.annotation.security.DenyAll; import javax.annotation.security.DenyAll;
import javax.annotation.security.PermitAll; import javax.annotation.security.PermitAll;
@ -50,6 +50,12 @@ public interface MethodSecurityService {
@PreAuthorize("permitAll") @PreAuthorize("permitAll")
String preAuthorizePermitAll(); String preAuthorizePermitAll();
@PreAuthorize("!anonymous")
void preAuthorizeNotAnonymous();
@PreAuthorize("@authz.check(#result)")
void preAuthorizeBean(@P("result") boolean result);
@PreAuthorize("hasRole('ADMIN')") @PreAuthorize("hasRole('ADMIN')")
void preAuthorizeAdmin(); void preAuthorizeAdmin();

View File

@ -53,6 +53,14 @@ public class MethodSecurityServiceImpl implements MethodSecurityService {
return SecurityContextHolder.getContext().getAuthentication(); return SecurityContextHolder.getContext().getAuthentication();
} }
@Override
public void preAuthorizeNotAnonymous() {
}
@Override
public void preAuthorizeBean(boolean b) {
}
@Override @Override
public void preAuthorizeAdmin() { public void preAuthorizeAdmin() {
} }