User Registration Script

Currently, the Jabber technology has no concept of anonymous users—users who can connect to the server with no previous registration requirement. Until this is possible, we have to make do with creating specific users for specific scenarios.

To this end, it would be useful to be able to run a quick script to register a new user, rather than grab an existing client, start it up, and go through the process of registering a new user with the Jabber server, with whatever window navigation and mouse clicking that might entail. All the script must do is interact with the Jabber server in the context of the jabber:iq:register namespace, specifically, pre-session. It must be able to make a registration inquiry by sending an IQ-get and returning the fields listed in the result and to make a registration attempt, when supplied with values for the registration fields.

We should be able to invoke our script, reguser, in one of two ways. The first, specifying merely a hostname (and optional port, which will default to 5222 if not specified), implies a registration inquiry, that we wish to make an inquiry of the Jabber server as to (a) whether registration is possible and (b) if so, what fields are required. The second way, specifying not only the host and optional port but also a list of field name and value pairs, implies a registration attempt. Example 7-5 shows both these ways in action.

Example 7-5. Uses of the reguser script
$ ./reguser yak:5222 [Enquiry] ...

Get Programming Jabber now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.