当前位置: 首页>>代码示例>>Java>>正文


Java RequiresPermissions.value方法代码示例

本文整理汇总了Java中org.apache.shiro.authz.annotation.RequiresPermissions.value方法的典型用法代码示例。如果您正苦于以下问题:Java RequiresPermissions.value方法的具体用法?Java RequiresPermissions.value怎么用?Java RequiresPermissions.value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.shiro.authz.annotation.RequiresPermissions的用法示例。


在下文中一共展示了RequiresPermissions.value方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doAround

import org.apache.shiro.authz.annotation.RequiresPermissions; //导入方法依赖的package包/类
@Around("execution(* *..controller..*.*(..))")
public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
	// 获取request
	RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
	ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) requestAttributes;
	HttpServletRequest request = servletRequestAttributes.getRequest();

	UpmsLog upmsLog = new UpmsLog();
	// 从注解中获取操作名称、获取响应结果
	Object result = pjp.proceed();
	Signature signature = pjp.getSignature();
	MethodSignature methodSignature = (MethodSignature) signature;
	Method method = methodSignature.getMethod();
	if (method.isAnnotationPresent(ApiOperation.class)) {
		ApiOperation log = method.getAnnotation(ApiOperation.class);
		upmsLog.setDescription(log.value());
	}
	if (method.isAnnotationPresent(RequiresPermissions.class)) {
		RequiresPermissions requiresPermissions = method.getAnnotation(RequiresPermissions.class);
		String[] permissions = requiresPermissions.value();
		if (permissions.length > 0) {
			upmsLog.setPermissions(permissions[0]);
		}
	}
	endTime = System.currentTimeMillis();
	_log.debug("doAround>>>result={},耗时:{}", result, endTime - startTime);

	upmsLog.setBasePath(RequestUtil.getBasePath(request));
	upmsLog.setIp(RequestUtil.getIpAddr(request));
	upmsLog.setMethod(request.getMethod());
	if (request.getMethod().equalsIgnoreCase("GET")) {
		upmsLog.setParameter(request.getQueryString());
	} else {
		upmsLog.setParameter(ObjectUtils.toString(request.getParameterMap()));
	}
	upmsLog.setResult(JSON.toJSONString(result));
	upmsLog.setSpendTime((int) (endTime - startTime));
	upmsLog.setStartTime(startTime);
	upmsLog.setUri(request.getRequestURI());
	upmsLog.setUrl(ObjectUtils.toString(request.getRequestURL()));
	upmsLog.setUserAgent(request.getHeader("User-Agent"));
	upmsLog.setUsername(ObjectUtils.toString(request.getUserPrincipal()));
	upmsApiService.insertUpmsLogSelective(upmsLog);
	return result;
}
 
开发者ID:youngMen1,项目名称:-Spring-SpringMVC-Mybatis-,代码行数:46,代码来源:LogAspect.java

示例2: doAround

import org.apache.shiro.authz.annotation.RequiresPermissions; //导入方法依赖的package包/类
@Around("execution(* *..controller..*.*(..))")
public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
	// 获取request
	RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
	ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) requestAttributes;
	HttpServletRequest request = servletRequestAttributes.getRequest();

	UpmsLog upmsLog = new UpmsLog();
	// 从注解中获取操作名称、获取响应结果
	Object result = pjp.proceed();
	Signature signature = pjp.getSignature();
	MethodSignature methodSignature = (MethodSignature) signature;
	Method method = methodSignature.getMethod();
	if (method.isAnnotationPresent(ApiOperation.class)) {
		ApiOperation log = method.getAnnotation(ApiOperation.class);
		upmsLog.setDescription(log.value());
	}
	if (method.isAnnotationPresent(RequiresPermissions.class)) {
		RequiresPermissions requiresPermissions = method.getAnnotation(RequiresPermissions.class);
		String[] permissions = requiresPermissions.value();
		if (permissions.length > 0) {
			upmsLog.setPermissions(permissions[0]);
		}
	}
	endTime = System.currentTimeMillis();
	LOGGER.debug("doAround>>>result={},耗时:{}", result, endTime - startTime);

	upmsLog.setBasePath(RequestUtil.getBasePath(request));
	upmsLog.setIp(RequestUtil.getIpAddr(request));
	upmsLog.setMethod(request.getMethod());
	if ("GET".equalsIgnoreCase(request.getMethod())) {
		upmsLog.setParameter(request.getQueryString());
	} else {
		upmsLog.setParameter(ObjectUtils.toString(request.getParameterMap()));
	}
	upmsLog.setResult(JSON.toJSONString(result));
	upmsLog.setSpendTime((int) (endTime - startTime));
	upmsLog.setStartTime(startTime);
	upmsLog.setUri(request.getRequestURI());
	upmsLog.setUrl(ObjectUtils.toString(request.getRequestURL()));
	upmsLog.setUserAgent(request.getHeader("User-Agent"));
	upmsLog.setUsername(ObjectUtils.toString(request.getUserPrincipal()));
	upmsApiService.insertUpmsLogSelective(upmsLog);
	return result;
}
 
开发者ID:ChangyiHuang,项目名称:shuzheng,代码行数:46,代码来源:LogAspect.java


注:本文中的org.apache.shiro.authz.annotation.RequiresPermissions.value方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。