【问题标题】:Password protected web page in restful webservices using apache shiro使用 apache shiro 在 RESTful Web 服务中受密码保护的网页
【发布时间】:2016-01-05 01:39:38
【问题描述】:

我想让我的网站页面受到密码保护。我使用 jersey 在 java 中使用 restful webservices 制作网站。所以任何人都可以告诉我如何使用 apache shiro 保护我的网页。任何人都实施了保护网站的示例如果是,请使用 apache shiro,而不是请分享示例。我将不胜感激:)

【问题讨论】:

    标签: shiro


    【解决方案1】:

    为了使用 shiro 保护您的 web 服务,您可以使用以下模板文件并可以根据自己的要求进行自定义。包括罐子或根据需要添加到 pom 中。

    将这些添加到 web.xml

    <filter>
            <filter-name>Shiro</filter-name>
            <filter-class>
                org.apache.shiro.web.servlet.IniShiroFilter
            </filter-class>
        </filter>
        <filter-mapping>
            <filter-name>Shiro</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
    

    现在将 shiro.ini 放置在 WEB-INF 中(我在 shiro.ini 中使用用户名和角色的基本身份验证,您可以从数据库等中使用根据您的需要,假设 /rest 是球衣休息服务的网址)

    [main]
    
    
    
        [urls]
        /rest/** = noSessionCreation,authcBasic
        /**= anon
    
        [users]
        admin=admin
    

    【讨论】:

    • 谢谢你有任何使用 apache shiro 保护网站的例子,如果是的话,请分享这个例子,我将不胜感激:)
    • 我在这个 git repo 中添加了一些资源,一旦你得到我将删除 repo。你可以用这个来理解。 github.com/devmgs/shirotest
    • 所以我可以删除回购,因为不希望代码公开
    猜你喜欢
    • 2013-12-29
    • 2012-07-07
    • 2016-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-13
    • 2011-03-11
    • 2011-01-12
    相关资源
    最近更新 更多