Coverage Report - org.apache.shiro.aspectj.AspectjAnnotationsAuthorizingMethodInterceptor
 
Classes in this File Line Coverage Branch Coverage Complexity
AspectjAnnotationsAuthorizingMethodInterceptor
100%
10/10
50%
1/2
2
 
 1  
 /*
 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.apache.shiro.aop.MethodInvocation;
 22  
 import org.apache.shiro.authz.aop.AnnotationsAuthorizingMethodInterceptor;
 23  
 import org.aspectj.lang.JoinPoint;
 24  
 import org.aspectj.lang.reflect.MethodSignature;
 25  
 import org.slf4j.Logger;
 26  
 import org.slf4j.LoggerFactory;
 27  
 
 28  
 import java.util.Arrays;
 29  
 
 30  
 /**
 31  
  * Extends the annotations authorizing method interceptor class hierarchie to adapt
 32  
  * an aspectj {@link JoinPoint} into a {@link MethodInvocation} amd to perform the
 33  
  * authorization of method invocations.
 34  
  *
 35  
  * @since 1.0
 36  
  */
 37  2
 public class AspectjAnnotationsAuthorizingMethodInterceptor extends AnnotationsAuthorizingMethodInterceptor {
 38  
     /**
 39  
      * This class's private log instance.
 40  
      */
 41  1
     private static final Logger log = LoggerFactory.getLogger(AspectjAnnotationsAuthorizingMethodInterceptor.class);
 42  
 
 43  
     /**
 44  
      * Performs the method interception of the before advice at the specified joint point.
 45  
      *
 46  
      * @param aJoinPoint The joint point to intercept.
 47  
      * @throws Throwable If an error occurs berforming the method invocation.
 48  
      */
 49  
     protected void performBeforeInterception(JoinPoint aJoinPoint) throws Throwable {
 50  18
         if (log.isTraceEnabled()) log.trace("#### Invoking a method decorated with a Shiro annotation" +
 51  18
                 "\n\tkind       : " + aJoinPoint.getKind() +
 52  18
                 "\n\tjoinPoint  : " + aJoinPoint +
 53  18
                 "\n\tannotations: " + Arrays.toString(((MethodSignature) aJoinPoint.getSignature()).getMethod().getAnnotations()) +
 54  18
                 "\n\ttarget     : " + aJoinPoint.getTarget()
 55  
         );
 56  
 
 57  
         // 1. Adapt the join point into a method invocation
 58  18
         BeforeAdviceMethodInvocationAdapter mi = BeforeAdviceMethodInvocationAdapter.createFrom(aJoinPoint);
 59  
 
 60  
         // 2. Delegate the authorization of the method call to the super class
 61  18
         super.invoke(mi);
 62  10
     }
 63  
 }