org.elkoserver.server.context.users
Class DevicePersistentUserFactory

java.lang.Object
  extended by org.elkoserver.server.context.users.DevicePersistentUserFactory
All Implemented Interfaces:
UserFactory
Direct Known Subclasses:
DeviceEphemeralUserFactory

public class DevicePersistentUserFactory
extends Object
implements UserFactory

Factory that generates a persistent user object from connected mobile device information.


Nested Class Summary
protected static class DevicePersistentUserFactory.DeviceCredentials
          Struct object holding login info for a device user.
 
Constructor Summary
DevicePersistentUserFactory(String device)
          JSON-driven constructor.
 
Method Summary
protected  DevicePersistentUserFactory.DeviceCredentials extractCredentials(Trace appTrace, JSONObject param)
          Extract the user login credentials from a user factory parameter object.
 String getDevice()
          Obtain the name of the device this factory works with.
 void provideUser(Contextor contextor, Connection connection, JSONObject param, ArgRunnable handler)
          Produce a user object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DevicePersistentUserFactory

@JSONMethod(value="device")
public DevicePersistentUserFactory(String device)
JSON-driven constructor.

Parameters:
device - The name of the device (IOS, etc).
Method Detail

getDevice

public String getDevice()
Obtain the name of the device this factory works with.

Parameters:
return - this factory's device string.

provideUser

public void provideUser(Contextor contextor,
                        Connection connection,
                        JSONObject param,
                        ArgRunnable handler)
Produce a user object.

Specified by:
provideUser in interface UserFactory
Parameters:
contextor - The contextor of the server in which the requested user will be present
connection - The connection over which the new user presented themself.
param - Arbitary JSON object parameterizing the construction. this is analogous to the user record read from the ODB, but may be anything that makes sense for the particular factory implementation. Of course, the sender of this parameter must be coordinated with the factory implementation.
handler - Handler to be called with the result. The result will be the user object that was produced, or null if none could be.

extractCredentials

protected DevicePersistentUserFactory.DeviceCredentials extractCredentials(Trace appTrace,
                                                                           JSONObject param)
Extract the user login credentials from a user factory parameter object.

Parameters:
appTrace - Trace object for error logging
param - User factory parameters
Returns:
a credentials object as described by the parameter object given, or null if parameters were missing or invalide somehow.