Coverage Report - org.apache.shiro.aspectj.ShiroAnnotationAuthorizingAspect
 
Classes in this File Line Coverage Branch Coverage Complexity
ShiroAnnotationAuthorizingAspect
75%
6/8
50%
1/2
1
 
 1  20
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License.  You may obtain a copy of the License at
 9  
  *
 10  
  *     http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing,
 13  
  * software distributed under the License is distributed on an
 14  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15  
  * KIND, either express or implied.  See the License for the
 16  
  * specific language governing permissions and limitations
 17  
  * under the License.
 18  
  */
 19  
 package org.apache.shiro.aspectj;
 20  
 
 21  
 import org.aspectj.lang.JoinPoint;
 22  
 import org.aspectj.lang.annotation.Aspect;
 23  
 import org.aspectj.lang.annotation.Before;
 24  
 import org.aspectj.lang.annotation.Pointcut;
 25  
 
 26  
 /**
 27  
  * Aspect that adds a before advice for each invocation of an annotated method.
 28  
  *
 29  
  */
 30  
 @Aspect()
 31  2
 public class ShiroAnnotationAuthorizingAspect {
 32  
 
 33  
     private static final String pointCupExpression =
 34  
             "execution(@org.apache.shiro.authz.annotation.RequiresAuthentication * *(..)) || " +
 35  
                     "execution(@org.apache.shiro.authz.annotation.RequiresGuest * *(..)) || " +
 36  
                     "execution(@org.apache.shiro.authz.annotation.RequiresPermissions * *(..)) || " +
 37  
                     "execution(@org.apache.shiro.authz.annotation.RequiresRoles * *(..)) || " +
 38  
                     "execution(@org.apache.shiro.authz.annotation.RequiresUser * *(..))";
 39  
 
 40  
     @Pointcut(pointCupExpression)
 41  0
     public void anyShiroAnnotatedMethod(){}
 42  
 
 43  
     @Pointcut(pointCupExpression)
 44  
     void anyShiroAnnotatedMethodCall(JoinPoint thisJoinPoint) {
 45  0
     }
 46  
 
 47  1
     private AspectjAnnotationsAuthorizingMethodInterceptor interceptor =
 48  1
             new AspectjAnnotationsAuthorizingMethodInterceptor();
 49  
 
 50  
     @Before("anyShiroAnnotatedMethodCall(thisJoinPoint)")
 51  
     public void executeAnnotatedMethod(JoinPoint thisJoinPoint) throws Throwable {
 52  18
         interceptor.performBeforeInterception(thisJoinPoint);
 53  10
     }
 54  
 }