- 浏览: 429016 次
- 性别:
- 来自: 广州
文章分类
最新评论
-
man1900:
想部署及学习了解,可参考本人新的博客获得下载源代码。http: ...
JOffice 中的JBPM4在线流程设计器--初览(Applet版) -
atgoingguoat:
哎。假的。
JOffice 中的JBPM4在线流程设计器--初览(Applet版) -
电竞杀神张无忌:
这是主流程调用子流程报的错大神指导原因吗? ...
JBPM4的子流程与父流程的设计及开发 -
贝塔ZQ:
pageoffice也是office在线编辑的吧,J.Offi ...
J.Office另一种在线Office编辑器整合 -
Mybonnie1:
你好,想问下,串行的多实例任务能做到回退么
Activiti 多个并发子流程的应用
在开发时,可以让系统记住登录,可以避免开发调试重复登录带来的麻烦,提高调试的效率,在系统中,点击“让系统记住我”选项。
若要启用该功能,系统需要进行以下的配置:
1.系统现在打开了用户密码加密的配置(加密配置为SHA-256),因而系统的密码需要重新设置,可以调用系统StringUtil的方法:
public static synchronized String encryptSha256(String inputStr) { try { MessageDigest md = MessageDigest.getInstance("SHA-256"); byte digest[] = md.digest(inputStr.getBytes("UTF-8")); return new String(Base64.encodeBase64(digest)); //return (new BASE64Encoder()).encode(digest); //return new String(Hex.encodeHex(digest)); } catch (Exception e) { return null; } } public static void main(String[]args){ String password="111"; String result=encryptSha256(password); //System.out.println("array:"+ new String(Hex.encodeHex(dis))); System.out.println("result:" + result); }
如密码为111,加密后为:9uCh4qxBlFqap/+KiqoM68EqO8yYGpKa1c+BCgkOEa4=
请执行:
update app_user set password='9uCh4qxBlFqap/+KiqoM68EqO8yYGpKa1c+BCgkOEa4=';
把所有的用户的密码更新为111
2.App-security.xml中打开配置:
<?xml version="1.0" encoding="UTF-8"?> <b:beans xmlns="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:b="http://www.springframework.org/schema/beans" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.4.xsd"> <http auto-config="true" access-denied-page="/403.jsp" lowercase-comparisons="true" > <intercept-url pattern="/images/**" filters="none"/> <intercept-url pattern="/css/**" filters="none"/> <intercept-url pattern="/js/**" filters="none"/> <intercept-url pattern="/403*" filters="none"/> <intercept-url pattern="/404*" filters="none"/> <intercept-url pattern="/500*" filters="none"/> <intercept-url pattern="/ext3/**" filters="none"/> <intercept-url pattern="/fckeditor/**" filters="none"/> <intercept-url pattern="/jsonStruts**" filters="none"/> <intercept-url pattern="/file-upload" access="ROLE_PUBLIC,ROLE_ANONYMOUS"/> <intercept-url pattern="/fileDetail.do" access="ROLE_PUBLIC"/> <intercept-url pattern="/index.jsp" access="ROLE_PUBLIC"/> <intercept-url pattern="/login.do**" access="ROLE_PUBLIC,ROLE_ANONYMOUS"/> <intercept-url pattern="/check.do**" access="ROLE_PUBLIC,ROLE_ANONYMOUS"/> <intercept-url pattern="/**" access="ROLE_PUBLIC"/> <form-login default-target-url="/index.jsp" login-page="/login.jsp" authentication-failure-url="/login.jsp?error=true" login-processing-url="/j_security_check" /> <logout logout-url="/j_logout.do" logout-success-url="/login.jsp"/> <remember-me key="RememberAppUser"/> </http> <authentication-manager alias="authenticationManager"/> <authentication-provider user-service-ref="appUserDao"> <password-encoder hash="sha-256" base64="true"/> </authentication-provider> </b:beans>
3.在LoginAction中,添加如下代码(红色部分):
package com.htsoft.oa.action.system; import javax.annotation.Resource; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import nl.captcha.Captcha; import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.lang.StringUtils; import org.springframework.security.AuthenticationManager; import org.springframework.security.context.SecurityContext; import org.springframework.security.context.SecurityContextHolder; import org.springframework.security.providers.UsernamePasswordAuthenticationToken; import org.springframework.security.ui.rememberme.TokenBasedRememberMeServices; import org.springframework.security.ui.webapp.AuthenticationProcessingFilter; import com.htsoft.core.util.AppUtil; import com.htsoft.core.util.StringUtil; import com.htsoft.core.web.action.BaseAction; import com.htsoft.oa.model.system.AppUser; import com.htsoft.oa.service.system.AppUserService; public class LoginAction extends BaseAction{ private AppUser user; private String username; private String password; private String checkCode;//验证码 //must be same to app-security.xml private String key="RememberAppUser"; //private String rememberMe;//自动登录 @Resource private AppUserService userService; @Resource(name="authenticationManager") private AuthenticationManager authenticationManager=null; /** * 登录 * @return */ public String login(){ StringBuffer msg = new StringBuffer("{msg:'"); Captcha captcha = (Captcha)getSession().getAttribute(Captcha.NAME); Boolean login = false; String newPassword=null; if(!"".equals(username)&&username!=null){ setUser(userService.findByUserName(username)); if(user!=null){ if(StringUtils.isNotEmpty(password)){ newPassword=StringUtil.encryptSha256(password); if(user.getPassword().equalsIgnoreCase(newPassword)){ if(captcha.isCorrect(checkCode)){ if(user.getStatus()==1){ login=true; } else msg.append("此用户已被禁用.'"); } else msg.append("验证码不正确.'"); } else msg.append("密码不正确.'"); } else msg.append("密码不能为空.'"); } else msg.append("用户不存在.'"); } if(login){ UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(username, password); SecurityContext securityContext = SecurityContextHolder.getContext(); securityContext.setAuthentication(authenticationManager.authenticate(authRequest)); SecurityContextHolder.setContext(securityContext); getSession().setAttribute(AuthenticationProcessingFilter.SPRING_SECURITY_LAST_USERNAME_KEY,username); String rememberMe = getRequest().getParameter("_spring_security_remember_me"); if(rememberMe!=null&&rememberMe.equals("on")){ //加入cookie long tokenValiditySeconds = 1209600; // 14 days long tokenExpiryTime = System.currentTimeMillis() + (tokenValiditySeconds * 1000); //DigestUtils.md5Hex(username + ":" + tokenExpiryTime + ":" + password + ":" + getKey()); String signatureValue = DigestUtils.md5Hex(username + ":" + tokenExpiryTime + ":" + user.getPassword() + ":" + key); String tokenValue = username + ":" + tokenExpiryTime + ":" + signatureValue; String tokenValueBase64 = new String(Base64.encodeBase64(tokenValue.getBytes())); getResponse().addCookie(makeValidCookie(tokenExpiryTime, tokenValueBase64)); } //登录成功后,需要把该用户显示至在线用户 AppUtil.addOnlineUser(getSession().getId(), user); setJsonString("{success:true}"); }else{ msg.append(",failure:true}"); setJsonString(msg.toString()); } return SUCCESS; } //add Cookie protected Cookie makeValidCookie(long expiryTime, String tokenValueBase64) { HttpServletRequest request=getRequest(); Cookie cookie = new Cookie(TokenBasedRememberMeServices.SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY, tokenValueBase64); cookie.setMaxAge(60 * 60 * 24 * 365 * 5); // 5 years cookie.setPath(org.springframework.util.StringUtils.hasLength(request.getContextPath()) ? request.getContextPath():"/"); return cookie; } public AppUser getUser() { return user; } public void setUser(AppUser user) { this.user = user; } 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 getCheckCode() { return checkCode; } public void setCheckCode(String checkCode) { this.checkCode = checkCode; } }
当登录后,该Cookie的信息如下图所示:
可以看到SPRING_SECURITY_REMEMBER_ME_COOKIE存在,并且有效期是五年,不过里面的令牌只有14天,则真正有效期是14天,主要该COOKIE没有被删除,下次访问系统时,可以不用登录,直接访问index.jsp则可。
发表评论
-
Activiti入门之三--ORM框架MyBatis的基础及使用
2014-05-12 14:29 73481. 概述 上篇我们介绍 ... -
Activiti入门篇之一 Maven环境搭建
2014-04-28 09:09 4362下载地址http://maven.apache.org/d ... -
Activiti 多个并发子流程的应用
2012-08-27 11:29 31778应用场景: 多个部门发起资金计划,最后统一到财务部 ... -
Activiti 工作流会签开发设计思路
2012-07-26 12:12 28354Activiti 工作流会签开 ... -
基于开源流程引擎Activiti5的工作流开发平台
2012-05-17 11:28 7172http://www.redxun.cn:8 ... -
Jbpm4或Activiti5的流程任务分发与汇总
2012-03-20 18:28 6200应用场景:在企业或事业单位,经常需要把一个任务分派给多条线去 ... -
基于标签方式的工作流启动及任务执行开发说明
2011-09-25 21:21 2264基于现在的系统的整 ... -
JOffice2 发布了开源的开发者体验版本啦!
2011-08-09 23:42 7258JOffice的爱好者有福音了,经公司决定,现在发布 ... -
关于JOffice的业务表单与流程的整合问题
2011-07-26 23:55 3272关于 JOffice 的业务表 ... -
利用Spring AOP与JAVA注解为系统增加日志功能
2010-04-20 10:15 17729Spring AOP一直是Spring的一个比较有特色的功能, ... -
Jasper Report与J.Office中的报表开发
2010-01-04 10:32 3719Jasper Report是一个强大 ... -
快速开发平台之---代码加速器
2010-01-02 16:53 8741一、代码加速器的介 ... -
基于Spring Security2与 Ext 的权限管理设计与实现
2009-12-25 12:29 8835一、Spring Security介绍 ... -
JOffice中的权限管理--功能粒度的权限管理配置
2009-11-14 20:20 9875JOffice中的权限管理是基于角色的管理策略,采用Spr ... -
关于JOffice的权限更新说明--角色权限授予
2009-11-11 12:09 2800JOffice OA 系统的权限是采用基于角色的管理,用户拥有 ... -
Struts,Spring,Hibernate,Ext3完整的应用程序搭建(一)
2009-09-20 12:27 3529最近一直在进行公司产品的研发,工作很辛苦,但收获也颇多,宏天软 ...
相关推荐
这个JOffice V1.2 beta版,也就是官方说开源的版本之一。 说实话,这个公司很讨厌,打着开源的幌子来宣传自己的产品,里面的 东西根本没有开源,还很恶心的包留了一部分代码,htcore.jar。 对于这样的开源,我表示...
关于 JOffice1.3使用手册,方便快捷,大家来下载
JOffice2中的JBPM4的任务回退实现
joffice技术框架介绍。
J.Office办公协同开发平台是支持流程管理、监控、优化、再造的全套IT管理开发平台,并且能与宏天的CMS集成单点登录、企业单位门户、业务流程管理、开发、整合、业务分析及重构等多重职能于一身的软件开发平台、发...
// 将所有重要的初始化放置在 InitInstance 中 } // 唯一的一个 CChatApp 对象 CChatApp theApp; // CChatApp 初始化 BOOL CChatApp::InitInstance() { // 如果一个运行在 Windows XP 上的应用程序清单指定...
JOffice中的权限管理是基于角色的管理策略,采用Spring Security2的配置方式,同时能够结合EXT3来进行整个系统的权限管理,通过使用配置文件,进行整个系统的功能集中管理,包括系统左边的导航菜单,数据列表中的...
office文档转pdf后,再转swf,最终显示需要的一些工具及jar包,包括一个office转pdf转swf的java文件。因目前可上传的文件大小限制,OpenOffice安装文件未上传,工具目前最新版本为3.4.1,请另行下载
用cmd命令打jar包 目标——将D:\myfile目录下的所有文件及文件夹打包到license.jar包中 步骤——1.用cd命令跳转至D:\myfile目录下 2.输入命令jar cvf license.jar *.* mysql->source F:/joffice131.sql
JoPro是一个生产力和办公套件,将文字处理器,电子表格设计器,演示设计器和svg查看器集成到一个应用程序中! 基于Netbeans平台。 图像和代码由Anthony Goubard设计。 最初称为Joffice。
JOffVis 一个基于 Java Swing 的工具,用于可视化 ...先决条件:1) Java SDK 72) Maven 3要编译应用程序,请运行以下命令mvn 干净编译要启动应用程序,请运行以下命令mvn exec:java -Dexec.mainClass="joffice.gui.App