Skip to content

Commit

Permalink
Merge pull request #783 from lashinijay/master-revamp-permission-mgt
Browse files Browse the repository at this point in the history
[Spring Cleanup] Remove Spring dependencies in permission management API
  • Loading branch information
lashinijay authored Jan 23, 2025
2 parents b8145c9 + 3d04b19 commit c122fe2
Show file tree
Hide file tree
Showing 11 changed files with 185 additions and 188 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ Copyright (c) 2019-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 @@ -50,11 +50,6 @@
<artifactId>org.wso2.carbon.user.mgt</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -1,47 +1,46 @@
/*
* 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.api.server.permission.management.common;

import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.user.mgt.RolePermissionManagementService;

/**
* DataHolder class for RolePermissionManagementService.
*/
public class RolePermissionManagementServiceDataHolder {

private static RolePermissionManagementService rolePermissionManagementService;
private RolePermissionManagementServiceDataHolder() {}

/**
* Get Role Permission Management Service.
*
* @return RolePermissionManagementService.
*/
public static RolePermissionManagementService getRolePermissionManagementService() {
return rolePermissionManagementService;
private static class RolePermissionManagementServiceHolder {

static final RolePermissionManagementService SERVICE = (RolePermissionManagementService) PrivilegedCarbonContext
.getThreadLocalCarbonContext().getOSGiService(RolePermissionManagementService.class, null);
}

/**
* Set RolePermissionManagementService.
* Get RolePermissionManagementService osgi service.
*
* @param rolePermissionManagementService RolePermissionManagementService.
* @return RolePermissionManagementService
*/
public static void setRolePermissionManagementService(RolePermissionManagementService
rolePermissionManagementService) {
RolePermissionManagementServiceDataHolder.rolePermissionManagementService =
rolePermissionManagementService;
}
public static RolePermissionManagementService getRolePermissionManagementService() {

return RolePermissionManagementServiceHolder.SERVICE;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
Expand Down Expand Up @@ -104,11 +106,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 Expand Up @@ -149,22 +146,12 @@
<artifactId>jackson-jaxrs-json-provider</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.server.api</groupId>
<artifactId>org.wso2.carbon.identity.api.server.permission.management.common</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.server.api</groupId>
<artifactId>org.wso2.carbon.identity.api.server.common</artifactId>
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) 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.permission.management.v1;

Expand All @@ -21,7 +23,8 @@
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Authorization;
import org.springframework.beans.factory.annotation.Autowired;
import org.wso2.carbon.identity.api.server.permission.management.v1.factories.PermissionManagementApiServiceFactory;
import org.wso2.carbon.identity.api.server.permission.management.v1.impl.PermissionManagementApiServiceImpl;
import org.wso2.carbon.identity.api.server.permission.management.v1.model.Error;
import org.wso2.carbon.identity.api.server.permission.management.v1.model.Permission;

Expand All @@ -36,8 +39,12 @@

public class PermissionManagementApi {

@Autowired
private PermissionManagementApiService delegate;
private final PermissionManagementApiService delegate;

public PermissionManagementApi() {

this.delegate = PermissionManagementApiServiceFactory.getPermissionManagementApi();
}

@Valid
@GET
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,40 @@
/*
* 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.permission.management.v1.factories;

import org.wso2.carbon.identity.api.server.permission.management.v1.PermissionManagementApiService;
import org.wso2.carbon.identity.api.server.permission.management.v1.impl.PermissionManagementApiServiceImpl;

/**
* Factory class for PermissionManagementApiService.
*/
public class PermissionManagementApiServiceFactory {

private final static PermissionManagementApiService service = new PermissionManagementApiServiceImpl();
private final static PermissionManagementApiService SERVICE = new PermissionManagementApiServiceImpl();

/**
* Get PermissionManagementApiService.
*
* @return PermissionManagementApiService
*/
public static PermissionManagementApiService getPermissionManagementApi() {

public static PermissionManagementApiService getPermissionManagementApi()
{
return service;
return SERVICE;
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
/*
* 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.api.server.permission.management.v1.core;
Expand All @@ -23,7 +25,6 @@
import org.wso2.carbon.identity.api.server.common.error.APIError;
import org.wso2.carbon.identity.api.server.common.error.ErrorResponse;
import org.wso2.carbon.identity.api.server.permission.management.common.Constant;
import org.wso2.carbon.identity.api.server.permission.management.common.RolePermissionManagementServiceDataHolder;
import org.wso2.carbon.identity.api.server.permission.management.v1.model.Permission;
import org.wso2.carbon.identity.core.util.IdentityTenantUtil;
import org.wso2.carbon.user.mgt.RolePermissionException;
Expand All @@ -36,8 +37,14 @@
*/
public class PermissionManagementService {

private final RolePermissionManagementService rolePermissionManagementService;
private static final Log LOG = LogFactory.getLog(PermissionManagementService.class);

public PermissionManagementService(RolePermissionManagementService rolePermissionManagementService) {

this.rolePermissionManagementService = rolePermissionManagementService;
}

/**
* Get all permissions array.
*
Expand All @@ -47,8 +54,6 @@ public Permission[] getAllPermissions() {

try {
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
RolePermissionManagementService rolePermissionManagementService =
RolePermissionManagementServiceDataHolder.getRolePermissionManagementService();
return getPermissionObjects(rolePermissionManagementService.getAllPermissions(IdentityTenantUtil
.getTenantId(tenantDomain)));
} catch (RolePermissionException e) {
Expand Down
Loading

0 comments on commit c122fe2

Please sign in to comment.