資源簡介
ssmshiro.rar

代碼片段和文件信息
package?com.fb.controller;
import?javax.annotation.Resource;
import?javax.servlet.http.HttpServletRequest;
import?javax.servlet.http.HttpServletResponse;
import?org.apache.shiro.SecurityUtils;
import?org.apache.shiro.authc.AuthenticationException;
import?org.apache.shiro.authc.UsernamePasswordToken;
import?org.apache.shiro.subject.Subject;
import?org.springframework.stereotype.Controller;
import?org.springframework.ui.Model;
import?org.springframework.web.bind.annotation.RequestMapping;
import?org.springframework.web.bind.annotation.RequestParam;
import?com.fb.md5.MD5Util;
import?com.fb.service.UserService;
@Controller
public?class?UserController?{
@Resource
private?UserService?us;
@RequestMapping(“l(fā)ogin.do“)
public?String?getUsers(Model?model?HttpServletRequest?request?HttpServletResponse?response
@RequestParam(“username“)?String?username?@RequestParam(“password“)?String?password)?throws?Exception?{
//輸出頁面?zhèn)鱽淼挠脩裘兔艽a用作比對。
System.out.println(“頁面?zhèn)魅胗脩裘兔艽a:“?+?username?+?“??“?+?password);
//將得到的密碼進(jìn)行md5加密,主要用來將密碼存入數(shù)據(jù)庫,這里只是輸出了加密后的密文
MD5Util.toMd5(password“123“1024);
//存儲異常信息
String?msg?=?null;
if?((username?!=?null?&&?password?!=?null))?{
UsernamePasswordToken?token?=?new?UsernamePasswordToken(username?password);
Subject?subject?=?SecurityUtils.getSubject();
try?{
subject.login(token);
}?catch?(AuthenticationException?e)?{
e.printStackTrace();
msg?=?e.getMessage();
}
if?(subject.isAuthenticated())?{
subject.logout();
System.out.println(“認(rèn)證成功“);
model.addAttribute(“username“?username);
return?“index“;
}?else?{
model.addAttribute(“exception“?msg);
System.out.println(“出現(xiàn)了異常==============“?+?msg);
return?“unauthorized“;
}
}
return?“l(fā)ogin“;
}
}
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????1566??2018-04-30?23:40??shirotest2\.classpath
?????文件???????1086??2018-04-30?23:35??shirotest2\.project
?????文件????????639??2018-04-30?23:35??shirotest2\.settings\.jsdtscope
?????文件?????????74??2018-05-01?16:25??shirotest2\.settings\org.eclipse.core.resources.prefs
?????文件????????430??2018-04-30?23:35??shirotest2\.settings\org.eclipse.jdt.core.prefs
?????文件?????????90??2018-04-30?23:35??shirotest2\.settings\org.eclipse.m2e.core.prefs
?????文件????????671??2018-04-30?23:35??shirotest2\.settings\org.eclipse.wst.common.component
?????文件????????292??2018-04-30?23:40??shirotest2\.settings\org.eclipse.wst.common.project.facet.core.xm
?????文件?????????49??2018-04-30?23:35??shirotest2\.settings\org.eclipse.wst.jsdt.ui.superType.container
?????文件??????????6??2018-04-30?23:35??shirotest2\.settings\org.eclipse.wst.jsdt.ui.superType.name
?????文件?????????50??2018-04-30?23:35??shirotest2\.settings\org.eclipse.wst.validation.prefs
?????文件???????3728??2018-05-01?15:41??shirotest2\pom.xm
?????文件???????1996??2018-05-01?22:49??shirotest2\src\main\java\com\fb\controller\UserController.java
?????文件????????115??2018-05-01?15:28??shirotest2\src\main\java\com\fb\dao\UserDao.java
?????文件????????414??2018-05-01?16:59??shirotest2\src\main\java\com\fb\md5\MD5Util.java
?????文件????????583??2018-05-01?00:50??shirotest2\src\main\java\com\fb\pojo\User.java
?????文件???????1711??2018-05-01?22:46??shirotest2\src\main\java\com\fb\realm\MyRealm.java
?????文件????????449??2018-05-01?00:51??shirotest2\src\main\java\com\fb\service\UserService.java
?????文件???????2487??2018-05-01?16:59??shirotest2\src\main\resources\applicationContext-shiro.xm
?????文件???????2879??2018-04-30?23:38??shirotest2\src\main\resources\application_spring_mvc.xm
?????文件????????183??2018-04-30?23:39??shirotest2\src\main\resources\jdbc.properties
?????文件????????589??2018-05-01?16:20??shirotest2\src\main\resources\log4j.properties
?????文件????????731??2018-05-01?22:48??shirotest2\src\main\resources\mapper\ConsumeMapper.xm
?????文件???????3057??2018-05-01?15:58??shirotest2\src\main\resources\spring-mybatis.xm
?????文件????????364??2018-05-01?16:25??shirotest2\src\main\webapp\index.jsp
?????文件????????502??2018-04-30?23:48??shirotest2\src\main\webapp\login.jsp
?????文件????????373??2018-05-01?16:25??shirotest2\src\main\webapp\unauthorized.jsp
?????文件???????2477??2018-05-01?22:52??shirotest2\src\main\webapp\WEB-INF\web.xm
?????文件???????2487??2018-05-01?16:59??shirotest2\target\classes\applicationContext-shiro.xm
?????文件???????2879??2018-05-01?15:42??shirotest2\target\classes\application_spring_mvc.xm
............此處省略53個(gè)文件信息
評論
共有 條評論