Search in sources :

Example 1 with RequiresRoles

use of com.ruoyi.common.security.annotation.RequiresRoles in project RuoYi-Cloud by yangzongzhuan.

the class PreAuthorizeAspect method checkMethodAnnotation.

/**
 * 对一个Method对象进行注解检查
 */
public void checkMethodAnnotation(Method method) {
    // 校验 @RequiresLogin 注解
    RequiresLogin requiresLogin = method.getAnnotation(RequiresLogin.class);
    if (requiresLogin != null) {
        AuthUtil.checkLogin();
    }
    // 校验 @RequiresRoles 注解
    RequiresRoles requiresRoles = method.getAnnotation(RequiresRoles.class);
    if (requiresRoles != null) {
        AuthUtil.checkRole(requiresRoles);
    }
    // 校验 @RequiresPermissions 注解
    RequiresPermissions requiresPermissions = method.getAnnotation(RequiresPermissions.class);
    if (requiresPermissions != null) {
        AuthUtil.checkPermi(requiresPermissions);
    }
}
Also used : RequiresPermissions(com.ruoyi.common.security.annotation.RequiresPermissions) RequiresLogin(com.ruoyi.common.security.annotation.RequiresLogin) RequiresRoles(com.ruoyi.common.security.annotation.RequiresRoles)

Example 2 with RequiresRoles

use of com.ruoyi.common.security.annotation.RequiresRoles in project RuoYi-Cloud-Oracle by yangzongzhuan.

the class PreAuthorizeAspect method checkMethodAnnotation.

/**
 * 对一个Method对象进行注解检查
 */
public void checkMethodAnnotation(Method method) {
    // 校验 @RequiresLogin 注解
    RequiresLogin requiresLogin = method.getAnnotation(RequiresLogin.class);
    if (requiresLogin != null) {
        AuthUtil.checkLogin();
    }
    // 校验 @RequiresRoles 注解
    RequiresRoles requiresRoles = method.getAnnotation(RequiresRoles.class);
    if (requiresRoles != null) {
        AuthUtil.checkRole(requiresRoles);
    }
    // 校验 @RequiresPermissions 注解
    RequiresPermissions requiresPermissions = method.getAnnotation(RequiresPermissions.class);
    if (requiresPermissions != null) {
        AuthUtil.checkPermi(requiresPermissions);
    }
}
Also used : RequiresPermissions(com.ruoyi.common.security.annotation.RequiresPermissions) RequiresLogin(com.ruoyi.common.security.annotation.RequiresLogin) RequiresRoles(com.ruoyi.common.security.annotation.RequiresRoles)

Aggregations

RequiresLogin (com.ruoyi.common.security.annotation.RequiresLogin)2 RequiresPermissions (com.ruoyi.common.security.annotation.RequiresPermissions)2 RequiresRoles (com.ruoyi.common.security.annotation.RequiresRoles)2