roster_server Package

roster_server Package

Toplevel RosterServer API. This presents entities to external consumers.

class roster_server.__init__.Server(config_instance, keyfile=None, certfile=None, inf_renew_time=None, core_die_time=None, clean_time=None, unittest_timestamp=None, unit_test=False)

Bases: object

Daemon library used to serve commands to the client.

CleanupCoreStore()

Cleans up expired instances in core_store

CoreRun(function, user_name, credfile, args=None, kwargs=None)

Runs a function in core_instance with arbitrary parameters

Inputs:
function: name of the function to be run user_name: user running the function args: list of arguments to be passed to function kwargs: dictionary of keyword arguments to be passed to function
Outputs:
dictionary: dictionary of return from function run and new cred string
example: {‘core_return’: returned_data,
‘new_credential’: u’
be4d4ecf-d670-44a0-b957-770e118e2755’}
GetCoreInstance(user_name)

Finds core instance in core store, if one cannot be found it will be created.

Inputs:
user_name: string of user name
Outputs:
instance: instance of dnsmgmtcore
GetCredentials(user_name, password)

Connects to credential cache and gets a credential file.

Inputs:
user_name: string of user name password: string of password (plaintext)
Outputs:
string: string of credential
example: u’be4d4ecf-d670-44a0-b957-770e118e2755’
GetVersion()
IsAuthenticated(user_name, credstring)

Checks if string is valid.

Inputs:
credstring: string of credential
Outputs:
bool: bool of valid string
LogException(function, args, kwargs, user_name)

Save functions traceback to logfile

Inputs:
function: string of function name args: args list kwargs: keyword args dict user_name: username string
Outputs:
str: uuid string from logfile
LogMessage(log_message, user_name)

Save a message to the logfile

Inputs:
log_message: string of the log message user_name: username string
Outputs:
str: uuid string from logfile
Serve(server_name=None, port=None)

Main server function

Inputs:
server_name: name of server you wish to create port: listening port number of server
StringToUnicode(object_to_convert)

Converts objects recursively into strings.

Inputs:
object_to_convert: the object that needs to be converted to unicode
Outputs:
converted_object: object can vary type, but all strings will be unicode

auth_pam Module

PAM module for Pluggable Authentication Module in RosterServer.

class roster_server.auth_pam.AuthenticationMethod(module=<module 'pam' from '/usr/lib/python2.6/site-packages/pam-0.1.4-py2.6.egg/pam.pyc'>)[source]

PAM authentication method,

Authenticate(user_name=None, password=None)[source]

Check, using PAM, if the user_name and password provided match. Inputs:

user_name: string of user name. password: string of password
Outputs:
boolean: authentication success
exception roster_server.auth_pam.PAMInputError[source]

Bases: exceptions.Exception

credentials Module

Credential caching for XMLRPC services.

exception roster_server.credentials.ConfigError[source]

Bases: exceptions.Exception

class roster_server.credentials.CredCache(config_instance, inf_renew_time, unit_test=False)[source]

Bases: object

Credentials cache for XMLRPC services.

Authenticated users are given a time-limited credential. Credentials map to Core instances, and can be used for repeated calls from a client.

CredCaches also handle verifying credentials, and invoking API calls as those credentials.

Authenticate(user_name, password)[source]

Authenticates user against authentication method

Inputs:
user_name: string of user name password: string of password
Outputs:
boolean of whether or not user is authenticated
CheckCredential(credential, user_name, core_instance)[source]

Checks users credential against database.

Inputs:
credential: string of credential core_instance: instance of Core
Outputs:
string or None, None if not authenticated, empty string if authenticated, string with new uuid if infinite key is being refreshed example: None, u’‘, u’be4d4ecf-d670-44a0-b957-770e118e2755’
GetCredentials(user_name, password, core_instance)[source]

Return a valid credential string given a username and password.

Inputs:
user_name: strin of login for a user password: string of user’s password core_instance: instance of Core
Outputs:
string: credential string
example: u’be4d4ecf-d670-44a0-b957-770e118e2755’
Raises:
AuthError Raised on invalid username/password combination

general_ldap Module

General LDAP module for LDAP authentication in RosterServer.

class roster_server.general_ldap.AuthenticationMethod(ldap_module=<module 'ldap' from '/usr/lib64/python2.6/site-packages/ldap/__init__.pyc'>)[source]

Bases: object

General LDAP authentication method, should work for most LDAP applications.

Authenticate(user_name=None, password=None, binddn=None, cert_file=None, server=None, version=None, tls=None)[source]

Authenticate method for LDAP

Inputs:
user_name: string of user name password: string of password binddn: string of binddn line cert_file: string of cert file location server: string of server url version: string of version constant from ldap module tls: string of tls enabled or not
Outputs:
boolean: authenticated or not
exception roster_server.general_ldap.GeneralLDAPConfigError[source]

Bases: exceptions.Exception

server Module

Server library for XML RPC Allows client to connect and run arbitrary functions in core.py.

exception roster_server.server.ArgumentError[source]

Bases: roster_core.errors.CoreError

exception roster_server.server.FunctionError[source]

Bases: roster_core.errors.CoreError

class roster_server.server.Server(config_instance, keyfile=None, certfile=None, inf_renew_time=None, core_die_time=None, clean_time=None, unittest_timestamp=None, unit_test=False)[source]

Bases: object

Daemon library used to serve commands to the client.

CleanupCoreStore()[source]

Cleans up expired instances in core_store

CoreRun(function, user_name, credfile, args=None, kwargs=None)[source]

Runs a function in core_instance with arbitrary parameters

Inputs:
function: name of the function to be run user_name: user running the function args: list of arguments to be passed to function kwargs: dictionary of keyword arguments to be passed to function
Outputs:
dictionary: dictionary of return from function run and new cred string
example: {‘core_return’: returned_data,
‘new_credential’: u’
be4d4ecf-d670-44a0-b957-770e118e2755’}
GetCoreInstance(user_name)[source]

Finds core instance in core store, if one cannot be found it will be created.

Inputs:
user_name: string of user name
Outputs:
instance: instance of dnsmgmtcore
GetCredentials(user_name, password)[source]

Connects to credential cache and gets a credential file.

Inputs:
user_name: string of user name password: string of password (plaintext)
Outputs:
string: string of credential
example: u’be4d4ecf-d670-44a0-b957-770e118e2755’
GetVersion()[source]
IsAuthenticated(user_name, credstring)[source]

Checks if string is valid.

Inputs:
credstring: string of credential
Outputs:
bool: bool of valid string
LogException(function, args, kwargs, user_name)[source]

Save functions traceback to logfile

Inputs:
function: string of function name args: args list kwargs: keyword args dict user_name: username string
Outputs:
str: uuid string from logfile
LogMessage(log_message, user_name)[source]

Save a message to the logfile

Inputs:
log_message: string of the log message user_name: username string
Outputs:
str: uuid string from logfile
Serve(server_name=None, port=None)[source]

Main server function

Inputs:
server_name: name of server you wish to create port: listening port number of server
StringToUnicode(object_to_convert)[source]

Converts objects recursively into strings.

Inputs:
object_to_convert: the object that needs to be converted to unicode
Outputs:
converted_object: object can vary type, but all strings will be unicode
exception roster_server.server.ServerError[source]

Bases: roster_core.errors.CoreError

class roster_server.server.ThreadedXMLRPCServer(server_address, HandlerClass, keyfile, certfile, logRequests=False)[source]

Bases: SocketServer.ThreadingMixIn, roster_server.ssl_xml_rpc_lib.SecureXMLRPCServer

ssl_xml_rpc_lib Module

Secure server library for XML RPC SSL wrapper for SimpleXMLRPCServer.

Most of code is from an example at: http://code.activestate.com/recipes/496786/

class roster_server.ssl_xml_rpc_lib.SecureXMLRPCServer(server_address, HandlerClass, keyfile, certfile, logRequests=False)[source]

Bases: BaseHTTPServer.HTTPServer, SimpleXMLRPCServer.SimpleXMLRPCDispatcher

Sets up the XML RPC server to use SSL

class roster_server.ssl_xml_rpc_lib.SecureXMLRpcRequestHandler(request, client_address, server)[source]

Bases: SimpleXMLRPCServer.SimpleXMLRPCRequestHandler

Sets up the XML RPC handler to use SSL

do_POST()[source]

Handles the HTTPS post

setup()[source]

Set up SSL transport