Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions performance/JWE/EncryptionBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
namespace Jose\Performance\JWE;

use Jose\Component\Core\AlgorithmManager;
use Jose\Component\Core\Converter\StandardConverter;
use Jose\Component\Core\JWK;
use Jose\Component\Core\JWKSet;
use Jose\Component\Encryption\Algorithm\ContentEncryption;
Expand All @@ -38,12 +37,10 @@ abstract class EncryptionBench
private $contentEncryptionAlgorithmsManager;
private $keyEncryptionAlgorithmsManager;
private $compressionMethodsManager;
private $jsonConverter;
private $serializerManager;

public function init()
{
$this->jsonConverter = new StandardConverter();
$this->keyEncryptionAlgorithmsManager = new AlgorithmManager([
new KeyEncryption\A128KW(),
new KeyEncryption\A192KW(),
Expand Down Expand Up @@ -77,9 +74,9 @@ public function init()
new Compression\ZLib(),
]);
$this->serializerManager = new JWESerializerManager([
new CompactSerializer($this->jsonConverter),
new JSONFlattenedSerializer($this->jsonConverter),
new JSONGeneralSerializer($this->jsonConverter),
new CompactSerializer(),
new JSONFlattenedSerializer(),
new JSONGeneralSerializer(),
]);
}

Expand All @@ -90,7 +87,6 @@ public function init()
public function encryption(array $params)
{
$jweBuilder = new JWEBuilder(
$this->jsonConverter,
$this->getKeyEncryptionAlgorithmsManager(),
$this->getContentEncryptionAlgorithmsManager(),
$this->getCompressionMethodsManager()
Expand Down
11 changes: 4 additions & 7 deletions performance/JWS/SignatureBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
namespace Jose\Performance\JWS;

use Jose\Component\Core\AlgorithmManager;
use Jose\Component\Core\Converter\StandardConverter;
use Jose\Component\Core\JWK;
use Jose\Component\Signature\Algorithm;
use Jose\Component\Signature\Algorithm\SignatureAlgorithm;
Expand All @@ -33,12 +32,10 @@ abstract class SignatureBench
{
private $payload = "It\xe2\x80\x99s a dangerous business, Frodo, going out your door. You step onto the road, and if you don't keep your feet, there\xe2\x80\x99s no knowing where you might be swept off to.";
private $signatureAlgorithmsManager;
private $jsonConverter;
private $serializerManager;

public function init()
{
$this->jsonConverter = new StandardConverter();
$this->signatureAlgorithmsManager = new AlgorithmManager([
new Algorithm\HS256(),
new Algorithm\HS384(),
Expand All @@ -56,9 +53,9 @@ public function init()
new Algorithm\EdDSA(),
]);
$this->serializerManager = new JWSSerializerManager([
new CompactSerializer($this->jsonConverter),
new JSONFlattenedSerializer($this->jsonConverter),
new JSONGeneralSerializer($this->jsonConverter),
new CompactSerializer(),
new JSONFlattenedSerializer(),
new JSONGeneralSerializer(),
]);
}

Expand All @@ -68,7 +65,7 @@ public function init()
*/
public function sign(array $params)
{
$jwsBuilder = new JWSBuilder($this->jsonConverter, $this->signatureAlgorithmsManager);
$jwsBuilder = new JWSBuilder($this->signatureAlgorithmsManager);
$jwsBuilder
->withPayload($this->payload)
->addSignature($this->getPrivateKey(), ['alg' => $params['algorithm']])
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
stopOnFailure="true"
bootstrap="vendor/autoload.php"
colors="true">
<testsuites>
Expand Down
11 changes: 2 additions & 9 deletions src/Bundle/JoseFramework/Controller/JWKSetControllerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,13 @@

namespace Jose\Bundle\JoseFramework\Controller;

use Jose\Component\Core\Converter\JsonConverter;
use Jose\Component\Core\JWKSet;
use Jose\Component\Core\Util\JsonConverter;

class JWKSetControllerFactory
{
private $jsonConverter;

public function __construct(JsonConverter $jsonConverter)
{
$this->jsonConverter = $jsonConverter;
}

public function create(JWKSet $jwkset): JWKSetController
{
return new JWKSetController($this->jsonConverter->encode($jwkset));
return new JWKSetController(JsonConverter::encode($jwkset));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
use Jose\Bundle\JoseFramework\DataCollector\Collector;
use Jose\Bundle\JoseFramework\DependencyInjection\Compiler;
use Jose\Bundle\JoseFramework\DependencyInjection\Source\SourceWithCompilerPasses;
use Jose\Component\Core\Converter\JsonConverter;
use Jose\Component\Core\Converter\StandardConverter;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
Expand Down Expand Up @@ -45,22 +43,10 @@ public function load(array $config, ContainerBuilder $container)
$container->registerForAutoconfiguration(Collector::class)->addTag('jose.data_collector');
$loader->load('dev_services.php');
}

$container->setAlias(JsonConverter::class, $config['json_converter']);
if (StandardConverter::class === $config['json_converter']) {
$loader->load('json_converter.php');
}
}

public function getNodeDefinition(NodeDefinition $node)
{
$node
->children()
->scalarNode('json_converter')
->defaultValue(StandardConverter::class)
->info('Converter used to encode and decode JSON objects (JWT payloads, keys, key sets...).')
->end()
->end();
}

public function prepend(ContainerBuilder $container, array $config): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
class JWKSource implements Source
{
/**
* @var null|JWKSourceInterface[]
* @var JWKSourceInterface[]|null
*/
private $jwkSources = null;

Expand Down
3 changes: 0 additions & 3 deletions src/Bundle/JoseFramework/Resources/config/jku_source.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
* of the MIT license. See the LICENSE file for details.
*/

use Jose\Component\Core\Converter\JsonConverter;
use Jose\Component\KeyManagement;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use function Symfony\Component\DependencyInjection\Loader\Configurator\ref;
Expand All @@ -25,7 +24,6 @@
$container->set(KeyManagement\JKUFactory::class)
->public()
->args([
ref(JsonConverter::class),
ref('jose.http_client'),
ref('jose.request_factory'),
])
Expand All @@ -34,7 +32,6 @@
$container->set(KeyManagement\X5UFactory::class)
->public()
->args([
ref(JsonConverter::class),
ref('jose.http_client'),
ref('jose.request_factory'),
])
Expand Down
24 changes: 0 additions & 24 deletions src/Bundle/JoseFramework/Resources/config/json_converter.php

This file was deleted.

5 changes: 2 additions & 3 deletions src/Bundle/JoseFramework/Services/JWEBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Jose\Bundle\JoseFramework\Event\Events;
use Jose\Bundle\JoseFramework\Event\JWEBuiltSuccessEvent;
use Jose\Component\Core\AlgorithmManager;
use Jose\Component\Core\Converter\JsonConverter;
use Jose\Component\Encryption\Compression\CompressionMethodManager;
use Jose\Component\Encryption\JWE;
use Jose\Component\Encryption\JWEBuilder as BaseJWEBuilder;
Expand All @@ -26,9 +25,9 @@ final class JWEBuilder extends BaseJWEBuilder
{
private $eventDispatcher;

public function __construct(JsonConverter $jsonConverter, AlgorithmManager $keyEncryptionAlgorithmManager, AlgorithmManager $contentEncryptionAlgorithmManager, CompressionMethodManager $compressionManager, EventDispatcherInterface $eventDispatcher)
public function __construct(AlgorithmManager $keyEncryptionAlgorithmManager, AlgorithmManager $contentEncryptionAlgorithmManager, CompressionMethodManager $compressionManager, EventDispatcherInterface $eventDispatcher)
{
parent::__construct($jsonConverter, $keyEncryptionAlgorithmManager, $contentEncryptionAlgorithmManager, $compressionManager);
parent::__construct($keyEncryptionAlgorithmManager, $contentEncryptionAlgorithmManager, $compressionManager);
$this->eventDispatcher = $eventDispatcher;
}

Expand Down
7 changes: 2 additions & 5 deletions src/Bundle/JoseFramework/Services/JWEBuilderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,17 @@
namespace Jose\Bundle\JoseFramework\Services;

use Jose\Component\Core\AlgorithmManagerFactory;
use Jose\Component\Core\Converter\JsonConverter;
use Jose\Component\Encryption\Compression\CompressionMethodManagerFactory;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

final class JWEBuilderFactory
{
private $eventDispatcher;
private $jsonEncoder;
private $algorithmManagerFactory;
private $compressionMethodManagerFactory;

public function __construct(JsonConverter $jsonEncoder, AlgorithmManagerFactory $algorithmManagerFactory, CompressionMethodManagerFactory $compressionMethodManagerFactory, EventDispatcherInterface $eventDispatcher)
public function __construct(AlgorithmManagerFactory $algorithmManagerFactory, CompressionMethodManagerFactory $compressionMethodManagerFactory, EventDispatcherInterface $eventDispatcher)
{
$this->jsonEncoder = $jsonEncoder;
$this->eventDispatcher = $eventDispatcher;
$this->algorithmManagerFactory = $algorithmManagerFactory;
$this->compressionMethodManagerFactory = $compressionMethodManagerFactory;
Expand All @@ -46,6 +43,6 @@ public function create(array $keyEncryptionAlgorithms, array $contentEncryptionA
$contentEncryptionAlgorithmManager = $this->algorithmManagerFactory->create($contentEncryptionAlgorithm);
$compressionMethodManager = $this->compressionMethodManagerFactory->create($compressionMethods);

return new JWEBuilder($this->jsonEncoder, $keyEncryptionAlgorithmManager, $contentEncryptionAlgorithmManager, $compressionMethodManager, $this->eventDispatcher);
return new JWEBuilder($keyEncryptionAlgorithmManager, $contentEncryptionAlgorithmManager, $compressionMethodManager, $this->eventDispatcher);
}
}
5 changes: 2 additions & 3 deletions src/Bundle/JoseFramework/Services/JWSBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Jose\Bundle\JoseFramework\Event\Events;
use Jose\Bundle\JoseFramework\Event\JWSBuiltSuccessEvent;
use Jose\Component\Core\AlgorithmManager;
use Jose\Component\Core\Converter\JsonConverter;
use Jose\Component\Signature\JWS;
use Jose\Component\Signature\JWSBuilder as BaseJWSBuilder;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
Expand All @@ -25,9 +24,9 @@ final class JWSBuilder extends BaseJWSBuilder
{
private $eventDispatcher;

public function __construct(JsonConverter $jsonConverter, AlgorithmManager $signatureAlgorithmManager, EventDispatcherInterface $eventDispatcher)
public function __construct(AlgorithmManager $signatureAlgorithmManager, EventDispatcherInterface $eventDispatcher)
{
parent::__construct($jsonConverter, $signatureAlgorithmManager);
parent::__construct($signatureAlgorithmManager);
$this->eventDispatcher = $eventDispatcher;
}

Expand Down
8 changes: 2 additions & 6 deletions src/Bundle/JoseFramework/Services/JWSBuilderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,16 @@
namespace Jose\Bundle\JoseFramework\Services;

use Jose\Component\Core\AlgorithmManagerFactory;
use Jose\Component\Core\Converter\JsonConverter;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

final class JWSBuilderFactory
{
private $eventDispatcher;

private $jsonEncoder;

private $signatureAlgorithmManagerFactory;

public function __construct(JsonConverter $jsonEncoder, AlgorithmManagerFactory $signatureAlgorithmManagerFactory, EventDispatcherInterface $eventDispatcher)
public function __construct(AlgorithmManagerFactory $signatureAlgorithmManagerFactory, EventDispatcherInterface $eventDispatcher)
{
$this->jsonEncoder = $jsonEncoder;
$this->signatureAlgorithmManagerFactory = $signatureAlgorithmManagerFactory;
$this->eventDispatcher = $eventDispatcher;
}
Expand All @@ -41,6 +37,6 @@ public function create(array $algorithms): JWSBuilder
{
$algorithmManager = $this->signatureAlgorithmManagerFactory->create($algorithms);

return new JWSBuilder($this->jsonEncoder, $algorithmManager, $this->eventDispatcher);
return new JWSBuilder($algorithmManager, $this->eventDispatcher);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

namespace Jose\Bundle\JoseFramework\Tests\Functional\Encryption;

use Jose\Component\Core\Converter\StandardConverter;
use Jose\Component\Core\JWK;
use Jose\Component\Encryption\JWEBuilder;
use Jose\Component\Encryption\JWEBuilderFactory;
Expand Down Expand Up @@ -53,7 +52,7 @@ public function iCanCreateAndLoadAToken()
/** @var JWEDecrypter $loader */
$loader = $container->get('jose.jwe_decrypter.loader1');

$serializer = new CompactSerializer(new StandardConverter());
$serializer = new CompactSerializer();

$jwe = $builder
->create()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Jose\Bundle\JoseFramework\Serializer\JWEEncoder;
use Jose\Bundle\JoseFramework\Services\JWEBuilderFactory;
use Jose\Bundle\JoseFramework\Services\JWELoaderFactory;
use Jose\Component\Core\Converter\StandardConverter;
use Jose\Component\Core\JWK;
use Jose\Component\Encryption\JWE;
use Jose\Component\Encryption\JWEBuilderFactory as BaseJWEBuilderFactory;
Expand Down Expand Up @@ -204,7 +203,7 @@ public function jWEEncoderSupportsCustomSerializerManager()
$client = static::createClient();
$container = $client->getContainer();
$jweSerializerManager = new JWESerializerManager([
new CompactSerializer(new StandardConverter()),
new CompactSerializer(),
]);
$serializer = new JWEEncoder($container->get(JWESerializerManagerFactory::class), $jweSerializerManager);
/** @var JWEBuilderFactory $jweFactory */
Expand Down Expand Up @@ -242,7 +241,7 @@ public function jWEEncoderShouldThrowOnUnsupportedFormatWhenEncoding()
$client = static::createClient();
$container = $client->getContainer();
$jweSerializerManager = new JWESerializerManager([
new CompactSerializer(new StandardConverter()),
new CompactSerializer(),
]);
$serializer = new JWEEncoder($container->get(JWESerializerManagerFactory::class), $jweSerializerManager);
/** @var JWEBuilderFactory $jweFactory */
Expand Down Expand Up @@ -275,7 +274,7 @@ public function jWEEncoderShouldThrowOnUnsupportedFormatWhenDecoding()
$client = static::createClient();
$container = $client->getContainer();
$jweSerializerManager = new JWESerializerManager([
new CompactSerializer(new StandardConverter()),
new CompactSerializer(),
]);
$serializer = new JWEEncoder($container->get(JWESerializerManagerFactory::class), $jweSerializerManager);
/** @var JWEBuilderFactory $jweFactory */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

use Jose\Bundle\JoseFramework\Serializer\JWSEncoder;
use Jose\Bundle\JoseFramework\Services\JWSBuilderFactory;
use Jose\Component\Core\Converter\StandardConverter;
use Jose\Component\Core\JWK;
use Jose\Component\Signature\JWS;
use Jose\Component\Signature\JWSBuilderFactory as BaseJWSBuilderFactory;
Expand Down Expand Up @@ -188,7 +187,7 @@ public function jWSEncoderSupportsCustomSerializerManager()
$client = static::createClient();
$container = $client->getContainer();
$jwsSerializerManager = new JWSSerializerManager([
new CompactSerializer(new StandardConverter()),
new CompactSerializer(),
]);
$serializer = new JWSEncoder($container->get(JWSSerializerManagerFactory::class), $jwsSerializerManager);
/** @var JWSBuilderFactory $jwsFactory */
Expand Down Expand Up @@ -224,7 +223,7 @@ public function jWSEncoderShouldThrowOnUnsupportedFormatWhenEncoding()
$client = static::createClient();
$container = $client->getContainer();
$serializerManager = new JWSSerializerManager([
new CompactSerializer(new StandardConverter()),
new CompactSerializer(),
]);
$serializer = new JWSEncoder($container->get(JWSSerializerManagerFactory::class), $serializerManager);
/** @var JWSBuilderFactory $jwsFactory */
Expand Down Expand Up @@ -255,7 +254,7 @@ public function jWSEncoderShouldThrowOnUnsupportedFormatWhenDecoding()
$client = static::createClient();
$container = $client->getContainer();
$serializerManager = new JWSSerializerManager([
new CompactSerializer(new StandardConverter()),
new CompactSerializer(),
]);
$serializer = new JWSEncoder($container->get(JWSSerializerManagerFactory::class), $serializerManager);
/** @var JWSBuilderFactory $jwsFactory */
Expand Down
Loading