restful 网络服务中使用 apache shiro 的密码保护网页
Password protected web page in restful webservices using apache shiro
我想为我的网站页面设置密码 protected.I 在 java 使用 jersey.So 使用 restful 网络服务创建网站 谁能告诉我如何保护我的网站使用 apache shiro.Any 的页面已经实现了使用 apache shiro 保护网站的示例,如果是,请分享 example.I 将不胜感激 :)
为了使用 shiro 保护您的网络服务,您可以使用以下模板文件,并可以根据您自己的要求进行自定义。根据需要包含罐子或添加到 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 是球衣休息服务的 url)
[main]
[urls]
/rest/** = noSessionCreation,authcBasic
/**= anon
[users]
admin=admin
我想为我的网站页面设置密码 protected.I 在 java 使用 jersey.So 使用 restful 网络服务创建网站 谁能告诉我如何保护我的网站使用 apache shiro.Any 的页面已经实现了使用 apache shiro 保护网站的示例,如果是,请分享 example.I 将不胜感激 :)
为了使用 shiro 保护您的网络服务,您可以使用以下模板文件,并可以根据您自己的要求进行自定义。根据需要包含罐子或添加到 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 是球衣休息服务的 url)
[main]
[urls]
/rest/** = noSessionCreation,authcBasic
/**= anon
[users]
admin=admin