在Java EE中使用过滤器授权 [英] Authorization using filters in Java EE

查看:116
本文介绍了在Java EE中使用过滤器授权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用户和密码MongoDB的基础。我有授权形式的JSP文件。
过滤器应检查 - 授权用户或没有。 Servlet的应授权用户,如果他没有被授权。

I have mongodb base with users and passwords. I have a jsp file with a form for authorization. filter should be check - authorized user or not. Servlet should authorize user if he not authorized.

请给出如何做到这一点简单的例子。

Please give simple examples of how to do it.


  • 如何验证授权用户或
    不?

  • 的用户没有登录。假设一个
    用户是在数据库中。它是如何结果
    授权?

抱歉不好英语。

推荐答案

下面是一个情景: -

Here's a scenario:-


  1. 用户进入安全网页。

  2. 过滤器拦截用户的请求。

  3. 过滤检索用户对象从会话。

  4. 如果用户对象存在,允许用户在安全的页面。

  5. 如果用户对象不存在,重定向用户到登录页面。

  1. User enters a secured page.
  2. Filter intercepts user request.
  3. Filter retrieves User object from session.
  4. If User object exists, allow user to the secured page.
  5. If User object doesn't exist, redirect user to the login page.

当用户从登录页面提交证件: -

When the user submits the credential from the login page:-


  1. 系统使用所提供的凭据对数据库进行身份验证的用户。

  2. 如果认证成功,在会议系统存储用户对象,并显示欢迎页面。

  3. 如果身份验证不成功,系统将用户返回到登录页面。

  1. System authenticates user using the provided credential against the database.
  2. If authentication is successful, system stores User object in the session and displays welcome page.
  3. If authentication is not successful, system brings user back to the login page.

这篇关于在Java EE中使用过滤器授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆