【发布时间】:2016-11-20 00:20:21
【问题描述】:
我曾经在一个桌面独立应用程序中成功实现了 Apache Shiro(没有 Spring 框架或任何与此相关的框架)。
我使用 INI 文件来获取 SecurityManager,如下所示:
Factory<org.apache.shiro.mgt.SecurityManager> factory = new IniSecurityManagerFactory(
"classpath:resources/shiro.ini");
org.apache.shiro.mgt.SecurityManager securityManager = factory.getInstance();
SecurityUtils.setSecurityManager(securityManager);
Subject currentUser = SecurityUtils.getSubject();
我在 stackoverflow 的一篇文章中读到,在使用 spring 时不建议使用 shiro INI。
在我的例子中,我现在在这个应用程序中使用 Spring Boot 和 Spring Data JPA 和 Hibernate。配置 Apache Shiro 的最佳方式是什么,以便我可以最大限度地利用这个安全框架。
编辑
我遇到的所有示例,都显示了网络示例。我需要专门用于独立应用程序。示例将不胜感激。
解决方案
在从这篇文章中学习和回答之后,我设法提出了this solution 并创建了 github 存储库。如果有人想让它变得更好,请成为我的客人。
【问题讨论】:
标签: java spring hibernate javafx-8 shiro