當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。