Skip to content

Commit

Permalink
[Spring Cleanup] Remove Spring dependency from fido2 API (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
lashinijay authored Jan 26, 2025
1 parent 1a480d2 commit 9304af2
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@
<artifactId>cxf-rt-rs-service-description</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@
<artifactId>cxf-rt-rs-service-description</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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}")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
/*
* 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;
import org.wso2.carbon.identity.rest.api.user.fido2.v1.impl.MeApiServiceImpl;

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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -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) {
Expand Down

This file was deleted.

0 comments on commit 9304af2

Please sign in to comment.