BPMX3模拟登录
实现功能只需要输入一个帐号即可登录系统。
需要实现上面的功能需要:
1.编辑imitate.jsp页面
<%@page import="com.hotent.core.util.ContextUtil"%>
<%@page import="com.hotent.platform.model.system.SysUser"%>
<%@page import="org.springframework.security.core.Authentication,
org.springframework.security.core.context.SecurityContext,
com.hotent.core.util.AppUtil,
org.springframework.security.authentication.AuthenticationManager,
org.springframework.security.core.context.SecurityContextHolder,
org.springframework.security.web.authentication.WebAuthenticationDetails,
org.springframework.security.authentication.UsernamePasswordAuthenticationToken"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%
AuthenticationManager authenticationManager=(AuthenticationManager)AppUtil.getBean("authenticationManager");
String account=request.getParameter("account"); UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(account, "");
authRequest.setDetails(new WebAuthenticationDetails(request));
SecurityContext securityContext = SecurityContextHolder.getContext();
Authentication auth = authenticationManager.authenticate(authRequest);
securityContext.setAuthentication(auth); SysUser user=ContextUtil.getCurrentUser(); out.print(user.getFullname());
%>
调用api验证用户,这里只输入了帐号,密码为空,但是数据库中的密码是使用sha256算法加密的密码,这个时候我们需要实现一个PasswordEncoder。
2.实现PasswordEncoder,这个encoder 始终返回为true,具体实现由用户自己实现。
package com.hotent.platform.service.system.impl;
import org.springframework.security.authentication.encoding.PasswordEncoder;
public class EmptyPasswordEncoder implements PasswordEncoder {
@Override
public String encodePassword(String rawPass, Object salt) {
System.out.println(rawPass);
return rawPass;
}
/**
* encPass:数据库密码
* rawPass:原密码
*/
@Override
public boolean isPasswordValid(String encPass, String rawPass, Object salt) {
return true;
}
}
3.配置app-security.xml.
<security:authentication-manager alias="authenticationManager" >
<security:authentication-provider user-service-ref="sysUserDao">
<security:password-encoder ref="passwordEncoder"/>
</security:authentication-provider>
</security:authentication-manager> <bean id="passwordEncoder" class="com.hotent.platform.service.system.impl.EmptyPasswordEncoder"></bean>
4.配置imitate.jsp匿名访问。
<property name="anonymousUrls">
<set>
<value>/mobileLogin.jsp</value>
<value>/mobileLogin.ht</value>
<value>/platform/mobile/lang/changLang.ht</value>
<value>/loginRedirect.ht</value>
<value>/login.jsp</value>
<value>/imitate.jsp</value>
<value>/login.ht</value>
<value>/bpmImage</value>
<value>/platform/bpm/processRun/processImage.ht</value>
<value>/platform/bpm/processRun/getFlowStatusByInstanceId.ht</value>
<value>/platform/bpm/processRun/taskUser.ht</value>
<value>/platform/bpm/taskOpinion/list.ht</value>
<!-- flex附件上传的 -->
<value>/platform/bpm/bpmDefinition/getXmlImport.ht</value>
<value>/mobile/system/mobileLogin.ht</value>
<value>/mobile/system/mobileLogout.ht</value>
</set>
</property>
BPMX3模拟登录的更多相关文章
- PHP cURL 使用cookie 模拟登录
cURL是什么 cURL: http://php.net/manual/zh/book.curl.php PHP 支持 Daniel Stenberg 创建的 libcurl 库,能够连接通讯各种服务 ...
- 【Python数据分析】Python模拟登录(一) requests.Session应用
最近由于某些原因,需要用到Python模拟登录网站,但是以前对这块并不了解,而且目标网站的登录方法较为复杂, 所以一下卡在这里了,于是我决定从简单的模拟开始,逐渐深入地研究下这块. 注:本文仅为交流学 ...
- Android利用HttpURLConnection实现模拟登录
最近在做一个APP,需要模拟登录教务处,之前曾经用HttpClient做过,点这里,但是发现最新的Android SDK已经不支持Httpclient了,所以只好在琢磨一下HttpURLConnect ...
- Python requests模拟登录
Python requests模拟登录 #!/usr/bin/env python # encoding: UTF-8 import json import requests # 跟urllib,ur ...
- php中CURL实现模拟登录并采集数据
在php中采集我们用的是简单的采集方式(例如file_get_contents)就无法做到了,但是如果想模拟登录用户并采集利用它就没办法了,我们可利用CURL函数来实现模拟登录并采集数据 这里要说一些 ...
- .NET微信模拟登录及{base_resp:{ret:-4,err_msg:nvalid referrer}}的解决办法
12年的时候写了些关于微信开发的内容,当时看好这个东西,可惜当时腾讯开放的权限太少,之后的一年多时间没有太关注了. 现在又要重新开始微信开发的阵容了,微信只是个入口,微网站才是趋势. 我是个水货,所以 ...
- curl模拟登录新浪微博
这几天要做个获取新浪微博@我的信息, 又不用第三方登录,所以只能通过模拟登录来获取信息,研究的一下发现直接模拟登录微博比较困难,验证的算法比较复杂,于是绕道通过登录新浪通行证后来获取cookie 来 ...
- curl 模拟登录微信公众平台带验证码
这段时间一直写个项目, 从切图到前端到后台都要搞定,真tm累. 今天下午手残,不停用错误的密码去模拟登录微信公众平台,结果后来出现验证码,瞬间悲剧(菜鸟从来没搞过带验证码的). 研究了一下,发现其实很 ...
- .net 模拟登录Post提交
最近在做一个项目,要求集成到第三方系统中,由于先前没有做过类似的活,所以折腾了几天,蹭着有闲情的时候记录一下. 以下实例,都是我用Asp.net语言进行开发的,关于HTML元素的获取,使用的是Goog ...
随机推荐
- Ubuntu Install Chrome Brwoser
在ubuntu下安装chrome浏览器,可以直接从官网下载:http://www.google.cn/intl/zh-CN/chrome/browser/thankyou.html?platform= ...
- domion Designer 管理员ID过期
上班没几天,刚接触lotus domion 有一个服务器上打开相应的数据库提示 你的证书已经过期,网上找到的解决方案: ---------------------------------------- ...
- javascript学习-原生javascript的小特效(多物体运动效果)
前些日子看了个视频所以就模仿它的技术来为大家做出几个简单的JS小特效 今天为大家做的是多个物体的运动效果, 1:HTML <body> <ul> <li> ...
- iOS - Swift 与 C 语言交互编程
前言 作为一种可与 Objective-C 相互调用的语言,Swift 也具有一些与 C 语言的类型和特性,如果你的代码有需要,Swift 也提供了和常见的 C 代码结构混合编程的编程方式. 1.基本 ...
- Xpert 调优
-- 10046 event 可以定义 SQL TRACE 级别 /* || 默认的10046级别跟 SQL TRACE 一样, 另外还有一些级别: || level 1: SQL Tracing | ...
- [转载]VFS—Kernel Space & User Space
在了解虚拟文件系统之前 , 需要先了解 Kernel Space 和 User Space 的区别 . 二者的差别在于内存使用上安全机制的差异 . kernel 执行时会占据一段系统的内存空间 , 这 ...
- img、input到底是行内还是块级元素?
一.img.input属于行内替换元素.height/width/padding/margin均可用.效果等于块元素. 行内非替换元素,例如, height/width/padding to ...
- scp lost connection
将本机的文件copy到远程时, scp -r /home/Projects/test.rpm root@172.1.1.1:/root; 我们得到了一个错误:lost connection lost ...
- python语法笔记(五)
1.python内存管理 (1)对象内存使用 &nsbp;&nsbp;&nsbp;&nsbp;在python中通过执行内建函数 id(obj) 可以获得对象obj在内存 ...
- xUtils更新到3.0后的基本使用规则
说实话,对于xUtils,是我最近才用到的开发框架(也是刚接触),对于其功能不得不说,简化了很多的开发步骤,可以说是非常好的开发工具,但是其最近更新到3.0也没有解决加载自定义ImageView报错的 ...