本文整理汇总了PHP中PFUser::setAuthorizedKeys方法的典型用法代码示例。如果您正苦于以下问题:PHP PFUser::setAuthorizedKeys方法的具体用法?PHP PFUser::setAuthorizedKeys怎么用?PHP PFUser::setAuthorizedKeys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PFUser
的用法示例。
在下文中一共展示了PFUser::setAuthorizedKeys方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateUsers
public function generateUsers()
{
$user_1 = new PFUser();
$user_1->setUserName(self::TEST_USER_1_NAME);
$user_1->setRealName(self::TEST_USER_1_REALNAME);
$user_1->setLdapId(self::TEST_USER_1_LDAPID);
$user_1->setPassword(self::TEST_USER_1_PASS);
$user_1->setStatus(self::TEST_USER_1_STATUS);
$user_1->setEmail(self::TEST_USER_1_EMAIL);
$user_1->setLanguage($GLOBALS['Language']);
$this->user_manager->createAccount($user_1);
$user_1->setLabFeatures(true);
$user_2 = new PFUser();
$user_2->setUserName(self::TEST_USER_2_NAME);
$user_2->setPassword(self::TEST_USER_2_PASS);
$user_2->setStatus(self::TEST_USER_2_STATUS);
$user_2->setEmail(self::TEST_USER_2_EMAIL);
$user_2->setLanguage($GLOBALS['Language']);
$user_2->setAuthorizedKeys('ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDHk9 toto@marche');
$this->user_manager->createAccount($user_2);
$user_3 = new PFUser();
$user_3->setUserName(self::TEST_USER_3_NAME);
$user_3->setPassword(self::TEST_USER_3_PASS);
$user_3->setStatus(self::TEST_USER_3_STATUS);
$user_3->setEmail(self::TEST_USER_3_EMAIL);
$user_3->setLanguage($GLOBALS['Language']);
$this->user_manager->createAccount($user_3);
$user_4 = new PFUser();
$user_4->setUserName(self::TEST_USER_4_NAME);
$user_4->setPassword(self::TEST_USER_4_PASS);
$user_4->setStatus(self::TEST_USER_4_STATUS);
$user_4->setEmail(self::TEST_USER_1_EMAIL);
$user_4->setLanguage($GLOBALS['Language']);
$this->user_manager->createAccount($user_4);
return $this;
}
示例2: getKeysFromString
private function getKeysFromString($keys_as_string)
{
$user = new PFUser();
$user->setAuthorizedKeys($keys_as_string);
return array_filter($user->getAuthorizedKeysArray());
}
示例3: updateUserSSHKeys
/**
* Update ssh keys for a user
*
* Should probably be merged with updateDb but I don't know the impact of
* validating keys each time we update a user
*
* @param PFUser $user
* @param String $keys
*/
public function updateUserSSHKeys(PFUser $user, array $keys)
{
$original_authorised_keys = $user->getAuthorizedKeysRaw();
$user->setAuthorizedKeys(implode(PFUser::SSH_KEY_SEPARATOR, $keys));
if ($this->updateDb($user)) {
$GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('account_editsshkeys', 'update_filesystem'));
$event_parameters = array('user_id' => $user->getId(), 'original_keys' => $original_authorised_keys);
$this->_getEventManager()->processEvent(Event::EDIT_SSH_KEYS, $event_parameters);
}
}
示例4: itRemovesSelectedSSHKeys
public function itRemovesSelectedSSHKeys() {
$user_ssh_keys =
'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC7pihW/WsGL8Pmk89ET/x1GTa646GWs/7DHujgxfP4ZH7mt6ta+KwH2tsEj5ESS19EIYG4hQYpckpd65fgihs7SrwLEVG3yO1gZSS+4bBfGaR/zQoFRNlJHiKh9vrr3AZZxCUUM4xpMi2wT4hBlr8lgYaxCQZpgXRqI6CSUSAVDM7e6Ct4zItmp7VqFLHTv7pljeIF+VTyoDWfMSaIBbDmmnZctR9hR3ywSmokvA9iN4a5bWjeXlIQdpjcjqapolvlo2XamN7HRTfxWefFceoVX3yVjTZ7DFkbHJdqwBMIQmAMbG633dx67dQLgeAKfWu/tGbCnalnzzeuMvU9b4oF comment1'
. PFUser::SSH_KEY_SEPARATOR . $this->an_ssh_key;
$ssh_keys_to_delete_index = array(0);
$this->user->setAuthorizedKeys($user_ssh_keys);
expect($this->user_manager)->updateUserSSHKeys($this->user, array($this->an_ssh_key))->once();
$this->user_manager->deleteSSHKeys($this->user, $ssh_keys_to_delete_index);
}