예제 #1
0
파일: index.php 프로젝트: evltuma/moodle
<?php

// Allows the admin to configure mnet stuff
require __DIR__ . '/../../config.php';
require_once $CFG->libdir . '/adminlib.php';
include_once $CFG->dirroot . '/mnet/lib.php';
require_login();
admin_externalpage_setup('net');
$context = context_system::instance();
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
$site = get_site();
$mnet = get_mnet_environment();
if (!extension_loaded('openssl')) {
    echo $OUTPUT->header();
    set_config('mnet_dispatcher_mode', 'off');
    print_error('requiresopenssl', 'mnet');
}
if (!function_exists('curl_init')) {
    echo $OUTPUT->header();
    set_config('mnet_dispatcher_mode', 'off');
    print_error('nocurl', 'mnet');
}
if (!isset($CFG->mnet_dispatcher_mode)) {
    set_config('mnet_dispatcher_mode', 'off');
}
/// If data submitted, process and store
if (($form = data_submitted()) && confirm_sesskey()) {
    if (!empty($form->submit) && $form->submit == get_string('savechanges')) {
        if (in_array($form->mode, array("off", "strict", "dangerous"))) {
            if (set_config('mnet_dispatcher_mode', $form->mode)) {
                redirect('index.php', get_string('changessaved'));
예제 #2
0
파일: serverlib.php 프로젝트: JP-Git/moodle
/**
 * Accepts a public key from a new remote host and returns the public key for
 * this host. If 'register all hosts' is turned on, it will bootstrap a record
 * for the remote host in the mnet_host table (if it's not already there)
 *
 * @param  string  $function      XML-RPC requires this but we don't... discard!
 * @param  array   $params        Array of parameters
 *                                $params[0] is the remote wwwroot
 *                                $params[1] is the remote public key
 * @return string                 The XML-RPC response
 */
function mnet_keyswap($function, $params) {
    global $CFG;
    $return = array();
    $mnet = get_mnet_environment();

    if (!empty($CFG->mnet_register_allhosts)) {
        $mnet_peer = new mnet_peer();
        @list($wwwroot, $pubkey, $application) = each($params);
        $keyok = $mnet_peer->bootstrap($wwwroot, $pubkey, $application);
        if ($keyok) {
            $mnet_peer->commit();
        }
    }
    return $mnet->public_key;
}
 /**
  * Constructor.
  */
 function auth_plugin_mnet()
 {
     $this->authtype = 'mnet';
     $this->config = get_config('auth_mnet');
     $this->mnet = get_mnet_environment();
 }
예제 #4
0
파일: lib.php 프로젝트: JP-Git/moodle
/**
 * 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
 */
function mnet_encrypt_message($message, $remote_certificate) {
    $mnet = get_mnet_environment();

    // Generate a key resource from the remote_certificate text string
    $publickey = openssl_get_publickey($remote_certificate);

    if ( gettype($publickey) != 'resource' ) {
        // Remote certificate is faulty.
        return false;
    }

    // Initialize vars
    $encryptedstring = '';
    $symmetric_keys = array();

    //        passed by ref ->     &$encryptedstring &$symmetric_keys
    $bool = openssl_seal($message, $encryptedstring, $symmetric_keys, array($publickey));
    $message = $encryptedstring;
    $symmetrickey = array_pop($symmetric_keys);

    $message = '<?xml version="1.0" encoding="iso-8859-1"?>
    <encryptedMessage>
        <EncryptedData Id="ED" xmlns="http://www.w3.org/2001/04/xmlenc#">
            <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#arcfour"/>
            <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
                <ds:RetrievalMethod URI="#EK" Type="http://www.w3.org/2001/04/xmlenc#EncryptedKey"/>
                <ds:KeyName>XMLENC</ds:KeyName>
            </ds:KeyInfo>
            <CipherData>
                <CipherValue>'.base64_encode($message).'</CipherValue>
            </CipherData>
        </EncryptedData>
        <EncryptedKey Id="EK" xmlns="http://www.w3.org/2001/04/xmlenc#">
            <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5"/>
            <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
                <ds:KeyName>SSLKEY</ds:KeyName>
            </ds:KeyInfo>
            <CipherData>
                <CipherValue>'.base64_encode($symmetrickey).'</CipherValue>
            </CipherData>
            <ReferenceList>
                <DataReference URI="#ED"/>
            </ReferenceList>
            <CarriedKeyName>XMLENC</CarriedKeyName>
        </EncryptedKey>
        <wwwroot>'.$mnet->wwwroot.'</wwwroot>
    </encryptedMessage>';
    return $message;
}
예제 #5
0
파일: lib.php 프로젝트: JP-Git/moodle
 public function __wakeup() {
     $this->mnet = get_mnet_environment();
 }
예제 #6
0
 /**
  * Constructor.
  */
 public function __construct()
 {
     $this->authtype = 'mnet';
     $this->config = get_config('auth_mnet');
     $this->mnet = get_mnet_environment();
 }
예제 #7
0
파일: client.php 프로젝트: vuchannguyen/web
 /**
  * Constructor returns true
  */
 function mnet_xmlrpc_client()
 {
     // make sure we've got this set up before we try and do anything else
     $this->mnet = get_mnet_environment();
     return true;
 }
 public function replaceMnetKeys()
 {
     $mnet = get_mnet_environment();
     $mnet->replace_keys();
 }
예제 #9
0
/**
* will provide all ent specific initializers after install
*
*/
function xmldb_local_ent_installer_install()
{
    global $DB, $CFG;
    mtrace("Installing local distribution configurations");
    // initalize MNET and ensure providing a first key
    // Unfortunately, during initial install, a suitable key pair WILL NOT be generated.
    // This will be fixed by further fix_config.php script.
    $mnet = get_mnet_environment();
    $mnet->init();
    // Init mnet auth.
    $authcontrol = new auth_remote_control('auth', 'mnet');
    $authcontrol->action('enable');
    // Disable IMS module.
    $authcontrol = new mod_remote_control('mod', 'imscp');
    $authcontrol->action('disable');
    // ## Publishflow
    // initiate publishflow platform type
    set_config('moodlenodetype', 'factory,catalog');
    // initiate publishflow retrofit mode for common
    set_config('enableretrofit', 1);
    // initiate publishflow files delivery
    set_config('coursedeliveryislocal', 1);
    // initiate publishflow categories
    set_config('coursedelivery_deploycategory', 1);
    // initiate publishflow categories
    set_config('coursedelivery_runningcategory', 1);
    // initiate publishflow categories
    set_config('coursedelivery_closedcategory', 1);
    // initiate publishflow topology prefixes
    set_config('mainhostprefix', 'http://commun');
    // initiate publishflow topology prefixes
    set_config('factoryprefix', 'http://commun');
    // initiate publishflow topology refresh
    set_config('coursedelivery_networkrefreshautomation', 604800);
    // ## sharedresource
    // initiate sharedresource model
    set_config('pluginchoice', 'scolomfr');
    // ## enhanced my
    // enable enhanced my
    set_config('localmyenable', 1);
    // enable my pinting categories
    set_config('localmyprintcategories', 1);
    // initiaing my enhanced module list
    set_config('localmymodules', "my_caption\nme\nleft_edition_column\nmy_courses\nauthored_courses\ncourse_areas\nauthored_courses\navailable_courses\nlatestnews_simple");
    // ## Adjust some fields length
    $dbman = $DB->get_manager();
    $table = new xmldb_table('user');
    $field = new xmldb_field('department');
    $field->set_attributes(XMLDB_TYPE_CHAR, '126', null, null, null, null, 'institution');
    $dbman->change_field_precision($table, $field);
    // ## Adding usertypes categorization
    $categoryrec = new StdClass();
    $categoryrec->name = ent_installer_string('usertypecategoryname');
    $oldcat = $DB->get_record('user_info_category', array('name' => $categoryrec->name));
    if (!$oldcat) {
        $usertypecategoryid = $DB->insert_record('user_info_category', $categoryrec);
    } else {
        $usertypecategoryid = $oldcat->id;
    }
    // ## Adding usertypes for ENT model
    $i = 0;
    $userfield = new StdClass();
    $userfield->name = ent_installer_string('usertypestudent');
    $userfield->shortname = 'eleve';
    $userfield->datatype = 'checkbox';
    $userfield->description = ent_installer_string('usertypestudentdesc');
    $userfield->descriptionformat = FORMAT_MOODLE;
    $userfield->categoryid = $usertypecategoryid;
    $userfield->sortorder = $i;
    $userfield->required = 0;
    $userfield->locked = 1;
    $userfield->visible = 0;
    $userfield->forceunique = 0;
    $userfield->signup = 0;
    if (!$DB->record_exists('user_info_field', array('shortname' => 'eleve'))) {
        $DB->insert_record('user_info_field', $userfield);
    }
    $i++;
    $userfield = new StdClass();
    $userfield->name = ent_installer_string('usertypeteacher');
    $userfield->shortname = 'enseignant';
    $userfield->datatype = 'checkbox';
    $userfield->description = ent_installer_string('usertypeteacherdesc');
    $userfield->descriptionformat = FORMAT_MOODLE;
    $userfield->categoryid = $usertypecategoryid;
    $userfield->sortorder = $i;
    $userfield->required = 0;
    $userfield->locked = 1;
    $userfield->visible = 0;
    $userfield->forceunique = 0;
    $userfield->signup = 0;
    if (!$DB->record_exists('user_info_field', array('shortname' => 'enseignant'))) {
        $DB->insert_record('user_info_field', $userfield);
    }
    $i++;
    $userfield = new StdClass();
    $userfield->name = ent_installer_string('usertypeparent');
    $userfield->shortname = 'parent';
    $userfield->datatype = 'checkbox';
    $userfield->description = ent_installer_string('usertypeparentdesc');
    $userfield->descriptionformat = FORMAT_MOODLE;
    $userfield->categoryid = $usertypecategoryid;
    $userfield->sortorder = $i;
    $userfield->required = 0;
    $userfield->locked = 1;
    $userfield->visible = 0;
    $userfield->forceunique = 0;
    $userfield->signup = 0;
    if (!$DB->record_exists('user_info_field', array('shortname' => 'parent'))) {
        $DB->insert_record('user_info_field', $userfield);
    }
    $i++;
    $userfield = new StdClass();
    $userfield->name = ent_installer_string('usertypestaff');
    $userfield->shortname = 'administration';
    $userfield->datatype = 'checkbox';
    $userfield->description = ent_installer_string('usertypestaffdesc');
    $userfield->descriptionformat = FORMAT_MOODLE;
    $userfield->categoryid = $usertypecategoryid;
    $userfield->sortorder = $i;
    $userfield->required = 0;
    $userfield->locked = 1;
    $userfield->visible = 0;
    $userfield->forceunique = 0;
    $userfield->signup = 0;
    if (!$DB->record_exists('user_info_field', array('shortname' => 'administration'))) {
        $DB->insert_record('user_info_field', $userfield);
    }
    $i++;
    $userfield = new StdClass();
    $userfield->name = ent_installer_string('usertypeworkmanager');
    $userfield->shortname = 'cdt';
    $userfield->datatype = 'checkbox';
    $userfield->description = ent_installer_string('usertypeworkmanagerdesc');
    $userfield->descriptionformat = FORMAT_MOODLE;
    $userfield->categoryid = $usertypecategoryid;
    $userfield->sortorder = $i;
    $userfield->required = 0;
    $userfield->locked = 1;
    $userfield->visible = 0;
    $userfield->forceunique = 0;
    $userfield->signup = 0;
    if (!$DB->record_exists('user_info_field', array('shortname' => 'cdt'))) {
        $DB->insert_record('user_info_field', $userfield);
    }
    // ## Adding academic information
    $categoryrec = new StdClass();
    $categoryrec->name = ent_installer_string('academicinfocategoryname');
    $academicinfocategoryid = $DB->insert_record('user_info_category', $categoryrec);
    $i = 0;
    $userfield = new StdClass();
    $userfield->name = ent_installer_string('transport');
    $userfield->shortname = 'transport';
    $userfield->datatype = 'checkbox';
    $userfield->description = ent_installer_string('transportdesc');
    $userfield->descriptionformat = FORMAT_MOODLE;
    $userfield->categoryid = $academicinfocategoryid;
    $userfield->sortorder = $i;
    $userfield->required = 0;
    $userfield->locked = 1;
    $userfield->visible = 0;
    $userfield->forceunique = 0;
    $userfield->signup = 0;
    if (!$DB->record_exists('user_info_field', array('shortname' => 'transport'))) {
        $DB->insert_record('user_info_field', $userfield);
    }
    $i++;
    $userfield = new StdClass();
    $userfield->name = ent_installer_string('cohort');
    $userfield->shortname = 'cohort';
    $userfield->datatype = 'text';
    $userfield->description = ent_installer_string('cohortdesc');
    $userfield->descriptionformat = FORMAT_MOODLE;
    $userfield->categoryid = $academicinfocategoryid;
    $userfield->sortorder = $i;
    $userfield->required = 0;
    $userfield->locked = 1;
    $userfield->visible = 0;
    $userfield->forceunique = 0;
    $userfield->signup = 0;
    $userfield->param1 = 30;
    $userfield->param2 = 32;
    if (!$DB->record_exists('user_info_field', array('shortname' => 'cohort'))) {
        $DB->insert_record('user_info_field', $userfield);
    }
    $i++;
    $userfield = new StdClass();
    $userfield->name = ent_installer_string('regime');
    $userfield->shortname = 'regime';
    $userfield->datatype = 'text';
    $userfield->description = ent_installer_string('regimedesc');
    $userfield->descriptionformat = FORMAT_MOODLE;
    $userfield->categoryid = $academicinfocategoryid;
    $userfield->sortorder = $i;
    $userfield->required = 0;
    $userfield->locked = 1;
    $userfield->visible = 0;
    $userfield->forceunique = 0;
    $userfield->signup = 0;
    $userfield->param1 = 30;
    $userfield->param2 = 128;
    if (!$DB->record_exists('user_info_field', array('shortname' => 'regime'))) {
        $DB->insert_record('user_info_field', $userfield);
    }
    return true;
}
예제 #10
0
파일: client.php 프로젝트: evltuma/moodle
 /**
  * Constructor
  */
 public function __construct()
 {
     // make sure we've got this set up before we try and do anything else
     $this->mnet = get_mnet_environment();
 }