com.diboot.iam.annotation.process.ApiPermissionExtractor Maven / Gradle / Ivy
/*
* Copyright (c) 2015-2029, www.dibo.ltd ([email protected]).
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.diboot.iam.annotation.process;
import com.diboot.core.util.AnnotationUtils;
import com.diboot.core.util.BeanUtils;
import com.diboot.core.util.ContextHolder;
import com.diboot.core.util.V;
import com.diboot.core.vo.ApiUri;
import com.diboot.iam.annotation.BindPermission;
import com.diboot.iam.cache.IamPermissionCacheManager;
import com.diboot.iam.config.Cons;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.*;
/**
* 权限码注解提取器
* @author JerryMa
* @version v2.6.0
* @date 2022/4/21
* Copyright © diboot.com
*/
@Slf4j
public class ApiPermissionExtractor {
/**
* 接口权限缓存
*/
private static List API_PERMISSION_CACHE = null;
/**
* 唯一KEY
*/
private static Set UNIQUE_KEY_SET = null;
/**
* 提取所有的权限定义
* @return
*/
public static List extractAllApiPermissions(){
if(API_PERMISSION_CACHE == null){
API_PERMISSION_CACHE = new ArrayList<>();
UNIQUE_KEY_SET = new HashSet<>();
// 初始化
// 提取rest controller
List