Summary of the invention
In view of this, the invention provides a kind of method and system realizing logging in XMPP server, when the third party website of social network sites is XMPP server, the user of social network sites can use account and this third party's XMPP server of password login of this social network sites.
For achieving the above object, the invention provides a kind of method realizing logging in XMPP server, comprising:
The account of reception client choice for use social network sites carries out the request logged in;
The third party returning described social network sites for described client logs in entrance, so that user logs in entrance input account by client described third party log in described social network sites;
The account visit information that the server receiving described social network sites when client returns, and when the identification information of described social network sites and described account visit information are sent as log-on message, receive described log-on message, described account visit information comprises account number information;
Judge the social network sites of the identification information ownership of described social network sites, and according to the rule formulated with the server of this social network sites in advance, judge whether described account number information meets registration conditions, if so, then set up and be connected with the XMPP between described client.
Preferably, the request that the account of described reception client choice for use social network sites carries out logging in comprises: receive client by accessing the HTTP entrance of specifying, the account of the use social network sites sent carries out the request logged in, wherein, the HTTP entrance XMPP server of specifying is use the account of specific social network sites to carry out logging in arranging.
Preferably, the request that the account of described reception client choice for use social network sites carries out logging in comprises: receive the option of client by choice for use social network sites account login on a user interface, the logging request sent;
The described third party returning described social network sites for described client logs in entrance and comprises: need to access by XML data stream notice client the third party that described social network sites server specifies and log in entrance.
Preferably, described account number information comprises: the login sessions mark of the user ID of described account, described account and/or session expired time.
Preferably, described account visit information also comprises: social network sites according to the key of arranging with XMPP server in advance, to the digital signature that described account number information generates;
The rule that described basis is formulated with the server of this social network sites in advance, judge whether described account number information meets registration conditions and comprise: according in advance with the key of this social network sites server commitment, the account number information described client sent generates digital signature, judge whether the digital signature that this digital signature and described account visit information comprise mates, if so, then registration conditions is met.
Preferably, the XMPP between described foundation with described client connects and comprises: inquire about and whether preserve the XMPP user name corresponding with described account, if so, then under described XMPP user name, sets up and is connected with between described client; If not, then the XMPP user name that establishment one is corresponding with described account, and under described XMPP user name, set up and be connected with between described client.
Corresponding method of the present invention, present invention also offers a kind of system realizing logging in XMPP server, comprising:
Request receiving module, the account for receiving client choice for use social network sites carries out the request logged in;
Redirection module, for after request receiving module receives described request, the third party returning described social network sites for described client logs in entrance, so that user logs in entrance input account by client described third party log in described social network sites;
Information receiving module, for the account visit information that the server receiving described social network sites when client returns, and when the identification information of described social network sites and described account visit information are sent as log-on message, receive described log-on message, described account visit information comprises account number information;
Information judging unit, for judging the social network sites of the identification information ownership of described social network sites, and according to the rule formulated with the server of this social network sites in advance, judge whether described account number information meets registration conditions, if so, then foundation is connected with the XMPP between described client.
Preferably, request receiving module comprises: the first request receiving module, for receiving client by accessing the HTTP entrance of specifying, the account of the use social network sites sent carries out the request logged in, wherein, the HTTP entrance XMPP server of specifying is use the account of certain specific social network sites to carry out logging in arranging.
Preferably, described request receiver module comprises: the second request receiving module, for receiving the option of client by choice for use social network sites account login on a user interface, the logging request sent;
Described redirection module comprises: the second redirection module, and the third party specified for needing to access described social network sites server by XML data stream notice client logs in entrance.
Preferably, described account number information comprises: the login sessions mark of the user ID of described account, described account and/or session expired time.
Preferably, described account visit information also comprises: social network sites according to the key of arranging with XMPP server in advance, to the digital signature that described account number information generates;
Described information judging unit comprises: information judgement subunit, for according in advance with the key of this social network sites server commitment, the account number information described client sent generates digital signature, judge whether the digital signature that this digital signature and described account visit information comprise mates, if so, then registration conditions is met.
Preferably, information judging unit comprises: connection establishment unit, for when described account number information conforms registration conditions, whether inquiry preserves the XMPP user corresponding with described account, if so, then under described XMPP user name, set up and be connected with between described client; If not, then the XMPP user that establishment one is corresponding with described account, and then under described XMPP user name, set up and be connected with between described client.
Known via above-mentioned technical scheme, compared with prior art, present disclosure provides a kind of method and system realizing logging in XMPP server, when the account of client choice for use social network sites logs in XMPP server, XMPP server is that the third party that client returns described social network sites logs in entrance.Client inputs described social network sites account by logging in entrance third party logs in the server of described social network sites, the server of described social network sites is that described client returns account number information and corresponding digital signature, client is by described account number information and digital signature, and the identification information of described social network sites sends to XMPP server, XMPP server is according to the rule of making an appointment with described social network sites, judge whether described account number information meets registration conditions, when meeting registration conditions, the XMPP set up between XMPP server with described client is connected.The user that this method achieves social network sites uses account and the password login third party XMPP server of social network sites, thus realizes third party website and utilize the existing subscriber group of social network sites to set up the object of good social networks.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, be clearly and completely described the technical scheme in the embodiment of the present invention, obviously, described embodiment is only the present invention's part embodiment, instead of whole embodiments.Based on the embodiment in the present invention, those of ordinary skill in the art, not making the every other embodiment obtained under creative work prerequisite, belong to the scope of protection of the invention.
See Fig. 1, realize the embodiment of the method logging in XMPP server for the present invention is a kind of, the method comprises:
Step S101: the account of reception client choice for use social network sites carries out the request logged in;
Wherein, the flow process of existing login XMPP server is: user inputs the account registered in XMPP server and corresponding password sends logging request, XMPP server can be verified this account and password, is verified, then allow this user by client-access XMPP server.
In order to the account being different from existing use XMPP server carries out the request that logs in, XMPP server can pre-set HTTP entrance, certainly for the account using different social network sites, can arrange different HTTP entrances.In this case the account that XMPP server receives client choice for use social network sites carries out the request logged in, can be: receive client by accessing the HTTP entrance of specifying, the account of the use social network sites sent carries out the request logged in, wherein, the HTTP entrance XMPP server of specifying is use the account of certain specific social network sites to carry out logging in arranging.
When user needs the account using certain social network sites to log in XMPP server, the HTTP entrance can specified by client-access.Such as, certain social network sites A has opened third party application DLL (dynamic link library) (API to this XMPP server (xmpp-example.com), ApplicationProgramming Interface), then can do following agreement between XMPP server and social network sites A: social network sites provides an api-key that can identify this XMPP server; The domain name of this social network sites of agreement mark is: sns-example.com.XMPP server just can set a http address: http://xmpp-example.com/login-using-sns-example, when client needs to use the account of social network sites A to log in this XMPP server, just can access this http entrance.
Certainly, XMPP server can also be set using on user's login interface " certain website account log in " option, then receiving client selects the account of certain social network sites to carry out the request logged in, can be: receive the option of client by choice for use social network sites account login on a user interface, the logging request sent.Still open third party's api interface for social network sites A to XMPP server (xmpp-example.com), the login option that XMPP server " can use the account of social network sites A " at UI Preferences, when user needs the account using social network sites A to log in XMPP server, just by selecting this option, connection request can be sent to XMPP server.
Certainly, the account that other modes can also be had to realize client choice for use social network sites carries out the request logged in, as long as can distinguish with the mode using the account of XMPP server to carry out logging in.
Step S102: the third party returning described social network sites for described client logs in entrance, so that user logs in entrance input account by client described third party log in described social network sites;
When receiving client and needing the account using the social network sites of specifying to log in the request of XMPP server, the third party returning this social network sites for this client is logged in entrance by XMPP server.Wherein, this third party logs in entrance, and for social network sites and this XMPP server are made an appointment, and the user provided for this XMPP server for this social network sites logs in entrance.
Wherein, the third party returning described social network sites for described client logs in the form of entrance, the difference of carrying out the mode of logging request according to the account of client choice for use social network sites can have multiple, can be: when user needs to use certain social network sites account to access XMPP server, the HTTP entrance of being specified by access XMPP server is connected, XMPP server is redirected to the entry address of specifying for this client automatically, and namely third party logs in entrance.Such as, still be described with the example enumerated above, this XMPP server is realize user the account of social network sites A can be used to log in, setting a http address is: http://xmpp-example.com/login-using-sns-example, does is being automatically redirected social network sites A that the third party that this XMPP server is specified logs in entry address: https: //sns-example.com/login when this http entrance of client-access? apikey=someapikey.The account that user just can log in entrance input social network sites by this third party logs in the server of this social network sites.
Certainly the third party returning described social network sites for described client logs in the mode of entrance, can also be: when user by client on a user interface choice for use social network sites account log in option, during the logging request sent, XMPP server can pass through extend markup language (XML) data flow, notice client needs to access the third party that described social network sites server specifies and logs in entrance, and client initiatively can be accessed this third party and be logged in entrance.Such as, when XMPP server informs client by XML stream: for using the account of social network sites sns-example.com to log in, needing to access this appointment third party and logging in entry address:
Https: //sns-example.com/login? apikey=someapikey, client initiatively can be accessed this third party and be logged in entry address, enters the interface that third party logs in entrance.
Log in the interface of entrance the third party returned, user can input the account of this social network sites by client and corresponding password logs in, to access the server of this social network sites.
Step S103: the account visit information that the server receiving described social network sites when client returns, and when the identification information of described social network sites and described account visit information are sent as log-on message, receive described log-on message, described account visit information comprises account number information;
When user logs in the third party of social network sites the account that entrance inputs this social network sites by client, after signing in this social network sites, this social network standing-meeting will return to this client as account visit information in this login process of this user for information about.Wherein account visit information comprises: the identification information of this account, and concrete can comprise: the information that user totem information is relevant with this account number with login sessions mark etc.
Certain account visit information can also comprise: the server of social network sites according to the key of arranging with XMPP server in advance, to the digital signature that account identification information generates.Such as, account number information can be generated digital signature by the key of making an appointment with XMPP server by social network sites, and social network sites can by client Cookies for client provides the digital signature of above generation.
Certainly, account visit information also can comprise session expired time etc. this logs in other relevant information with this account.
After client receives the account visit information that social network sites server returns, using this social network sites identification information and the account visit information that receives as the log-on message logging in XMPP server, send to XMPP server.Wherein, social network sites identification information is that XMPP server and social network sites server are made an appointment, so that this XMPP server can identify according to this social network sites, judges the server of this website logo from which social network sites.
Wherein, the form of the log-on message that client sends can have multiple, as long as XMPP server can be allowed to judge that this is not be used in the mode that account that XMPP server is registered and password carry out logging according to this log-on message, can judge that this client uses the account of which social network sites to carry out logging according to this log-on message simultaneously.
When client sends described log-on message, using account visit information and this website logo information combination together as user name, XMPP server can be logged in.Such as, XMPP server is sent to using the form of " account visit information social network sites mark " as user name.
When the account visit information that social network sites returns comprises account number information and digital signature, account number information can be combined into user name together with social network sites mark, and the digital signature returned by social network sites sends as password the request logging in XMPP server.
Step S104: the social network sites judging the identification information ownership of described social network sites, and according to the rule formulated with the server of this social network sites in advance, judge whether described account number information meets registration conditions, if so, then set up and be connected with the XMPP between described client.
When after the log-on message receiving client transmission, the social network sites mark that XMPP server will extract in log-on message, and identify according to this social network sites, draw the social network sites server that this social network sites mark is corresponding, thus determine that this social network sites is the account number information that this client returns, then according to pre-establishing rule with this website, judge whether this account number information meets the condition logging in XMPP server.
Wherein, judge that the rule whether described account number information meets registration conditions is that XMPP server and social network sites pre-establish.Concrete judgment mode can have multiple, as long as can judge the client sending this account visit information, used the account of this social network sites to log in social network sites, this account have passed the checking of social network sites.
Wherein account visit information can also comprise: social network sites server according to the key of arranging with XMPP server in advance, by account number information generate digital signature.Under this condition, judge whether described account number information meets registration conditions and can be: according in advance with the key of this social network sites server commitment, the account number information described client sent generates digital signature, and the digital signature comprised in the digital signature of described generation and described account visit information is compared, as the two coupling, then described account number information conforms registration conditions.
In addition, for preventing " Replay Attack " can also comprise session expired time in described account visit information, XMPP server can judge this session expired time, to determine whether this account number information meets registration conditions.
When described account number information conforms registration conditions, the XMPP server just XMPP that can set up between this client is connected.The concrete XMPP that sets up with this client connects and can be: inquire about and whether preserve the XMPP user name corresponding with described account, if so, then under described XMPP user name, foundation is connected with between described client; If not, then the XMPP user name that establishment one is corresponding with described account, and under described XMPP user name, set up and be connected with between described client.Such as, the incidence relation table between social network sites account (or social network sites user name) and this XMPP user name can be preserved in XMPP server.Setting up before XMPP is connected with this client, inquire about in this incidence relation table and whether preserve the XMPP user name corresponding with the account used during this client logs, if existed, then can under this XMPP user name, set up this XMPP user name to be connected with the XMPP between client, if there is no, then need to create XMPP user name corresponding to the account of this social network sites.
By the method for the present embodiment, when social network sites is the Website development api interface of XMPP server to third party, the user of social network sites can use account and the password login third party XMPP server of social network sites, thus realizes third party website and utilize the existing subscriber group of social network sites to set up the object of good social networks.
Also comprise before XMPP server is verified the log-on message that client sends: whether the form of the described log-on message received described in judgement meets the form of the account registered in XMPP server, if so, then carry out using the account of XMPP server to log in the proof procedure of XMPP server; If not, then the step of follow-up judgement identification information is carried out.Such as, when using the account of XMPP server to carry out login XMPP server, user is at client input account and password, the form of this account is: nodedomain/resource, node wherein, domain and resource field identifies user respectively, the server that user connects, and the resource of user in order to connect; And when client uses the account of social network sites to log in XMPP server, the form sending log-on message can be: " account number information social network sites mark ", can judge whether it is use social network sites account to log according to the form of log-on message.Certainly, as long as the form of the log-on message of transmission can have and multiplely be different from the account form registered in XMPP server, do not enumerate at this.
In order to understand the application process of the method for the invention better, see Fig. 2, be the method flow diagram of another embodiment of the present invention, the method comprising the steps of:
Step S201: receive client by accessing the HTTP entrance of specifying, the account of the use social network sites sent carries out the request logged in, wherein, the HTTP entrance XMPP server of specifying is use the account of certain specific social network sites to carry out logging in arranging;
Step S202: the third party returning described social network sites for described client logs in entrance, so that the account that user logs in entrance input social network sites by client described third party logs in described social network sites;
Step S203: the account number information that the server receiving described social network sites when client returns and digital signature, and using " account number information social network sites mark " as user name, digital signature as login password form send logging request time, receive described logging request;
Step S204: judge whether the user name in described logging request is use the account of social network sites to carry out the form logged in, and if so, then enters step S205; If not, step S206 is entered;
Step S205: according to the social network sites mark in user name, judge the social network sites of described social network sites mark ownership, and according in advance with the key of the server commitment of this social network sites, account number information in user name is generated digital signature, judge whether the digital signature generated mates with the digital signature received, if so, then foundation is connected with the XMPP between described client.
Step S206: then adopt the username and password inquiring about preservation in XMPP server to carry out the login process verified.
Corresponding method of the present invention, present invention also offers a kind of system realizing logging in XMPP server, see Fig. 3, system of the present invention comprises:
Request receiving module 301, the account for receiving client choice for use social network sites carries out the request logged in;
Redirection module 302, for after request receiving module receives described request, the third party returning described social network sites for described client logs in entrance, so that user logs in entrance input account by client described third party log in described social network sites;
Information receiving module 303, for the account visit information that the server receiving described social network sites when client returns, and when the identification information of described social network sites and described account visit information are sent as log-on message, receive described log-on message, described account visit information comprises account number information;
Information judging unit 304, for judging the social network sites of the identification information ownership of described social network sites, and according to the rule formulated with the server of this social network sites in advance, judge whether described account visit information meets registration conditions, if so, then foundation is connected with the XMPP between described client.
Wherein, described account number information comprises: the login sessions mark of the user ID of described account, described account and/or session expired time.
Send the difference of connection request mode used according to client, request receiving module comprises:
First request receiving module, for receiving client by accessing the HTTP entrance of specifying, the account of the use social network sites sent carries out the request logged in, and wherein, the HTTP entrance XMPP server of specifying is use the account of certain specific social network sites to carry out logging in arranging.
Second request receiving module, for receiving the option of client by choice for use social network sites account login on a user interface, the logging request sent;
After the second request receiving module receives this request, respective handling is carried out by redirection module, in this situation, redirection module comprises: the second redirection module, for receiving after logging request when the second request reception unit, needing to access by XML data stream notice client the third party that described social network sites server specifies and logging in entrance.
Further, described account visit information also comprises: social network sites according to the key of arranging with XMPP server in advance, to the digital signature that described account number information generates.
When the digital signature that the server that account visit information comprises social network sites returns, judge whether account number information meets login and carry part, can by judging that the mode of digital signature realizes, corresponding described information judging unit comprises: information judgement subunit, for according in advance with the key of this social network sites server commitment, the account number information described client sent generates digital signature, judge whether the digital signature that this digital signature and described account visit information comprise mates, if so, then registration conditions is met.
When described account number information conforms registration conditions, the XMPP server just XMPP that can set up between this client is connected.Setting up with this client the mode that XMPP is connected can have multiple, and further, information judging unit comprises:
Connection establishment unit, for when described account number information conforms registration conditions, whether inquiry preserves the XMPP user corresponding with described account, if so, then under described XMPP user name, sets up and is connected with between described client; If not, then the XMPP user that establishment one is corresponding with described account, and then under described XMPP user name, set up and be connected with between described client.
In this specification, each embodiment adopts the mode of going forward one by one to describe, and what each embodiment stressed is the difference with other embodiments, between each embodiment identical similar portion mutually see.For system disclosed in embodiment, because it corresponds to the method disclosed in Example, so description is fairly simple, relevant part illustrates see method part.
To the above-mentioned explanation of the disclosed embodiments, professional and technical personnel in the field are realized or uses the present invention.To be apparent for those skilled in the art to the multiple amendment of these embodiments, General Principle as defined herein can without departing from the spirit or scope of the present invention, realize in other embodiments.Therefore, the present invention can not be restricted to these embodiments shown in this article, but will meet the widest scope consistent with principle disclosed herein and features of novelty.