实现功能只需要输入一个帐号即可登录系统。

需要实现上面的功能需要:

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模拟登录的更多相关文章

  1. PHP cURL 使用cookie 模拟登录

    cURL是什么 cURL: http://php.net/manual/zh/book.curl.php PHP 支持 Daniel Stenberg 创建的 libcurl 库,能够连接通讯各种服务 ...

  2. 【Python数据分析】Python模拟登录(一) requests.Session应用

    最近由于某些原因,需要用到Python模拟登录网站,但是以前对这块并不了解,而且目标网站的登录方法较为复杂, 所以一下卡在这里了,于是我决定从简单的模拟开始,逐渐深入地研究下这块. 注:本文仅为交流学 ...

  3. Android利用HttpURLConnection实现模拟登录

    最近在做一个APP,需要模拟登录教务处,之前曾经用HttpClient做过,点这里,但是发现最新的Android SDK已经不支持Httpclient了,所以只好在琢磨一下HttpURLConnect ...

  4. Python requests模拟登录

    Python requests模拟登录 #!/usr/bin/env python # encoding: UTF-8 import json import requests # 跟urllib,ur ...

  5. php中CURL实现模拟登录并采集数据

    在php中采集我们用的是简单的采集方式(例如file_get_contents)就无法做到了,但是如果想模拟登录用户并采集利用它就没办法了,我们可利用CURL函数来实现模拟登录并采集数据 这里要说一些 ...

  6. .NET微信模拟登录及{base_resp:{ret:-4,err_msg:nvalid referrer}}的解决办法

    12年的时候写了些关于微信开发的内容,当时看好这个东西,可惜当时腾讯开放的权限太少,之后的一年多时间没有太关注了. 现在又要重新开始微信开发的阵容了,微信只是个入口,微网站才是趋势. 我是个水货,所以 ...

  7. curl模拟登录新浪微博

     这几天要做个获取新浪微博@我的信息, 又不用第三方登录,所以只能通过模拟登录来获取信息,研究的一下发现直接模拟登录微博比较困难,验证的算法比较复杂,于是绕道通过登录新浪通行证后来获取cookie 来 ...

  8. curl 模拟登录微信公众平台带验证码

    这段时间一直写个项目, 从切图到前端到后台都要搞定,真tm累. 今天下午手残,不停用错误的密码去模拟登录微信公众平台,结果后来出现验证码,瞬间悲剧(菜鸟从来没搞过带验证码的). 研究了一下,发现其实很 ...

  9. .net 模拟登录Post提交

    最近在做一个项目,要求集成到第三方系统中,由于先前没有做过类似的活,所以折腾了几天,蹭着有闲情的时候记录一下. 以下实例,都是我用Asp.net语言进行开发的,关于HTML元素的获取,使用的是Goog ...

随机推荐

  1. underscore的封装和扩展

    // 1. 不污染全局环境 (function() { // 2. 保留之前同名变量 var previousUnderscore = window._; var _ = function(obj) ...

  2. iOS - Socket 网络套接字

    1.Socket 网络上的两个程序通过一个双向的通信连接实现数据的交换,这个连接的一端称为一个 Socket.Socket 又称 "套接字",应用程序通常通过 "套接字& ...

  3. Java可视化AWT

    AWT 总体上Swing组件替代了绝大部分AWT组件,对AWT图形用户界面编程有极好的补充和加强. package ch11; import java.awt.*; /** * Created by ...

  4. wireshark使用教程

    Wireshark: https://www.wireshark.org/ 安装: apt-get install wireshark 教程: http://blog.csdn.net/leichel ...

  5. Android 进入页面默认定位到ListView的解决方法

    由于ListView会默认去获取焦点,如果说ListView在页面的下方的话,那么点击条目进入新页面并退出,那么这时候就会定位到ListView这里,而不是展示头部.   解决这个问题,只需要在Lis ...

  6. android studio导入 so ,jar 文件。

    环境为: Android Studio 1.0.2 如果是jar文件的话,请直接拷贝jar文件到项目的libs文件夹下,然后运行:Sync Project with Gradle Files.如下图2 ...

  7. 工作流学习——Activiti流程实例、任务管理四步曲 (zhuan)

    http://blog.csdn.net/zwk626542417/article/details/46646565 ***************************************** ...

  8. Freemarker 浅析 (zhuan)

    http://blog.csdn.net/marksinoberg/article/details/52006311 ***************************************** ...

  9. 2010 word 如何新建目录

    首先插入一个bullet 填充内容,编好编号,选择文字,右键,然后选择相应的level,然后点击一级菜单reference, 然后点击table of contents, 选择某一个样式,然后插入成功 ...

  10. TPatch动态补丁系统(iOS)

    版权声明:本文由朱煌原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/160 来源:腾云阁 https://www.qclou ...