# User Service Plugin Readme

## Overview

The User Service Plugin provides the ability to add,edit,delete users by sending an http request to the server. It is intended to be used by applications automating the user administration process. This plugin's functionality is useful for applications that need to administer users outside of the Wildfire admin console. An example of such an application might be a live sports reporting application that uses XMPP as its transport, and creates/deletes users according to the receipt, or non receipt, of a subscription fee.

## Installation

Copy userservice.jar into the plugins directory of your Wildfire server. The plugin will then be automatically deployed. To upgrade to a new version, copy the new userservice.jar file over the existing file.

## Configuration

Access to the service is restricted with a "secret" that can be viewed and set from the User Service page in the Wildfire admin console This should really only be considered weak security. The plugin was initially written with the assumption that http access to the Wildfire service was only available to trusted machines. In the case of the plugin's author, a web application running on the same server as Wildfire makes the request.

## Using the Plugin

To administer users, submit HTTP requests to the userservice service. The service address is [hostname]plugins/userService/userservice. For example, if your server name is "example.com", the URL is http://example.com/plugins/userService/userservice

The following parameters can be passed into the request:

Name | Description
--- | ---
type | Required | The admin service required. Possible values are add, delete, update
secret | required | The secret key that allows access to the User Service.
jid | required for delete and update operations | The bare JID (address) of the user to be administered(ie includes @yourdomain.com).
username | required for add operation | The username of the new user. ie the part before the @ symbol.
password | required for add operation | The password of the new user or the user being updated.
name | optional | The display name of the new user or the user being updated.
email | optional | The email address of the new user or the user being updated.

Sample HTML

The following example adds a user

http://example.com:9090/plugins/userService/userservice?type=add&secret=bigsecret&username=kafka&password=drowssap&name=franz&email=franz@kafka.com

The following example deletes a user

http://example.com:9090/plugins/userService/userservice?type=delete&secret=bigsecret&jid=kafka@example.com

This example updates a user

http://example.com:9090/plugins/userService/userservice?type=update&secret=bigsecret&jid=kafka@example.com&password=drowssap&name=franz&email=beetle@kafka.com

* When sending double characters (Chinese/Japanese/Korean etc) you should URLEncode the string as utf8.
In Java this is done like this
URLEncoder.encode(username, "UTF-8"));
If the strings are encoded incorrectly, double byte characters will look garbeled in the Admin Console.

## Server Reply

The server will reply to all User Service requests with an XML result page. If the request was processed successfully the return will be a "result" element with a text body of "OK". If the request was unsuccessful, the return will be an "error" element with a text body of one of the following error strings.

Error String | Description
--- | ---
IllegalArgumentException | one of the parameters passed in to the User Service was bad.
UserNotFoundException | No user of the name specified, for a delete or update operation, exists on this server.
UserAlreadyExistsException | A user with the same name as the user about to be added, already exists.
RequestNotAuthorised | The supplied secret does not match the secret specified in the Admin Console.
UserServiceDisabled | The User Service is currently set to disabled in the Admin Console.