Skip to content

Commit

Permalink
Merge branch 'master' into Idle-Account-Suspension-API
Browse files Browse the repository at this point in the history
  • Loading branch information
KaveeshaPiumini authored Jan 21, 2025
2 parents 0e0565f + 7197a01 commit 62027fc
Show file tree
Hide file tree
Showing 131 changed files with 826 additions and 485 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.wso2.carbon.identity.server.api</groupId>
<artifactId>org.wso2.carbon.identity.api.expired.password.identification</artifactId>
<version>1.3.21-SNAPSHOT</version>
<version>1.3.25-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.identity.server.api</groupId>
<artifactId>org.wso2.carbon.identity.api.expired.password.identification</artifactId>
<version>1.3.21-SNAPSHOT</version>
<version>1.3.25-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>identity-api-server</artifactId>
<groupId>org.wso2.carbon.identity.server.api</groupId>
<version>1.3.21-SNAPSHOT</version>
<version>1.3.25-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org).
~ Copyright (c) 2023-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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.wso2.carbon.identity.server.api</groupId>
<artifactId>org.wso2.carbon.identity.api.idle.account.identification</artifactId>
<version>1.3.21-SNAPSHOT</version>
<version>1.3.25-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -61,11 +63,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) 2023, WSO2 LLC. (http://www.wso2.com).
* Copyright (c) 2023-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
Expand All @@ -18,33 +18,30 @@

package org.wso2.carbon.identity.api.idle.account.identification.common;

import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.identity.idle.account.identification.services.IdleAccountIdentificationService;

/**
* Service holder class for idle account identification.
*/
public class IdleAccountIdentificationServiceHolder {

private static IdleAccountIdentificationService idleAccountIdentificationService;
private IdleAccountIdentificationServiceHolder() {}

/**
* Get IdleAccountIdentificationService OSGi service.
*
* @return Idle account identification Service.
*/
public static IdleAccountIdentificationService getIdleAccountIdentificationService() {
private static class IdleAccountServiceHolder {

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

/**
* Set IdleAccountIdentificationService OSGi service.
* Get IdleAccountIdentificationService OSGi service.
*
* @param idleAccountIdentificationService Idle account identification Service.
* @return Idle account identification Service.
*/
public static void setIdleAccountIdentificationService(
IdleAccountIdentificationService idleAccountIdentificationService) {
public static IdleAccountIdentificationService getIdleAccountIdentificationService() {

IdleAccountIdentificationServiceHolder.idleAccountIdentificationService = idleAccountIdentificationService;
return IdleAccountServiceHolder.SERVICE;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org).
~ Copyright (c) 2023-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">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.wso2.carbon.identity.server.api</groupId>
<artifactId>org.wso2.carbon.identity.api.idle.account.identification</artifactId>
<version>1.3.21-SNAPSHOT</version>
<version>1.3.25-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

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
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,28 @@

package org.wso2.carbon.identity.api.idle.account.identification.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.idle.account.identification.v1.factories.InactiveUsersApiServiceFactory;
import org.wso2.carbon.identity.api.idle.account.identification.v1.model.Error;
import org.wso2.carbon.identity.api.idle.account.identification.v1.model.InactiveUser;
import org.wso2.carbon.identity.api.idle.account.identification.v1.model.Unauthorized;
import org.wso2.carbon.identity.api.idle.account.identification.v1.InactiveUsersApiService;

import javax.validation.Valid;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import io.swagger.annotations.*;
import org.wso2.carbon.identity.idle.account.identification.exception.IdleAccountIdentificationClientException;

import javax.validation.constraints.*;

@Path("/inactive-users")
@Api(description = "The inactive-users API")

public class InactiveUsersApi {

@Autowired
private InactiveUsersApiService delegate;
private final InactiveUsersApiService delegate;

public InactiveUsersApi() {

this.delegate = InactiveUsersApiServiceFactory.getInactiveUsersApi();
}

@Valid
@GET
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com).
* Copyright (c) 2023-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
Expand All @@ -21,12 +21,20 @@
import org.wso2.carbon.identity.api.idle.account.identification.v1.InactiveUsersApiService;
import org.wso2.carbon.identity.api.idle.account.identification.v1.impl.InactiveUsersApiServiceImpl;

/**
* Factory class for InactiveUsersApiService.
*/
public class InactiveUsersApiServiceFactory {

private final static InactiveUsersApiService service = new InactiveUsersApiServiceImpl();
private final static InactiveUsersApiService SERVICE = new InactiveUsersApiServiceImpl();

/**
* Get InactiveUsersApiService.
*
* @return InactiveUsersApiService.
*/
public static InactiveUsersApiService getInactiveUsersApi()
{
return service;
return SERVICE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.identity.api.idle.account.identification.common.IdleAccountIdentificationServiceHolder;
import org.wso2.carbon.identity.api.idle.account.identification.common.util.IdleAccountIdentificationConstants;
import org.wso2.carbon.identity.api.idle.account.identification.v1.model.InactiveUser;
import org.wso2.carbon.identity.api.server.common.error.APIError;
Expand All @@ -34,6 +33,7 @@
import org.wso2.carbon.identity.idle.account.identification.exception.IdleAccountIdentificationException;
import org.wso2.carbon.identity.idle.account.identification.exception.IdleAccountIdentificationServerException;
import org.wso2.carbon.identity.idle.account.identification.models.InactiveUserModel;
import org.wso2.carbon.identity.idle.account.identification.services.IdleAccountIdentificationService;

import java.io.IOException;
import java.time.LocalDate;
Expand All @@ -58,8 +58,14 @@
*/
public class InactiveUsersManagementApiService {

private final IdleAccountIdentificationService idleAccountIdentificationService;
private static final Log LOG = LogFactory.getLog(InactiveUsersManagementApiService.class);

public InactiveUsersManagementApiService(IdleAccountIdentificationService idleAccountIdentificationService) {

this.idleAccountIdentificationService = idleAccountIdentificationService;
}

/**
* Get inactive users.
*
Expand All @@ -79,11 +85,11 @@ public List<InactiveUser> getInactiveUsers(String inactiveAfter, String excludeB
validateDatesCombination(inactiveAfterDate, excludeBeforeDate);

if (excludeBeforeDate == null) {
inactiveUsers = IdleAccountIdentificationServiceHolder.getIdleAccountIdentificationService().
getInactiveUsersFromSpecificDate(inactiveAfterDate, tenantDomain);
inactiveUsers = idleAccountIdentificationService
.getInactiveUsersFromSpecificDate(inactiveAfterDate, tenantDomain);
} else {
inactiveUsers = IdleAccountIdentificationServiceHolder.getIdleAccountIdentificationService().
getLimitedInactiveUsersFromSpecificDate(inactiveAfterDate, excludeBeforeDate, tenantDomain);
inactiveUsers = idleAccountIdentificationService
.getLimitedInactiveUsersFromSpecificDate(inactiveAfterDate, excludeBeforeDate, tenantDomain);
}
return buildResponse(inactiveUsers);
} catch (IdleAccountIdentificationException e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* 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.api.idle.account.identification.v1.factories;

import org.wso2.carbon.identity.api.idle.account.identification.common.IdleAccountIdentificationServiceHolder;
import org.wso2.carbon.identity.api.idle.account.identification.v1.core.InactiveUsersManagementApiService;
import org.wso2.carbon.identity.idle.account.identification.services.IdleAccountIdentificationService;

/**
* Factory class for InactiveUsersManagementApiService.
*/
public class InactiveUsersManagementApiServiceFactory {

private static final InactiveUsersManagementApiService SERVICE;

static {
IdleAccountIdentificationService idleAccountIdentificationService = IdleAccountIdentificationServiceHolder
.getIdleAccountIdentificationService();
if (idleAccountIdentificationService == null) {
throw new IllegalStateException("IdleAccountIdentificationService is not available from OSGi context.");
}
SERVICE = new InactiveUsersManagementApiService(idleAccountIdentificationService);
}

/**
* Get InactiveUsersManagementApiService.
*
* @return InactiveUsersManagementApiService
*/
public static InactiveUsersManagementApiService getInactiveUsersManagementApiService() {
return SERVICE;
}
}
Loading

0 comments on commit 62027fc

Please sign in to comment.