Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Spring Cleanup] Remove Spring dependencies in OIDC scope management API #785

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ Copyright (c) 2020-2025, WSO2 LLC. (http://www.wso2.com).
~
~ WSO2 Inc. licenses this file to you under the Apache 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
Expand Down Expand Up @@ -45,11 +45,6 @@
</build>

<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.inbound.auth.oauth2</groupId>
<artifactId>org.wso2.carbon.identity.oauth</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,46 @@
/*
* Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2020-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.api.server.oidc.scope.management.common;

import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.identity.oauth.OAuthAdminServiceImpl;

/**
* OIDCScopeManagementService OSGi service holder.
*/
public class OIDCScopeManagementServiceHolder {

private static OAuthAdminServiceImpl oauthAdminService;
private OIDCScopeManagementServiceHolder () {}

public static OAuthAdminServiceImpl getOAuthAdminService() {
private static class OAuthAdminServiceImplServiceHolder {

return oauthAdminService;
static final OAuthAdminServiceImpl SERVICE = (OAuthAdminServiceImpl) PrivilegedCarbonContext
.getThreadLocalCarbonContext().getOSGiService(OAuthAdminServiceImpl.class, null);
}

public static void setOauthAdminService(OAuthAdminServiceImpl oauthAdminService) {
/**
* Get OAuthAdminService OSGi service.
*
* @return OAuthAdminServiceImpl
*/
public static OAuthAdminServiceImpl getOAuthAdminService() {

OIDCScopeManagementServiceHolder.oauthAdminService = oauthAdminService;
return OAuthAdminServiceImplServiceHolder.SERVICE;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ Copyright (c) 2020-2025, WSO2 LLC. (http://www.wso2.com).
~
~ WSO2 Inc. licenses this file to you under the Apache 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
Expand Down Expand Up @@ -131,21 +131,6 @@
<artifactId>javax.ws.rs-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,45 +1,44 @@
/*
* Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* Licensed 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.
*/
* 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.api.server.oidc.scope.management.v1;

import org.springframework.beans.factory.annotation.Autowired;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
import java.io.InputStream;

import org.wso2.carbon.identity.api.server.oidc.scope.management.v1.factories.OidcApiServiceFactory;
import org.wso2.carbon.identity.api.server.oidc.scope.management.v1.model.ErrorResponse;
import org.wso2.carbon.identity.api.server.oidc.scope.management.v1.model.Scope;
import org.wso2.carbon.identity.api.server.oidc.scope.management.v1.model.ScopeUpdateRequest;
import org.wso2.carbon.identity.api.server.oidc.scope.management.v1.OidcApiService;

import javax.validation.Valid;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import io.swagger.annotations.*;

import javax.validation.constraints.*;

@Path("/oidc")
@Api(description = "The oidc API")

public class OidcApi {

@Autowired
private OidcApiService delegate;
private final OidcApiService delegate;

public OidcApi() {

this.delegate = OidcApiServiceFactory.getOidcApi();
}

@Valid
@POST
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
/*
* Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* Licensed 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.
*/
* Copyright (c) 2020-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.api.server.oidc.scope.management.v1.factories;

Expand All @@ -21,10 +23,10 @@

public class OidcApiServiceFactory {

private final static OidcApiService service = new OidcApiServiceImpl();
private final static OidcApiService SERVICE = new OidcApiServiceImpl();

public static OidcApiService getOidcApi()
{
return service;
public static OidcApiService getOidcApi() {

return SERVICE;
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
/*
* Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2020-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.api.server.oidc.scope.management.v1.core;

import org.apache.commons.logging.Log;
Expand All @@ -24,6 +27,7 @@
import org.wso2.carbon.identity.api.server.oidc.scope.management.v1.model.ScopeUpdateRequest;
import org.wso2.carbon.identity.oauth.IdentityOAuthAdminException;
import org.wso2.carbon.identity.oauth.IdentityOAuthClientException;
import org.wso2.carbon.identity.oauth.OAuthAdminServiceImpl;
import org.wso2.carbon.identity.oauth.dto.ScopeDTO;

import java.util.ArrayList;
Expand All @@ -32,15 +36,19 @@

import javax.ws.rs.core.Response;

import static org.wso2.carbon.identity.api.server.oidc.scope.management.common.OIDCScopeManagementServiceHolder.getOAuthAdminService;

/**
* OIDC scope management APIs are processed in this class.
*/
public class OidcScopeManagementService {

private final OAuthAdminServiceImpl oauthAdminService;
private static final Log LOG = LogFactory.getLog(OidcScopeManagementService.class);

public OidcScopeManagementService(OAuthAdminServiceImpl oauthAdminService) {

this.oauthAdminService = oauthAdminService;
}

/**
* Add an OIDC scope.
*
Expand All @@ -54,7 +62,7 @@ public String addScope(Scope scopeObject) {
String[] claimArray = claimList.toArray(new String[claimList.size()]);
ScopeDTO scopeDTO = new ScopeDTO(scopeObject.getName(), scopeObject.getDisplayName(),
scopeObject.getDescription(), claimArray);
getOAuthAdminService().addScope(scopeDTO);
oauthAdminService.addScope(scopeDTO);
return scopeDTO.getName();
} catch (IdentityOAuthAdminException e) {
throw handleException(e, "Server encountered an error while adding OIDC scope: " + scopeObject.getName());
Expand All @@ -69,7 +77,7 @@ public String addScope(Scope scopeObject) {
public void deleteScope(String id) {

try {
getOAuthAdminService().deleteScope(id);
oauthAdminService.deleteScope(id);
} catch (IdentityOAuthClientException e) {
if (LOG.isDebugEnabled()) {
LOG.debug(e);
Expand All @@ -88,7 +96,7 @@ public void deleteScope(String id) {
public Scope getScope(String id) {

try {
ScopeDTO scopeDTO = getOAuthAdminService().getScope(id);
ScopeDTO scopeDTO = oauthAdminService.getScope(id);
return convertScopeDTOObjectToScope(scopeDTO);
} catch (IdentityOAuthAdminException e) {
throw handleException(e, "Server encountered an error while retrieving OIDC scope: " + id);
Expand All @@ -103,7 +111,7 @@ public Scope getScope(String id) {
public List<Scope> getScopes() {

try {
ScopeDTO[] scopes = getOAuthAdminService().getScopes();
ScopeDTO[] scopes = oauthAdminService.getScopes();
return buildScopeList(scopes);
} catch (IdentityOAuthAdminException e) {
throw handleException(e, "Server encountered an error while listing OIDC scopes.");
Expand All @@ -124,7 +132,7 @@ public void updateScope(String id, ScopeUpdateRequest scopeUpdateObject) {
String[] claimArray = claimList.toArray(new String[claimList.size()]);
ScopeDTO scopeDTO = new ScopeDTO(id, scopeUpdateObject.getDisplayName(),
scopeUpdateObject.getDescription(), claimArray);
getOAuthAdminService().updateScope(scopeDTO);
oauthAdminService.updateScope(scopeDTO);
} catch (IdentityOAuthAdminException e) {
throw handleException(e, "Server encountered an error while updating OIDC scope: " + id);
}
Expand Down
Loading
Loading