001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.security.access.control;
016    
017    import com.liferay.portal.kernel.security.access.control.AccessControl;
018    import com.liferay.portal.kernel.security.access.control.AccessControlled;
019    import com.liferay.portal.spring.aop.AnnotationChainableMethodAdvice;
020    
021    import org.aopalliance.intercept.MethodInvocation;
022    
023    /**
024     * @author Tomas Polesovsky
025     * @author Igor Spasic
026     * @author Michael C. Han
027     * @author Raymond Aug??
028     * @author Shuyang Zhou
029     */
030    public class AccessControlAdvice
031            extends AnnotationChainableMethodAdvice<AccessControlled> {
032    
033            @Override
034            public Object before(MethodInvocation methodInvocation) throws Throwable {
035                    AccessControlled accessControlled = findAnnotation(methodInvocation);
036    
037                    if (accessControlled == AccessControl.NULL_ACCESS_CONTROLLED) {
038                            return null;
039                    }
040    
041                    _accessControlAdvisor.accept(methodInvocation, accessControlled);
042    
043                    return null;
044            }
045    
046            @Override
047            public AccessControlled getNullAnnotation() {
048                    return AccessControl.NULL_ACCESS_CONTROLLED;
049            }
050    
051            public void setAccessControlAdvisor(
052                    AccessControlAdvisor accessControlAdvisor) {
053    
054                    _accessControlAdvisor = accessControlAdvisor;
055            }
056    
057            private AccessControlAdvisor _accessControlAdvisor;
058    
059    }