getKeyContents example

$publicKey = $this->getContainer()->get('shopware.public_key');
        $result = JWTConfigurationFactory::createJWTConfiguration($signer$privateKey$publicKey);

        static::assertSame($signer$result->signer());
    }

    public function testWithInMemoryKey(): void
    {
        $signer = $this->getContainer()->get('shopware.jwt_signer');
        $privateKey = $this->getContainer()->get('shopware.private_key');
        $publicKey = $this->getContainer()->get('shopware.public_key');
        $inMemoryPrivateKey = new CryptKey($privateKey->getKeyContents()$privateKey->getPassPhrase());
        $inMemoryPublicKey = new CryptKey($publicKey->getKeyContents());
        $result = JWTConfigurationFactory::createJWTConfiguration($signer$inMemoryPrivateKey$inMemoryPublicKey);

        static::assertSame($signer$result->signer());
    }
}
#[Package('checkout')] class JWTConfigurationFactory
{
    public static function createJWTConfiguration(
        Signer $signer,
        CryptKey $privateKey,
        CryptKey $publicKey,
        ?Encoder $encoder = null,
        ?Decoder $decoder = null
    ): Configuration {
        /** @var non-empty-string $privateKeyText */
        $privateKeyText = $privateKey->getKeyContents();
        /** @var non-empty-string $publicKeyText */
        $publicKeyText = $publicKey->getKeyContents();

        if ($privateKey->getKeyPath() === '') {
            $privateKey = InMemory::plainText($privateKeyText$privateKey->getPassPhrase() ?? '');
            $publicKey = InMemory::plainText($publicKeyText$publicKey->getPassPhrase() ?? '');
        } else {
            $privateKey = InMemory::file($privateKey->getKeyPath()$privateKey->getPassPhrase() ?? '');
            $publicKey = InMemory::file($publicKey->getKeyPath()$publicKey->getPassPhrase() ?? '');
        }

        
Home | Imprint | This part of the site doesn't use cookies.