Tag: shiro

Ajax Session Time Out FullAjaxExceptionHandlerFactory无法使用shiro

我使用Ajax会话超时添加的代码的详细信息,如BaluC所述 faces-config.xml中 org.omnifaces.exceptionhandler.FullAjaxExceptionHandlerFactory 在web.xml javax.faces.application.ViewExpiredException /expired.xhtml 应用-config.xml中 [main] user.loginUrl = /login.xhtml [users] admin = password [urls] /login.xhtml = user /css/**=anon /images/**=anon /emailimages/**=anon /login=anon /test=anon /sso=anon /ssologin=anon /**=authc <!– –> <!– –> <!– –> <!– –> <!– –> <!– –> <!– –> 添加了从BaluC博客复制的类文件FacesAjaxAwareUserFilter **代码** Jar文件已添加 omniface-1.7.jar 在.xhtml文件中添加了此内容 xmlns:o=”http://omnifaces.org/ui” xmlns:of=”http://omnifaces.org/functions” 想出了一个警告 NLS missing message: CANNOT_FIND_FACELET_TAGLIB in: org.eclipse.jst.jsf.core.validation.internal.facelet.messages […]

Chrome关闭后,Jsessionid cookie不会过期

我使用Shiro框架进行身份validation。 问题是:当我关闭Chrome浏览器并再次打开它时,我仍然可以访问受保护的URL。 如果我手动删除jsessionid cookie一切正常,则禁止访问受保护的URL。 在jsessionid的设置中,我看到: Expires:浏览会话结束时 。 所以它应该过期,但事实并非如此。 我也在firefox中进行了这个操作,没有那个问题。 我甚至不知道调查的方式。 PS我不使用shiro remember-mefunction。 但是,无论如何,在使用时,Shiro会创建另一个cookie(名为rememberMe)。

netbeans 8.0.1无法找到shiro.ini

我在WEB-INF下的网页下添加了这个shir.ini : [main] # Objects and their properties are defined here, # Such as the securityManager, Realms and anything # else needed to build the SecurityManager shiro.loginUrl = /index.jsp [users] root = 12345,admin guest = 12345,guest [roles] admin = * [urls] /index.xhtml = authc /login.xhtml = authc /info.xhtml = anon /logout = logout /admin/** = […]

如何获取/设置JdbcRealm的salt

我试图使用Shiro JdbcRealm和SHA256 hashedcredentialsMatcher。 我需要更新遗留数据库并为每个用户分配适当的盐(通过批处理例程)。 如何使用Shiro框架获取/设置给定帐户的盐?

Spring MongoDB和Apache Shiro

我试图使用Apache Shiro与Spring和MongoDB。 我正在使用自动assembly的Spring Data Repositories。 我为Shiro创建了自己的自定义域,它使用Spring Data存储库与Mongo交谈: public class PlatformRealm extends AuthorizingRealm { @Autowired(required = true) protected UserRepository userRepository = null; @Override protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException { … } } 我看到的问题是userRepository没有自动assembly。 我在控制台输出中得到以下行,引用PlatformRealm: INFO org.springframework.web.context.support.XmlWebApplicationContext – Bean ‘platformRealm’ of type [class com.resonance.platform.core.security.PlatformRealm] is not eligible for getting processed by all BeanPostProcessors (for example: not […]

Apache Shiro的Spring Boot

我目前正在尝试将Apache Shiro集成到我的Spring Boot restful API中,但我遇到了一些问题,并且想知道是否有人可以提供帮助。 我的Application.class: @Configuration @EnableTransactionManagement @EnableAutoConfiguration @ComponentScan(basePackages = “org.xelamitchell.sophia.server”) public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } } 我的WebConfig.class: @Configuration @EnableWebMvc public class WebConfig extends WebMvcConfigurerAdapter { @Bean public DispatcherServlet dispatcherServlet() { DispatcherServlet servlet = new DispatcherServlet(); servlet.setDispatchOptionsRequest(true); return servlet; } @Bean public ServletRegistrationBean dispatcherRegistration(DispatcherServlet dispatcherServlet) { […]

将值传递给Shiro ini中的枚举属性

我正在使用JDBC Realm并在SQL中存储身份validation数据。 我将salt存储在users表中并依赖于DEFAULT_SALTED_AUTHENICATION_QUERY。 要调用该查询,我必须设置SaltStyle。 因此,我需要通过INI将SaltStyle.COLUMN枚举值传递给JdbcRealm。 SaltStyle不是类,所以我无法创建引用 无论我做什么传递都会产生此错误= org.apache.shiro.config.UnresolveableReferenceException: 无法从文档中的详尽搜索或参考中找到示例。 任何帮助深表感谢。 #==================================================================== # Shiro INI configuration # # =================================================================== [main] JdbcRealm=org.apache.shiro.realm.jdbc.JdbcRealm JdbcRealm.permissionsLookupEnabled = true sha256Matcher = org.apache.shiro.authc.credential.HashedCredentialsMatcher sha256Matcher.hashAlgorithmName=SHA-256 sha256Matcher.hashIterations=1 JdbcRealm.credentialsMatcher = $sha256Matcher JdbcRealm.saltStyle= enum expression needed here 这是JdbcRealm中的属性 public void setSaltStyle(SaltStyle saltStyle) { this.saltStyle = saltStyle; if (saltStyle == SaltStyle.COLUMN && authenticationQuery.equals (DEFAULT_AUTHENTICATION_QUERY)) { authenticationQuery = […]

请确保至少有一个领域可以对这些令牌进行身份validation

所以我已经设置了我的shiro有两个领域。 用户名和密码域,使用标准UsernamePasswordToken。 我还设置了一个自定义承载认证令牌,用于处理从用户传入的令牌。 如果我只是使用我的passwordValidatorRealm它可以找到,如果没有找到用户会抛出未知帐户,如果密码不匹配则抛出不正确的凭据,完美。 但是只要我输入我的tokenValidatorRealm它就会抛出一个 org.apache.shiro.authc.AuthenticationException: Authentication token of type [class org.apache.shiro.authc.UsernamePasswordToken] could not be authenticated by any configured realms. 在这个例子中,我的tokenValidatorRealm返回null,因为没有提供令牌,所以它继续前进到passwordValidatorRealm并且只是中断。 为什么引入第二个领域的任何想法都会导致我的工作密码ValidatorRealm破坏? 尝试过不同的身份validation策略,但没有运气。 使用shiro 1.2.2 编辑 我有两个实现,一个用于密码,一个用于令牌 密码: public class PasswordAuthorizingRealm extends AuthenticatingRealm { @Override protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException { if (authenticationToken instanceof UsernamePasswordToken) { UsernamePasswordToken usernamePasswordToken = (UsernamePasswordToken) authenticationToken; String username = […]

将Apache Shiro Security Library与基于Dropwizard的JAX-RS应用程序集成

我想改变Dropwizard以支持Shiro。 我已经阅读了文档并且很少有人感到困惑。 我想将Shiro与表单登录身份validation和Apache Shiro Annotations结合使用。 我认为我需要使用Jersey Filters来支持Shiro。 这是支持泽西的Shiro注释而不是经典的Shiro Filter方法的正确方法吗? 由于Jersey Filters可以很好地访问带注释的资源,因此对我来说使用注释似乎是完美的。 我宁愿不使用AOP方法,与JAX-RS作为独立模块进行动态集成可能真的很棒。

使用sessionId或用户名+密码进行Shiro身份validation

我在Java身份validation框架和身份validation工作流程方面没有太多经验(只有一些理论知识),所以出于教育目的,我正在尝试为我的HTTP应用程序创建这种类型的身份validation: 客户端将登录名+密码发布到/login 。 Shiro通过给定的凭据登录用户。 服务器返回客户端他的sessionId 。 客户端请求某种资源/myresource?sessionId=1234567 。 Shiro通过给定的sessionId登录Subject。 然后,服务器执行获取/myresource的常规工作流程(使用Shiro管理方法级访问权限)。 基本上我有这些问题: 我想我不需要HTTP会话也不需要Servlet会话。 Shiro拥有自己的会话管理器,足以满足我的需求。 我错了吗? 给客户端提供真正的sessionId或者我应该发送某种sessionToken(在服务器端解析为sessionId)是一种好的做法吗? 如何使用sessionId(客户端应在本地存储)登录主题? 在进行这种身份validation之前还有其他我需要知道的事情吗? 提前致谢。