判断当前用户对访问的方法是否有权限

@param pjp            方法
@param requestMapping 方法上的annotation

@return

@throws Throwable
486415
@Around("anyPublicMethod() && @annotation(requestMapping)")
    public Object decideAccess(ProceedingJoinPoint pjp, RequestMapping requestMapping) throws Throwable {

        Object rtnOb = null;

        try {
            // 执行方法
            rtnOb = pjp.proceed();
        } catch (Throwable t) {
            LOG.info(t.getMessage());
            throw t;
        }

        return rtnOb;
    }
1102662
protected boolean isOpenAPIMethod(MethodDoc methodDoc) {
		AnnotationDesc[] annotations = methodDoc.annotations();
		boolean isActionMethod = false;
		for (int i = 0; i < annotations.length; i++) {
			if (annotations[i].annotationType().name().equals("RequestMapping")
					|| annotations[i].annotationType().name().equals("PostMapping")
					|| annotations[i].annotationType().name().equals("GetMapping")
					|| annotations[i].annotationType().name().equals("DeleteMapping")
					|| annotations[i].annotationType().name().equals("PutMapping")
					|| annotations[i].annotationType().name().equals("PatchMapping") ) {
				isActionMethod = true;
				break;
			}
		}
		Tag[] t = methodDoc.tags(WRAPITaglet.NAME);
		return isActionMethod
				|| t.length > 0
				|| this.isProgramElementDocAnnotatedWith(methodDoc, "javax.ws.rs.Path");
	}
205089
Object bindAndInvoke(Object o, StaplerRequest req, StaplerResponse rsp, Object... headArgs) throws IllegalAccessException, InvocationTargetException, ServletException {
        Class[] types = getParameterTypes();
        Annotation[][] annotations = getParameterAnnotations();
        String[] parameterNames = getParameterNames();

        Object[] arguments = new Object[types.length];

        // fill in the first N arguments
        System.arraycopy(headArgs,0,arguments,0,headArgs.length);

        try {
            // find the rest of the arguments. either known types, or with annotations
            for( int i=headArgs.length; i<types.length; i++ ) {
                Class t = types[i];
                if(t==StaplerRequest.class || t==HttpServletRequest.class) {
                    arguments[i] = req;
                    continue;
                }
                if(t==StaplerResponse.class || t==HttpServletResponse.class) {
                    arguments[i] = rsp;
                    continue;
                }

                // if the databinding method is provided, call that
                Function binder = PARSE_METHODS.getUnchecked(t);
                if (binder!=RETURN_NULL) {
                    arguments[i] = binder.bindAndInvoke(null,req,rsp);
                    continue;
                }
                
                arguments[i] = AnnotationHandler.handle(req,annotations[i],
                    i<parameterNames.length ? parameterNames[i] : null,
                    t);
            }
        } catch (IllegalArgumentException e) {
            throw new IllegalArgumentException("Failed to invoke "+getDisplayName(),e);
        }

        return invoke(req, rsp, o,arguments);
    }
177014
public ModelAndView handleRequest(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		String requestedPath = (StringUtils.isEmpty(mapping)) ? helper
				.getPathWithinApplication(request) : helper
				.getPathWithinServletMapping(request);

		if (StringUtils.isNotEmpty(controllerMapping)) {
			requestedPath = requestedPath.substring(controllerMapping.length());
		}

		requestHandler.processRequest(requestedPath, request, response);
		return null;
	}
899776
public Binder catchException(Class<? extends Throwable> throwable, MethodHandle function) {
        return new Binder(this, new Catch(throwable, function));
    }
567809
@Around(value = "execution(* *(..)) && (@annotation(annotation))")
    public Object countMethod(ProceedingJoinPoint pjp, Count annotation) throws Throwable {
    	return count(pjp, annotation.producerId(), annotation.subsystem(), annotation.category());
    }
850457
private CodeBlock methodCallCodeWithJMapperTypeParameters( CodeBlock.Builder builder, ImmutableList<? extends JMapperType> parameters
    ) {
        return methodCallParametersCode( builder, Lists.transform( parameters, new Function<JMapperType, CodeBlock>() {

            @Override
            public CodeBlock apply( JMapperType jMapperType ) {
                return jMapperType.getInstance();
            }
        } ) );
    }
967988
public static Predicate<RequestHandler> withMethodAnnotation(final Class<? extends Annotation> annotation) {
    return input -> input.isAnnotatedWith(annotation);
  }
7575
public static Throwable getThrowable(ServletRequest req) {

        CmsFlexController controller = (CmsFlexController)req.getAttribute(ATTRIBUTE_NAME);
        if (controller != null) {
            return controller.getThrowable();
        } else {
            return null;
        }
    }
933385
public void audit(final JoinPoint jointPoint) throws Throwable {
        MethodSignature methodSignature = (MethodSignature) jointPoint.getSignature();
        Method method = methodSignature.getMethod();
        AuditManager.getInstance().audit(jointPoint.getTarget().getClass(), method, jointPoint.getArgs());
    }
236013
private static AnnotatedHttpServiceElement create(String pathPrefix, Object object, Method method,
                                                      List<ExceptionHandlerFunction> baseExceptionHandlers,
                                                      List<RequestConverterFunction> baseRequestConverters,
                                                      List<ResponseConverterFunction> baseResponseConverters) {

        final Set<Annotation> methodAnnotations = httpMethodAnnotations(method);
        if (methodAnnotations.isEmpty()) {
            throw new IllegalArgumentException("HTTP Method specification is missing: " + method.getName());
        }

        final Set<HttpMethod> methods = toHttpMethods(methodAnnotations);
        if (methods.isEmpty()) {
            throw new IllegalArgumentException(method.getDeclaringClass().getName() + '#' + method.getName() +
                                               " must have an HTTP method annotation.");
        }

        final Class<?> clazz = object.getClass();
        final PathMapping pathMapping = pathStringMapping(pathPrefix, method, methodAnnotations)
                .withHttpHeaderInfo(methods, consumableMediaTypes(method, clazz),
                                    producibleMediaTypes(method, clazz));

        final List<ExceptionHandlerFunction> eh =
                getAnnotatedInstances(method, clazz, ExceptionHandler.class, ExceptionHandlerFunction.class)
                        .addAll(baseExceptionHandlers).add(defaultExceptionHandler).build();
        final List<RequestConverterFunction> req =
                getAnnotatedInstances(method, clazz, RequestConverter.class, RequestConverterFunction.class)
                        .addAll(baseRequestConverters).build();
        final List<ResponseConverterFunction> res =
                getAnnotatedInstances(method, clazz, ResponseConverter.class, ResponseConverterFunction.class)
                        .addAll(baseResponseConverters).build();

        List<AnnotatedValueResolver> resolvers;
        try {
            resolvers = AnnotatedValueResolver.ofServiceMethod(method, pathMapping.paramNames(),
                                                               toRequestObjectResolvers(req));
        } catch (NoParameterException ignored) {
            // Allow no parameter like below:
            //
            // @Get("/")
            // public String method1() { ... }
            //
            resolvers = ImmutableList.of();
        }

        final Set<String> expectedParamNames = pathMapping.paramNames();
        final Set<String> requiredParamNames =
                resolvers.stream()
                         .filter(AnnotatedValueResolver::isPathVariable)
                         .map(AnnotatedValueResolver::httpElementName)
                         .collect(Collectors.toSet());

        if (!expectedParamNames.containsAll(requiredParamNames)) {
            final Set<String> missing = Sets.difference(requiredParamNames, expectedParamNames);
            throw new IllegalArgumentException("cannot find path variables: " + missing);
        }

        // Warn unused path variables only if there's no '@RequestObject' annotation.
        if (resolvers.stream().noneMatch(r -> r.annotationType() == RequestObject.class) &&
            !requiredParamNames.containsAll(expectedParamNames)) {
            final Set<String> missing = Sets.difference(expectedParamNames, requiredParamNames);
            logger.warn("Some path variables of the method '" + method.getName() +
                        "' of the class '" + clazz.getName() +
                        "' do not have their corresponding parameters annotated with @Param. " +
                        "They would not be automatically injected: " + missing);
        }

        final Optional<HttpStatus> defaultResponseStatus = findFirst(method, StatusCode.class)
                .map(code -> {
                    final int statusCode = code.value();
                    checkArgument(statusCode >= 0,
                                  "invalid HTTP status code: %s (expected: >= 0)", statusCode);
                    return HttpStatus.valueOf(statusCode);
                });
        final HttpHeaders defaultHeaders = HttpHeaders.of(defaultResponseStatus(defaultResponseStatus, method));

        final HttpHeaders defaultTrailingHeaders = HttpHeaders.of();
        final String classAlias = clazz.getName();
        final String methodAlias = String.format("%s.%s()", classAlias, method.getName());
        setAdditionalHeader(defaultHeaders, clazz, "header", classAlias, "class", AdditionalHeader.class,
                            AdditionalHeader::name, AdditionalHeader::value);
        setAdditionalHeader(defaultHeaders, method, "header", methodAlias, "method", AdditionalHeader.class,
                            AdditionalHeader::name, AdditionalHeader::value);
        setAdditionalHeader(defaultTrailingHeaders, clazz, "trailer", classAlias, "class",
                            AdditionalTrailer.class, AdditionalTrailer::name, AdditionalTrailer::value);
        setAdditionalHeader(defaultTrailingHeaders, method, "trailer", methodAlias, "method",
                            AdditionalTrailer.class, AdditionalTrailer::name, AdditionalTrailer::value);

        if (ArmeriaHttpUtil.isContentAlwaysEmpty(defaultHeaders.status()) &&
            !defaultTrailingHeaders.isEmpty()) {
            logger.warn("A response with HTTP status code '{}' cannot have a content. " +
                        "Trailing headers defined at '{}' might be ignored.",
                        defaultHeaders.status().code(), methodAlias);
        }

        // A CORS preflight request can be received because we handle it specially. The following
        // decorator will prevent the service from an unexpected request which has OPTIONS method.
        final Function<Service<HttpRequest, HttpResponse>,
                ? extends Service<HttpRequest, HttpResponse>> initialDecorator;
        if (methods.contains(HttpMethod.OPTIONS)) {
            initialDecorator = Function.identity();
        } else {
            initialDecorator = delegate -> new SimpleDecoratingService<HttpRequest, HttpResponse>(delegate) {
                @Override
                public HttpResponse serve(ServiceRequestContext ctx, HttpRequest req) throws Exception {
                    if (req.method() == HttpMethod.OPTIONS) {
                        // This must be a CORS preflight request.
                        throw HttpStatusException.of(HttpStatus.FORBIDDEN);
                    }
                    return delegate().serve(ctx, req);
                }
            };
        }
        return new AnnotatedHttpServiceElement(pathMapping,
                                               new AnnotatedHttpService(object, method, resolvers, eh,
                                                                        res, pathMapping, defaultHeaders,
                                                                        defaultTrailingHeaders),
                                               decorator(method, clazz, initialDecorator));
    }
1094264
public boolean requestShouldBeHandledByTAI(HttpServletRequest request, MicroProfileJwtTaiRequest mpJwtTaiRequest, boolean defaultConfig) {
        String methodName = "requestShouldBeHandledByTAI";
        if (tc.isDebugEnabled()) {
            Tr.entry(tc, methodName, request, mpJwtTaiRequest);
        }

        mpJwtTaiRequest = setTaiRequestConfigInfo(request, mpJwtTaiRequest, defaultConfig);
        boolean result = false;
        boolean ignoreAppAuthMethod = true;

        MicroProfileJwtConfig mpJwtConfig = null;
        try {
            mpJwtConfig = mpJwtTaiRequest.getOnlyMatchingConfig();
        } catch (MpJwtProcessingException e) {

        }
        if (mpJwtConfig != null) {
            if (shouldDeferToJwtSso(request, mpJwtConfig, mpJwtTaiRequest.getJwtSsoConfig())) {
                return false;
            }
            ignoreAppAuthMethod = mpJwtConfig.ignoreApplicationAuthMethod(); // true by default
            if (ignoreAppAuthMethod) {
                result = mpJwtTaiRequest.hasServices();
            } else {
                result = isMpJwtSpecifiedInLoginConfig(request);
            }
        }

        if (tc.isDebugEnabled()) {
            Tr.exit(tc, methodName, result);
        }
        return result;
    }
393605
public static Map createParamMap(PageContext pContext)
    {
        final HttpServletRequest request =
                (HttpServletRequest) pContext.getRequest();
        return new EnumeratedMap()
        {
            public Enumeration enumerateKeys()
            {
                return request.getParameterNames();
            }

            public Object getValue(Object pKey)
            {
                if (pKey instanceof String) {
                    return request.getParameter((String) pKey);
                } else {
                    return null;
                }
            }

            public boolean isMutable()
            {
                return false;
            }
        };
    }
714603
@GetMapping("/attributeMapping")
  public String viewAttributeMapping(
      @RequestParam() String mappingProjectId,
      @RequestParam() String target,
      @RequestParam() String source,
      @RequestParam() String targetAttribute,
      Model model) {
    MappingProject project = mappingService.getMappingProject(mappingProjectId);
    MappingTarget mappingTarget = project.getMappingTarget(target);
    EntityMapping entityMapping = mappingTarget.getMappingForSource(source);
    AttributeMapping attributeMapping = entityMapping.getAttributeMapping(targetAttribute);

    if (attributeMapping == null) {
      attributeMapping = entityMapping.addAttributeMapping(targetAttribute);
    }

    if (attributeMapping.getTargetAttribute().hasRefEntity()) {
      EntityType refEntityType = attributeMapping.getTargetAttribute().getRefEntity();
      Iterable<Entity> refEntities = () -> dataService.findAll(refEntityType.getId()).iterator();
      model.addAttribute("categories", refEntities);
    }

    Multimap<Relation, OntologyTerm> tagsForAttribute =
        ontologyTagService.getTagsForAttribute(
            entityMapping.getTargetEntityType(), attributeMapping.getTargetAttribute());

    model.addAttribute("tags", tagsForAttribute.values());
    model.addAttribute(
        "dataExplorerUri", menuReaderService.findMenuItemPath(DataExplorerController.ID));
    model.addAttribute("mappingProject", project);
    model.addAttribute("entityMapping", entityMapping);
    model.addAttribute(
        "sourceAttributesSize",
        Iterables.size(entityMapping.getSourceEntityType().getAtomicAttributes()));
    model.addAttribute("attributeMapping", attributeMapping);
    model.addAttribute(
        "attributes", newArrayList(dataService.getEntityType(source).getAtomicAttributes()));

    return VIEW_ATTRIBUTE_MAPPING;
  }
75071
private void parseControllerMethod(JaxrsApplicationParser.Result result, JaxrsApplicationParser.ResourceContext context, Class<?> controllerClass, Method method) {
        final RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class);
        if (requestMapping != null) {

            // subContext
            context = context.subPath(requestMapping.path().length == 0 ? "" : requestMapping.path()[0]);
            final Map<String, Type> pathParamTypes = new LinkedHashMap<>();
            for (Parameter parameter : method.getParameters()) {
                final PathVariable pathVariableAnnotation = parameter.getAnnotation(PathVariable.class);
                if (pathVariableAnnotation != null) {
                    pathParamTypes.put(pathVariableAnnotation.value(), parameter.getParameterizedType());
                }
            }
            context = context.subPathParamTypes(pathParamTypes);
            final RequestMethod httpMethod = requestMapping.method().length == 0 ? RequestMethod.GET : requestMapping.method()[0];

            // path parameters
            final PathTemplate pathTemplate = PathTemplate.parse(context.path);
            final Map<String, Type> contextPathParamTypes = context.pathParamTypes;
            final List<MethodParameterModel> pathParams = pathTemplate.getParts().stream()
                    .filter(PathTemplate.Parameter.class::isInstance)
                    .map(PathTemplate.Parameter.class::cast)
                    .map(parameter -> {
                        final Type type = contextPathParamTypes.get(parameter.getOriginalName());
                        final Type paramType = type != null ? type : String.class;
                        foundType(result, paramType, controllerClass, method.getName());
                        return new MethodParameterModel(parameter.getValidName(), paramType);
                    })
                    .collect(Collectors.toList());

            // query parameters
            final List<RestQueryParam> queryParams = new ArrayList<>();
            for (Parameter param : method.getParameters()) {
                final RequestParam requestParamAnnotation = param.getAnnotation(RequestParam.class);
                if (requestParamAnnotation != null) {
                    queryParams.add(new RestQueryParam.Single(new MethodParameterModel(requestParamAnnotation.value(), param.getParameterizedType())));
                    foundType(result, param.getParameterizedType(), controllerClass, method.getName());
                }
            }

            // entity parameter
            final MethodParameterModel entityParameter = getEntityParameter(method);
            if (entityParameter != null) {
                foundType(result, entityParameter.getType(), controllerClass, method.getName());
            }

            // return Type
            final Class<?> returnType = method.getReturnType();
            final Type genericReturnType = method.getGenericReturnType();
            final Type modelReturnType;
            if (genericReturnType instanceof ParameterizedType && returnType == ResponseEntity.class) {
                final ParameterizedType parameterizedReturnType = (ParameterizedType) genericReturnType;
                modelReturnType = parameterizedReturnType.getActualTypeArguments()[0];
                foundType(result, modelReturnType, controllerClass, method.getName());
            } else {
                modelReturnType = genericReturnType;
                foundType(result, modelReturnType, controllerClass, method.getName());
            }

            model.getMethods().add(new RestMethodModel(controllerClass, method.getName(), modelReturnType,
                    controllerClass, httpMethod.name(), context.path, pathParams, queryParams, entityParameter, null));
        }
    }
67376
@Around(value = "availableBrowsersCallPointcut()")
    public Object availableBrowsersCalls(ProceedingJoinPoint pjp)
            throws Throwable {

        if (pjp.getArgs().length > 0) {
            if (pjp.getArgs()[0] instanceof ITestContext) {
                if (Arrays.asList(((ITestContext) pjp.getArgs()[0]).getIncludedGroups()).contains("mobile")) {
                    return pjp.proceed();
                }
            }
        }

        if (!"".equals(System.getProperty("FORCE_BROWSER", ""))) {
            List<String[]> lData = Lists.newArrayList();
            lData.add(new String[]{System.getProperty("FORCE_BROWSER")});
            logger.debug("Forcing browser to {}",
                    System.getProperty("FORCE_BROWSER"));
            return lData.iterator();
        }
        return pjp.proceed();
    }
1098233
private <I extends Message, O extends Message> ListenableFuture<JsonRpcResponse> invoke(
      ServerMethod<I, O> method, JsonObject parameter, JsonElement id) {
    I request;
    try {
      request = (I) Messages.fromJson(method.inputBuilder(), parameter);
    } catch (Exception e) {
      serverLogger.logServerFailure(method, e);
      SettableFuture<JsonRpcResponse> future = SettableFuture.create();
      future.setException(e);
      return future;
    }
    ListenableFuture<O> response = method.invoke(request);
    return Futures.transform(response, new JsonConverter(id), TRANSFORM_EXECUTOR);
  }