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);
}
}
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);
}
}
}
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);
}
});
}
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));
}
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);
}
}
Aggregations