/**
  * @inheritdoc
  */
 protected static function checkProperty($property, $value)
 {
     if ($property === 'key' && !SshKey::validatePublicKey($value)) {
         return ["The SSH key is invalid"];
     }
     return [];
 }
Esempio n. 2
0
 public function testStripStuffAfter()
 {
     $SshKey = new SshKey();
     $SshKey->set(array('type' => 'Git', 'username' => 'gwoo', 'content' => 'ssh-rsa this is a key== something'));
     $this->assertTrue($SshKey->save());
     $result = $SshKey->read(array('type' => 'Git', 'username' => 'gwoo'));
     $expected = array('ssh-rsa thisisakey==');
     $this->assertEqual($result, $expected);
     $SshKey->set(array('type' => 'Git', 'username' => 'gwoo', 'content' => 'ssh-rsa this is a key= something'));
     $this->assertTrue($SshKey->save());
     $result = $SshKey->read(array('type' => 'Git', 'username' => 'gwoo'));
     $expected = array('ssh-rsa thisisakey==', 'ssh-rsa thisisakey=');
     $this->assertIdentical($result, $expected);
     $SshKey->set(array('type' => 'Git', 'username' => 'gwoo', 'content' => 'ssh-rsa this is a key something'));
     $this->assertTrue($SshKey->save());
     $result = $SshKey->read(array('type' => 'Git', 'username' => 'gwoo'));
     $expected = array('ssh-rsa thisisakey==', 'ssh-rsa thisisakey=', 'ssh-rsa thisisakey');
     $this->assertIdentical($result, $expected);
     $path = Configure::read("Content.git") . 'repo' . DS . '.ssh' . DS . 'authorized_keys';
     $Cleanup = new File($path);
     $Cleanup->delete();
 }
Esempio n. 3
0
 public static function fromFile($filename)
 {
     return new SshPublicKey(SshKey::readFile($filename));
 }
Esempio n. 4
0
 public static function fromFile($filename, $password = '')
 {
     return new SshPrivateKey(SshKey::readFile($filename), $password);
 }