Esframework 4.0 Quick Start (15) -- client login verification

Source: Internet
Author: User

In earlier versions of the rapid engine, the client login authentication mechanism is not provided. To verify the user's account and password information, we only need to manually passCustom Information. InNew Version released on March 25The client rapid engine is built in to verify the user's account and password during initialization, which makes logon verification easier.

 

I. esplus. application. Basic Space support

To verify the password of a user account, several additional infrastructure is added to the esplus. application. Basic namespace.

(1) esplus. application. Basic. passive.IbasicoutterAdded the logon method:

///   <Summary>
/// Client Login verification.
///   </Summary>
///   <Param name = "systemtoken"> System flag. </Param>
///   <Param name = "password"> Login Password </Param>
Logonresult Logon ( String Systemtoken, String Password );

This method submits the account, password, system sign, and other information of the current login user to the server, and then returns the login result after server verification. The system identifier systemtoken indicates the system from which the current client comes from. The server can verify that the identifier matches the server to determine whether the client and server belong to the same system. In common applications, we can ignore it.

Logon result usageLogonresultEnumeration:

Public   Enum   Logonresult
{
///   <Summary>
/// Login successful
///   </Summary>
Succeed =   0 ,
///   <Summary>
/// Incorrect account or password
///   </Summary>
Erroruserorpassword,
///   <Summary>
/// Logged in elsewhere
///   </Summary>
Hadloggedon
}

IfLogon ModeSet to relogonmode. ignorenew, And the userid used for this logon is online, the logon method returns logonresult. hadloggedon to indicate that the user has logged on elsewhere.

 

(2) esplus. application. Basic. server space increasedIbasicbusinesshandlerInterface

After the client submits the account, password, system sign, and other information of the currently logged-on user to the server, the server calls ibasicbusinesshandler to verify the account information.

Public   Interface   Ibasicbusinesshandler
{
///   <Summary>
/// Client Login verification.
///   </Summary>
///   <Param name = "userid"> Login User Account </Param>
///   <Param name = "systemtoken"> System flag. Used to verify whether the client and the server belong to the same system. </Param>
///   <Param name = "password"> Login Password </Param>
///   <Returns> If both the password and system flag are correct, true is returned; otherwise, false is returned. </Returns>
Bool Verifyuser ( String Systemtoken, String Userid, String Password );
}

Note: When implementing ibasicbusinesshandler, we do not need to judge whether the re-login mode and the user are online. These are already done by the framework. Therefore, the verifyuser method only returns a bool value to indicate whether the account password is correct. After implementing this interface and injecting it into esplus, you can verify the user by calling the ibasicoutter logon method.

The framework provides the ibasicbusinesshandler Implementation of the Null Object Mode.EmptybasicbusinesshandlerWhen verifyuser is implemented, true is always returned.

2. built-in login verification of rapid Engine

In this version change, the client's rapid engine and the server's rapid engine's initialize method have all changed to support the user login authentication mechanism.

(1) initialize method of irapidpassiveengine:

Logonresult Initialize ( String Userid, String   Logonpassword , String Serverip, Int SERVERPORT, Ibasicbusinesshandler Basichandler, Icustomizeinfobusinesshandler Customizehandler );

This method adds the logonpassword parameter and returns the logon result.

In internal implementation,The initialize method first establishes a TCP connection with the server, and then sends a login verification request and obtains the login result through the ibasicoutter logon method.If the logon is successful, the system returns directly. Otherwise, the TCP connection is closed and the result is returned. Note that if a TCP connection fails to be established with the server, initialize will directly throw the corresponding exception instead of expressing it through the return value.

Where does the systemtoken required by the ibasicoutter logon method come from? Irapidpassiveengine adds a read/write attribute systemtoken. If we set it, the logon method will pass it as the parameter value.

During User Login Attempts,ProgramInitialize can be called repeatedly for verification, without the need to create a new client rapid engine instance every time. The relevant attributes of the rapid engine are available only after the initialize method returns a successful logon. For example, we can use the newly added currentuserid attribute to know the userid of the currently successfully logged on user.

(2) initialize method of irapidserverengine:

Void Initialize ( Int Port, Icustomizeinfobusinesshandler Customizeinfobusinesshandler, Ibasicbusinesshandler Basicbusinesshandler , Ifilebusinesshandler Filebusinesshandler, Ifriendsmanager Friendsmanager, Igroupmanager Groupmanager );

The initialize method of the server-side rapid engine adds the ibasicbusinesshandler parameter. As mentioned above, the server uses it to verify the account information submitted by the client. If you do not care about Account Verification, you can pass in the emptybasicbusinesshandler instance mentioned above, or directly pass in null-in this case, the engine uses emptybasicbusinesshandler by default to process user login verification.

 

(3) For most systems, it is sufficient to use the account and password for logon. In some special systems, if you need to verify more information (such as timestamp) during logon, you can use the systemtoken attribute of irapidpassiveengine to pass these additional verification information, because the value of systemtoken is also submitted to the verifyuser method of the server for verification.

 

In combination with this version change, we have released the latest esframework, help documentation, and updated all Demo source code. You can download it from the end of esframework 4.0 overview.

 

Esframework 4.0 Overview

What are the advantages of esframework 4.0?

Esframework 4.0 upgrade description (continuous update)

Esframework 4.0 Quick StartArticle

All articles in esframework 4.0 advanced edition Series

 

 

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.