Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]
Library functions for mnet
Author: | Donal McMullan donal@catalyst.net.nz |
License: | http://www.gnu.org/copyleft/gpl.html GNU Public License |
Version: | 0.0.1 |
File Size: | 924 lines (34 kb) |
Included or required: | 0 times |
Referenced: | 10 times |
Includes or requires: | 0 files |
mnet_get_hostname_from_uri($uri = null) X-Ref |
Strip extraneous detail from a URL or URI and return the hostname param: string $uri The URI of a file on the remote computer, optionally return: string Just the hostname |
mnet_get_public_key($uri, $application=null) X-Ref |
Get the remote machine's SSL Cert param: string $uri The URI of a file on the remote computer, including return: string A PEM formatted SSL Certificate. |
mnet_set_public_key($uri, $key = null) X-Ref |
Store a URI's public key in a static variable, or retrieve the key for a URI param: string $uri The URI of a file on the remote computer, including its param: mixed $key A public key to store in the array OR null. If the key return: mixed A public key OR true/false. |
mnet_sign_message($message, $privatekey = null) X-Ref |
Sign a message and return it in an XML-Signature document This function can sign any content, but it was written to provide a system of signing XML-RPC request and response messages. The message will be base64 encoded, so it does not need to be text. We compute the SHA1 digest of the message. We compute a signature on that digest with our private key. We link to the public key that can be used to verify our signature. We base64 the message data. We identify our wwwroot - this must match our certificate's CN The XML-RPC document will be parceled inside an XML-SIG document, which holds the base64_encoded XML as an object, the SHA1 digest of that document, and a signature of that document using the local private key. This signature will uniquely identify the RPC document as having come from this server. See the {@Link http://www.w3.org/TR/xmldsig-core/ XML-DSig spec} at the W3c site param: string $message The data you want to sign param: resource $privatekey The private key to sign the response with return: string An XML-DSig document |
mnet_encrypt_message($message, $remote_certificate) X-Ref |
Encrypt a message and return it in an XML-Encrypted document This function can encrypt any content, but it was written to provide a system of encrypting XML-RPC request and response messages. The message will be base64 encoded, so it does not need to be text - binary data should work. We compute the SHA1 digest of the message. We compute a signature on that digest with our private key. We link to the public key that can be used to verify our signature. We base64 the message data. We identify our wwwroot - this must match our certificate's CN The XML-RPC document will be parceled inside an XML-SIG document, which holds the base64_encoded XML as an object, the SHA1 digest of that document, and a signature of that document using the local private key. This signature will uniquely identify the RPC document as having come from this server. See the {@Link http://www.w3.org/TR/xmlenc-core/ XML-ENC spec} at the W3c site param: string $message The data you want to sign param: string $remote_certificate Peer's certificate in PEM format return: string An XML-ENC document |
mnet_get_keypair() X-Ref |
Get your SSL keys from the database, or create them (if they don't exist yet) Get your SSL keys from the database, or (if they don't exist yet) call mnet_generate_keypair to create them param: string $string The text you want to sign return: string The signature over that text |
mnet_generate_keypair($dn = null, $days=28) X-Ref |
Generate public/private keys and store in the config table Use the distinguished name provided to create a CSR, and then sign that CSR with the same credentials. Store the keypair you create in the config table. If a distinguished name is not provided, create one using the fullname of 'the course with ID 1' as your organization name, and your hostname (as detailed in $CFG->wwwroot). param: array $dn The distinguished name of the server return: string The signature over that text |
mnet_update_sso_access_control($username, $mnet_host_id, $accessctrl) X-Ref |
No description |
mnet_get_peer_host($mnethostid) X-Ref |
No description |
mnet_sso_apply_indirection($jumpurl, $url) X-Ref |
Inline function to modify a url string so that mnet users are requested to log in at their mnet identity provider (if they are not already logged in) before ultimately being directed to the original url. param: string $jumpurl the url which user should initially be directed to. param: array $url array with 2 elements return: string the url the remote user should be supplied with. |
mnet_get_app_jumppath($applicationid) X-Ref |
No description |
mnet_debug($debugdata, $debuglevel=1) X-Ref |
Output debug information about mnet. this will go to the <b>error_log</b>. param: mixed $debugdata this can be a string, or array or object. param: int $debuglevel optional , defaults to 1. bump up for very noisy debug info |
mnet_profile_field_options() X-Ref |
Return an array of information about all moodle's profile fields which ones are optional, which ones are forced. This is used as the basis of providing lists of profile fields to the administrator to pick which fields to import/export over MNET return: array(forced => array, optional => array) |
mnet_get_hosts($withdeleted = false) X-Ref |
Returns information about MNet peers param: bool $withdeleted should the deleted peers be returned too return: array |
mnet_get_service_info(mnet_peer $mnet_peer, $fulldata=true) X-Ref |
return an array information about services enabled for the given peer. in two modes, fulldata or very basic data. param: mnet_peer $mnet_peer the peer to get information abut param: boolean $fulldata whether to just return which services are published/subscribed, or more information (defaults to full) return: array If $fulldata is false, an array is returned like: |
mnet_fields_to_send(mnet_peer $peer) X-Ref |
return an array of the profile fields to send with user information to the given mnet host. param: mnet_peer $peer the peer to send the information to return: array (like 'username', 'firstname', etc) |
mnet_fields_to_import(mnet_peer $peer) X-Ref |
return an array of the profile fields to import from the given host, when creating/updating user accounts param: mnet_peer $peer the peer we're getting the information from return: array (like 'username', 'firstname', etc) |
_mnet_field_helper(mnet_peer $peer, $key) X-Ref |
helper for {@see mnet_fields_to_import} and {@mnet_fields_to_send} param: mnet_peer $peer the peer object param: string $key 'import' or 'export' return: array (like 'username', 'firstname', etc) |
mnet_strip_user($user, $fields) X-Ref |
given a user object (or array) and a list of allowed fields, strip out all the fields that should not be included. This can be used both for outgoing data and incoming data. param: mixed $user array or object representing a database record param: array $fields an array of allowed fields (usually from mnet_fields_to_{send,import} return: mixed array or object, depending what type of $user object was passed (datatype is respected) |