Start of topic | Skip to actions
Connector InterfaceProvision System Request (PSR)Each method in the connector takes a psr as the only input. The psr object is defined in systems as a ProvisionRequest. This object wraps up all of the data that is passed into the Provision Manager to allow the connectors to process the requested data.
bg_initThe purpose of the background initialization is to perform any task that may take a long time. By moving the task to inside of the connector thread long pauses do not effect other systems loading or the service in general. bg_init should update the connectors status attribute (see systems.py) to properly reflect its state. Arguments: PSR, uid is usedReturns: 2 value tuple: True/False, initialization message (errors, all's well...) enable_accountThis method should enable the proper user's account. This may involve first creating an account or just adding the users name to the proper file. As always it is system specific. Arguments: PSR, uid is usedReturns: True/False disable_accountThis method should disable the proper user's account. This may involve deleting the account, hiding the account, or just locking the account from use. As always it is system specific. Arguments: PSR, uid is usedReturns: True/False get_account_infoThis method should return whatever information should be exposed about the user. If the requested user does not have an account in the system then the account status value should be systems.NO_ACCOUNT Roles are not supported so information either is or is not exposed to any client using the identity service. Consider the following example: Attributes in SomeDataStore for user 'cpepe' are: uid:cpepe, job:programmer, password:myPasswordIsAwesome, phone:781-555-5634 Passwords are sensitive data and generally aren't going to be passed around, especially if they are stored in clear text. get_account_info may only return the uid, job, and phone attributes while omitting the password. It is up to the connector to expose information to the identity service. Arguments: psr, Nothing is usedReturns: Dictionary of attributes and their current values update_accountThis method should use the input psr to update a users account information. As with get_account_info the connector has as much flexibility as it needs. Continuing with the example of SomeDataStore; the uid attribute is used as the key for the account and cannot be changed in most cases. Logic in this method can create readonly attributes to prevent them from being changed (assuming the end provisioning system would allow them to be changed). Arguments: PSR, Data contains a dictionary of attributes and values to be updatedReturns: True/False Example ConnectorThis is a fully functional and legitimate connector for use with the identity service. The enable and disable methods do nothing but do report success back to the Provision Manager. Enable/disable actions will be recorded as successful in the audit trail. The account information is created on the fly and complete nonsense however it could just as easily have been read from a database, flatfile, remote system, or any other data source. Similarly the update method merely prints out the input given to it but could use that information in any way that is relevant to the provision system it is connecting to.
"""
Test Connector to allow nop and test actions to query a running IDM server.
@author cpepe@brandeis.edu
@date 14 July 2008
"""
import os
import time
import systems
from systems import Connector
class TestConnector(Connector):
def __init__(self):
Connector.__init__(self, name='TestConnector',
configFile='/etc/identity/conf/connectors/test.conf')
def bg_init(self):
self.status = systems.LOADED
return True, 'Test connector loaded'
def enable_account(self, psr):
return True
def disable_account(self, psr):
return True
def get_account_info(self, psr):
"""
dummy up some information about the user that is 'stored' in the test connector
"""
import os
import random
return { psr.uid : {'uid': psr.uid, 'status': systems.ENABLED, 'random': random.randint(0,100)} }
def update_account(self, psr):
if type(psr.data) is not type(dict()):
logger.error('%s: [PSR %s] Account cannot be updated because data is in invalid format: %s' % (self.name, str(psr.id), str(psr.data)))
return False #<-- Early Return
for key, val in psr.data.iteritems():
print '%s: Pretending to update %s with %s' % (self.name, str(key), str(val))
return True
| |||||||||||||||||||||