Beispiel #1
0
 /**
  * @test
  *
  * @uses Lcobucci\JWT\RsaKeys
  *
  * @covers Lcobucci\JWT\Signer\Keychain::getPrivateKey
  */
 public function getPrivateKeyShouldBeAbleToUseAPassphrase()
 {
     $keychain = new Keychain();
     $privateKey = $keychain->getPrivateKey($this->encryptedPrivateRsaContent(), 'testing');
     $this->assertInternalType('resource', $privateKey);
     $this->assertEquals(openssl_pkey_get_details($privateKey), openssl_pkey_get_details($this->encryptedPrivateRsa()));
 }
Beispiel #2
0
    public function get_sign(){
        $data = $this->get_token();
        $signer = new Sha256();
        $keychain = new Keychain();

        $sign = (new Builder())->setIssuer('pditt') // Configures the issuer (iss claim)
                                ->setAudience('pditt') // Configures the audience (aud claim)
                                ->setId($this->lms_desc, true) // Configures the id (jti claim), replicating as a header item
                                ->set('token', $data) // Configures a new claim, called "uid"
                                ->sign($signer,  $keychain->getPrivateKey('file://' . $this->private_key_file_name)) // creates a signature using your private key
                                ->getToken(); // Retrieves the generated token
                                
        return (string)$sign;
    }
Beispiel #3
0
 /**
  * @beforeClass
  */
 public static function createEcdsaKeys()
 {
     $keychain = new Keychain();
     $dir = 'file://' . __DIR__;
     static::$ecdsaKeys = ['private' => $keychain->getPrivateKey($dir . '/ecdsa/private.key'), 'public1' => $keychain->getPublicKey($dir . '/ecdsa/public1.key'), 'public2' => $keychain->getPublicKey($dir . '/ecdsa/public2.key')];
 }