【发布时间】:2016-01-05 01:39:38
【问题描述】:
我想让我的网站页面受到密码保护。我使用 jersey 在 java 中使用 restful webservices 制作网站。所以任何人都可以告诉我如何使用 apache shiro 保护我的网页。任何人都实施了保护网站的示例如果是,请使用 apache shiro,而不是请分享示例。我将不胜感激:)
【问题讨论】:
标签: shiro
我想让我的网站页面受到密码保护。我使用 jersey 在 java 中使用 restful webservices 制作网站。所以任何人都可以告诉我如何使用 apache shiro 保护我的网页。任何人都实施了保护网站的示例如果是,请使用 apache shiro,而不是请分享示例。我将不胜感激:)
【问题讨论】:
标签: shiro
为了使用 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
【讨论】: