/**
  * @inheritdoc
  */
 protected static function checkProperty($property, $value)
 {
     if ($property === 'key' && !SshKey::validatePublicKey($value)) {
         return ["The SSH key is invalid"];
     }
     return [];
 }
Example #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();
 }
Example #3
0
 public static function fromFile($filename)
 {
     return new SshPublicKey(SshKey::readFile($filename));
 }
Example #4
0
 public static function fromFile($filename, $password = '')
 {
     return new SshPrivateKey(SshKey::readFile($filename), $password);
 }