From 20d164c6440cc238c9a0e033981b17def4918b0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Pupier?= Date: Tue, 5 May 2026 09:53:47 +0200 Subject: [PATCH] Removal of Camel Elytron component MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit the component was deprecated in Camel 4.0.0 Signed-off-by: Aurélien Pupier --- bom/camel-bom/pom.xml | 5 - catalog/camel-allcomponents/pom.xml | 5 - .../apache/camel/catalog/others.properties | 1 - .../apache/camel/catalog/others/elytron.json | 15 -- components/camel-elytron/pom.xml | 116 ------------- .../org/apache/camel/other.properties | 7 - .../src/generated/resources/elytron.json | 15 -- .../camel-elytron/src/main/docs/elytron.adoc | 52 ------ .../elytron/ElytronSecurityProvider.java | 158 ------------------ .../ElytronSercurityConfiguration.java | 42 ----- .../component/elytron/BaseElytronTest.java | 143 ---------------- .../elytron/ElytronBearerTokenTest.java | 128 -------------- .../src/test/resources/log4j2.properties | 29 ---- components/pom.xml | 1 - coverage/pom.xml | 5 - .../modules/others/examples/json/elytron.json | 1 - docs/components/modules/others/nav.adoc | 1 - .../modules/others/pages/elytron.adoc | 1 - .../pages/camel-4x-upgrade-guide-4_21.adoc | 4 + parent/pom.xml | 8 - 20 files changed, 4 insertions(+), 733 deletions(-) delete mode 100644 catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others/elytron.json delete mode 100644 components/camel-elytron/pom.xml delete mode 100644 components/camel-elytron/src/generated/resources/META-INF/services/org/apache/camel/other.properties delete mode 100644 components/camel-elytron/src/generated/resources/elytron.json delete mode 100644 components/camel-elytron/src/main/docs/elytron.adoc delete mode 100644 components/camel-elytron/src/main/java/org/apache/camel/component/elytron/ElytronSecurityProvider.java delete mode 100644 components/camel-elytron/src/main/java/org/apache/camel/component/elytron/ElytronSercurityConfiguration.java delete mode 100644 components/camel-elytron/src/test/java/org/apache/camel/component/elytron/BaseElytronTest.java delete mode 100644 components/camel-elytron/src/test/java/org/apache/camel/component/elytron/ElytronBearerTokenTest.java delete mode 100644 components/camel-elytron/src/test/resources/log4j2.properties delete mode 120000 docs/components/modules/others/examples/json/elytron.json delete mode 120000 docs/components/modules/others/pages/elytron.adoc diff --git a/bom/camel-bom/pom.xml b/bom/camel-bom/pom.xml index b6331d727f3d1..197b045cb6bf0 100644 --- a/bom/camel-bom/pom.xml +++ b/bom/camel-bom/pom.xml @@ -827,11 +827,6 @@ camel-elasticsearch-rest-client 4.21.0-SNAPSHOT - - org.apache.camel - camel-elytron - 4.21.0-SNAPSHOT - org.apache.camel camel-endpointdsl diff --git a/catalog/camel-allcomponents/pom.xml b/catalog/camel-allcomponents/pom.xml index 27310d6f498a6..eba17d5cbe70b 100644 --- a/catalog/camel-allcomponents/pom.xml +++ b/catalog/camel-allcomponents/pom.xml @@ -707,11 +707,6 @@ camel-elasticsearch-rest-client ${project.version} - - org.apache.camel - camel-elytron - ${project.version} - org.apache.camel camel-event diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others.properties b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others.properties index eef523c42ca57..deded373fdb44 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others.properties +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others.properties @@ -10,7 +10,6 @@ csimple-joor debug diagram dsl-modeline -elytron endpointdsl headersmap health diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others/elytron.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others/elytron.json deleted file mode 100644 index 68e2b40843840..0000000000000 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others/elytron.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "other": { - "kind": "other", - "name": "elytron", - "title": "Elytron", - "description": "Elytron Security Provider for camel-undertow", - "deprecated": true, - "firstVersion": "3.1.0", - "label": "security", - "supportLevel": "Stable", - "groupId": "org.apache.camel", - "artifactId": "camel-elytron", - "version": "4.21.0-SNAPSHOT" - } -} diff --git a/components/camel-elytron/pom.xml b/components/camel-elytron/pom.xml deleted file mode 100644 index 680286540d062..0000000000000 --- a/components/camel-elytron/pom.xml +++ /dev/null @@ -1,116 +0,0 @@ - - - - 4.0.0 - - - org.apache.camel - components - 4.21.0-SNAPSHOT - - - camel-elytron - jar - Camel :: Elytron (deprecated) - Elytron Security Provider for camel-undertow - - - - 3.1.0 - - - - - org.apache.camel - camel-undertow - - - - org.wildfly.security - wildfly-elytron - ${wildfly-elytron} - - - * - * - - - - - org.wildfly.security.elytron-web - undertow-server - ${elytron-web} - - - org.wildfly.security.elytron-web - undertow-server-servlet - ${elytron-web} - - - io.undertow - undertow-servlet - ${undertow-servlet-version} - - - com.fasterxml.jackson.jakarta.rs - jackson-jakarta-rs-json-provider - - - jakarta.json - jakarta.json-api - ${jakarta-json-api-version} - - - org.eclipse.parsson - parsson - ${parson-version} - - - - com.nimbusds - nimbus-jose-jwt - ${nimbus-jose-jwt} - - - - - org.apache.camel - camel-test-junit6 - test - - - org.apache.camel - camel-test-spring-junit6 - test - - - org.junit.jupiter - junit-jupiter - test - - - org.apache.logging.log4j - log4j-slf4j-impl - ${log4j2-version} - test - - - - diff --git a/components/camel-elytron/src/generated/resources/META-INF/services/org/apache/camel/other.properties b/components/camel-elytron/src/generated/resources/META-INF/services/org/apache/camel/other.properties deleted file mode 100644 index 7f45f31b5f592..0000000000000 --- a/components/camel-elytron/src/generated/resources/META-INF/services/org/apache/camel/other.properties +++ /dev/null @@ -1,7 +0,0 @@ -# Generated by camel build tools - do NOT edit this file! -name=elytron -groupId=org.apache.camel -artifactId=camel-elytron -version=4.21.0-SNAPSHOT -projectName=Camel :: Elytron (deprecated) -projectDescription=Elytron Security Provider for camel-undertow diff --git a/components/camel-elytron/src/generated/resources/elytron.json b/components/camel-elytron/src/generated/resources/elytron.json deleted file mode 100644 index 68e2b40843840..0000000000000 --- a/components/camel-elytron/src/generated/resources/elytron.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "other": { - "kind": "other", - "name": "elytron", - "title": "Elytron", - "description": "Elytron Security Provider for camel-undertow", - "deprecated": true, - "firstVersion": "3.1.0", - "label": "security", - "supportLevel": "Stable", - "groupId": "org.apache.camel", - "artifactId": "camel-elytron", - "version": "4.21.0-SNAPSHOT" - } -} diff --git a/components/camel-elytron/src/main/docs/elytron.adoc b/components/camel-elytron/src/main/docs/elytron.adoc deleted file mode 100644 index 789625a515301..0000000000000 --- a/components/camel-elytron/src/main/docs/elytron.adoc +++ /dev/null @@ -1,52 +0,0 @@ -= Elytron Component (deprecated) -:doctitle: Elytron -:shortname: elytron -:artifactid: camel-elytron -:description: Elytron Security Provider for camel-undertow -:since: 3.1 -:supportlevel: Stable-deprecated -:deprecated: *deprecated* -:tabs-sync-option: - -*Since Camel {since}* - -The Elytron Security Provider provides Elytron security over the Camel Elytron component. -It enables the Camel Elytron component to use Elytron security capabilities. -To force Camel Elytron to use elytron security provider, add the elytron security provider library -on classpath and provide instance of `ElytronSecurityConfiguration` as `securityConfiguration` -parameter into the Camel Elytron component or provide both `securityConfiguration` and `securityProvider` -into the Camel Elytron component. - -Configuration has to provide all three security attributes: - -[width="100%",cols="2,5,^3",options="header"] -|=== -| Name | Description | Type -| *domainBuilder* | Builder for security domain. | `SecurityDomain.Builder` -| *mechanismName* | MechanismName should be selected with regard to default securityRealm. For -example, to use bearer_token security, mechanism name has to be `BEARER_TOKEN` and realm has to be `TokenSecurityReal` | `String` -| *elytronProvider* | Instance of WildFlyElytronBaseProvider with respect of mechanismName | `WildFlyElytronBaseProvider` -|=== - -Each exchange created by Undertow endpoint with Elytron security contains header `securityIdentity` -with current Elytron's security identity as value. -(`org.wildfly.security.auth.server.SecurityIdentity`) or is _FORBIDDEN_ (status code 403) - -Maven users will need to add the following dependency to their `pom.xml` -for this component: - -[source,xml] ----- - - org.apache.camel - camel-elytron - x.x.x - - ----- - -== Other Elytron capabilities - -This security provider contains only basic Elytron dependencies (without any transitive dependency -from `org.wildfly.security:wildfly-elytron`). -Ignored libraries should be added among application's dependencies for their usage. diff --git a/components/camel-elytron/src/main/java/org/apache/camel/component/elytron/ElytronSecurityProvider.java b/components/camel-elytron/src/main/java/org/apache/camel/component/elytron/ElytronSecurityProvider.java deleted file mode 100644 index 157fa052e1644..0000000000000 --- a/components/camel-elytron/src/main/java/org/apache/camel/component/elytron/ElytronSecurityProvider.java +++ /dev/null @@ -1,158 +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.elytron; - -import java.security.Provider; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.function.BiConsumer; - -import io.undertow.security.handlers.AuthenticationCallHandler; -import io.undertow.security.handlers.AuthenticationConstraintHandler; -import io.undertow.server.HttpHandler; -import io.undertow.server.HttpServerExchange; -import io.undertow.util.StatusCodes; -import org.apache.camel.RuntimeCamelException; -import org.apache.camel.component.undertow.spi.UndertowSecurityProvider; -import org.wildfly.elytron.web.undertow.server.ElytronContextAssociationHandler; -import org.wildfly.elytron.web.undertow.server.ElytronRunAsHandler; -import org.wildfly.security.WildFlyElytronBaseProvider; -import org.wildfly.security.auth.server.MechanismConfiguration; -import org.wildfly.security.auth.server.MechanismConfigurationSelector; -import org.wildfly.security.auth.server.MechanismRealmConfiguration; -import org.wildfly.security.auth.server.SecurityDomain; -import org.wildfly.security.auth.server.SecurityIdentity; -import org.wildfly.security.auth.server.http.HttpAuthenticationFactory; -import org.wildfly.security.authz.Roles; -import org.wildfly.security.http.HttpAuthenticationException; -import org.wildfly.security.http.HttpServerAuthenticationMechanismFactory; -import org.wildfly.security.http.util.FilterServerMechanismFactory; -import org.wildfly.security.http.util.SecurityProviderServerMechanismFactory; - -/** - * Implementation of `UndertowSecurityProvider` which adds elytron capability into camel-undertow. Provider requires - * instance of `ElytronSecurityConfiguration` to be provided as `securityConfiguration` parameter in camel-undertow. - */ -@Deprecated -public class ElytronSecurityProvider implements UndertowSecurityProvider { - /** - * Name of the header which contains associated security identity if request is authenticated. - */ - public static final String SECURITY_IDENTITY_HEADER = "securityIdentity"; - - private SecurityDomain securityDomain; - private WildFlyElytronBaseProvider elytronProvider; - private String mechanismName; - - /** - * Provider adds header `securityIdentity` with value of type `SecurityIdentity` after successful authentication. - */ - @Override - public void addHeader(BiConsumer consumer, HttpServerExchange httpExchange) throws Exception { - SecurityIdentity securityIdentity = this.securityDomain.getCurrentSecurityIdentity(); - //add security principal to headers - consumer.accept(SECURITY_IDENTITY_HEADER, securityIdentity); - } - - /** - * Authentication is verified by securityDomain from configuration. - */ - @Override - public int authenticate(HttpServerExchange httpExchange, List allowedRoles) throws Exception { - SecurityIdentity identity = this.securityDomain.getCurrentSecurityIdentity(); - - if (identity != null) { - //already authenticated - Set roles = new HashSet<>(); - Roles identityRoles = identity.getRoles(); - - if (identityRoles != null) { - for (String roleName : identityRoles) { - roles.add(roleName); - } - } - - if (isAllowed(roles, allowedRoles)) { - return StatusCodes.OK; - } - } - - return StatusCodes.FORBIDDEN; - } - - @Override - public boolean acceptConfiguration(Object configuration, String endpointUri) throws Exception { - if (configuration instanceof ElytronSercurityConfiguration) { - ElytronSercurityConfiguration conf = (ElytronSercurityConfiguration) configuration; - this.securityDomain = conf.getDomainBuilder().build(); - this.mechanismName = conf.getMechanismName(); - this.elytronProvider = conf.getElytronProvider(); - return true; - } - - return false; - } - - /** - * Elytron hook into undertow is by creation of wrapping httpHandler. - */ - @Override - public HttpHandler wrapHttpHandler(HttpHandler httpHandler) throws Exception { - HttpAuthenticationFactory httpAuthenticationFactory = createHttpAuthenticationFactory(securityDomain); - - HttpHandler rootHandler = new ElytronRunAsHandler(httpHandler); - rootHandler = new AuthenticationCallHandler(rootHandler); - rootHandler = new AuthenticationConstraintHandler(rootHandler); - - return ElytronContextAssociationHandler.builder() - .setNext(rootHandler) - .setMechanismSupplier(() -> { - try { - return Collections.singletonList(httpAuthenticationFactory.createMechanism(mechanismName)); - } catch (HttpAuthenticationException e) { - throw new RuntimeCamelException(e); - } - }).build(); - } - - private HttpAuthenticationFactory createHttpAuthenticationFactory(final SecurityDomain securityDomain) { - HttpServerAuthenticationMechanismFactory providerFactory - = new SecurityProviderServerMechanismFactory(() -> new Provider[] { this.elytronProvider }); - HttpServerAuthenticationMechanismFactory httpServerMechanismFactory - = new FilterServerMechanismFactory(providerFactory, true, this.mechanismName); - - return HttpAuthenticationFactory.builder() - .setSecurityDomain(securityDomain) - .setMechanismConfigurationSelector(MechanismConfigurationSelector.constantSelector( - MechanismConfiguration.builder() - .addMechanismRealm(MechanismRealmConfiguration.builder().setRealmName("Elytron Realm").build()) - .build())) - .setFactory(httpServerMechanismFactory) - .build(); - } - - public boolean isAllowed(Set roles, List allowedRoles) { - for (String role : allowedRoles) { - if (roles.contains(role)) { - return true; - } - } - return false; - } -} diff --git a/components/camel-elytron/src/main/java/org/apache/camel/component/elytron/ElytronSercurityConfiguration.java b/components/camel-elytron/src/main/java/org/apache/camel/component/elytron/ElytronSercurityConfiguration.java deleted file mode 100644 index cda10e52cf8e6..0000000000000 --- a/components/camel-elytron/src/main/java/org/apache/camel/component/elytron/ElytronSercurityConfiguration.java +++ /dev/null @@ -1,42 +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.elytron; - -import org.wildfly.security.WildFlyElytronBaseProvider; -import org.wildfly.security.auth.server.SecurityDomain; - -/** - * Instance of this interface has to be provided as `securityConfiguration` parameter into camel-undertow. - */ -@Deprecated -public interface ElytronSercurityConfiguration { - - /** - * Elytron security provider, has to support mechanism from parameter mechanismName. - */ - WildFlyElytronBaseProvider getElytronProvider(); - - /** - * Name of the mechanism, which will be used for selection of authentication mechanism. - */ - String getMechanismName(); - - /** - * Definition of Builder, which will be used for creation of security domain. - */ - SecurityDomain.Builder getDomainBuilder(); -} diff --git a/components/camel-elytron/src/test/java/org/apache/camel/component/elytron/BaseElytronTest.java b/components/camel-elytron/src/test/java/org/apache/camel/component/elytron/BaseElytronTest.java deleted file mode 100644 index a0373ec0c7d8a..0000000000000 --- a/components/camel-elytron/src/test/java/org/apache/camel/component/elytron/BaseElytronTest.java +++ /dev/null @@ -1,143 +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.elytron; - -import java.io.File; -import java.io.FileWriter; -import java.io.Writer; -import java.net.URL; -import java.security.KeyPair; -import java.security.KeyPairGenerator; -import java.security.NoSuchAlgorithmException; -import java.util.Properties; -import java.util.concurrent.atomic.AtomicInteger; - -import org.apache.camel.BindToRegistry; -import org.apache.camel.CamelContext; -import org.apache.camel.component.undertow.UndertowComponent; -import org.apache.camel.component.undertow.spi.UndertowSecurityProvider; -import org.apache.camel.test.AvailablePortFinder; -import org.apache.camel.test.junit6.CamelTestSupport; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.extension.RegisterExtension; -import org.wildfly.security.WildFlyElytronBaseProvider; -import org.wildfly.security.auth.permission.LoginPermission; -import org.wildfly.security.auth.realm.token.TokenSecurityRealm; -import org.wildfly.security.auth.server.SecurityDomain; -import org.wildfly.security.authz.RoleMapper; -import org.wildfly.security.authz.Roles; -import org.wildfly.security.permission.PermissionVerifier; - -/** - * Base class of tests which allocates ports - */ -public abstract class BaseElytronTest extends CamelTestSupport { - - @RegisterExtension - static AvailablePortFinder.Port port = AvailablePortFinder.find(); - private static KeyPair keyPair; - - private final AtomicInteger counter = new AtomicInteger(1); - - abstract String getMechanismName(); - - abstract TokenSecurityRealm createBearerRealm(); - - abstract WildFlyElytronBaseProvider getElytronProvider(); - - @BeforeAll - public static void initPort() throws Exception { - keyPair = null; - - URL location = ElytronSecurityProvider.class.getProtectionDomain().getCodeSource().getLocation(); - File file = new File(location.getPath() + "META-INF/services/" + UndertowSecurityProvider.class.getName()); - file.getParentFile().mkdirs(); - - Writer output = new FileWriter(file); - output.write(ElytronSecurityProvider.class.getName()); - output.close(); - - file.deleteOnExit(); - } - - protected static int getPort() { - return port.getPort(); - } - - @BindToRegistry("prop") - public Properties loadProperties() { - - Properties prop = new Properties(); - prop.setProperty("port", Integer.toString(getPort())); - return prop; - } - - @Override - protected CamelContext createCamelContext() throws Exception { - CamelContext context = super.createCamelContext(); - - context.getPropertiesComponent().setLocation("ref:prop"); - - context.getComponent("undertow", UndertowComponent.class).setSecurityConfiguration(new ElytronSercurityConfiguration() { - @Override - public WildFlyElytronBaseProvider getElytronProvider() { - return BaseElytronTest.this.getElytronProvider(); - } - - @Override - public String getMechanismName() { - return BaseElytronTest.this.getMechanismName(); - } - - @Override - public SecurityDomain.Builder getDomainBuilder() { - return getSecurityDomainBuilder(); - } - - }); - - return context; - } - - SecurityDomain.Builder getSecurityDomainBuilder() { - - SecurityDomain.Builder builder = SecurityDomain.builder() - .setDefaultRealmName("realm"); - - builder.addRealm("realm", createBearerRealm()) - .build(); - - builder.setPermissionMapper((principal, roles) -> PermissionVerifier.from(new LoginPermission())); - builder.setRoleMapper(RoleMapper.constant(Roles.of("guest")).or(roles -> roles)); - - return builder; - } - - public KeyPair getKeyPair() throws NoSuchAlgorithmException { - if (keyPair == null) { - keyPair = generateKeyPair(); - } - return keyPair; - } - - private KeyPair generateKeyPair() throws NoSuchAlgorithmException { - KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA"); - generator.initialize(2048); - return generator.generateKeyPair(); - } - -} diff --git a/components/camel-elytron/src/test/java/org/apache/camel/component/elytron/ElytronBearerTokenTest.java b/components/camel-elytron/src/test/java/org/apache/camel/component/elytron/ElytronBearerTokenTest.java deleted file mode 100644 index 7e30efc733acc..0000000000000 --- a/components/camel-elytron/src/test/java/org/apache/camel/component/elytron/ElytronBearerTokenTest.java +++ /dev/null @@ -1,128 +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.elytron; - -import java.security.NoSuchAlgorithmException; -import java.security.PrivateKey; -import java.util.Date; - -import com.nimbusds.jose.JOSEException; -import com.nimbusds.jose.JWSAlgorithm; -import com.nimbusds.jose.JWSHeader; -import com.nimbusds.jose.crypto.RSASSASigner; -import com.nimbusds.jwt.JWTClaimsSet; -import com.nimbusds.jwt.SignedJWT; -import io.undertow.util.Headers; -import org.apache.camel.CamelExecutionException; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.http.base.HttpOperationFailedException; -import org.junit.jupiter.api.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.wildfly.security.WildFlyElytronBaseProvider; -import org.wildfly.security.auth.realm.token.TokenSecurityRealm; -import org.wildfly.security.auth.realm.token.validator.JwtValidator; -import org.wildfly.security.authz.RoleDecoder; -import org.wildfly.security.http.HttpConstants; -import org.wildfly.security.http.bearer.WildFlyElytronHttpBearerProvider; - -import static org.apache.camel.test.junit6.TestSupport.assertIsInstanceOf; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.fail; - -public class ElytronBearerTokenTest extends BaseElytronTest { - private static final Logger LOG = LoggerFactory.getLogger(ElytronBearerTokenTest.class); - - @Override - String getMechanismName() { - return HttpConstants.BEARER_TOKEN; - } - - @Override - TokenSecurityRealm createBearerRealm() { - try { - return TokenSecurityRealm.builder().principalClaimName("username") - .validator(JwtValidator.builder().publicKey(getKeyPair().getPublic()).build()).build(); - } catch (NoSuchAlgorithmException e) { - fail("Can not prepare realm becase of " + e); - } - return null; - } - - @Override - WildFlyElytronBaseProvider getElytronProvider() { - return WildFlyElytronHttpBearerProvider.getInstance(); - } - - @Test - public void testBearerToken() throws Exception { - String response = template.requestBodyAndHeader("undertow:http://localhost:{{port}}/myapp", - "empty body", - Headers.AUTHORIZATION.toString(), - "Bearer " + createToken("alice", "user", new Date(new Date().getTime() + 10000), getKeyPair().getPrivate()), - String.class); - assertNotNull(response); - assertEquals("Hello alice!", response); - } - - @Test - public void testBearerTokenBadRole() throws Exception { - Date date = new Date(new Date().getTime() + 10000); - String authHeader = Headers.AUTHORIZATION.toString(); - String authHeaderValue = "Bearer " + createToken("alice", "guest", date, getKeyPair().getPrivate()); - - Exception ex = assertThrows(CamelExecutionException.class, - () -> template.requestBodyAndHeader("undertow:http://localhost:{{port}}/myapp", - "empty body", authHeader, authHeaderValue, String.class)); - - HttpOperationFailedException he = assertIsInstanceOf(HttpOperationFailedException.class, ex.getCause()); - assertEquals(403, he.getStatusCode()); - } - - @Override - protected RouteBuilder createRouteBuilder() { - return new RouteBuilder() { - public void configure() { - from("undertow:http://localhost:{{port}}/myapp?allowedRoles=user") - .transform(simple("Hello ${in.header.securityIdentity.principal}!")); - } - }; - } - - private String createToken(String userName, String roles, Date expirationDate, PrivateKey signingKey) { - JWTClaimsSet.Builder claimsSet = new JWTClaimsSet.Builder(); - - claimsSet.subject("123445667"); - claimsSet.claim("username", userName); - claimsSet.audience("resource-server"); - claimsSet.issuer("elytron.org"); - claimsSet.claim(RoleDecoder.KEY_ROLES, roles); - claimsSet.expirationTime(expirationDate); - - SignedJWT signedJWT = new SignedJWT(new JWSHeader(JWSAlgorithm.RS256), claimsSet.build()); - - try { - signedJWT.sign(new RSASSASigner(signingKey)); - } catch (JOSEException e) { - LOG.warn("Cannot sign object: {}", e.getMessage(), e); - } - - return signedJWT.serialize(); - } -} diff --git a/components/camel-elytron/src/test/resources/log4j2.properties b/components/camel-elytron/src/test/resources/log4j2.properties deleted file mode 100644 index d1607be0a61ad..0000000000000 --- a/components/camel-elytron/src/test/resources/log4j2.properties +++ /dev/null @@ -1,29 +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. -## --------------------------------------------------------------------------- - -appender.file.type = File -appender.file.name = file -appender.file.fileName = target/camel-elytron-test.log -appender.file.layout.type = PatternLayout -appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n -appender.out.type = Console -appender.out.name = out -appender.out.layout.type = PatternLayout -appender.out.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n -rootLogger.level = INFO -rootLogger.appenderRef.file.ref = file - diff --git a/components/pom.xml b/components/pom.xml index 938dbb180b798..394edb5f1fb37 100644 --- a/components/pom.xml +++ b/components/pom.xml @@ -133,7 +133,6 @@ camel-ehcache camel-elasticsearch camel-elasticsearch-rest-client - camel-elytron camel-event camel-exec camel-fastjson diff --git a/coverage/pom.xml b/coverage/pom.xml index 4985e1a0b8cda..e95e4347d2306 100644 --- a/coverage/pom.xml +++ b/coverage/pom.xml @@ -857,11 +857,6 @@ camel-elasticsearch-rest-client ${project.version} - - org.apache.camel - camel-elytron - ${project.version} - org.apache.camel camel-exec diff --git a/docs/components/modules/others/examples/json/elytron.json b/docs/components/modules/others/examples/json/elytron.json deleted file mode 120000 index 8ae83d1042a75..0000000000000 --- a/docs/components/modules/others/examples/json/elytron.json +++ /dev/null @@ -1 +0,0 @@ -../../../../../../components/camel-elytron/src/generated/resources/elytron.json \ No newline at end of file diff --git a/docs/components/modules/others/nav.adoc b/docs/components/modules/others/nav.adoc index 4dc82ace6e27f..0b52a00a28d54 100644 --- a/docs/components/modules/others/nav.adoc +++ b/docs/components/modules/others/nav.adoc @@ -20,7 +20,6 @@ *** xref:kamelet-main-support.adoc[Kamelet Main Support] *** xref:java-xml-io-dsl.adoc[XML Io Dsl] *** xref:yaml-dsl.adoc[YAML DSL] -** xref:elytron.adoc[Elytron] ** xref:headersmap.adoc[Headersmap] ** xref:jandex.adoc[Jandex] ** xref:jasypt.adoc[Jasypt] diff --git a/docs/components/modules/others/pages/elytron.adoc b/docs/components/modules/others/pages/elytron.adoc deleted file mode 120000 index e399972ac1076..0000000000000 --- a/docs/components/modules/others/pages/elytron.adoc +++ /dev/null @@ -1 +0,0 @@ -../../../../../components/camel-elytron/src/main/docs/elytron.adoc \ No newline at end of file diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc index 7e56b09bd0f12..acfd903d8a75a 100644 --- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc +++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc @@ -202,6 +202,10 @@ Camel Guava EventBus was deprecated with Camel 4.6. The component is now removed Camel Grape was deprecated with Camel 4.1. The component is now removed. +=== camel-elytron removal + +Camel Grape was deprecated with Camel 4.0. The component is now removed. + === camel-telemetry If you have custom telemetry implementations, the following interfaces have changed: diff --git a/parent/pom.xml b/parent/pom.xml index bebbb2f6f4fc1..53e828ec7225a 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -156,7 +156,6 @@ 1.330 9.3.4 9.3.4 - 4.1.2.Final 2.0.5 1.2 3.6.3 @@ -414,7 +413,6 @@ 1.30.1-alpha 10.2.0 1.2.5 - 1.1.7 1.17.0 1.17.0 3.0.7 @@ -521,7 +519,6 @@ 5.5.0 5.0.0 4.10.0 - 2.2.2.Final 3.13.2 4.4.1 7.1.1 @@ -1351,11 +1348,6 @@ camel-elasticsearch-rest-client ${project.version} - - org.apache.camel - camel-elytron - ${project.version} - org.apache.camel camel-event