Skip to content

Commit 4e00ee3

Browse files
committed
fixed AspectJ AOP
1 parent 454bb6e commit 4e00ee3

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

support/aspectj/src/main/aspect/org/apache/shiro/aspectj/ShiroAnnotationAuthorizingAspect.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,28 @@
2424
import org.aspectj.lang.annotation.Pointcut;
2525

2626
/**
27-
* Aspect that adds a before advice for each invocation of an annotated method.
27+
* Aspect that adds a before advice for each invocation of an annotated method or class.
2828
*/
29-
@Aspect()
29+
@Aspect
3030
public class ShiroAnnotationAuthorizingAspect {
3131

32-
private static final String pointCupExpression =
32+
private static final String pointCutExpression =
3333
"execution(@org.apache.shiro.authz.annotation.RequiresAuthentication * *(..)) || " +
34+
"execution(* (@org.apache.shiro.authz.annotation.RequiresAuthentication *).*(..)) || " +
3435
"execution(@org.apache.shiro.authz.annotation.RequiresGuest * *(..)) || " +
36+
"execution(* (@org.apache.shiro.authz.annotation.RequiresGuest *).*(..)) || " +
3537
"execution(@org.apache.shiro.authz.annotation.RequiresPermissions * *(..)) || " +
38+
"execution(* (@org.apache.shiro.authz.annotation.RequiresPermissions *).*(..)) || " +
3639
"execution(@org.apache.shiro.authz.annotation.RequiresRoles * *(..)) || " +
37-
"execution(@org.apache.shiro.authz.annotation.RequiresUser * *(..))";
40+
"execution(* (@org.apache.shiro.authz.annotation.RequiresRoles *).*(..)) || " +
41+
"execution(@org.apache.shiro.authz.annotation.RequiresUser * *(..)) || " +
42+
"execution(* (@org.apache.shiro.authz.annotation.RequiresUser *).*(..))";
3843

39-
@Pointcut(pointCupExpression)
44+
@Pointcut(pointCutExpression)
4045
public void anyShiroAnnotatedMethod() {
4146
}
4247

43-
@Pointcut(pointCupExpression)
48+
@Pointcut(pointCutExpression)
4449
void anyShiroAnnotatedMethodCall(JoinPoint thisJoinPoint) {
4550
}
4651

support/aspectj/src/test/java/org/apache/shiro/aspectj/RestrictedDummyService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
import org.apache.shiro.authz.annotation.RequiresPermissions;
2222

2323
/**
24-
* Extends the secure dummy service and makes it some access more restrictive.
24+
* Extends the secure dummy service and applies an additional class-level restriction.
2525
*/
26+
@RequiresPermissions("dummy:admin")
2627
public class RestrictedDummyService extends SecuredDummyService {
2728

28-
@RequiresPermissions("dummy:admin")
2929
public void retrieve() {
3030
log("retrieve *RESTRICTED*");
3131
super.retrieve();

0 commit comments

Comments
 (0)