BPMX3 Analog Login

Source: Internet
Author: User
Tags sha256 algorithm

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.