Search in sources :

Example 1 with EdcException

use of org.eclipse.dataspaceconnector.spi.EdcException in project edc-showcase by microsoft.

the class EdcExtension method beforeTestExecution.

@Override
public void beforeTestExecution(ExtensionContext extensionContext) {
    var typeManager = new TypeManager();
    var monitor = ExtensionLoader.loadMonitor();
    MonitorProvider.setInstance(monitor);
    context = new TestServiceExtensionContext(typeManager, monitor, new MultiSourceServiceLocator());
    context.initialize();
    serviceMocks.forEach((key, value) -> context.registerService(cast(key), value));
    try {
        if (!serviceMocks.containsKey(Vault.class)) {
            ExtensionLoader.loadVault(context);
        }
        runningServiceExtensions = context.loadServiceExtensions();
        ExtensionLoader.bootServiceExtensions(runningServiceExtensions, context);
    } catch (Exception e) {
        throw new EdcException(e);
    }
}
Also used : TypeManager(org.eclipse.dataspaceconnector.spi.types.TypeManager) Vault(org.eclipse.dataspaceconnector.spi.security.Vault) EdcException(org.eclipse.dataspaceconnector.spi.EdcException) EdcException(org.eclipse.dataspaceconnector.spi.EdcException)

Example 2 with EdcException

use of org.eclipse.dataspaceconnector.spi.EdcException in project DataSpaceConnector by eclipse-dataspaceconnector.

the class AbstractQueuedProvisioner method run.

private void run() {
    while (active.get()) {
        try {
            var entry = queue.poll(provisionWait, TimeUnit.MILLISECONDS);
            if (entry != null) {
                onEntry(entry);
            }
            // simulate async behavior
            Thread.sleep(provisionWait);
        } catch (InterruptedException e) {
            Thread.interrupted();
            throw new EdcException(e);
        }
    }
}
Also used : EdcException(org.eclipse.dataspaceconnector.spi.EdcException)

Example 3 with EdcException

use of org.eclipse.dataspaceconnector.spi.EdcException in project DataSpaceConnector by eclipse-dataspaceconnector.

the class CoreServicesExtension method registerParser.

private void registerParser(ServiceExtensionContext context) {
    var resolver = context.getService(PrivateKeyResolver.class);
    resolver.addParser(PrivateKey.class, encoded -> {
        try {
            KeyFactory keyFactory = KeyFactory.getInstance("RSA");
            return keyFactory.generatePrivate(new PKCS8EncodedKeySpec(Base64.getDecoder().decode(encoded.getBytes())));
        } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
            throw new EdcException(e);
        }
    });
}
Also used : PKCS8EncodedKeySpec(java.security.spec.PKCS8EncodedKeySpec) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) InvalidKeySpecException(java.security.spec.InvalidKeySpecException) EdcException(org.eclipse.dataspaceconnector.spi.EdcException) KeyFactory(java.security.KeyFactory)

Example 4 with EdcException

use of org.eclipse.dataspaceconnector.spi.EdcException in project DataSpaceConnector by eclipse-dataspaceconnector.

the class TransformerRegistryImpl method transform.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Nullable
private <INPUT, OUTPUT> OUTPUT transform(INPUT object, Class<OUTPUT> outputType, TransformerContext context) {
    Objects.requireNonNull(object);
    IdsTypeTransformer idsTypeTransformer = findEligibleTransformer(object, outputType);
    if (idsTypeTransformer == null) {
        // this is a programming error
        throw new EdcException("Transformer not found for pair:" + new TransformKey(object.getClass(), outputType));
    }
    return outputType.cast(idsTypeTransformer.transform(object, context));
}
Also used : IdsTypeTransformer(org.eclipse.dataspaceconnector.ids.spi.transform.IdsTypeTransformer) EdcException(org.eclipse.dataspaceconnector.spi.EdcException) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with EdcException

use of org.eclipse.dataspaceconnector.spi.EdcException in project DataSpaceConnector by eclipse-dataspaceconnector.

the class Oauth2Extension method createTokenSigner.

private static JWSSigner createTokenSigner(Oauth2Configuration configuration) {
    var privateKeyAlias = configuration.getPrivateKeyAlias();
    var privateKey = configuration.getPrivateKeyResolver().resolvePrivateKey(privateKeyAlias, PrivateKey.class);
    if (privateKey == null) {
        throw new EdcException("Failed to resolve private key, required for JWSSigner.");
    }
    if ("EC".equals(privateKey.getAlgorithm())) {
        try {
            return new ECDSASigner((ECPrivateKey) privateKey);
        } catch (JOSEException e) {
            throw new EdcException("Failed to load JWSSigner for EC private key: " + e);
        }
    } else {
        return new RSASSASigner(privateKey);
    }
}
Also used : ECDSASigner(com.nimbusds.jose.crypto.ECDSASigner) RSASSASigner(com.nimbusds.jose.crypto.RSASSASigner) EdcException(org.eclipse.dataspaceconnector.spi.EdcException) JOSEException(com.nimbusds.jose.JOSEException)

Aggregations

EdcException (org.eclipse.dataspaceconnector.spi.EdcException)83 IOException (java.io.IOException)13 Test (org.junit.jupiter.api.Test)10 JOSEException (com.nimbusds.jose.JOSEException)7 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)6 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)4 SQLException (java.sql.SQLException)4 ParseException (java.text.ParseException)4 Policy (org.eclipse.dataspaceconnector.policy.model.Policy)4 Monitor (org.eclipse.dataspaceconnector.spi.monitor.Monitor)4 BadRequestException (com.azure.cosmos.implementation.BadRequestException)3 Instant (java.time.Instant)3 Map (java.util.Map)3 Request (okhttp3.Request)3 Result (org.eclipse.dataspaceconnector.spi.result.Result)3 TestResourceDefinition (org.eclipse.dataspaceconnector.transfer.core.TestResourceDefinition)3 CosmosClientBuilder (com.azure.cosmos.CosmosClientBuilder)2 CosmosException (com.azure.cosmos.CosmosException)2 JsonCreator (com.fasterxml.jackson.annotation.JsonCreator)2 JsonTypeName (com.fasterxml.jackson.annotation.JsonTypeName)2