在Java EE中使用过滤器授权

编程入门 行业动态 更新时间:2024-10-27 23:23:06
本文介绍了在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:-

  • 用户进入安全网页。
  • 过滤器拦截用户的请求。
  • 过滤检索用户对象从会话。
  • 如果用户对象存在,允许用户在安全的页面。
  • 如果用户对象不存在,重定向用户到登录页面。
  • User enters a secured page.
  • Filter intercepts user request.
  • Filter retrieves User object from session.
  • If User object exists, allow user to the secured page.
  • If User object doesn't exist, redirect user to the login page.
  • 当用户从登录页面提交证件: -

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

  • 系统使用所提供的凭据对数据库进行身份验证的用户。
  • 如果认证成功,在会议系统存储用户对象,并显示欢迎页面。
  • 如果身份验证不成功,系统将用户返回到登录页面。
  • System authenticates user using the provided credential against the database.
  • If authentication is successful, system stores User object in the session and displays welcome page.
  • If authentication is not successful, system brings user back to the login page.
  • 更多推荐

    在Java EE中使用过滤器授权

    本文发布于:2023-07-07 13:34:22,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1063911.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:过滤器   Java   EE

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!