- protected void doGet(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException {
- UserService userService = UserServiceFactory.getUserService();
-
- String thisURL = req.getRequestURI();
- if(req.getUserPrincipal() != null){
- resp.getWriter().print("<p>Hello, " +
- req.getUserPrincipal().getName() +
- "! You can <a href="" +
- userService.createLogoutURL(thisURL) +
- "">sign out</a>.</p>");
- }else{
- resp.getWriter().print("<p>Please <a href="" +
- userService.createLoginURL(thisURL) +
- "">sign in</a>.</p>");
- }
- }
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
UserService userService = UserServiceFactory.getUserService();
String thisURL = req.getRequestURI();
if(req.getUserPrincipal() != null){
resp.getWriter().print("<p>Hello, " +
req.getUserPrincipal().getName() +
"! You can <a href="" +
userService.createLogoutURL(thisURL) +
"">sign out</a>.</p>");
}else{
resp.getWriter().print("<p>Please <a href="" +
userService.createLoginURL(thisURL) +
"">sign in</a>.</p>");
}
}
からのweb.xml
- <security-constraint>
- <web-resource-collection>
- <url-pattern>/admin/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <role-name>admin</role-name>
- </auth-constraint>
- </security-constraint>
<security-constraint>
<web-resource-collection>
<url-pattern>/admin/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
とすれば/admin/以下は管理者のみしか見ることができない。
ちなみにローカルで実行するとダミーアカウントでの認証になる。
0 件のコメント:
コメントを投稿