Skip to content

Commit

Permalink
[Spring Cleanup] Remove Spring dependencies in authenticator managem…
Browse files Browse the repository at this point in the history
…ent API (#688)

* Remove Spring dependencies in authenticator management API

* Resolve PR comments

* Refactor ServerAuthenticatorManagementServiceFactory class
  • Loading branch information
NipuniBhagya authored Dec 9, 2024
1 parent 1954f9a commit eff8fce
Show file tree
Hide file tree
Showing 11 changed files with 222 additions and 269 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ Copyright (c) 2021-2024, 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 @@ -47,11 +47,6 @@
<artifactId>org.wso2.carbon.identity.application.mgt</artifactId>
<scope>provided</scope>
</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,80 +1,65 @@
/*
* Copyright (c) 2021, 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) 2021-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.authenticators.common;

import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.identity.application.mgt.ApplicationManagementService;
import org.wso2.carbon.idp.mgt.IdentityProviderManager;
import org.wso2.carbon.idp.mgt.IdpManager;

/**
* Service holder class for server configuration related services.
*/
public class AuthenticatorsServiceHolder {

private static AuthenticatorsServiceHolder instance = new AuthenticatorsServiceHolder();

private ApplicationManagementService applicationManagementService;
private IdentityProviderManager identityProviderManager;

private AuthenticatorsServiceHolder() {

}

public static AuthenticatorsServiceHolder getInstance() {
private static class ApplicationManagementServiceHolder {
static final ApplicationManagementService SERVICE = (ApplicationManagementService) PrivilegedCarbonContext
.getThreadLocalCarbonContext()
.getOSGiService(ApplicationManagementService.class, null);
}

return instance;
private static class IdentityProviderManagerHolder {
static final IdpManager SERVICE = (IdpManager) PrivilegedCarbonContext
.getThreadLocalCarbonContext()
.getOSGiService(IdpManager.class, null);
}

/**
* Get ApplicationManagementService osgi service.
*
* @return ApplicationManagementService
*/
public ApplicationManagementService getApplicationManagementService() {

return AuthenticatorsServiceHolder.getInstance().applicationManagementService;
}

/**
* Set ApplicationManagementService osgi service.
*
* @param applicationManagementService ApplicationManagementService.
*/
public void setApplicationManagementService(ApplicationManagementService applicationManagementService) {

AuthenticatorsServiceHolder.getInstance().applicationManagementService = applicationManagementService;
}

/**
* Get IdentityProviderManager osgi service.
*
* @return IdentityProviderManager
*/
public IdentityProviderManager getIdentityProviderManager() {
public static ApplicationManagementService getApplicationManagementService() {

return AuthenticatorsServiceHolder.getInstance().identityProviderManager;
return ApplicationManagementServiceHolder.SERVICE;
}

/**
* Set IdentityProviderManager osgi service.
* Get IdpManager osgi service.
*
* @param identityProviderManager IdentityProviderManager.
* @return IdpManager
*/
public void setIdentityProviderManager(IdentityProviderManager identityProviderManager) {
public static IdpManager getIdentityProviderManager() {

AuthenticatorsServiceHolder.getInstance().identityProviderManager = identityProviderManager;
return IdentityProviderManagerHolder.SERVICE;
}
}

This file was deleted.

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) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ Copyright (c) 2021-2024, 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 @@ -105,11 +105,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 @@ -169,6 +164,12 @@
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.server.api</groupId>
<artifactId>org.wso2.carbon.identity.api.server.authenticators.common</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
/*
* Copyright (c) 2021, WSO2 LLC. (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) 2021-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.authenticators.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 java.util.List;

import org.wso2.carbon.identity.api.server.authenticators.v1.factories.AuthenticatorsApiServiceFactory;
import org.wso2.carbon.identity.api.server.authenticators.v1.model.Authenticator;
import org.wso2.carbon.identity.api.server.authenticators.v1.model.ConnectedApps;
import org.wso2.carbon.identity.api.server.authenticators.v1.model.Error;
Expand All @@ -39,8 +41,12 @@

public class AuthenticatorsApi {

@Autowired
private AuthenticatorsApiService delegate;
private final AuthenticatorsApiService delegate;

public AuthenticatorsApi() {

this.delegate = AuthenticatorsApiServiceFactory.getAuthenticatorsApi();
}

@Valid
@GET
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,40 @@
/*
* Copyright (c) 2021, 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) 2021-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.authenticators.v1.factories;

import org.wso2.carbon.identity.api.server.authenticators.v1.AuthenticatorsApiService;
import org.wso2.carbon.identity.api.server.authenticators.v1.impl.AuthenticatorsApiServiceImpl;

/**
* This class is the factory class for AuthenticatorsApiService.
*/
public class AuthenticatorsApiServiceFactory {

private final static AuthenticatorsApiService service = new AuthenticatorsApiServiceImpl();
private final static AuthenticatorsApiService SERVICE = new AuthenticatorsApiServiceImpl();

/**
* Get AuthenticatorsApiService.
*
* @return AuthenticatorsApiService
*/
public static AuthenticatorsApiService getAuthenticatorsApi()
{
return service;
return SERVICE;
}
}
Loading

0 comments on commit eff8fce

Please sign in to comment.