Class ReactiveAuthorizationAdvisorProxyFactory
java.lang.Object
org.springframework.security.authorization.ReactiveAuthorizationAdvisorProxyFactory
- All Implemented Interfaces:
AuthorizationProxyFactory
public final class ReactiveAuthorizationAdvisorProxyFactory
extends Object
implements AuthorizationProxyFactory
A proxy factory for applying authorization advice to an arbitrary object.
For example, consider a non-Spring-managed object Foo
:
class Foo { @PreAuthorize("hasAuthority('bar:read')") String bar() { ... } }Use
ReactiveAuthorizationAdvisorProxyFactory
to wrap the instance in Spring
Security's PreAuthorize
method
interceptor like so:
AuthorizationManagerBeforeMethodInterceptor preAuthorize = AuthorizationManagerBeforeMethodInterceptor.preAuthorize(); AuthorizationProxyFactory proxyFactory = new AuthorizationProxyFactory(preAuthorize); Foo foo = new Foo(); foo.bar(); // passes Foo securedFoo = proxyFactory.proxy(foo); securedFoo.bar(); // access denied!
- Since:
- 6.3
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionProxy an object to enforce authorization advice.void
setAdvisors
(Collection<AuthorizationAdvisor> advisors) Add advisors that should be included to each proxy created.void
setAdvisors
(AuthorizationAdvisor... advisors) Add advisors that should be included to each proxy created.
-
Constructor Details
-
ReactiveAuthorizationAdvisorProxyFactory
public ReactiveAuthorizationAdvisorProxyFactory()
-
-
Method Details
-
proxy
Proxy an object to enforce authorization advice.Proxies any instance of a non-final class or a class that implements more than one interface.
If
target
is anIterator
,Collection
,Array
,Map
,Stream
, orOptional
, then the element or value type is proxied.If
target
is aClass
, thenProxyFactory.getProxyClass(java.lang.ClassLoader)
is invoked instead.- Specified by:
proxy
in interfaceAuthorizationProxyFactory
- Parameters:
target
- the instance to proxy- Returns:
- the proxied instance
-
setAdvisors
Add advisors that should be included to each proxy created.All advisors are re-sorted by their advisor order.
- Parameters:
advisors
- the advisors to add
-
setAdvisors
Add advisors that should be included to each proxy created.All advisors are re-sorted by their advisor order.
- Parameters:
advisors
- the advisors to add
-