如何使用 Wicket 密码保护页面?
我想用密码保护 Wicket 中的网页,以便用户只有在登录后才能访问它。
我还希望该页面显示登录页面,然后在登录原始页面后,用户尝试到达。
这是如何用检票口完成的?我已经创建了一个登录页面并扩展了会话类。
I want to password protect a webpage in Wicket so the user may only access it if he/she has logged in.
I'd also like the page to show the login page, and then after logging in the original page the user was trying to get to.
How is this done with wicket? I've already created a login page and extended the session class.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
框架提供的方式是提供一个 IAuthorizationStrategy 您的应用程序的实例,例如,通过添加到您的应用程序
init()
方法:Wicket 授权功能的工作示例位于 Wicket Stuff 这里,它演示了一些相当复杂的东西。对于非常简单的情况,请查看 简单页面授权策略。在非常基本的层面上,这可以像这样使用(取自链接的 Javadoc):
编辑以响应评论
我认为最好的方法是,如果您只是要使用类似 < code>SimplePageAuthorizationStrategy 而不是该类本身。我做了这样的事情来捕获使用自定义注释进行注释的页面:
然后您需要注册 IUnauthorizedComponentInstantiationListener 类似于 SimplePageAuthorizationStrategy (链接到源代码),应该类似于:
The framework-supplied way is to provide an IAuthorizationStrategy instance for your application, e.g., by adding to your Application
init()
method:A working example of Wickets authorization functionality is on Wicket Stuff here, which demonstrates some reasonably complex stuff. For really simple cases, have a look at the SimplePageAuthorizationStrategy. At a very basic level, this could be used like so (taken from the linked Javadoc):
Edit in response to comment
I think the best way forward, if you're just going to use something like
SimplePageAuthorizationStrategy
rather than that class itself. I did something like this to capture pages that are annotated with a custom annotation:Then you'd need to register an IUnauthorizedComponentInstantiationListener similar to what is done in SimplePageAuthorizationStrategy (link is to the source code), which should be something like: