$endpoint['force_ssl_trust'] = ibm_sbt_decrypt(IBM_SBT_SETTINGS_KEY, $record->force_ssl_trust, base64_decode($record->iv)); $endpoint['basic_auth_method'] = ibm_sbt_decrypt(IBM_SBT_SETTINGS_KEY, $record->basic_auth_method, base64_decode($record->iv)); $endpoint['basic_auth_password'] = ibm_sbt_decrypt(IBM_SBT_SETTINGS_KEY, $record->basic_auth_password, base64_decode($record->iv)); $endpoint['basic_auth_username'] = ibm_sbt_decrypt(IBM_SBT_SETTINGS_KEY, $record->basic_auth_username, base64_decode($record->iv)); $endpoint['auth_type'] = ibm_sbt_decrypt(IBM_SBT_SETTINGS_KEY, $record->auth_type, base64_decode($record->iv)); $endpoint['authorization_url'] = ibm_sbt_decrypt(IBM_SBT_SETTINGS_KEY, $record->authorization_url, base64_decode($record->iv)); $endpoint['oauth2_callback_url'] = ibm_sbt_decrypt(IBM_SBT_SETTINGS_KEY, $record->oauth2_callback_url, base64_decode($record->iv)); $endpoint['request_token_url'] = ibm_sbt_decrypt(IBM_SBT_SETTINGS_KEY, $record->request_token_url, base64_decode($record->iv)); $endpoint['client_secret'] = ibm_sbt_decrypt(IBM_SBT_SETTINGS_KEY, $record->client_secret, base64_decode($record->iv)); $endpoint['client_id'] = ibm_sbt_decrypt(IBM_SBT_SETTINGS_KEY, $record->client_id, base64_decode($record->iv)); $endpoint['consumer_secret'] = ibm_sbt_decrypt(IBM_SBT_SETTINGS_KEY, $record->consumer_secret, base64_decode($record->iv)); $endpoint['consumer_key'] = ibm_sbt_decrypt(IBM_SBT_SETTINGS_KEY, $record->consumer_key, base64_decode($record->iv)); $endpoint['access_token_url'] = ibm_sbt_decrypt(IBM_SBT_SETTINGS_KEY, $record->access_token_url, base64_decode($record->iv)); $endpoint['server_url'] = ibm_sbt_decrypt(IBM_SBT_SETTINGS_KEY, $record->server_url, base64_decode($record->iv)); $endpoint['name'] = ibm_sbt_decrypt(IBM_SBT_SETTINGS_KEY, $record->name, base64_decode($record->iv)); $endpoint['oauth_origin'] = ibm_sbt_decrypt(IBM_SBT_SETTINGS_KEY, $record->oauth_origin, base64_decode($record->iv)); echo json_encode($endpoint); } } } } } /** * Populates and encrypts the database record object with the submitted $_POST values. * * @param object $record * @return object */ function populateRecord($record) { $iv = null;
/** * Returns a value from the credentials store * * @param string $skey * @param string $endpoint * * @return */ private function _get($skey, $endpoint) { global $DB; global $USER; $uid = null; if (isset($USER->id) && $USER->id != 0) { $uid = $USER->id; } else { if (isset($_GET['uid'])) { $uid = $_GET['uid']; } else { if (isset($_COOKIE['ibm-sbt-uid']) && $_COOKIE['ibm-sbt-uid'] != null) { $uid = $_COOKIE['ibm-sbt-uid']; } else { if (self::$uid != null) { $uid = self::$uid; } else { return null; } } } } $record = $DB->get_record(SESSION_NAME, array('user_id' => intval($uid))); if ($record == null || empty($record)) { return null; } if (!isset($record->{$skey})) { $this->_initProfileSession(); } $endpointMappings = (array) json_decode($record->{$skey}); if ($endpointMappings == null) { return null; } // Get value, decrypt and return if (!isset($endpointMappings[$endpoint])) { return null; } $value = $endpointMappings[$endpoint]; if ($value == "" || $value == null) { return null; } $value = ibm_sbt_decrypt($this->key, $value, base64_decode($this->iv)); return $value; }
/** * Returns the authentication method used for basic authentication. * * @return string global|profile|prompt */ public function getBasicAuthMethod($endpoint = "connections") { global $DB; $endpoints = $DB->get_records(ENDPOINTS); foreach ($endpoints as $e) { $e->name = stripslashes(ibm_sbt_decrypt(IBM_SBT_SETTINGS_KEY, $e->name, base64_decode($e->iv))); if ($e->name == $endpoint) { return stripslashes(ibm_sbt_decrypt(IBM_SBT_SETTINGS_KEY, $e->basic_auth_method, base64_decode($e->iv))); } } return null; }
/** * Returns a value from the credentials store * * @param string $skey * @return */ private function _get($skey) { $data = null; if ($this->_isUserLoggedIn()) { $data = $this->_getSessionInfoFromProfile(); } else { $data = $this->_getSessionInfoFromCookie(); } $key = $data['key']; $iv = $data['iv']; $iv = base64_decode($iv); $sessionID = $data['sessionID']; // Get session $session = get_option($sessionID); if ($session === false) { return; } else { // Get value, decrypt and return if (!isset($session[$skey]) || !$session[$skey]) { return null; } $value = $session[$skey]; if ($value == "" || $value == null) { return null; } $value = ibm_sbt_decrypt($key, $value, $iv); return $value; } return null; }