[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/mnet/ -> lib.php (summary)

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: 589 lines (22 kb)
Included or required:0 times
Referenced: 3 times
Includes or requires: 0 files

Defines 12 functions

  mnet_get_hostname_from_uri()
  mnet_get_public_key()
  mnet_set_public_key()
  mnet_sign_message()
  mnet_encrypt_message()
  mnet_get_keypair()
  mnet_generate_keypair()
  ip_in_range()
  mnet_permit_rpc_call()
  mnet_update_sso_access_control()
  mnet_get_peer_host()
  mnet_sso_apply_indirection()

Functions
Functions that are not part of a class:

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

ip_in_range($address, $network, $mask)   X-Ref
Check that an IP address falls within the given network/mask
ok for export

param: string   $address        Dotted quad
param: string   $network        Dotted quad
param: string   $mask           A number, e.g. 16, 24, 32
return: bool

mnet_permit_rpc_call($includefile, $functionname, $class=false)   X-Ref
Check that a given function (or method) in an include file has been designated
ok for export

param: string   $includefile    The path to the include file
param: string   $functionname   The name of the function (or method) to
param: mixed    $class          A class name, or false if we're just testing
return: int                      Zero (RPC_OK) if all ok - appropriate

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($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.

uses global MNETIDPJUMPURL the url which user should initially be directed to
MNETIDPJUMPURL is a URL associated with a moodle networking peer when it
is fulfiling a role as an identity provider (IDP). Different urls for
different peers, the jumpurl is formed partly from the IDP's webroot, and
partly from a predefined local path within that webwroot.
The result of the user hitting MNETIDPJUMPURL is that they will be asked
to login (at their identity provider (if they aren't already)), mnet
will prepare the necessary authentication information, then redirect
them back to somewhere at the content provider(CP) moodle (this moodle)
param: array $url array with 2 elements
return: string the url the remote user should be supplied with.



Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7