/** * Construcctor de I18nRouter * llena $__routes y crea la instancia del modelo que se encarga de interpretar las rutas * @access public * @return void */ function I18nRouter() { $this->__setLocale(); $this->__resortLangs(); $key = new Key(); $this->__urlsKey = $key->getUrls(); }
public function test_not_mandatory_extra_validator_should_pass_with_absent_key() { $subValidator = new Length(1, 3); $validator = new Key('bar', $subValidator, false); $obj = array(); $this->assertTrue($validator->validate($obj)); }
/** * @param $text * @return string */ public function encrypt($text) { $encrypted = $this->mcrypt($this->stringFormatter->prepareString($text)); $result = rtrim(base64_encode($encrypted), '=') . $this->key->getRandomHexadecimalPosition() . $this->IV->getRandomHexadecimalPosition(); $this->resetCurrentProcess(); return $result; }
/** * Diffie-Hellman, ECDHE, etc. * * Get a shared secret from a private key you possess and a public key for * the intended message recipient * * @param EncryptionSecretKey $privateKey * @param EncryptionPublicKey $publicKey * @param bool $get_as_object Get as a Key object? * @return string */ public static function getSharedSecret(Key $privateKey, Key $publicKey, bool $get_as_object = false) { if ($get_as_object) { return new EncryptionKey(\Sodium\crypto_scalarmult($privateKey->getRawKeyMaterial(), $publicKey->getRawKeyMaterial())); } return \Sodium\crypto_scalarmult($privateKey->getRawKeyMaterial(), $publicKey->getRawKeyMaterial()); }
public function testNotMandatoryExtraValidatorShouldPassWithAbsentKey() { $subValidator = new Length(1, 3); $validator = new Key('bar', $subValidator, false); $obj = array(); $this->assertTrue($validator->validate($obj)); }
/** * @group certificate * * @test */ public function assert_that_key_usage_check_works_correctly() { $key = new Key(array(Key::USAGE_SIGNING => true)); $this->assertTrue($key->canBeUsedFor(Key::USAGE_SIGNING)); $this->assertFalse($key->canBeUsedFor(Key::USAGE_ENCRYPTION)); $key[Key::USAGE_ENCRYPTION] = false; $this->assertFalse($key->canBeUsedFor(Key::USAGE_ENCRYPTION)); }
/** * @param $encrypted_text * @return string */ public function decrypt($encrypted_text) { $this->IV->setHexadecimalPosition(substr($encrypted_text, -2)); $this->key->setHexadecimalPosition(substr($encrypted_text, -4, 2)); $encrypted_text = base64_decode(substr($encrypted_text, 0, -4)); $decrypted = $this->mdecrypt($encrypted_text); $this->resetCurrentProcess(); return $this->stringFormatter->cleanString($decrypted); }
/** @return Key[] */ public function getKeys() { $keys = []; $keysNames = $this->predis->smembers($this->getKeyName("tag:{$this->key}")); foreach ($keysNames as $key) { $k = new Key($this->predis, $key); $k->setKeyPrefix($this->keyPrefix); $keys[] = $k; } return $keys; }
/** * Make changes to the database. * * @return void */ public function up() { Schema::create('keys', function ($table) { $table->increments('id'); $table->string('name'); $table->string('api_key'); $table->timestamps(); }); $key = new Key(); $key->name = "default"; $key->api_key = Config::get('solder.platform_key'); $key->save(); }
/** * @param array $keys */ public function __construct(array $keys) { if (!empty($keys)) { foreach ($keys as $value) { $key = new Key(); $key->setKey(isset($value['key']) ? $value['key'] : null); $key->setValue(isset($value['value']) ? $value['value'] : null); $key->setCas(isset($value['cas']) ? $value['cas'] : null); $this->addKey($value['key'], $key); } //sort the keys ksort($this->keys); } }
/** * @group certificate * * @test */ public function assert_that_offsetunset_unsets_offset() { $key = new Key(array(Key::USAGE_SIGNING => true, Key::USAGE_ENCRYPTION => true)); $this->assertTrue($key->offsetExists(Key::USAGE_SIGNING)); $this->assertTrue($key->offsetExists(Key::USAGE_ENCRYPTION)); $key->offsetUnset(Key::USAGE_SIGNING); $this->assertFalse($key->offsetExists(Key::USAGE_SIGNING)); $this->assertTrue($key->offsetExists(Key::USAGE_ENCRYPTION)); $key->offsetUnset(Key::USAGE_ENCRYPTION); $this->assertFalse($key->offsetExists(Key::USAGE_SIGNING)); $this->assertFalse($key->offsetExists(Key::USAGE_ENCRYPTION)); }
function showFP() { $db = new PHPWS_DB('ps_page'); $db->addWhere('front_page', 1); if ($db->isTableColumn('deleted')) { $db->addWhere('deleted', 0); } Key::restrictView($db, 'pagesmith'); $db->loadClass('pagesmith', 'PS_Page.php'); $result = $db->getObjects('PS_Page'); if (!PHPWS_Error::logIfError($result) && !empty($result)) { PHPWS_Core::initModClass('pagesmith', 'PageSmith.php'); foreach ($result as $page) { $content = $page->view(); if ($content && !PHPWS_Error::logIfError($content)) { if (Current_User::allow('pagesmith', 'edit_page', $page->id)) { $content .= sprintf('<p class="pagesmith-edit">%s</p>', $page->editLink()); } Layout::add($content, 'pagesmith', 'view_' . $page->id, TRUE); } } } else { return null; } }
/** * {@inheritdoc} Best place to ensure the logic is encapsulated in a single place */ public function offsetSet($offset, $value) { if ($offset === 'X509Certificate') { $value = preg_replace('~\\s+~', '', $value); } parent::offsetSet($offset, $value); }
public function testMultiChangePassword() { $firstPassword = '******'; $secondPassword = '******'; $otpKey = 'I am a test key'; $data = openssl_random_pseudo_bytes(117); // Set up a user $user = new User(); $user->setOtpKey($otpKey, $firstPassword); // Setup a key $defaultKeyPassphrase = $user->dangerouslyRegenerateAccountKeyPassphrase($firstPassword); $key = Key::generate($defaultKeyPassphrase, 1024); $user->accountKey = $key; // Encrypt some data $encryptedData = $user->getAccountKey()->encrypt($data); // Change user's password // This must update the password on the default key and OTP key as well $user->changePassword($firstPassword, $secondPassword); // Decrypt data $newKeyPassphrase = $user->getAccountKeyPassphrase($secondPassword); $decrypted = $user->getAccountKey()->decrypt($encryptedData, $newKeyPassphrase); // Default Key passphrase should have changed and remain valid $this->assertNotEquals($newKeyPassphrase, $defaultKeyPassphrase); $this->assertEquals($data, $decrypted); // OTP key should have been encrypted with the new password $this->assertEquals($otpKey, $user->getOtpKey($secondPassword)); }
public static function Create($Key = 0, $Company = false) { $Return = false; if ($Key !== 0) { if (\Session::exists("refKey")) { if (\Session::get("refKey") != $Key) { //This computer has multiple Keys? I'm not sure how or why this would happen. //It is a possibility so I guess I should probably plan for it $SavedKey = new Key(\Session::get("refKey")); if ($SavedKey->validKey()) { //Has two valid keys? What on earth? I will have to account for this later } else { \Session::put("refKey", $Key); $Return = true; } } } else { \Session::put("refKey", $Key); $Return = true; } if (\Cookie::exists("refKey")) { if (\Cookie::get("refKey") != $Key) { $SavedKey = new Key(\Cookie::get("refKey")); if ($SavedKey->validKey()) { //Has two valid keys? What on earth? I will have to account for this later } else { \Cookie::put("refKey", $Key, \Config::get("tracking/cookie_expiry")); $Return = true; } } } else { \Cookie::put("refKey", $Key, \Config::get("tracking/cookie_expiry")); $Return = true; } if ($Company != false) { if (count(\DB::getInstance()->table("companyip")->where("IP", \Connection::IP())->where("Company", $Company->ID())) == 0) { \DB::getInstance()->table("companyip")->insert(array("IP" => \Connection::IP(), "Company" => $Company->ID(), "LastScene" => \Time::get(), "Hits" => 1)); } else { \DB::getInstance()->table("companyip")->where("IP", \Connection::IP())->increment("Hits"); } } //IP Based Search will go here return $Return; } return false; }
/** * Get a map of id => name for the keys belonging to $this->user * * @return array */ protected function getUserKeys() { $keyMap = []; $keys = Key::find(['user_id = :user_id:', 'bind' => ['user_id' => $this->user->id]]); foreach ($keys as $key) { $keyMap[$key->id] = $key->name; } return $keyMap; }
public function action_do_delete($key_id) { $key = Key::find($key_id); if (empty($key)) { return Redirect::back(); } $key->delete(); return Redirect::to('key/list')->with('success', 'API Key deleted!'); }
/** * @param mixed $value * @param string|null $passphrase */ public function __construct($value, $passphrase = null) { if (is_string($value) && is_file($value) && is_readable($value)) { $value = file_get_contents($value); } if (!is_resource($value)) { $value = openssl_pkey_get_private($value, $passphrase); } parent::__construct($value); }
/** * @param mixed $value */ public function __construct($value) { if (is_string($value) && is_file($value) && is_readable($value)) { $value = file_get_contents($value); } if (!is_resource($value)) { $value = openssl_pkey_get_public($value); } parent::__construct($value); }
public function postDelete($key_id) { $key = Key::find($key_id); if (empty($key)) { return Redirect::to('key/list')->withErrors(new MessageBag(array('Platform Key not found'))); } $key->delete(); Cache::forget('keys'); return Redirect::to('key/list')->with('success', 'API Key deleted!'); }
public function get_verify($key = null) { if (empty($key)) { return Response::json(array("error" => "No API key provided.")); } $key = Key::where('api_key', '=', $key)->first(); if (empty($key)) { return Response::json(array("error" => "Invalid key provided.")); } else { return Response::json(array("valid" => "Key validated.", "name" => $key->name, "created_at" => $key->created_at)); } }
private function load() { if ($this->key_id) { $key = new Key($this->key_id); } else { $key = Key::getHomeKey(); } $this->url = PHPWS_Core::getHomeHttp() . $key->url; $this->tag = md5($this->url); $this->file = QR_IMAGE_DIR . $this->tag . '_' . $this->size . '.png'; $this->image = QR_IMAGE_HTTP . $this->tag . '_' . $this->size . '.png'; }
public static function constructFromArray($props) { $layers = array(); if (isset($props['layers'])) { foreach ($props['layers'] as $layer) { if ($layer instanceof Layer) { $layers[] = $layer; } else { $layers[] = Layer::constructFromArray($layer); } } } $directions = array(); if (isset($props['directions'])) { foreach ($props['directions'] as $direction) { switch ($direction['directionType']) { case 'metronome': $directions[] = DirectionMetronome::constructFromArray($direction); break; case 'dynamics': $directions[] = DirectionDynamics::constructFromArray($direction); break; default: } } } if ($props['time'] instanceof Time) { $time = $props['time']; } else { $time = Time::constructFromArray($props['time']); } if ($props['clef'] instanceof Clef) { $clef = $props['clef']; } else { $clef = Clef::constructFromArray($props['clef']); } if ($props['key'] instanceof Key) { $key = $props['key']; } else { $key = Key::constructFromArray($props['key']); } $divisions = $props['divisions']; if ($props['barline'] instanceof Barline) { $barline = $props['barline']; } else { $barline = Barline::constructFromArray($props['barline']); } $implicit = $props['implicit']; $nonControlling = $props['nonControlling']; $width = $props['width']; return new Measure($layers, $directions, $time, $clef, $key, $divisions, $barline, $implicit, $nonControlling, $width); }
public function upload() { $s3 = \Aws\S3\S3Client::factory(array('key' => 'AKIAIUCV4E2L4HDCDOUA', 'secret' => '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', 'region' => 'us-east-1')); $key = new Key(); if (Input::file('key') != null) { exec('openssl rsa -noout -in ' . Input::file('key')->getRealPath(), $cli_output, $cli_exec_result_success); // lmao why is this logic reversed? and it works? if (!$cli_exec_result_success) { $s3->putObject(array('Bucket' => App::isLocal() ? 'devkeys.nosprawl.software' : 'keys.nosprawl.software', 'Key' => Input::file('key')->getClientOriginalName(), 'SourceFile' => Input::file('key')->getRealPath())); $key->remote_url = Input::file('key')->getClientOriginalName(); } else { return Redirect::to('integrations')->withMessage("Key not added. Please upload a valid PEM file."); } } $key->integration_id = Input::get('integration_id'); $key->username = Input::get('username'); $key->password = Input::get('password'); if ($key->save()) { return Redirect::to('integrations')->withMessage("Credentials added."); } else { return Redirect::to('integrations')->withMessage("Key not added."); } }
public function view() { $key = \Key::getCurrent(); if (!\Key::checkKey($key)) { return; } $tpl = array(); $allSettings = $this->settings->getAll(); foreach ($allSettings as $key => $value) { if ($value == 1) { $tpl[$key] = ""; // dummy template } } $content = \PHPWS_Template::process($tpl, 'addthis', 'addThis.tpl'); \Layout::add($content, 'addthis', 'DEFAULT'); }
public static function showBlocks($key) { $db = new PHPWS_DB('block'); $db->addWhere('block_pinned.key_id', $key->id); $db->addWhere('id', 'block_pinned.block_id'); Key::restrictView($db, 'block'); $result = $db->getObjects('Block_Item'); if (PHPWS_Error::isError($result)) { PHPWS_Error::log($result); return NULL; } if (empty($result)) { return NULL; } foreach ($result as $block) { $block->setPinKey($key); Layout::add($block->view(), 'block', $block->getContentVar()); $GLOBALS['Current_Blocks'][$block->id] = TRUE; } }
} \Locale::setDefault($SESSION->lang); $l10n->setLanguage($SESSION->lang); //============================================================================================ // Model //============================================================================================ require 'models/grouping.php'; require 'models/cpu.php'; require 'models/mon.php'; require 'models/per.php'; require 'models/key.php'; require 'models/furniture.php'; $cpu = new Cpu(); $mon = new Monitor(); $per = new Peripheral(); $key = new Key(); $furniture = new Furniture(); $equip = new Grouping(); //============================================================================================ // Load the page requested by the user //============================================================================================ if (!isset($_GET['page'])) { $data = $equip->listItems(); for ($i = 0; $i < count($data); $i++) { $z = $equip->countItems($data[$i]['group_id']); $data[$i]['noi'] = $z[0]['count']; } $employees = $equip->listEmployees(); $allCpu = $equip->listcpuUG(); $allMon = $equip->listmonUG(); $allPer = $equip->listperUG();
public function apiKeysAction() { $user = $this->_helper->db->findById(); $keyTable = $this->_helper->db->getTable('Key'); $this->view->user = $user; $this->view->currentUser = $this->getCurrentUser(); $this->view->keys = $keyTable->findBy(array('user_id' => $user->id)); if ($this->getRequest()->isPost()) { // Create a new API key. if ($this->getParam('api_key_label')) { $key = new Key(); $key->user_id = $user->id; $key->label = $this->getParam('api_key_label'); $key->key = sha1($user->username . microtime() . rand()); $key->save(); $this->_helper->flashMessenger(__('A new API key was successfully created.'), 'success'); } // Rescend API keys. if ($this->getParam('api_key_rescind')) { foreach ($this->getParam('api_key_rescind') as $keyId) { $keyTable->find($keyId)->delete(); } $this->_helper->flashMessenger(__('An existing API key was successfully rescinded.'), 'success'); } $this->_helper->redirector->gotoRoute(); } }
* to the home page. The HTML form allows the user access to all keys/chords in the DB. * It will then construct an Object of the Key class depending on the variables POSTed to it. * It then computes what chords to display using functions of the Key Object and * displays these chords to the browser by including the "formatChordDisplay.php" script/program. * It also gives the User an option to log out. */ include 'Key.class.php'; session_start(); if ($_SESSION['auth'] != 'yes') { header('Location: index.php'); exit; } if (isset($_POST["myKey"])) { $userNote = $_POST["myKey"]; $userTonality = $_POST["myTonality"]; $userKey = new Key($userNote, $userTonality); $chordsToDisplay = $userKey->getKeyChordImages(); $relativeChordsToDisplay = $userKey->getRelativeKeyChordImages(); } ?> <html> <head> <title>Songwriting Chord Toolkit</title> <link rel = "stylesheet" href = "myStyle.css"/> <link href='https://fonts.googleapis.com/css?family=Ubuntu+Condensed' rel='stylesheet' type='text/css'> </head> <body> <div id = 'contentFull'>
/** * Create a new user * * @param $email */ public function createAction($email) { if (!$this->isValidEmail($email)) { die("'{$email}' is not a valid email address\n"); } if ($user = User::findFirst(['email = :email:', 'bind' => ['email' => $email]])) { die("The account {$email} already exists. Duplicate account emails are not allowed.\n"); } echo "Creating user '{$email}'\n"; $password = $this->promptCreatePassword(); echo "Keying...\n"; $user = new User(); $user->email = $email; $user->setPassword($password); // Create OTP key $otp = Seed::generate(40); $user->setOtpKey($otp->getValue(Seed::FORMAT_BASE32), $password); // Create account key $key = Key::generate($user->dangerouslyRegenerateAccountKeyPassphrase($password)); $key->setName('Account key'); // Save user and key $this->db->begin(); $user->create(); $key->user_id = $user->id; $key->create(); $user->accountKey_id = $key->id; $user->update(); $this->db->commit(); echo "Created user {$email} with id {$user->id}\n"; echo "OTP: {$this->generateOtpUri($user, $otp)}\n"; }