CAMEL-15373 - Create an AWS2-STS component
diff --git a/components/camel-aws2-sts/src/generated/java/org/apache/camel/component/aws2/ecs/ECS2ComponentConfigurer.java b/components/camel-aws2-sts/src/generated/java/org/apache/camel/component/aws2/ecs/ECS2ComponentConfigurer.java
index 160cffa..b13da9a 100644
--- a/components/camel-aws2-sts/src/generated/java/org/apache/camel/component/aws2/ecs/ECS2ComponentConfigurer.java
+++ b/components/camel-aws2-sts/src/generated/java/org/apache/camel/component/aws2/ecs/ECS2ComponentConfigurer.java
@@ -4,6 +4,7 @@
import java.util.Map;
import org.apache.camel.CamelContext;
+import org.apache.camel.component.aws2.sts.STS2Component;
import org.apache.camel.spi.GeneratedPropertyConfigurer;
import org.apache.camel.spi.PropertyConfigurerGetter;
import org.apache.camel.util.CaseInsensitiveMap;
@@ -15,9 +16,9 @@
@SuppressWarnings("unchecked")
public class ECS2ComponentConfigurer extends PropertyConfigurerSupport implements GeneratedPropertyConfigurer, PropertyConfigurerGetter {
- private org.apache.camel.component.aws2.ecs.STS2Configuration getOrCreateConfiguration(STS2Component target) {
+ private org.apache.camel.component.aws2.sts.STS2Configuration getOrCreateConfiguration(STS2Component target) {
if (target.getConfiguration() == null) {
- target.setConfiguration(new org.apache.camel.component.aws2.ecs.STS2Configuration());
+ target.setConfiguration(new org.apache.camel.component.aws2.sts.STS2Configuration());
}
return target.getConfiguration();
}
@@ -32,12 +33,12 @@
case "autoDiscoverClient": getOrCreateConfiguration(target).setAutoDiscoverClient(property(camelContext, boolean.class, value)); return true;
case "basicpropertybinding":
case "basicPropertyBinding": target.setBasicPropertyBinding(property(camelContext, boolean.class, value)); return true;
- case "configuration": target.setConfiguration(property(camelContext, org.apache.camel.component.aws2.ecs.STS2Configuration.class, value)); return true;
+ case "configuration": target.setConfiguration(property(camelContext, org.apache.camel.component.aws2.sts.STS2Configuration.class, value)); return true;
case "ecsclient":
case "ecsClient": getOrCreateConfiguration(target).setEcsClient(property(camelContext, software.amazon.awssdk.services.ecs.EcsClient.class, value)); return true;
case "lazystartproducer":
case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true;
- case "operation": getOrCreateConfiguration(target).setOperation(property(camelContext, org.apache.camel.component.aws2.ecs.ECS2Operations.class, value)); return true;
+ case "operation": getOrCreateConfiguration(target).setOperation(property(camelContext, org.apache.camel.component.aws2.sts.STS2Operations.class, value)); return true;
case "pojorequest":
case "pojoRequest": getOrCreateConfiguration(target).setPojoRequest(property(camelContext, boolean.class, value)); return true;
case "proxyhost":
@@ -61,10 +62,10 @@
answer.put("accessKey", java.lang.String.class);
answer.put("autoDiscoverClient", boolean.class);
answer.put("basicPropertyBinding", boolean.class);
- answer.put("configuration", org.apache.camel.component.aws2.ecs.STS2Configuration.class);
+ answer.put("configuration", org.apache.camel.component.aws2.sts.STS2Configuration.class);
answer.put("ecsClient", software.amazon.awssdk.services.ecs.EcsClient.class);
answer.put("lazyStartProducer", boolean.class);
- answer.put("operation", org.apache.camel.component.aws2.ecs.ECS2Operations.class);
+ answer.put("operation", org.apache.camel.component.aws2.sts.STS2Operations.class);
answer.put("pojoRequest", boolean.class);
answer.put("proxyHost", java.lang.String.class);
answer.put("proxyPort", java.lang.Integer.class);
diff --git a/components/camel-aws2-sts/src/generated/java/org/apache/camel/component/aws2/ecs/ECS2EndpointConfigurer.java b/components/camel-aws2-sts/src/generated/java/org/apache/camel/component/aws2/ecs/ECS2EndpointConfigurer.java
index d4eb8ea..62c878a 100644
--- a/components/camel-aws2-sts/src/generated/java/org/apache/camel/component/aws2/ecs/ECS2EndpointConfigurer.java
+++ b/components/camel-aws2-sts/src/generated/java/org/apache/camel/component/aws2/ecs/ECS2EndpointConfigurer.java
@@ -4,6 +4,7 @@
import java.util.Map;
import org.apache.camel.CamelContext;
+import org.apache.camel.component.aws2.sts.STS2Endpoint;
import org.apache.camel.spi.GeneratedPropertyConfigurer;
import org.apache.camel.spi.PropertyConfigurerGetter;
import org.apache.camel.util.CaseInsensitiveMap;
@@ -17,7 +18,7 @@
@Override
public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) {
- ECS2Endpoint target = (ECS2Endpoint) obj;
+ STS2Endpoint target = (STS2Endpoint) obj;
switch (ignoreCase ? name.toLowerCase() : name) {
case "accesskey":
case "accessKey": target.getConfiguration().setAccessKey(property(camelContext, java.lang.String.class, value)); return true;
@@ -29,7 +30,7 @@
case "ecsClient": target.getConfiguration().setEcsClient(property(camelContext, software.amazon.awssdk.services.ecs.EcsClient.class, value)); return true;
case "lazystartproducer":
case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true;
- case "operation": target.getConfiguration().setOperation(property(camelContext, org.apache.camel.component.aws2.ecs.ECS2Operations.class, value)); return true;
+ case "operation": target.getConfiguration().setOperation(property(camelContext, org.apache.camel.component.aws2.sts.STS2Operations.class, value)); return true;
case "pojorequest":
case "pojoRequest": target.getConfiguration().setPojoRequest(property(camelContext, boolean.class, value)); return true;
case "proxyhost":
@@ -56,7 +57,7 @@
answer.put("basicPropertyBinding", boolean.class);
answer.put("ecsClient", software.amazon.awssdk.services.ecs.EcsClient.class);
answer.put("lazyStartProducer", boolean.class);
- answer.put("operation", org.apache.camel.component.aws2.ecs.ECS2Operations.class);
+ answer.put("operation", org.apache.camel.component.aws2.sts.STS2Operations.class);
answer.put("pojoRequest", boolean.class);
answer.put("proxyHost", java.lang.String.class);
answer.put("proxyPort", java.lang.Integer.class);
@@ -70,7 +71,7 @@
@Override
public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
- ECS2Endpoint target = (ECS2Endpoint) obj;
+ STS2Endpoint target = (STS2Endpoint) obj;
switch (ignoreCase ? name.toLowerCase() : name) {
case "accesskey":
case "accessKey": return target.getConfiguration().getAccessKey();
diff --git a/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Endpoint.java b/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Endpoint.java
deleted file mode 100644
index 4d9313f..0000000
--- a/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Endpoint.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.aws2.ecs;
-
-import java.net.URI;
-
-import org.apache.camel.Category;
-import org.apache.camel.Component;
-import org.apache.camel.Consumer;
-import org.apache.camel.Processor;
-import org.apache.camel.Producer;
-import org.apache.camel.spi.UriEndpoint;
-import org.apache.camel.spi.UriParam;
-import org.apache.camel.support.ScheduledPollEndpoint;
-import org.apache.camel.util.ObjectHelper;
-import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
-import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
-import software.amazon.awssdk.http.SdkHttpClient;
-import software.amazon.awssdk.http.SdkHttpConfigurationOption;
-import software.amazon.awssdk.http.apache.ApacheHttpClient;
-import software.amazon.awssdk.http.apache.ProxyConfiguration;
-import software.amazon.awssdk.regions.Region;
-import software.amazon.awssdk.services.sts.StsClient;
-import software.amazon.awssdk.services.sts.StsClientBuilder;
-import software.amazon.awssdk.utils.AttributeMap;
-
-/**
- * Manage AWS ECS cluster instances using AWS SDK version 2.x.
- */
-@UriEndpoint(firstVersion = "3.5.0", scheme = "aws2-ecs", title = "AWS 2 Security Token Service", syntax = "aws2-sts:label", producerOnly = true, category = {Category.CLOUD, Category.MANAGEMENT})
-public class ECS2Endpoint extends ScheduledPollEndpoint {
-
- private StsClient stsClient;
-
- @UriParam
- private STS2Configuration configuration;
-
- public ECS2Endpoint(String uri, Component component, STS2Configuration configuration) {
- super(uri, component);
- this.configuration = configuration;
- }
-
- @Override
- public Consumer createConsumer(Processor processor) throws Exception {
- throw new UnsupportedOperationException("You cannot receive messages from this endpoint");
- }
-
- @Override
- public Producer createProducer() throws Exception {
- return new STS2Producer(this);
- }
-
- @Override
- public void doStart() throws Exception {
- super.doStart();
-
- stsClient = configuration.getStsClient() != null ? configuration.getStsClient() : createStsClient();
- }
-
- @Override
- public void doStop() throws Exception {
- if (ObjectHelper.isEmpty(configuration.getStsClient())) {
- if (stsClient != null) {
- stsClient.close();
- }
- }
- super.doStop();
- }
-
- public STS2Configuration getConfiguration() {
- return configuration;
- }
-
- public StsClient getStsClient() {
- return stsClient;
- }
-
- StsClient createStsClient() {
- StsClient client = null;
- StsClientBuilder clientBuilder = StsClient.builder();
- ProxyConfiguration.Builder proxyConfig = null;
- ApacheHttpClient.Builder httpClientBuilder = null;
- boolean isClientConfigFound = false;
- if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
- proxyConfig = ProxyConfiguration.builder();
- URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":" + configuration.getProxyPort());
- proxyConfig.endpoint(proxyEndpoint);
- httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build());
- isClientConfigFound = true;
- }
- if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) {
- AwsBasicCredentials cred = AwsBasicCredentials.create(configuration.getAccessKey(), configuration.getSecretKey());
- if (isClientConfigFound) {
- clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder).credentialsProvider(StaticCredentialsProvider.create(cred));
- } else {
- clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred));
- }
- } else {
- if (!isClientConfigFound) {
- clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder);
- }
- }
- if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
- clientBuilder = clientBuilder.region(Region.of(configuration.getRegion()));
- }
- if (configuration.isTrustAllCertificates()) {
- SdkHttpClient ahc = ApacheHttpClient.builder().buildWithDefaults(AttributeMap
- .builder()
- .put(
- SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES,
- Boolean.TRUE
- )
- .build());
- clientBuilder.httpClient(ahc);
- }
- client = clientBuilder.build();
- return client;
- }
-}
diff --git a/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/ecs/STS2Component.java b/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/ecs/STS2Component.java
deleted file mode 100644
index 3527d8e..0000000
--- a/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/ecs/STS2Component.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.aws2.ecs;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Endpoint;
-import org.apache.camel.spi.Metadata;
-import org.apache.camel.spi.annotations.Component;
-import org.apache.camel.support.DefaultComponent;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import software.amazon.awssdk.services.sts.StsClient;
-
-/**
- * For working with Amazon STS SDK v2.
- */
-@Component("aws2-sts")
-public class STS2Component extends DefaultComponent {
-
- private static final Logger LOG = LoggerFactory.getLogger(STS2Component.class);
-
- @Metadata
- private STS2Configuration configuration = new STS2Configuration();
-
- public STS2Component() {
- this(null);
- }
-
- public STS2Component(CamelContext context) {
- super(context);
-
- registerExtension(new STS2ComponentVerifierExtension());
- }
-
- @Override
- protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
- STS2Configuration configuration = this.configuration != null ? this.configuration.copy() : new STS2Configuration();
- ECS2Endpoint endpoint = new ECS2Endpoint(uri, this, configuration);
- setProperties(endpoint, parameters);
- if (endpoint.getConfiguration().isAutoDiscoverClient()) {
- checkAndSetRegistryClient(configuration, endpoint);
- }
- if (configuration.getStsClient() == null && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) {
- throw new IllegalArgumentException("Amazon STS client or accessKey and secretKey must be specified");
- }
-
- return endpoint;
- }
-
- public STS2Configuration getConfiguration() {
- return configuration;
- }
-
- /**
- * Component configuration
- */
- public void setConfiguration(STS2Configuration configuration) {
- this.configuration = configuration;
- }
-
- private void checkAndSetRegistryClient(STS2Configuration configuration, ECS2Endpoint endpoint) {
- if (ObjectHelper.isEmpty(endpoint.getConfiguration().getStsClient())) {
- LOG.debug("Looking for an StsClient instance in the registry");
- Set<StsClient> clients = getCamelContext().getRegistry().findByType(StsClient.class);
- if (clients.size() == 1) {
- LOG.debug("Found exactly one StsClient instance in the registry");
- configuration.setStsClient(clients.stream().findFirst().get());
- } else {
- LOG.debug("No StsClient instance in the registry");
- }
- } else {
- LOG.debug("StsClient instance is already set at endpoint level: skipping the check in the registry");
- }
- }
-}
diff --git a/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/ecs/STS2ComponentVerifierExtension.java b/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/ecs/STS2ComponentVerifierExtension.java
deleted file mode 100644
index cb05382..0000000
--- a/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/ecs/STS2ComponentVerifierExtension.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.aws2.ecs;
-
-import java.util.Map;
-
-import org.apache.camel.component.extension.verifier.DefaultComponentVerifierExtension;
-import org.apache.camel.component.extension.verifier.ResultBuilder;
-import org.apache.camel.component.extension.verifier.ResultErrorBuilder;
-import org.apache.camel.component.extension.verifier.ResultErrorHelper;
-import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
-import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
-import software.amazon.awssdk.core.exception.SdkClientException;
-import software.amazon.awssdk.regions.Region;
-import software.amazon.awssdk.services.sts.StsClient;
-import software.amazon.awssdk.services.sts.StsClientBuilder;
-
-public class STS2ComponentVerifierExtension extends DefaultComponentVerifierExtension {
-
- public STS2ComponentVerifierExtension() {
- this("aws2-sts");
- }
-
- public STS2ComponentVerifierExtension(String scheme) {
- super(scheme);
- }
-
- // *********************************
- // Parameters validation
- // *********************************
-
- @Override
- protected Result verifyParameters(Map<String, Object> parameters) {
-
- ResultBuilder builder = ResultBuilder.withStatusAndScope(Result.Status.OK, Scope.PARAMETERS).error(ResultErrorHelper.requiresOption("accessKey", parameters))
- .error(ResultErrorHelper.requiresOption("secretKey", parameters)).error(ResultErrorHelper.requiresOption("region", parameters));
-
- // Validate using the catalog
-
- super.verifyParametersAgainstCatalog(builder, parameters);
-
- return builder.build();
- }
-
- // *********************************
- // Connectivity validation
- // *********************************
-
- @Override
- protected Result verifyConnectivity(Map<String, Object> parameters) {
- ResultBuilder builder = ResultBuilder.withStatusAndScope(Result.Status.OK, Scope.CONNECTIVITY);
-
- try {
- STS2Configuration configuration = setProperties(new STS2Configuration(), parameters);
- if (!StsClient.serviceMetadata().regions().contains(Region.of(configuration.getRegion()))) {
- ResultErrorBuilder errorBuilder = ResultErrorBuilder.withCodeAndDescription(VerificationError.StandardCode.ILLEGAL_PARAMETER, "The service is not supported in this region");
- return builder.error(errorBuilder.build()).build();
- }
- AwsBasicCredentials cred = AwsBasicCredentials.create(configuration.getAccessKey(), configuration.getSecretKey());
- StsClientBuilder clientBuilder = StsClient.builder();
- StsClient client = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)).region(Region.of(configuration.getRegion())).build();
- client.serviceName();
- } catch (SdkClientException e) {
- ResultErrorBuilder errorBuilder = ResultErrorBuilder.withCodeAndDescription(VerificationError.StandardCode.AUTHENTICATION, e.getMessage())
- .detail("aws_sts_exception_message", e.getMessage()).detail(VerificationError.ExceptionAttribute.EXCEPTION_CLASS, e.getClass().getName())
- .detail(VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE, e);
-
- builder.error(errorBuilder.build());
- } catch (Exception e) {
- builder.error(ResultErrorBuilder.withException(e).build());
- }
- return builder.build();
- }
-}
diff --git a/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/ecs/STS2Configuration.java b/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/ecs/STS2Configuration.java
deleted file mode 100644
index 5949b8f..0000000
--- a/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/ecs/STS2Configuration.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.aws2.ecs;
-
-import org.apache.camel.RuntimeCamelException;
-import org.apache.camel.spi.Metadata;
-import org.apache.camel.spi.UriParam;
-import org.apache.camel.spi.UriParams;
-import org.apache.camel.spi.UriPath;
-import software.amazon.awssdk.core.Protocol;
-import software.amazon.awssdk.services.sts.StsClient;
-
-@UriParams
-public class STS2Configuration implements Cloneable {
-
- @UriPath(description = "Logical name")
- @Metadata(required = true)
- private String label;
- @UriParam
- private StsClient stsClient;
- @UriParam(label = "security", secret = true)
- private String accessKey;
- @UriParam(label = "security", secret = true)
- private String secretKey;
- @UriParam
- @Metadata(required = true)
- private ECS2Operations operation;
- @UriParam(enums = "HTTP,HTTPS", defaultValue = "HTTPS")
- private Protocol proxyProtocol = Protocol.HTTPS;
- @UriParam
- private String proxyHost;
- @UriParam
- private Integer proxyPort;
- @UriParam
- private String region;
- @UriParam(defaultValue = "false")
- private boolean pojoRequest;
- @UriParam(defaultValue = "false")
- private boolean trustAllCertificates;
- @UriParam(label = "common", defaultValue = "true")
- private boolean autoDiscoverClient = true;
-
- public StsClient getStsClient() {
- return stsClient;
- }
-
- /**
- * To use a existing configured AWS ECS as client
- */
- public void setStsClient(StsClient ecsClient) {
- this.stsClient = ecsClient;
- }
-
- public String getAccessKey() {
- return accessKey;
- }
-
- /**
- * Amazon AWS Access Key
- */
- public void setAccessKey(String accessKey) {
- this.accessKey = accessKey;
- }
-
- public String getSecretKey() {
- return secretKey;
- }
-
- /**
- * Amazon AWS Secret Key
- */
- public void setSecretKey(String secretKey) {
- this.secretKey = secretKey;
- }
-
- public ECS2Operations getOperation() {
- return operation;
- }
-
- /**
- * The operation to perform
- */
- public void setOperation(ECS2Operations operation) {
- this.operation = operation;
- }
-
- public Protocol getProxyProtocol() {
- return proxyProtocol;
- }
-
- /**
- * To define a proxy protocol when instantiating the ECS client
- */
- public void setProxyProtocol(Protocol proxyProtocol) {
- this.proxyProtocol = proxyProtocol;
- }
-
- public String getProxyHost() {
- return proxyHost;
- }
-
- /**
- * To define a proxy host when instantiating the ECS client
- */
- public void setProxyHost(String proxyHost) {
- this.proxyHost = proxyHost;
- }
-
- public Integer getProxyPort() {
- return proxyPort;
- }
-
- /**
- * To define a proxy port when instantiating the ECS client
- */
- public void setProxyPort(Integer proxyPort) {
- this.proxyPort = proxyPort;
- }
-
- public String getRegion() {
- return region;
- }
-
- /**
- * The region in which ECS client needs to work. When using this
- * parameter, the configuration will expect the lowercase name of the
- * region (for example ap-east-1) You'll need to use the name
- * Region.EU_WEST_1.id()
- */
- public void setRegion(String region) {
- this.region = region;
- }
-
- public boolean isPojoRequest() {
- return pojoRequest;
- }
-
- /**
- * If we want to use a POJO request as body or not
- */
- public void setPojoRequest(boolean pojoRequest) {
- this.pojoRequest = pojoRequest;
- }
-
- public boolean isTrustAllCertificates() {
- return trustAllCertificates;
- }
-
- /**
- * If we want to trust all certificates in case of overriding the endpoint
- */
- public void setTrustAllCertificates(boolean trustAllCertificates) {
- this.trustAllCertificates = trustAllCertificates;
- }
-
- public boolean isAutoDiscoverClient() {
- return autoDiscoverClient;
- }
-
- /**
- * Setting the autoDiscoverClient mechanism, if true, the component will
- * look for a client instance in the registry automatically otherwise it
- * will skip that checking.
- */
- public void setAutoDiscoverClient(boolean autoDiscoverClient) {
- this.autoDiscoverClient = autoDiscoverClient;
- }
-
- // *************************************************
- //
- // *************************************************
-
- public STS2Configuration copy() {
- try {
- return (STS2Configuration)super.clone();
- } catch (CloneNotSupportedException e) {
- throw new RuntimeCamelException(e);
- }
- }
-}
diff --git a/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/ecs/STS2Producer.java b/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/ecs/STS2Producer.java
deleted file mode 100644
index 10af2a9..0000000
--- a/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/ecs/STS2Producer.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.aws2.ecs;
-
-import org.apache.camel.Endpoint;
-import org.apache.camel.Exchange;
-import org.apache.camel.InvalidPayloadException;
-import org.apache.camel.Message;
-import org.apache.camel.support.DefaultProducer;
-import org.apache.camel.util.ObjectHelper;
-import org.apache.camel.util.URISupport;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import software.amazon.awssdk.awscore.exception.AwsServiceException;
-
-/**
- * A Producer which sends messages to the Amazon ECS Service SDK v2
- * <a href="http://aws.amazon.com/ecs/">AWS ECS</a>
- */
-public class STS2Producer extends DefaultProducer {
-
- private static final Logger LOG = LoggerFactory.getLogger(STS2Producer.class);
-
- private transient String ecsProducerToString;
-
- public STS2Producer(Endpoint endpoint) {
- super(endpoint);
- }
-
- @Override
- public void process(Exchange exchange) throws Exception {
- switch (determineOperation(exchange)) {
- case listClusters:
- listClusters(getEndpoint().getEcsClient(), exchange);
- break;
- case describeCluster:
- describeCluster(getEndpoint().getEcsClient(), exchange);
- break;
- case createCluster:
- createCluster(getEndpoint().getEcsClient(), exchange);
- break;
- case deleteCluster:
- deleteCluster(getEndpoint().getEcsClient(), exchange);
- break;
- default:
- throw new IllegalArgumentException("Unsupported operation");
- }
- }
-
- private ECS2Operations determineOperation(Exchange exchange) {
- ECS2Operations operation = exchange.getIn().getHeader(ECS2Constants.OPERATION, ECS2Operations.class);
- if (operation == null) {
- operation = getConfiguration().getOperation();
- }
- return operation;
- }
-
- protected STS2Configuration getConfiguration() {
- return getEndpoint().getConfiguration();
- }
-
- @Override
- public String toString() {
- if (ecsProducerToString == null) {
- ecsProducerToString = "ECSProducer[" + URISupport.sanitizeUri(getEndpoint().getEndpointUri()) + "]";
- }
- return ecsProducerToString;
- }
-
- @Override
- public ECS2Endpoint getEndpoint() {
- return (ECS2Endpoint)super.getEndpoint();
- }
-
- private void listClusters(EcsClient ecsClient, Exchange exchange) throws InvalidPayloadException {
- if (getConfiguration().isPojoRequest()) {
- Object payload = exchange.getIn().getMandatoryBody();
- if (payload instanceof ListClustersRequest) {
- ListClustersResponse result;
- try {
- ListClustersRequest request = (ListClustersRequest)payload;
- result = ecsClient.listClusters(request);
- } catch (AwsServiceException ase) {
- LOG.trace("List Clusters command returned the error code {}", ase.awsErrorDetails().errorCode());
- throw ase;
- }
- Message message = getMessageForResponse(exchange);
- message.setBody(result);
- }
- } else {
- Builder builder = ListClustersRequest.builder();
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(ECS2Constants.MAX_RESULTS))) {
- int maxRes = exchange.getIn().getHeader(ECS2Constants.MAX_RESULTS, Integer.class);
- builder.maxResults(maxRes);
- }
- ListClustersResponse result;
- try {
- ListClustersRequest request = builder.build();
- result = ecsClient.listClusters(request);
- } catch (AwsServiceException ase) {
- LOG.trace("List Clusters command returned the error code {}", ase.awsErrorDetails().errorCode());
- throw ase;
- }
- Message message = getMessageForResponse(exchange);
- message.setBody(result);
- }
- }
-
- private void createCluster(EcsClient ecsClient, Exchange exchange) throws InvalidPayloadException {
- if (getConfiguration().isPojoRequest()) {
- Object payload = exchange.getIn().getMandatoryBody();
- if (payload instanceof CreateClusterRequest) {
- CreateClusterResponse result;
- try {
- CreateClusterRequest request = (CreateClusterRequest)payload;
- result = ecsClient.createCluster(request);
- } catch (AwsServiceException ase) {
- LOG.trace("Create Cluster command returned the error code {}", ase.awsErrorDetails().errorCode());
- throw ase;
- }
- Message message = getMessageForResponse(exchange);
- message.setBody(result);
- }
- } else {
- CreateClusterRequest.Builder builder = CreateClusterRequest.builder();
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(ECS2Constants.CLUSTER_NAME))) {
- String name = exchange.getIn().getHeader(ECS2Constants.CLUSTER_NAME, String.class);
- builder.clusterName(name);
- }
- CreateClusterResponse result;
- try {
- CreateClusterRequest request = builder.build();
- result = ecsClient.createCluster(request);
- } catch (AwsServiceException ase) {
- LOG.trace("Create Cluster command returned the error code {}", ase.awsErrorDetails().errorCode());
- throw ase;
- }
- Message message = getMessageForResponse(exchange);
- message.setBody(result);
- }
- }
-
- private void describeCluster(EcsClient ecsClient, Exchange exchange) throws InvalidPayloadException {
- if (getConfiguration().isPojoRequest()) {
- Object payload = exchange.getIn().getMandatoryBody();
- if (payload instanceof DescribeClustersRequest) {
- DescribeClustersResponse result;
- try {
- DescribeClustersRequest request = (DescribeClustersRequest)payload;
- result = ecsClient.describeClusters(request);
- } catch (AwsServiceException ase) {
- LOG.trace("Describe Clusters command returned the error code {}", ase.awsErrorDetails().errorCode());
- throw ase;
- }
- Message message = getMessageForResponse(exchange);
- message.setBody(result);
- }
- } else {
- DescribeClustersRequest.Builder builder = DescribeClustersRequest.builder();
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(ECS2Constants.CLUSTER_NAME))) {
- String clusterName = exchange.getIn().getHeader(ECS2Constants.CLUSTER_NAME, String.class);
- builder.clusters(clusterName);
- }
- DescribeClustersResponse result;
- try {
- DescribeClustersRequest request = builder.build();
- result = ecsClient.describeClusters(request);
- } catch (AwsServiceException ase) {
- LOG.trace("Describe Clusters command returned the error code {}", ase.awsErrorDetails().errorCode());
- throw ase;
- }
- Message message = getMessageForResponse(exchange);
- message.setBody(result);
- }
- }
-
- private void deleteCluster(EcsClient ecsClient, Exchange exchange) throws InvalidPayloadException {
- if (getConfiguration().isPojoRequest()) {
- Object payload = exchange.getIn().getMandatoryBody();
- if (payload instanceof DeleteClusterRequest) {
- DeleteClusterResponse result;
- try {
- DeleteClusterRequest request = (DeleteClusterRequest)payload;
- result = ecsClient.deleteCluster(request);
- } catch (AwsServiceException ase) {
- LOG.trace("Delete Cluster command returned the error code {}", ase.awsErrorDetails().errorCode());
- throw ase;
- }
- Message message = getMessageForResponse(exchange);
- message.setBody(result);
- }
- } else {
- DeleteClusterRequest.Builder builder = DeleteClusterRequest.builder();
- if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(ECS2Constants.CLUSTER_NAME))) {
- String name = exchange.getIn().getHeader(ECS2Constants.CLUSTER_NAME, String.class);
- builder.cluster(name);
- } else {
- throw new IllegalArgumentException("Cluster name must be specified");
- }
- DeleteClusterResponse result;
- try {
- DeleteClusterRequest request = builder.build();
- result = ecsClient.deleteCluster(request);
- } catch (AwsServiceException ase) {
- LOG.trace("Delete Cluster command returned the error code {}", ase.awsErrorDetails().errorCode());
- throw ase;
- }
- Message message = getMessageForResponse(exchange);
- message.setBody(result);
- }
- }
-
- public static Message getMessageForResponse(final Exchange exchange) {
- return exchange.getMessage();
- }
-}
diff --git a/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Component.java b/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Component.java
new file mode 100644
index 0000000..d6357b0
--- /dev/null
+++ b/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Component.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws2.sts;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.annotations.Component;
+import org.apache.camel.support.DefaultComponent;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import software.amazon.awssdk.services.sts.StsClient;
+
+/**
+ * For working with Amazon STS SDK v2.
+ */
+@Component("aws2-sts")
+public class STS2Component extends DefaultComponent {
+
+ private static final Logger LOG = LoggerFactory.getLogger(STS2Component.class);
+
+ @Metadata
+ private STS2Configuration configuration = new STS2Configuration();
+
+ public STS2Component() {
+ this(null);
+ }
+
+ public STS2Component(CamelContext context) {
+ super(context);
+
+ registerExtension(new STS2ComponentVerifierExtension());
+ }
+
+ @Override
+ protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+ STS2Configuration configuration = this.configuration != null ? this.configuration.copy()
+ : new STS2Configuration();
+ STS2Endpoint endpoint = new STS2Endpoint(uri, this, configuration);
+ setProperties(endpoint, parameters);
+ if (endpoint.getConfiguration().isAutoDiscoverClient()) {
+ checkAndSetRegistryClient(configuration, endpoint);
+ }
+ if (configuration.getStsClient() == null
+ && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) {
+ throw new IllegalArgumentException("Amazon STS client or accessKey and secretKey must be specified");
+ }
+
+ return endpoint;
+ }
+
+ public STS2Configuration getConfiguration() {
+ return configuration;
+ }
+
+ /**
+ * Component configuration
+ */
+ public void setConfiguration(STS2Configuration configuration) {
+ this.configuration = configuration;
+ }
+
+ private void checkAndSetRegistryClient(STS2Configuration configuration, STS2Endpoint endpoint) {
+ if (ObjectHelper.isEmpty(endpoint.getConfiguration().getStsClient())) {
+ LOG.debug("Looking for an StsClient instance in the registry");
+ Set<StsClient> clients = getCamelContext().getRegistry().findByType(StsClient.class);
+ if (clients.size() == 1) {
+ LOG.debug("Found exactly one StsClient instance in the registry");
+ configuration.setStsClient(clients.stream().findFirst().get());
+ } else {
+ LOG.debug("No StsClient instance in the registry");
+ }
+ } else {
+ LOG.debug("StsClient instance is already set at endpoint level: skipping the check in the registry");
+ }
+ }
+}
diff --git a/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2ComponentVerifierExtension.java b/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2ComponentVerifierExtension.java
new file mode 100644
index 0000000..9006288
--- /dev/null
+++ b/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2ComponentVerifierExtension.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws2.sts;
+
+import java.util.Map;
+
+import org.apache.camel.component.extension.verifier.DefaultComponentVerifierExtension;
+import org.apache.camel.component.extension.verifier.ResultBuilder;
+import org.apache.camel.component.extension.verifier.ResultErrorBuilder;
+import org.apache.camel.component.extension.verifier.ResultErrorHelper;
+import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
+import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
+import software.amazon.awssdk.core.exception.SdkClientException;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.sts.StsClient;
+import software.amazon.awssdk.services.sts.StsClientBuilder;
+
+public class STS2ComponentVerifierExtension extends DefaultComponentVerifierExtension {
+
+ public STS2ComponentVerifierExtension() {
+ this("aws2-sts");
+ }
+
+ public STS2ComponentVerifierExtension(String scheme) {
+ super(scheme);
+ }
+
+ // *********************************
+ // Parameters validation
+ // *********************************
+
+ @Override
+ protected Result verifyParameters(Map<String, Object> parameters) {
+
+ ResultBuilder builder = ResultBuilder.withStatusAndScope(Result.Status.OK, Scope.PARAMETERS)
+ .error(ResultErrorHelper.requiresOption("accessKey", parameters))
+ .error(ResultErrorHelper.requiresOption("secretKey", parameters))
+ .error(ResultErrorHelper.requiresOption("region", parameters));
+
+ // Validate using the catalog
+
+ super.verifyParametersAgainstCatalog(builder, parameters);
+
+ return builder.build();
+ }
+
+ // *********************************
+ // Connectivity validation
+ // *********************************
+
+ @Override
+ protected Result verifyConnectivity(Map<String, Object> parameters) {
+ ResultBuilder builder = ResultBuilder.withStatusAndScope(Result.Status.OK, Scope.CONNECTIVITY);
+
+ try {
+ STS2Configuration configuration = setProperties(new STS2Configuration(), parameters);
+ if (!StsClient.serviceMetadata().regions().contains(Region.of(configuration.getRegion()))) {
+ ResultErrorBuilder errorBuilder = ResultErrorBuilder.withCodeAndDescription(
+ VerificationError.StandardCode.ILLEGAL_PARAMETER,
+ "The service is not supported in this region");
+ return builder.error(errorBuilder.build()).build();
+ }
+ AwsBasicCredentials cred = AwsBasicCredentials.create(configuration.getAccessKey(),
+ configuration.getSecretKey());
+ StsClientBuilder clientBuilder = StsClient.builder();
+ StsClient client = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred))
+ .region(Region.of(configuration.getRegion())).build();
+ client.serviceName();
+ } catch (SdkClientException e) {
+ ResultErrorBuilder errorBuilder = ResultErrorBuilder
+ .withCodeAndDescription(VerificationError.StandardCode.AUTHENTICATION, e.getMessage())
+ .detail("aws_sts_exception_message", e.getMessage())
+ .detail(VerificationError.ExceptionAttribute.EXCEPTION_CLASS, e.getClass().getName())
+ .detail(VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE, e);
+
+ builder.error(errorBuilder.build());
+ } catch (Exception e) {
+ builder.error(ResultErrorBuilder.withException(e).build());
+ }
+ return builder.build();
+ }
+}
diff --git a/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Configuration.java b/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Configuration.java
new file mode 100644
index 0000000..cf4f16a
--- /dev/null
+++ b/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Configuration.java
@@ -0,0 +1,193 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws2.sts;
+
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriParams;
+import org.apache.camel.spi.UriPath;
+import software.amazon.awssdk.core.Protocol;
+import software.amazon.awssdk.services.sts.StsClient;
+
+@UriParams
+public class STS2Configuration implements Cloneable {
+
+ @UriPath(description = "Logical name")
+ @Metadata(required = true)
+ private String label;
+ @UriParam
+ private StsClient stsClient;
+ @UriParam(label = "security", secret = true)
+ private String accessKey;
+ @UriParam(label = "security", secret = true)
+ private String secretKey;
+ @UriParam
+ @Metadata(required = true)
+ private STS2Operations operation;
+ @UriParam(enums = "HTTP,HTTPS", defaultValue = "HTTPS")
+ private Protocol proxyProtocol = Protocol.HTTPS;
+ @UriParam
+ private String proxyHost;
+ @UriParam
+ private Integer proxyPort;
+ @UriParam
+ private String region;
+ @UriParam(defaultValue = "false")
+ private boolean pojoRequest;
+ @UriParam(defaultValue = "false")
+ private boolean trustAllCertificates;
+ @UriParam(label = "common", defaultValue = "true")
+ private boolean autoDiscoverClient = true;
+
+ public StsClient getStsClient() {
+ return stsClient;
+ }
+
+ /**
+ * To use a existing configured AWS ECS as client
+ */
+ public void setStsClient(StsClient ecsClient) {
+ this.stsClient = ecsClient;
+ }
+
+ public String getAccessKey() {
+ return accessKey;
+ }
+
+ /**
+ * Amazon AWS Access Key
+ */
+ public void setAccessKey(String accessKey) {
+ this.accessKey = accessKey;
+ }
+
+ public String getSecretKey() {
+ return secretKey;
+ }
+
+ /**
+ * Amazon AWS Secret Key
+ */
+ public void setSecretKey(String secretKey) {
+ this.secretKey = secretKey;
+ }
+
+ public STS2Operations getOperation() {
+ return operation;
+ }
+
+ /**
+ * The operation to perform
+ */
+ public void setOperation(STS2Operations operation) {
+ this.operation = operation;
+ }
+
+ public Protocol getProxyProtocol() {
+ return proxyProtocol;
+ }
+
+ /**
+ * To define a proxy protocol when instantiating the ECS client
+ */
+ public void setProxyProtocol(Protocol proxyProtocol) {
+ this.proxyProtocol = proxyProtocol;
+ }
+
+ public String getProxyHost() {
+ return proxyHost;
+ }
+
+ /**
+ * To define a proxy host when instantiating the ECS client
+ */
+ public void setProxyHost(String proxyHost) {
+ this.proxyHost = proxyHost;
+ }
+
+ public Integer getProxyPort() {
+ return proxyPort;
+ }
+
+ /**
+ * To define a proxy port when instantiating the ECS client
+ */
+ public void setProxyPort(Integer proxyPort) {
+ this.proxyPort = proxyPort;
+ }
+
+ public String getRegion() {
+ return region;
+ }
+
+ /**
+ * The region in which ECS client needs to work. When using this parameter, the
+ * configuration will expect the lowercase name of the region (for example
+ * ap-east-1) You'll need to use the name Region.EU_WEST_1.id()
+ */
+ public void setRegion(String region) {
+ this.region = region;
+ }
+
+ public boolean isPojoRequest() {
+ return pojoRequest;
+ }
+
+ /**
+ * If we want to use a POJO request as body or not
+ */
+ public void setPojoRequest(boolean pojoRequest) {
+ this.pojoRequest = pojoRequest;
+ }
+
+ public boolean isTrustAllCertificates() {
+ return trustAllCertificates;
+ }
+
+ /**
+ * If we want to trust all certificates in case of overriding the endpoint
+ */
+ public void setTrustAllCertificates(boolean trustAllCertificates) {
+ this.trustAllCertificates = trustAllCertificates;
+ }
+
+ public boolean isAutoDiscoverClient() {
+ return autoDiscoverClient;
+ }
+
+ /**
+ * Setting the autoDiscoverClient mechanism, if true, the component will look
+ * for a client instance in the registry automatically otherwise it will skip
+ * that checking.
+ */
+ public void setAutoDiscoverClient(boolean autoDiscoverClient) {
+ this.autoDiscoverClient = autoDiscoverClient;
+ }
+
+ // *************************************************
+ //
+ // *************************************************
+
+ public STS2Configuration copy() {
+ try {
+ return (STS2Configuration) super.clone();
+ } catch (CloneNotSupportedException e) {
+ throw new RuntimeCamelException(e);
+ }
+ }
+}
diff --git a/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Constants.java b/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Constants.java
similarity index 75%
rename from components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Constants.java
rename to components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Constants.java
index 49debe6..1cbcc77 100644
--- a/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Constants.java
+++ b/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Constants.java
@@ -14,13 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.component.aws2.ecs;
+package org.apache.camel.component.aws2.sts;
/**
- * Constants used in Camel AWS2 ECS module
+ * Constants used in Camel AWS2 STS module
*/
-public interface ECS2Constants {
- String OPERATION = "CamelAwsECSOperation";
- String MAX_RESULTS = "CamelAwsECSMaxResults";
- String CLUSTER_NAME = "CamelAwsECSClusterName";
+public interface STS2Constants {
+ String OPERATION = "CamelAwsECSOperation";
+ String MAX_RESULTS = "CamelAwsECSMaxResults";
+ String CLUSTER_NAME = "CamelAwsECSClusterName";
}
diff --git a/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Endpoint.java b/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Endpoint.java
new file mode 100644
index 0000000..96df599
--- /dev/null
+++ b/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Endpoint.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws2.sts;
+
+import java.net.URI;
+
+import org.apache.camel.Category;
+import org.apache.camel.Component;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.support.DefaultEndpoint;
+import org.apache.camel.support.ScheduledPollEndpoint;
+import org.apache.camel.util.ObjectHelper;
+import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
+import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
+import software.amazon.awssdk.http.SdkHttpClient;
+import software.amazon.awssdk.http.SdkHttpConfigurationOption;
+import software.amazon.awssdk.http.apache.ApacheHttpClient;
+import software.amazon.awssdk.http.apache.ProxyConfiguration;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.sts.StsClient;
+import software.amazon.awssdk.services.sts.StsClientBuilder;
+import software.amazon.awssdk.utils.AttributeMap;
+
+/**
+ * Manage AWS ECS cluster instances using AWS SDK version 2.x.
+ */
+@UriEndpoint(firstVersion = "3.5.0", scheme = "aws2-sts", title = "AWS 2 Security Token Service (STS)", syntax = "aws2-sts:label", producerOnly = true, category = {
+ Category.CLOUD, Category.MANAGEMENT })
+public class STS2Endpoint extends DefaultEndpoint {
+
+ private StsClient stsClient;
+
+ @UriParam
+ private STS2Configuration configuration;
+
+ public STS2Endpoint(String uri, Component component, STS2Configuration configuration) {
+ super(uri, component);
+ this.configuration = configuration;
+ }
+
+ @Override
+ public Consumer createConsumer(Processor processor) throws Exception {
+ throw new UnsupportedOperationException("You cannot receive messages from this endpoint");
+ }
+
+ @Override
+ public Producer createProducer() throws Exception {
+ return new STS2Producer(this);
+ }
+
+ @Override
+ public void doStart() throws Exception {
+ super.doStart();
+
+ stsClient = configuration.getStsClient() != null ? configuration.getStsClient() : createStsClient();
+ }
+
+ @Override
+ public void doStop() throws Exception {
+ if (ObjectHelper.isEmpty(configuration.getStsClient())) {
+ if (stsClient != null) {
+ stsClient.close();
+ }
+ }
+ super.doStop();
+ }
+
+ public STS2Configuration getConfiguration() {
+ return configuration;
+ }
+
+ public StsClient getStsClient() {
+ return stsClient;
+ }
+
+ StsClient createStsClient() {
+ StsClient client = null;
+ StsClientBuilder clientBuilder = StsClient.builder();
+ ProxyConfiguration.Builder proxyConfig = null;
+ ApacheHttpClient.Builder httpClientBuilder = null;
+ boolean isClientConfigFound = false;
+ if (ObjectHelper.isNotEmpty(configuration.getProxyHost())
+ && ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
+ proxyConfig = ProxyConfiguration.builder();
+ URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":"
+ + configuration.getProxyPort());
+ proxyConfig.endpoint(proxyEndpoint);
+ httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build());
+ isClientConfigFound = true;
+ }
+ if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) {
+ AwsBasicCredentials cred = AwsBasicCredentials.create(configuration.getAccessKey(),
+ configuration.getSecretKey());
+ if (isClientConfigFound) {
+ clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder)
+ .credentialsProvider(StaticCredentialsProvider.create(cred));
+ } else {
+ clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred));
+ }
+ } else {
+ if (!isClientConfigFound) {
+ clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder);
+ }
+ }
+ if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
+ clientBuilder = clientBuilder.region(Region.of(configuration.getRegion()));
+ }
+ if (configuration.isTrustAllCertificates()) {
+ SdkHttpClient ahc = ApacheHttpClient.builder().buildWithDefaults(AttributeMap.builder()
+ .put(SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, Boolean.TRUE).build());
+ clientBuilder.httpClient(ahc);
+ }
+ client = clientBuilder.build();
+ return client;
+ }
+}
diff --git a/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Operations.java b/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Operations.java
similarity index 85%
rename from components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Operations.java
rename to components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Operations.java
index 09930f8..ecc3051 100644
--- a/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/ecs/ECS2Operations.java
+++ b/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Operations.java
@@ -14,9 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.component.aws2.ecs;
+package org.apache.camel.component.aws2.sts;
-public enum ECS2Operations {
+public enum STS2Operations {
- listClusters, describeCluster, createCluster, deleteCluster
+ assumeRole
}
diff --git a/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Producer.java b/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Producer.java
new file mode 100644
index 0000000..74f2157
--- /dev/null
+++ b/components/camel-aws2-sts/src/main/java/org/apache/camel/component/aws2/sts/STS2Producer.java
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws2.sts;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.InvalidPayloadException;
+import org.apache.camel.Message;
+import org.apache.camel.support.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.URISupport;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import software.amazon.awssdk.awscore.exception.AwsServiceException;
+import software.amazon.awssdk.services.sts.StsClient;
+import software.amazon.awssdk.services.sts.model.AssumeRoleRequest;
+import software.amazon.awssdk.services.sts.model.AssumeRoleRequest.Builder;
+import software.amazon.awssdk.services.sts.model.AssumeRoleResponse;
+
+/**
+ * A Producer which sends messages to the Amazon ECS Service SDK v2
+ * <a href="http://aws.amazon.com/ecs/">AWS ECS</a>
+ */
+public class STS2Producer extends DefaultProducer {
+
+ private static final Logger LOG = LoggerFactory.getLogger(STS2Producer.class);
+
+ private transient String ecsProducerToString;
+
+ public STS2Producer(Endpoint endpoint) {
+ super(endpoint);
+ }
+
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ switch (determineOperation(exchange)) {
+ case assumeRole:
+ assumeRole(getEndpoint().getStsClient(), exchange);
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported operation");
+ }
+ }
+
+ private STS2Operations determineOperation(Exchange exchange) {
+ STS2Operations operation = exchange.getIn().getHeader(STS2Constants.OPERATION, STS2Operations.class);
+ if (operation == null) {
+ operation = getConfiguration().getOperation();
+ }
+ return operation;
+ }
+
+ protected STS2Configuration getConfiguration() {
+ return getEndpoint().getConfiguration();
+ }
+
+ @Override
+ public String toString() {
+ if (ecsProducerToString == null) {
+ ecsProducerToString = "ECSProducer[" + URISupport.sanitizeUri(getEndpoint().getEndpointUri()) + "]";
+ }
+ return ecsProducerToString;
+ }
+
+ @Override
+ public STS2Endpoint getEndpoint() {
+ return (STS2Endpoint) super.getEndpoint();
+ }
+
+ private void assumeRole(StsClient stsClient, Exchange exchange) throws InvalidPayloadException {
+ if (getConfiguration().isPojoRequest()) {
+ Object payload = exchange.getIn().getMandatoryBody();
+ if (payload instanceof AssumeRoleRequest) {
+ AssumeRoleResponse result;
+ try {
+ AssumeRoleRequest request = (AssumeRoleRequest) payload;
+ result = stsClient.assumeRole(request);
+ } catch (AwsServiceException ase) {
+ LOG.trace("Assume Role command returned the error code {}", ase.awsErrorDetails().errorCode());
+ throw ase;
+ }
+ Message message = getMessageForResponse(exchange);
+ message.setBody(result);
+ }
+ } else {
+ Builder builder = AssumeRoleRequest.builder();
+ if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(STS2Constants.MAX_RESULTS))) {
+ int maxRes = exchange.getIn().getHeader(STS2Constants.MAX_RESULTS, Integer.class);
+ builder.maxResults(maxRes);
+ }
+ ListClustersResponse result;
+ try {
+ ListClustersRequest request = builder.build();
+ result = ecsClient.listClusters(request);
+ } catch (AwsServiceException ase) {
+ LOG.trace("List Clusters command returned the error code {}", ase.awsErrorDetails().errorCode());
+ throw ase;
+ }
+ Message message = getMessageForResponse(exchange);
+ message.setBody(result);
+ }
+ }
+
+ public static Message getMessageForResponse(final Exchange exchange) {
+ return exchange.getMessage();
+ }
+}
diff --git a/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ComponentClientRegistryTest.java b/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ComponentClientRegistryTest.java
index fb406b4..2ee7c98 100644
--- a/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ComponentClientRegistryTest.java
+++ b/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ComponentClientRegistryTest.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel.component.aws2.ecs;
+import org.apache.camel.component.aws2.sts.STS2Component;
+import org.apache.camel.component.aws2.sts.STS2Endpoint;
import org.apache.camel.test.junit5.CamelTestSupport;
import org.junit.jupiter.api.Test;
@@ -32,7 +34,7 @@
AmazonECSClientMock clientMock = new AmazonECSClientMock();
context.getRegistry().bind("amazonEcsClient", clientMock);
STS2Component component = context.getComponent("aws2-ecs", STS2Component.class);
- ECS2Endpoint endpoint = (ECS2Endpoint)component.createEndpoint("aws2-ecs://TestDomain");
+ STS2Endpoint endpoint = (STS2Endpoint)component.createEndpoint("aws2-ecs://TestDomain");
assertNotNull(endpoint.getConfiguration().getEcsClient());
}
@@ -52,7 +54,7 @@
AmazonECSClientMock clientMock = new AmazonECSClientMock();
context.getRegistry().bind("amazonEcsClient", clientMock);
STS2Component component = context.getComponent("aws2-ecs", STS2Component.class);
- ECS2Endpoint endpoint = (ECS2Endpoint)component.createEndpoint("aws2-ecs://TestDomain?accessKey=xxx&secretKey=yyy&autoDiscoverClient=false");
+ STS2Endpoint endpoint = (STS2Endpoint)component.createEndpoint("aws2-ecs://TestDomain?accessKey=xxx&secretKey=yyy&autoDiscoverClient=false");
assertNotSame(clientMock, endpoint.getConfiguration().getEcsClient());
}
@@ -63,7 +65,7 @@
AmazonECSClientMock clientMock = new AmazonECSClientMock();
context.getRegistry().bind("amazonEcsClient", clientMock);
STS2Component component = context.getComponent("aws2-ecs", STS2Component.class);
- ECS2Endpoint endpoint = (ECS2Endpoint)component.createEndpoint("aws2-ecs://TestDomain?accessKey=xxx&secretKey=yyy");
+ STS2Endpoint endpoint = (STS2Endpoint)component.createEndpoint("aws2-ecs://TestDomain?accessKey=xxx&secretKey=yyy");
assertSame(clientMock, endpoint.getConfiguration().getEcsClient());
}
diff --git a/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ComponentConfigurationTest.java b/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ComponentConfigurationTest.java
index 721cb42..4ed7aa0 100644
--- a/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ComponentConfigurationTest.java
+++ b/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ComponentConfigurationTest.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel.component.aws2.ecs;
+import org.apache.camel.component.aws2.sts.STS2Component;
+import org.apache.camel.component.aws2.sts.STS2Endpoint;
import org.apache.camel.test.junit5.CamelTestSupport;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.core.Protocol;
@@ -30,7 +32,7 @@
STS2Component component = context.getComponent("aws2-ecs", STS2Component.class);
component.getConfiguration().setAccessKey("XXX");
component.getConfiguration().setSecretKey("YYY");
- ECS2Endpoint endpoint = (ECS2Endpoint)component.createEndpoint("aws2-ecs://label");
+ STS2Endpoint endpoint = (STS2Endpoint)component.createEndpoint("aws2-ecs://label");
assertEquals("XXX", endpoint.getConfiguration().getAccessKey());
assertEquals("YYY", endpoint.getConfiguration().getSecretKey());
@@ -42,7 +44,7 @@
component.getConfiguration().setAccessKey("XXX");
component.getConfiguration().setSecretKey("YYY");
component.getConfiguration().setRegion(Region.US_WEST_1.toString());
- ECS2Endpoint endpoint = (ECS2Endpoint)component.createEndpoint("aws2-ecs://label?accessKey=xxxxxx&secretKey=yyyyy®ion=US_EAST_1");
+ STS2Endpoint endpoint = (STS2Endpoint)component.createEndpoint("aws2-ecs://label?accessKey=xxxxxx&secretKey=yyyyy®ion=US_EAST_1");
assertEquals("xxxxxx", endpoint.getConfiguration().getAccessKey());
assertEquals("yyyyy", endpoint.getConfiguration().getSecretKey());
@@ -55,7 +57,7 @@
component.getConfiguration().setAccessKey("XXX");
component.getConfiguration().setSecretKey("YYY");
component.getConfiguration().setRegion(Region.US_WEST_1.toString());
- ECS2Endpoint endpoint = (ECS2Endpoint)component
+ STS2Endpoint endpoint = (STS2Endpoint)component
.createEndpoint("aws2-ecs://label?accessKey=xxxxxx&secretKey=yyyyy®ion=US_EAST_1&proxyHost=localhost&proxyPort=9000&proxyProtocol=HTTP");
assertEquals("xxxxxx", endpoint.getConfiguration().getAccessKey());
diff --git a/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ComponentVerifierExtensionTest.java b/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ComponentVerifierExtensionTest.java
index 0116365..485cbbe 100644
--- a/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ComponentVerifierExtensionTest.java
+++ b/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ComponentVerifierExtensionTest.java
@@ -20,6 +20,7 @@
import java.util.Map;
import org.apache.camel.Component;
+import org.apache.camel.component.aws2.sts.STS2Operations;
import org.apache.camel.component.extension.ComponentVerifierExtension;
import org.apache.camel.test.junit5.CamelTestSupport;
import org.junit.jupiter.api.Test;
@@ -47,7 +48,7 @@
parameters.put("accessKey", "k");
parameters.put("region", "l");
parameters.put("label", "test");
- parameters.put("operation", ECS2Operations.listClusters);
+ parameters.put("operation", STS2Operations.listClusters);
ComponentVerifierExtension.Result result = verifier.verify(ComponentVerifierExtension.Scope.PARAMETERS, parameters);
@@ -64,7 +65,7 @@
parameters.put("accessKey", "k");
parameters.put("region", "US_EAST_1");
parameters.put("label", "test");
- parameters.put("operation", ECS2Operations.listClusters);
+ parameters.put("operation", STS2Operations.listClusters);
ComponentVerifierExtension.Result result = verifier.verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters);
@@ -81,7 +82,7 @@
parameters.put("accessKey", "k");
parameters.put("region", "l");
parameters.put("label", "test");
- parameters.put("operation", ECS2Operations.listClusters);
+ parameters.put("operation", STS2Operations.listClusters);
ComponentVerifierExtension.Result result = verifier.verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters);
diff --git a/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ProducerSpringTest.java b/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ProducerSpringTest.java
index b5d7858..4f423c7 100644
--- a/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ProducerSpringTest.java
+++ b/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ProducerSpringTest.java
@@ -19,6 +19,8 @@
import org.apache.camel.EndpointInject;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
+import org.apache.camel.component.aws2.sts.STS2Constants;
+import org.apache.camel.component.aws2.sts.STS2Operations;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.spring.junit5.CamelSpringTestSupport;
import org.junit.jupiter.api.Test;
@@ -43,7 +45,7 @@
Exchange exchange = template.request("direct:listClusters", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
- exchange.getIn().setHeader(ECS2Constants.OPERATION, ECS2Operations.listClusters);
+ exchange.getIn().setHeader(STS2Constants.OPERATION, STS2Operations.listClusters);
}
});
@@ -61,7 +63,7 @@
Exchange exchange = template.request("direct:listClustersPojo", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
- exchange.getIn().setHeader(ECS2Constants.OPERATION, ECS2Operations.listClusters);
+ exchange.getIn().setHeader(STS2Constants.OPERATION, STS2Operations.listClusters);
exchange.getIn().setBody(ListClustersRequest.builder().maxResults(10).build());
}
});
@@ -80,8 +82,8 @@
Exchange exchange = template.request("direct:createCluster", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
- exchange.getIn().setHeader(ECS2Constants.OPERATION, ECS2Operations.createCluster);
- exchange.getIn().setHeader(ECS2Constants.CLUSTER_NAME, "Test");
+ exchange.getIn().setHeader(STS2Constants.OPERATION, STS2Operations.createCluster);
+ exchange.getIn().setHeader(STS2Constants.CLUSTER_NAME, "Test");
}
});
@@ -98,8 +100,8 @@
Exchange exchange = template.request("direct:describeCluster", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
- exchange.getIn().setHeader(ECS2Constants.OPERATION, ECS2Operations.describeCluster);
- exchange.getIn().setHeader(ECS2Constants.CLUSTER_NAME, "Test");
+ exchange.getIn().setHeader(STS2Constants.OPERATION, STS2Operations.describeCluster);
+ exchange.getIn().setHeader(STS2Constants.CLUSTER_NAME, "Test");
}
});
@@ -116,8 +118,8 @@
Exchange exchange = template.request("direct:deleteCluster", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
- exchange.getIn().setHeader(ECS2Constants.OPERATION, ECS2Operations.deleteCluster);
- exchange.getIn().setHeader(ECS2Constants.CLUSTER_NAME, "Test");
+ exchange.getIn().setHeader(STS2Constants.OPERATION, STS2Operations.deleteCluster);
+ exchange.getIn().setHeader(STS2Constants.CLUSTER_NAME, "Test");
}
});
diff --git a/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ProducerTest.java b/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ProducerTest.java
index 142ecab..0f02c8a 100644
--- a/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ProducerTest.java
+++ b/components/camel-aws2-sts/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ProducerTest.java
@@ -21,6 +21,8 @@
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.aws2.sts.STS2Constants;
+import org.apache.camel.component.aws2.sts.STS2Operations;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.junit5.CamelTestSupport;
import org.junit.jupiter.api.Test;
@@ -47,7 +49,7 @@
Exchange exchange = template.request("direct:listClusters", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
- exchange.getIn().setHeader(ECS2Constants.OPERATION, ECS2Operations.listClusters);
+ exchange.getIn().setHeader(STS2Constants.OPERATION, STS2Operations.listClusters);
}
});
@@ -65,7 +67,7 @@
Exchange exchange = template.request("direct:listClustersPojo", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
- exchange.getIn().setHeader(ECS2Constants.OPERATION, ECS2Operations.listClusters);
+ exchange.getIn().setHeader(STS2Constants.OPERATION, STS2Operations.listClusters);
exchange.getIn().setBody(ListClustersRequest.builder().maxResults(10).build());
}
});
@@ -84,8 +86,8 @@
Exchange exchange = template.request("direct:createCluster", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
- exchange.getIn().setHeader(ECS2Constants.OPERATION, ECS2Operations.createCluster);
- exchange.getIn().setHeader(ECS2Constants.CLUSTER_NAME, "Test");
+ exchange.getIn().setHeader(STS2Constants.OPERATION, STS2Operations.createCluster);
+ exchange.getIn().setHeader(STS2Constants.CLUSTER_NAME, "Test");
}
});
@@ -102,8 +104,8 @@
Exchange exchange = template.request("direct:describeCluster", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
- exchange.getIn().setHeader(ECS2Constants.OPERATION, ECS2Operations.describeCluster);
- exchange.getIn().setHeader(ECS2Constants.CLUSTER_NAME, "Test");
+ exchange.getIn().setHeader(STS2Constants.OPERATION, STS2Operations.describeCluster);
+ exchange.getIn().setHeader(STS2Constants.CLUSTER_NAME, "Test");
}
});
@@ -120,8 +122,8 @@
Exchange exchange = template.request("direct:deleteCluster", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
- exchange.getIn().setHeader(ECS2Constants.OPERATION, ECS2Operations.deleteCluster);
- exchange.getIn().setHeader(ECS2Constants.CLUSTER_NAME, "Test");
+ exchange.getIn().setHeader(STS2Constants.OPERATION, STS2Operations.deleteCluster);
+ exchange.getIn().setHeader(STS2Constants.CLUSTER_NAME, "Test");
}
});