本文整理汇总了PHP中PFUser::getAuthorizedKeysArray方法的典型用法代码示例。如果您正苦于以下问题:PHP PFUser::getAuthorizedKeysArray方法的具体用法?PHP PFUser::getAuthorizedKeysArray怎么用?PHP PFUser::getAuthorizedKeysArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PFUser
的用法示例。
在下文中一共展示了PFUser::getAuthorizedKeysArray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ssh_keys_list
public function ssh_keys_list()
{
$keys = array();
foreach ($this->user->getAuthorizedKeysArray() as $ssh_key_number => $ssh_key_value) {
$keys[] = array('ssh_key_ellipsis_value' => substr($ssh_key_value, 0, 40) . '...' . substr($ssh_key_value, -40), 'ssh_key_value' => $ssh_key_value, 'ssh_key_number' => $ssh_key_number);
}
return $keys;
}
示例2: deleteSSHKeys
public function deleteSSHKeys(PFUser $user, array $ssh_key_index_to_delete)
{
$user_keys_to_keep = $user->getAuthorizedKeysArray();
foreach ($ssh_key_index_to_delete as $ssh_key_index) {
unset($user_keys_to_keep[$ssh_key_index]);
}
$this->updateUserSSHKeys($user, array_values($user_keys_to_keep));
}
示例3: getKeysFromString
private function getKeysFromString($keys_as_string)
{
$user = new PFUser();
$user->setAuthorizedKeys($keys_as_string);
return array_filter($user->getAuthorizedKeysArray());
}
示例4: writeSSHFile
private function writeSSHFile(PFUser $user, $ssh_dir)
{
$authorized_keys_new = "{$ssh_dir}/authorized_keys_new";
touch($authorized_keys_new);
$this->backend->chmod($authorized_keys_new, 0600);
$ssh_keys = implode("\n", $user->getAuthorizedKeysArray());
if (file_put_contents($authorized_keys_new, $ssh_keys) === false) {
throw new RuntimeException("Unable to write authorized_keys_new file for " . $user->getUserName());
}
if (rename($authorized_keys_new, "{$ssh_dir}/authorized_keys") === false) {
throw new RuntimeException("Unable to rename {$authorized_keys_new} file for " . $user->getUserName());
}
}