| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | /** |
| | |
| | | @DependsOn("springContextHolder") |
| | | @Transactional(readOnly = true) |
| | | public class PermissionCheckFactory implements ICheck { |
| | | @Resource |
| | | private ShiroExtUtil shiroExtUtil; |
| | | |
| | | public static ICheck me() { |
| | | return SpringContextHolder.getBean(ICheck.class); |
| | |
| | | |
| | | @Override |
| | | public boolean check(Object[] permissions) { |
| | | ShiroUser user = ShiroExtUtil.getUser(); |
| | | ShiroUser user = shiroExtUtil.getUser(); |
| | | if (null == user) { |
| | | return false; |
| | | } |
| | |
| | | return true; |
| | | } |
| | | String join = CollectionKit.join(permissions, ","); |
| | | if (ShiroExtUtil.hasAnyRoles(join)) { |
| | | if (shiroExtUtil.hasAnyRoles(join)) { |
| | | return true; |
| | | } |
| | | return false; |
| | |
| | | @Override |
| | | public boolean checkAll() { |
| | | HttpServletRequest request = HttpKit.getRequest(); |
| | | ShiroUser user = ShiroExtUtil.getUser(); |
| | | ShiroUser user = shiroExtUtil.getUser(); |
| | | if (null == user) { |
| | | return false; |
| | | } |
| | |
| | | if (str.length > 3) { |
| | | requestURI = "/" + str[1] + "/" + str[2]; |
| | | } |
| | | if (ShiroExtUtil.hasPermission(requestURI)) { |
| | | if (shiroExtUtil.hasPermission(requestURI)) { |
| | | return true; |
| | | } |
| | | return false; |