src/KeyStoreLoader/File.php
public function load($user, $file)
    {
        if (!is_string($user)) {
            throw new \InvalidArgumentException();
        }

        if (!is_string($file)) {
            throw new \InvalidArgumentException();
        }

        $algos = \fpoirotte\Pssht\Algorithms::factory();
        $types = array(
            'ssh-dss',
            'ssh-rsa',
#            'ecdsa-sha2-nistp256',
#            'ecdsa-sha2-nistp384',
#            'ecdsa-sha2-nistp521',
        );

        foreach (file($file) as $line) {
            $fields = explode(' ', preg_replace('/\\s+/', ' ', trim($line)));
            $max    = count($fields);
            for ($i = 0; $i < $max; $i++) {
                if (in_array($fields[$i], $types, true)) {
                    $cls = $algos->getClass('PublicKey', $fields[$i]);
                    $this->store->add($user, $cls::loadPublic($fields[$i+1]));
                    break;
                }
            }
        }

        return $this;
    }
public function load($user, $file)
    {
        if (!is_string($user)) {
            throw new \InvalidArgumentException();
        }

        if (!is_string($file)) {
            throw new \InvalidArgumentException();
        }

        $algos = \fpoirotte\Pssht\Algorithms::factory();
        $types = array(
            'ssh-dss',
            'ssh-rsa',
#            'ecdsa-sha2-nistp256',
#            'ecdsa-sha2-nistp384',
#            'ecdsa-sha2-nistp521',
        );

        foreach (file($file) as $line) {
            $fields = explode(' ', preg_replace('/\\s+/', ' ', trim($line)));
            $max    = count($fields);
            for ($i = 0; $i < $max; $i++) {
                if (in_array($fields[$i], $types, true)) {
                    $cls = $algos->getClass('PublicKey', $fields[$i]);
                    $this->store->add($user, $cls::loadPublic($fields[$i+1]));
                    break;
                }
            }
        }

        return $this;
    }
public function load ( $ user , $ file ) { if ( ! is_string ( $ user ) ) { throw new \ InvalidArgumentException ( ) ; } if ( ! is_string ( $ file ) ) { throw new \ InvalidArgumentException ( ) ; } $ algos = \ fpoirotte \ Pssht \ Algorithms :: factory ( ) ; $ types = array ( 'ssh-dss' , 'ssh-rsa' , #            'ecdsa-sha2-nistp256', #            'ecdsa-sha2-nistp384', #            'ecdsa-sha2-nistp521', ) ; foreach ( file ( $ file ) as $ line ) { $ fields = explode ( ' ' , preg_replace ( '/\\s+/' , ' ' , trim ( $ line ) ) ) ; $ max = count ( $ fields ) ; for ( $ i = 0 ; $ i < $ max ; $ i ++ ) { if ( in_array ( $ fields [ $ i ] , $ types , true ) ) { $ cls = $ algos -> getClass ( 'PublicKey' , $ fields [ $ i ] ) ; $ this -> store -> add ( $ user , $ cls :: loadPublic ( $ fields [ $ i + 1 ] ) ) ; break ; } } } return $ this ; }
Load the keys in the given file as if they belonged
to the specified user.

\param string $user
User the keys belong to.

\param string $file
File containing the keys to load.
It should follow the format of OpenSSH's
authorized_keys file.

\retval File
Returns this loader.
Load the keys in the given file as if they belonged to the specified user .