Skip to content

Commit

Permalink
集成shrio并实现登录认证,加入bootstrap和jquery
Browse files Browse the repository at this point in the history
  • Loading branch information
xwj-vic committed Mar 7, 2017
1 parent b6dd42b commit 46b1ade
Show file tree
Hide file tree
Showing 45 changed files with 20,763 additions and 192 deletions.
70 changes: 70 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@
<version>2.8.5</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.8.5</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.8.5</version>
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
Expand All @@ -111,6 +123,12 @@
<version>4.3.5.RELEASE</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>4.3.5.RELEASE</version>
</dependency>

<!--2)spring dao层依赖-->
<dependency>
<groupId>org.springframework</groupId>
Expand Down Expand Up @@ -143,6 +161,58 @@
<artifactId>spring-test</artifactId>
<version>4.3.5.RELEASE</version>
</dependency>

<!--添加权限认证shiro依赖-->
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-spring</artifactId>
<version>1.3.2</version>
</dependency>

<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-web</artifactId>
<version>1.3.2</version>
</dependency>

<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-core</artifactId>
<version>1.3.2</version>
</dependency>

<!--添加ehcache-->
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>2.10.3</version>
</dependency>

<!-- 添加 shiro-ehcache 接口依赖-->
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-ehcache</artifactId>
<version>1.3.2</version>
</dependency>

<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.10</version>
</dependency>

<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.8.10</version>
</dependency>

<dependency>
<groupId>aopalliance</groupId>
<artifactId>aopalliance</artifactId>
<version>1.0</version>
</dependency>

</dependencies>
<build>
<finalName>ssmshiro</finalName>
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/cache/cachedemo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package cache;

/**
* Created by xuweijie on 2017/3/7.
*/
public class cachedemo {
}
13 changes: 0 additions & 13 deletions src/main/java/dao/QueryTestDao.java

This file was deleted.

13 changes: 13 additions & 0 deletions src/main/java/dao/ShiroUserDao.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package dao;

import entity.User;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
* Created by xuweijie on 2017/3/7.
*/
public interface ShiroUserDao {
public User queryByName(String username);
}
76 changes: 0 additions & 76 deletions src/main/java/entity/Seckill.java

This file was deleted.

83 changes: 83 additions & 0 deletions src/main/java/entity/User.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package entity;

/**
* Created by xuweijie on 2017/3/7.
*/
public class User {
private int id;
private String username;
private String password;
private String salt;
private String sex;
private String age;
private String address;

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getUsername() {
return username;
}

public void setUsername(String username) {
this.username = username;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public String getSalt() {
return salt;
}

public void setSalt(String salt) {
this.salt = salt;
}

public String getSex() {
return sex;
}

public void setSex(String sex) {
this.sex = sex;
}

public String getAge() {
return age;
}

public void setAge(String age) {
this.age = age;
}

public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address;
}

@Override
public String toString() {
return "User{" +
"id=" + id +
", username='" + username + '\'' +
", password='" + password + '\'' +
", salt='" + salt + '\'' +
", sex='" + sex + '\'' +
", age='" + age + '\'' +
", address='" + address + '\'' +
'}';
}
}
24 changes: 24 additions & 0 deletions src/main/java/exception/CustomException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package exception;

/**
* Created by xuweijie on 2017/3/3.
* 异常处理公共类
*/
public class CustomException extends Exception {
//异常信息
private String message;

public CustomException(String message) {
super(message);
this.message = message;
}

@Override
public String getMessage() {
return message;
}

public void setMessage(String message) {
this.message = message;
}
}
11 changes: 0 additions & 11 deletions src/main/java/service/Queryservice.java

This file was deleted.

13 changes: 13 additions & 0 deletions src/main/java/service/ShiroUserService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package service;

import entity.User;

import java.util.List;

/**
* 认证授权服务接口
* Created by xuweijie on 2017/3/3.
*/
public interface ShiroUserService {
public User queryUser(String username);
}
22 changes: 0 additions & 22 deletions src/main/java/service/impl/QueryserviceImpl.java

This file was deleted.

27 changes: 27 additions & 0 deletions src/main/java/service/impl/ShiroUserServiceImpl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package service.impl;

import dao.ShiroUserDao;
import entity.User;
import org.apache.shiro.authc.LockedAccountException;
import org.apache.shiro.authc.UnknownAccountException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import service.ShiroUserService;
import util.MD5Util;

import java.util.List;

/**
* Created by xuweijie on 2017/3/6.
*/
@Service
public class ShiroUserServiceImpl implements ShiroUserService {

@Autowired
private ShiroUserDao userDao;

public User queryUser(String username) {
return userDao.queryByName(username);
}
}
Loading

0 comments on commit 46b1ade

Please sign in to comment.