The implementation function only needs to enter an account to log into the system.
Need to implement the above features:
1. Edit Imitate.jsp Page
<% @pageImport= "Com.hotent.core.util.ContextUtil"%><% @pageImport= "Com.hotent.platform.model.system.SysUser"%><% @pageImport= "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=NewUsernamepasswordauthenticationtoken (Account, ""); Authrequest.setdetails (Newwebauthenticationdetails (Request)); SecurityContext SecurityContext=Securitycontextholder.getcontext (); Authentication Auth=authenticationmanager.authenticate (authrequest); Securitycontext.setauthentication (auth); Sysuser User=Contextutil.getcurrentuser (); Out.print (User.getfullname ());%>
Call the API authentication user, here only enter the account number, the password is empty, but the password in the database is encrypted using the SHA256 algorithm password, this time we need to implement a passwordencoder.
2. Implement Passwordencoder, this encoder always returns to True, implementation is implemented by the user itself.
PackageCom.hotent.platform.service.system.impl;ImportOrg.springframework.security.authentication.encoding.PasswordEncoder; Public classEmptypasswordencoderImplementsPasswordencoder {@Override Publicstring Encodepassword (string rawpass, Object salt) {System.out.println (rawpass); returnRawpass; } /*** Encpass: Database Password * Rawpass: original password*/@Override Public Booleanispasswordvalid (String encpass, String rawpass, Object salt) {return true; }}
3. Configure App-security.xml.
<Security:authentication-manageralias= "AuthenticationManager" > <Security:authentication-providerUser-service-ref= "Sysuserdao"> <Security:password-encoderref= "Passwordencoder"/> </Security:authentication-provider> </Security:authentication-manager> <BeanID= "Passwordencoder"class= "Com.hotent.platform.service.system.impl.EmptyPasswordEncoder"></Bean>
4. Configure imitate.jsp Anonymous access.
< Propertyname= "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 Attachments are uploaded - <value>/platform/bpm/bpmdefinition/getxmlimport.ht</value> <value>/mobile/system/mobilelogin.ht</value> <value>/mobile/system/mobilelogout.ht</value> </Set> </ Property>
BPMX3 Impersonation Login