• 大小: 69.58MB
    文件类型: .zip
    金币: 2
    下载: 0 次
    发布日期: 2024-01-27
  • 语言: Java
  • 标签: java  web  商城  访问控制  

资源简介

水果商城前后台完整服务器带数据库实现,并且有项目文档,后台实现了访问控制

资源截图

代码片段和文件信息

/*
 * 

 * 
 */
package com.easyshopping;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import com.easyshopping.Setting.AccountLockType;
import com.easyshopping.Setting.CaptchaType;
import com.easyshopping.entity.Admin;
import com.easyshopping.service.AdminService;
import com.easyshopping.service.CaptchaService;
import com.easyshopping.util.SettingUtils;

import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.time.DateUtils;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.DisabledAccountException;
import org.apache.shiro.authc.IncorrectCredentialsException;
import org.apache.shiro.authc.LockedAccountException;
import org.apache.shiro.authc.SimpleAuthenticationInfo;
import org.apache.shiro.authc.UnknownAccountException;
import org.apache.shiro.authc.pam.UnsupportedTokenException;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;

/**
 * 权限认证
 * 
 * 
 * @version 1.0
 */
public class AuthenticationRealm extends AuthorizingRealm {

@Resource(name = “captchaServiceImpl“)
private CaptchaService captchaService;
@Resource(name = “adminServiceImpl“)
private AdminService adminService;

/**
 * 获取认证信息
 * 
 * @param token
 *            令牌
 * @return 认证信息
 */
@Override
protected AuthenticationInfo doGetAuthenticationInfo(org.apache.shiro.authc.AuthenticationToken token) {
AuthenticationToken authenticationToken = (AuthenticationToken) token;
String username = authenticationToken.getUsername();
String password = new String(authenticationToken.getPassword());
String captchaId = authenticationToken.getCaptchaId();
String captcha = authenticationToken.getCaptcha();
String ip = authenticationToken.getHost();
if (!captchaService.isValid(CaptchaType.adminLogin captchaId captcha)) {
throw new UnsupportedTokenException();
}
if (username != null && password != null) {
Admin admin = adminService.findByUsername(username);
if (admin == null) {
throw new UnknownAccountException();
}
if (!admin.getIsEnabled()) {
throw new DisabledAccountException();
}
Setting setting = SettingUtils.get();
if (admin.getIsLocked()) {
if (ArrayUtils.contains(setting.getAccountLockTypes() AccountLockType.admin)) {
int loginFailureLockTime = setting.getAccountLockTime();
if (loginFailureLockTime == 0) {
throw new LockedAccountException();
}
Date lockedDate = admin.getLockedDate();
Date unlockDate = DateUtils.addMinutes(lockedDate loginFailureLockTime);
if (new Date().after(unlockDate)) {
admin.setLoginFailureCount(0);
admin.setIsLocked(false);
admin.setLockedDate(null);
adminService.update(admi

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-05-19 21:10  大疆果园\
     文件     3406517  2017-05-11 00:29  大疆果园\djorchard.sql
     目录           0  2017-05-11 00:32  大疆果园\大疆果园\
     目录           0  2017-05-19 21:09  大疆果园\大疆果园\DJorchard\
     文件         561  2015-03-04 20:20  大疆果园\大疆果园\DJorchard\.classpath
     文件        1262  2017-05-11 01:05  大疆果园\大疆果园\DJorchard\.project
     目录           0  2017-05-16 19:53  大疆果园\大疆果园\DJorchard\.settings\
     文件         503  2015-03-04 20:20  大疆果园\大疆果园\DJorchard\.settings\.jsdtscope
     文件          74  2017-05-21 12:44  大疆果园\大疆果园\DJorchard\.settings\com.genuitec.eclipse.core.prefs
     文件        1009  2017-05-11 00:48  大疆果园\大疆果园\DJorchard\.settings\com.genuitec.eclipse.j2eedt.core.prefs
     文件          57  2017-05-16 19:53  大疆果园\大疆果园\DJorchard\.settings\org.eclipse.core.resources.prefs
     文件         364  2015-03-04 20:20  大疆果园\大疆果园\DJorchard\.settings\org.eclipse.jdt.core.prefs
     文件         506  2017-05-11 01:05  大疆果园\大疆果园\DJorchard\.settings\org.eclipse.wst.common.component
     文件         252  2015-03-04 20:20  大疆果园\大疆果园\DJorchard\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2015-03-04 20:20  大疆果园\大疆果园\DJorchard\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2015-03-04 20:20  大疆果园\大疆果园\DJorchard\.settings\org.eclipse.wst.jsdt.ui.superType.name
     文件          81  2015-03-04 20:20  大疆果园\大疆果园\DJorchard\.settings\org.hibernate.eclipse.console.prefs
     目录           0  2017-05-10 23:47  大疆果园\大疆果园\DJorchard\WebContent\
     目录           0  2017-05-10 23:47  大疆果园\大疆果园\DJorchard\WebContent\meta-INF\
     文件          39  2015-03-04 20:20  大疆果园\大疆果园\DJorchard\WebContent\meta-INF\MANIFEST.MF
     目录           0  2017-05-10 23:47  大疆果园\大疆果园\DJorchard\WebContent\WEB-INF\
     目录           0  2017-05-17 12:17  大疆果园\大疆果园\DJorchard\WebContent\WEB-INF\classes\
     目录           0  2017-05-17 12:17  大疆果园\大疆果园\DJorchard\WebContent\WEB-INF\classes\admin\
     目录           0  2017-05-17 12:17  大疆果园\大疆果园\DJorchard\WebContent\WEB-INF\classes\admin\ad\
     文件        4615  2015-03-04 20:20  大疆果园\大疆果园\DJorchard\WebContent\WEB-INF\classes\admin\ad\add.ftl
     文件        5253  2015-03-04 20:20  大疆果园\大疆果园\DJorchard\WebContent\WEB-INF\classes\admin\ad\edit.ftl
     文件        4851  2015-03-04 20:20  大疆果园\大疆果园\DJorchard\WebContent\WEB-INF\classes\admin\ad\list.ftl
     目录           0  2017-05-17 12:17  大疆果园\大疆果园\DJorchard\WebContent\WEB-INF\classes\admin\ad_position\
     文件        3004  2015-03-04 20:20  大疆果园\大疆果园\DJorchard\WebContent\WEB-INF\classes\admin\ad_position\add.ftl
     文件        3214  2015-03-04 20:20  大疆果园\大疆果园\DJorchard\WebContent\WEB-INF\classes\admin\ad_position\edit.ftl
     文件        4422  2015-03-04 20:20  大疆果园\大疆果园\DJorchard\WebContent\WEB-INF\classes\admin\ad_position\list.ftl
............此处省略2726个文件信息

评论

共有 条评论