From 9304af2e36d3aed9adc62a13f3b1c302f6626f17 Mon Sep 17 00:00:00 2001 From: Lashini Jayasekara <30428591+lashinijay@users.noreply.github.com> Date: Sun, 26 Jan 2025 07:48:39 +0530 Subject: [PATCH] [Spring Cleanup] Remove Spring dependency from fido2 API (#248) --- .../pom.xml | 5 --- .../pom.xml | 5 --- .../rest/api/user/fido2/v1/MeApi.java | 27 +++++++------ .../v1/factories/MeApiServiceFactory.java | 22 ++++++++++- .../v1/factories/WebAuthnServiceFactory.java | 39 +++++++++++++++++++ .../user/fido2/v1/impl/MeApiServiceImpl.java | 28 +++++++++++-- .../META-INF/cxf/user-fido2-v1-cxf.xml | 21 ---------- 7 files changed, 100 insertions(+), 47 deletions(-) create mode 100644 components/org.wso2.carbon.identity.api.user.fido2/org.wso2.carbon.identity.api.user.fido2.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/fido2/v1/factories/WebAuthnServiceFactory.java delete mode 100644 components/org.wso2.carbon.identity.api.user.fido2/org.wso2.carbon.identity.api.user.fido2.v1/src/main/resources/META-INF/cxf/user-fido2-v1-cxf.xml diff --git a/components/org.wso2.carbon.identity.api.user.fido2/org.wso2.carbon.identity.api.user.fido2.common/pom.xml b/components/org.wso2.carbon.identity.api.user.fido2/org.wso2.carbon.identity.api.user.fido2.common/pom.xml index 1003a0a21..485cdaf9f 100644 --- a/components/org.wso2.carbon.identity.api.user.fido2/org.wso2.carbon.identity.api.user.fido2.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.user.fido2/org.wso2.carbon.identity.api.user.fido2.common/pom.xml @@ -36,11 +36,6 @@ cxf-rt-rs-service-description provided - - org.springframework - spring-web - provided - javax.ws.rs javax.ws.rs-api diff --git a/components/org.wso2.carbon.identity.api.user.fido2/org.wso2.carbon.identity.api.user.fido2.v1/pom.xml b/components/org.wso2.carbon.identity.api.user.fido2/org.wso2.carbon.identity.api.user.fido2.v1/pom.xml index 6b219448a..a72f69b61 100644 --- a/components/org.wso2.carbon.identity.api.user.fido2/org.wso2.carbon.identity.api.user.fido2.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.user.fido2/org.wso2.carbon.identity.api.user.fido2.v1/pom.xml @@ -88,11 +88,6 @@ cxf-rt-rs-service-description provided - - org.springframework - spring-web - provided - javax.ws.rs javax.ws.rs-api diff --git a/components/org.wso2.carbon.identity.api.user.fido2/org.wso2.carbon.identity.api.user.fido2.v1/src/gen/java/org/wso2/carbon/identity/rest/api/user/fido2/v1/MeApi.java b/components/org.wso2.carbon.identity.api.user.fido2/org.wso2.carbon.identity.api.user.fido2.v1/src/gen/java/org/wso2/carbon/identity/rest/api/user/fido2/v1/MeApi.java index b65db2581..29f8c1487 100644 --- a/components/org.wso2.carbon.identity.api.user.fido2/org.wso2.carbon.identity.api.user.fido2.v1/src/gen/java/org/wso2/carbon/identity/rest/api/user/fido2/v1/MeApi.java +++ b/components/org.wso2.carbon.identity.api.user.fido2/org.wso2.carbon.identity.api.user.fido2.v1/src/gen/java/org/wso2/carbon/identity/rest/api/user/fido2/v1/MeApi.java @@ -1,22 +1,23 @@ /* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2019-2025, WSO2 LLC. (http://www.wso2.com). * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. + * WSO2 LLC. 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. + * 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.wso2.carbon.identity.rest.api.user.fido2.v1; -import org.springframework.beans.factory.annotation.Autowired; import org.wso2.carbon.identity.rest.api.user.fido2.v1.dto.*; import org.wso2.carbon.identity.rest.api.user.fido2.v1.MeApiService; import org.wso2.carbon.identity.rest.api.user.fido2.v1.factories.MeApiServiceFactory; @@ -40,8 +41,12 @@ @io.swagger.annotations.Api(value = "/me", description = "the me API") public class MeApi { - @Autowired - private MeApiService delegate; + private final MeApiService delegate; + + public MeApi() { + + this.delegate = MeApiServiceFactory.getMeApi(); + } @DELETE @Path("/webauthn/{credentialId}") diff --git a/components/org.wso2.carbon.identity.api.user.fido2/org.wso2.carbon.identity.api.user.fido2.v1/src/gen/java/org/wso2/carbon/identity/rest/api/user/fido2/v1/factories/MeApiServiceFactory.java b/components/org.wso2.carbon.identity.api.user.fido2/org.wso2.carbon.identity.api.user.fido2.v1/src/gen/java/org/wso2/carbon/identity/rest/api/user/fido2/v1/factories/MeApiServiceFactory.java index f8f28c215..433a0321a 100644 --- a/components/org.wso2.carbon.identity.api.user.fido2/org.wso2.carbon.identity.api.user.fido2.v1/src/gen/java/org/wso2/carbon/identity/rest/api/user/fido2/v1/factories/MeApiServiceFactory.java +++ b/components/org.wso2.carbon.identity.api.user.fido2/org.wso2.carbon.identity.api.user.fido2.v1/src/gen/java/org/wso2/carbon/identity/rest/api/user/fido2/v1/factories/MeApiServiceFactory.java @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2019-2025, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. 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.wso2.carbon.identity.rest.api.user.fido2.v1.factories; import org.wso2.carbon.identity.rest.api.user.fido2.v1.MeApiService; @@ -5,10 +23,10 @@ public class MeApiServiceFactory { - private final static MeApiService service = new MeApiServiceImpl(); + private final static MeApiService SERVICE = new MeApiServiceImpl(); public static MeApiService getMeApi() { - return service; + return SERVICE; } } diff --git a/components/org.wso2.carbon.identity.api.user.fido2/org.wso2.carbon.identity.api.user.fido2.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/fido2/v1/factories/WebAuthnServiceFactory.java b/components/org.wso2.carbon.identity.api.user.fido2/org.wso2.carbon.identity.api.user.fido2.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/fido2/v1/factories/WebAuthnServiceFactory.java new file mode 100644 index 000000000..f265e49b2 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.fido2/org.wso2.carbon.identity.api.user.fido2.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/fido2/v1/factories/WebAuthnServiceFactory.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. 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.wso2.carbon.identity.rest.api.user.fido2.v1.factories; + +import org.wso2.carbon.identity.application.authenticator.fido2.core.WebAuthnService; + +/** + * Factory class for WebAuthnService. + */ +public class WebAuthnServiceFactory { + + private static final WebAuthnService SERVICE = new WebAuthnService(); + + /** + * This method is used to get the WebAuthnService instance. + * + * @return WebAuthnService instance. + */ + public static WebAuthnService getWebAuthnService() { + + return SERVICE; + } +} diff --git a/components/org.wso2.carbon.identity.api.user.fido2/org.wso2.carbon.identity.api.user.fido2.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/fido2/v1/impl/MeApiServiceImpl.java b/components/org.wso2.carbon.identity.api.user.fido2/org.wso2.carbon.identity.api.user.fido2.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/fido2/v1/impl/MeApiServiceImpl.java index ced7ed072..61ccd8712 100644 --- a/components/org.wso2.carbon.identity.api.user.fido2/org.wso2.carbon.identity.api.user.fido2.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/fido2/v1/impl/MeApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.user.fido2/org.wso2.carbon.identity.api.user.fido2.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/fido2/v1/impl/MeApiServiceImpl.java @@ -1,9 +1,26 @@ +/* + * Copyright (c) 2019-2025, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. 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.wso2.carbon.identity.rest.api.user.fido2.v1.impl; import com.fasterxml.jackson.core.JsonProcessingException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.wso2.carbon.identity.api.user.fido2.common.Constants; import org.wso2.carbon.identity.api.user.fido2.common.Util; import org.wso2.carbon.identity.application.authenticator.fido2.core.WebAuthnService; @@ -15,6 +32,7 @@ import org.wso2.carbon.identity.core.util.IdentityCoreConstants; import org.wso2.carbon.identity.core.util.IdentityUtil; import org.wso2.carbon.identity.rest.api.user.fido2.v1.MeApiService; +import org.wso2.carbon.identity.rest.api.user.fido2.v1.factories.WebAuthnServiceFactory; import java.io.IOException; import java.net.URLDecoder; @@ -28,8 +46,12 @@ public class MeApiServiceImpl extends MeApiService { private static final Log log = LogFactory.getLog(MeApiServiceImpl.class); - @Autowired - private WebAuthnService webAuthnService; + private final WebAuthnService webAuthnService; + + public MeApiServiceImpl() { + + this.webAuthnService = WebAuthnServiceFactory.getWebAuthnService(); + } @Override public Response meWebauthnCredentialIdDelete(String credentialId) { diff --git a/components/org.wso2.carbon.identity.api.user.fido2/org.wso2.carbon.identity.api.user.fido2.v1/src/main/resources/META-INF/cxf/user-fido2-v1-cxf.xml b/components/org.wso2.carbon.identity.api.user.fido2/org.wso2.carbon.identity.api.user.fido2.v1/src/main/resources/META-INF/cxf/user-fido2-v1-cxf.xml deleted file mode 100644 index a94ada1bf..000000000 --- a/components/org.wso2.carbon.identity.api.user.fido2/org.wso2.carbon.identity.api.user.fido2.v1/src/main/resources/META-INF/cxf/user-fido2-v1-cxf.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - -