|
@@ -86,14 +86,28 @@ public final class AuthorizationAdvisorProxyFactory
|
|
private static final TargetVisitor DEFAULT_VISITOR_SKIP_VALUE_TYPES = TargetVisitor.of(new ClassVisitor(),
|
|
private static final TargetVisitor DEFAULT_VISITOR_SKIP_VALUE_TYPES = TargetVisitor.of(new ClassVisitor(),
|
|
new IgnoreValueTypeVisitor(), DEFAULT_VISITOR);
|
|
new IgnoreValueTypeVisitor(), DEFAULT_VISITOR);
|
|
|
|
|
|
- private List<AuthorizationAdvisor> advisors;
|
|
|
|
|
|
+ private List<AuthorizationAdvisor> advisors = new ArrayList<>();
|
|
|
|
|
|
private TargetVisitor visitor = DEFAULT_VISITOR;
|
|
private TargetVisitor visitor = DEFAULT_VISITOR;
|
|
|
|
|
|
- private AuthorizationAdvisorProxyFactory(List<AuthorizationAdvisor> advisors) {
|
|
|
|
- this.advisors = new ArrayList<>(advisors);
|
|
|
|
- this.advisors.add(new AuthorizeReturnObjectMethodInterceptor(this));
|
|
|
|
- setAdvisors(this.advisors);
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Construct an {@link AuthorizationAdvisorProxyFactory} with the following advisors
|
|
|
|
+ * @param advisors the list of advisors to wrap around proxied objects
|
|
|
|
+ * @since 6.4
|
|
|
|
+ */
|
|
|
|
+ public AuthorizationAdvisorProxyFactory(List<AuthorizationAdvisor> advisors) {
|
|
|
|
+ this.advisors.addAll(advisors);
|
|
|
|
+ AnnotationAwareOrderComparator.sort(this.advisors);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Construct an {@link AuthorizationAdvisorProxyFactory} with the following advisors
|
|
|
|
+ * @param advisors the list of advisors to wrap around proxied objects
|
|
|
|
+ * @since 6.4
|
|
|
|
+ */
|
|
|
|
+ public AuthorizationAdvisorProxyFactory(AuthorizationAdvisor... advisors) {
|
|
|
|
+ this.advisors.addAll(List.of(advisors));
|
|
|
|
+ AnnotationAwareOrderComparator.sort(this.advisors);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -108,7 +122,9 @@ public final class AuthorizationAdvisorProxyFactory
|
|
advisors.add(AuthorizationManagerAfterMethodInterceptor.postAuthorize());
|
|
advisors.add(AuthorizationManagerAfterMethodInterceptor.postAuthorize());
|
|
advisors.add(new PreFilterAuthorizationMethodInterceptor());
|
|
advisors.add(new PreFilterAuthorizationMethodInterceptor());
|
|
advisors.add(new PostFilterAuthorizationMethodInterceptor());
|
|
advisors.add(new PostFilterAuthorizationMethodInterceptor());
|
|
- return new AuthorizationAdvisorProxyFactory(advisors);
|
|
|
|
|
|
+ AuthorizationAdvisorProxyFactory proxyFactory = new AuthorizationAdvisorProxyFactory(advisors);
|
|
|
|
+ proxyFactory.addAdvisors(new AuthorizeReturnObjectMethodInterceptor(proxyFactory));
|
|
|
|
+ return proxyFactory;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -123,7 +139,9 @@ public final class AuthorizationAdvisorProxyFactory
|
|
advisors.add(AuthorizationManagerAfterReactiveMethodInterceptor.postAuthorize());
|
|
advisors.add(AuthorizationManagerAfterReactiveMethodInterceptor.postAuthorize());
|
|
advisors.add(new PreFilterAuthorizationReactiveMethodInterceptor());
|
|
advisors.add(new PreFilterAuthorizationReactiveMethodInterceptor());
|
|
advisors.add(new PostFilterAuthorizationReactiveMethodInterceptor());
|
|
advisors.add(new PostFilterAuthorizationReactiveMethodInterceptor());
|
|
- return new AuthorizationAdvisorProxyFactory(advisors);
|
|
|
|
|
|
+ AuthorizationAdvisorProxyFactory proxyFactory = new AuthorizationAdvisorProxyFactory(advisors);
|
|
|
|
+ proxyFactory.addAdvisors(new AuthorizeReturnObjectMethodInterceptor(proxyFactory));
|
|
|
|
+ return proxyFactory;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -161,13 +179,21 @@ public final class AuthorizationAdvisorProxyFactory
|
|
return factory.getProxy();
|
|
return factory.getProxy();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void addAdvisors(AuthorizationAdvisor... advisors) {
|
|
|
|
+ this.advisors.addAll(List.of(advisors));
|
|
|
|
+ AnnotationAwareOrderComparator.sort(this.advisors);
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Add advisors that should be included to each proxy created.
|
|
* Add advisors that should be included to each proxy created.
|
|
*
|
|
*
|
|
* <p>
|
|
* <p>
|
|
* All advisors are re-sorted by their advisor order.
|
|
* All advisors are re-sorted by their advisor order.
|
|
* @param advisors the advisors to add
|
|
* @param advisors the advisors to add
|
|
|
|
+ * @deprecated Either use the constructor to provide a complete set of advisors or use
|
|
|
|
+ * {@link #addAdvisors(AuthorizationAdvisor...)} to add to the existing list
|
|
*/
|
|
*/
|
|
|
|
+ @Deprecated
|
|
public void setAdvisors(AuthorizationAdvisor... advisors) {
|
|
public void setAdvisors(AuthorizationAdvisor... advisors) {
|
|
this.advisors = new ArrayList<>(List.of(advisors));
|
|
this.advisors = new ArrayList<>(List.of(advisors));
|
|
AnnotationAwareOrderComparator.sort(this.advisors);
|
|
AnnotationAwareOrderComparator.sort(this.advisors);
|
|
@@ -179,7 +205,10 @@ public final class AuthorizationAdvisorProxyFactory
|
|
* <p>
|
|
* <p>
|
|
* All advisors are re-sorted by their advisor order.
|
|
* All advisors are re-sorted by their advisor order.
|
|
* @param advisors the advisors to add
|
|
* @param advisors the advisors to add
|
|
|
|
+ * @deprecated Either use the constructor to provide a complete set of advisors or use
|
|
|
|
+ * {@link #addAdvisors(AuthorizationAdvisor...)} to add to the existing list
|
|
*/
|
|
*/
|
|
|
|
+ @Deprecated
|
|
public void setAdvisors(Collection<AuthorizationAdvisor> advisors) {
|
|
public void setAdvisors(Collection<AuthorizationAdvisor> advisors) {
|
|
this.advisors = new ArrayList<>(advisors);
|
|
this.advisors = new ArrayList<>(advisors);
|
|
AnnotationAwareOrderComparator.sort(this.advisors);
|
|
AnnotationAwareOrderComparator.sort(this.advisors);
|