Skip to content

Commit

Permalink
Merge pull request #698 from NipuniBhagya/feature-remove-spring-gover…
Browse files Browse the repository at this point in the history
…nance

[Spring Cleanup] Remove Spring dependencies in the identity governance API
  • Loading branch information
lashinijay authored Dec 9, 2024
2 parents ce407d6 + 10fce43 commit 9818baa
Show file tree
Hide file tree
Showing 10 changed files with 145 additions and 153 deletions.
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-2024, 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">
<parent>
Expand All @@ -28,10 +30,5 @@
<groupId>org.wso2.carbon.identity.governance</groupId>
<artifactId>org.wso2.carbon.identity.governance</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,37 +1,45 @@
/*
* Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2019-2024, 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.identity.governance.common;

import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.identity.governance.IdentityGovernanceService;

/**
* Service holder class for identity governance.
*/
public class GovernanceDataHolder {

private static IdentityGovernanceService identityGovernanceService;
private GovernanceDataHolder() {}

public static IdentityGovernanceService getIdentityGovernanceService() {

return identityGovernanceService;
private static class IdentityGovernanceServiceHolder {
static final IdentityGovernanceService SERVICE = (IdentityGovernanceService) PrivilegedCarbonContext
.getThreadLocalCarbonContext().getOSGiService(IdentityGovernanceService.class, null);
}

public static void setIdentityGovernanceService(IdentityGovernanceService identityGovernanceService) {
/**
* Get IdentityGovernanceService osgi service.
*
* @return IdentityGovernanceService
*/
public static IdentityGovernanceService getIdentityGovernanceService() {

GovernanceDataHolder.identityGovernanceService = identityGovernanceService;
return IdentityGovernanceServiceHolder.SERVICE;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ Copyright (c) 2019-2024, 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">
<parent>
<groupId>org.wso2.carbon.identity.server.api</groupId>
Expand Down Expand Up @@ -105,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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, WSO2 LLC. (http://www.wso2.com).
* Copyright (c) 2019-2024, 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
Expand All @@ -18,7 +18,7 @@

package org.wso2.carbon.identity.api.server.identity.governance.v1;

import org.springframework.beans.factory.annotation.Autowired;
import org.wso2.carbon.identity.api.server.identity.governance.v1.factories.IdentityGovernanceApiServiceFactory;
import org.wso2.carbon.identity.api.server.identity.governance.v1.model.CategoriesRes;
import org.wso2.carbon.identity.api.server.identity.governance.v1.model.CategoryRes;
import org.wso2.carbon.identity.api.server.identity.governance.v1.model.ConnectorRes;
Expand All @@ -28,7 +28,6 @@
import org.wso2.carbon.identity.api.server.identity.governance.v1.model.MultipleConnectorsPatchReq;
import org.wso2.carbon.identity.api.server.identity.governance.v1.model.PreferenceResp;
import org.wso2.carbon.identity.api.server.identity.governance.v1.model.PreferenceSearchAttribute;
import org.wso2.carbon.identity.api.server.identity.governance.v1.IdentityGovernanceApiService;

import javax.validation.Valid;
import javax.ws.rs.*;
Expand All @@ -42,8 +41,12 @@

public class IdentityGovernanceApi {

@Autowired
private IdentityGovernanceApiService delegate;
private final IdentityGovernanceApiService delegate;

public IdentityGovernanceApi() {

this.delegate = IdentityGovernanceApiServiceFactory.getIdentityGovernanceApi();
}

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

import org.wso2.carbon.identity.api.server.identity.governance.v1.IdentityGovernanceApiService;
import org.wso2.carbon.identity.api.server.identity.governance.v1.impl.IdentityGovernanceApiServiceImpl;

/**
* Factory class for Identity Governance API.
*/
public class IdentityGovernanceApiServiceFactory {

private final static IdentityGovernanceApiService service = new IdentityGovernanceApiServiceImpl();
private final static IdentityGovernanceApiService SERVICE = new IdentityGovernanceApiServiceImpl();

/**
* Get Identity Governance API Service.
*
* @return IdentityGovernanceApiService
*/
public static IdentityGovernanceApiService getIdentityGovernanceApi()
{
return service;
return SERVICE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,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.identity.governance.common.GovernanceConstants;
import org.wso2.carbon.identity.api.server.identity.governance.common.GovernanceDataHolder;
import org.wso2.carbon.identity.api.server.identity.governance.v1.model.CategoriesRes;
import org.wso2.carbon.identity.api.server.identity.governance.v1.model.CategoryConnectorsRes;
import org.wso2.carbon.identity.api.server.identity.governance.v1.model.CategoryRes;
Expand Down Expand Up @@ -68,8 +67,14 @@
*/
public class ServerIdentityGovernanceService {

private final IdentityGovernanceService identityGovernanceService;
private static final Log LOG = LogFactory.getLog(ServerIdentityGovernanceService.class);

public ServerIdentityGovernanceService(IdentityGovernanceService identityGovernanceService) {

this.identityGovernanceService = identityGovernanceService;
}

/**
* Get all governance connector categories.
*
Expand All @@ -84,7 +89,6 @@ public List<CategoriesRes> getGovernanceConnectors(Integer limit, Integer offset
handleNotImplementedCapabilities(limit, offset, filter, sort);

try {
IdentityGovernanceService identityGovernanceService = GovernanceDataHolder.getIdentityGovernanceService();
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
Map<String, List<ConnectorConfig>> connectorConfigs =
identityGovernanceService.getCategorizedConnectorListWithConfigs(tenantDomain);
Expand Down Expand Up @@ -125,7 +129,6 @@ public CategoryRes getGovernanceConnectorCategory(String categoryId) {
public List<ConnectorRes> getGovernanceConnectorsByCategory(String categoryId) {

try {
IdentityGovernanceService identityGovernanceService = GovernanceDataHolder.getIdentityGovernanceService();
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
String category = new String(Base64.getUrlDecoder().decode(categoryId), StandardCharsets.UTF_8);
List<ConnectorConfig> connectorConfigs =
Expand Down Expand Up @@ -155,7 +158,6 @@ public List<ConnectorRes> getGovernanceConnectorsByCategory(String categoryId) {
public ConnectorRes getGovernanceConnector(String categoryId, String connectorId) {

try {
IdentityGovernanceService identityGovernanceService = GovernanceDataHolder.getIdentityGovernanceService();
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
String connectorName = new String(Base64.getUrlDecoder().decode(connectorId), StandardCharsets.UTF_8);
ConnectorConfig connectorConfig =
Expand Down Expand Up @@ -188,7 +190,6 @@ public ConnectorRes getGovernanceConnector(String categoryId, String connectorId
*/
public List<PreferenceResp> getConfigPreference(List<PreferenceSearchAttribute> preferenceSearchAttribute) {

IdentityGovernanceService identityGovernanceService = GovernanceDataHolder.getIdentityGovernanceService();
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
List<PreferenceResp> preferenceRespList = new ArrayList<>();
for (PreferenceSearchAttribute prefSearchAttr : preferenceSearchAttribute) {
Expand Down Expand Up @@ -288,7 +289,6 @@ public void updateGovernanceConnectorProperty(String categoryId, String connecto
ConnectorsPatchReq governanceConnector) {

try {
IdentityGovernanceService identityGovernanceService = GovernanceDataHolder.getIdentityGovernanceService();
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();

ConnectorRes connector = getGovernanceConnector(categoryId, connectorId);
Expand Down Expand Up @@ -330,7 +330,6 @@ public void updateGovernanceConnectorProperties(String categoryId,
MultipleConnectorsPatchReq multipleConnectorsPatchReq) {

try {
IdentityGovernanceService identityGovernanceService = GovernanceDataHolder.getIdentityGovernanceService();
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();

// Check whether the category ID exists.
Expand Down
Loading

0 comments on commit 9818baa

Please sign in to comment.