-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #470 from Thisara-Welmilla/idle-account-identifica…
…tion-API-support Add idle account identification API
- Loading branch information
Showing
18 changed files
with
1,640 additions
and
2 deletions.
There are no files selected for viewing
127 changes: 127 additions & 0 deletions
127
...nt.identification/org.wso2.carbon.identity.api.idle.account.identification.common/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org). | ||
~ | ||
~ 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. | ||
--> | ||
<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.2.68-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>org.wso2.carbon.identity.api.idle.account.identification.common</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.wso2.carbon.identity.governance</groupId> | ||
<artifactId>org.wso2.carbon.identity.idle.account.identification</artifactId> | ||
<scope>provided</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>javax.ws.rs</groupId> | ||
<artifactId>jsr311-api</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.cxf</groupId> | ||
<artifactId>cxf-rt-frontend-jaxrs</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.cxf</groupId> | ||
<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> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.swagger</groupId> | ||
<artifactId>swagger-jaxrs</artifactId> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-annotations</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-core</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>com.fasterxml.jackson.dataformat</groupId> | ||
<artifactId>jackson-dataformat-yaml</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>javax.ws.rs</groupId> | ||
<artifactId>jsr311-api</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>com.google.guava</groupId> | ||
<artifactId>guava</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.jaxrs</groupId> | ||
<artifactId>jackson-jaxrs-json-provider</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.wso2.carbon</groupId> | ||
<artifactId>org.wso2.carbon.utils</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.wso2.carbon.identity.framework</groupId> | ||
<artifactId>org.wso2.carbon.identity.core</artifactId> | ||
<scope>provided</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>javax.ws.rs</groupId> | ||
<artifactId>jsr311-api</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
48 changes: 48 additions & 0 deletions
48
...n/java/org/wso2/carbon/identity/api/idle/account/identification/common/ContextLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright (c) 2023, 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.common; | ||
|
||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
import org.wso2.carbon.base.MultitenantConstants; | ||
import org.wso2.carbon.identity.core.util.IdentityCoreConstants; | ||
import org.wso2.carbon.identity.core.util.IdentityUtil; | ||
|
||
/** | ||
* Load information from context. | ||
*/ | ||
public class ContextLoader { | ||
|
||
private static final Log LOG = LogFactory.getLog(ContextLoader.class); | ||
|
||
/** | ||
* Retrieves loaded tenant domain from carbon context. | ||
* | ||
* @return tenant domain of the request is being served. | ||
*/ | ||
public static String getTenantDomainFromContext() { | ||
|
||
String tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME; | ||
if (IdentityUtil.threadLocalProperties.get().get(IdentityCoreConstants.TENANT_NAME_FROM_CONTEXT) != null) { | ||
tenantDomain = (String) IdentityUtil.threadLocalProperties.get() | ||
.get(IdentityCoreConstants.TENANT_NAME_FROM_CONTEXT); | ||
} | ||
return tenantDomain; | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...entity/api/idle/account/identification/common/IdleAccountIdentificationServiceHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (c) 2023, 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.common; | ||
|
||
import org.wso2.carbon.identity.idle.account.identification.services.IdleAccountIdentificationService; | ||
|
||
/** | ||
* Service holder class for idle account identification. | ||
*/ | ||
public class IdleAccountIdentificationServiceHolder { | ||
|
||
private static IdleAccountIdentificationService idleAccountIdentificationService; | ||
|
||
/** | ||
* Get IdleAccountIdentificationService OSGi service. | ||
* | ||
* @return Idle account identification Service. | ||
*/ | ||
public static IdleAccountIdentificationService getIdleAccountIdentificationService() { | ||
|
||
return idleAccountIdentificationService; | ||
} | ||
|
||
/** | ||
* Set IdleAccountIdentificationService OSGi service. | ||
* | ||
* @param idleAccountIdentificationService Idle account identification Service. | ||
*/ | ||
public static void setIdleAccountIdentificationService( | ||
IdleAccountIdentificationService idleAccountIdentificationService) { | ||
|
||
IdleAccountIdentificationServiceHolder.idleAccountIdentificationService = idleAccountIdentificationService; | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...le/account/identification/common/factory/IdleAccountIdentificationOSGIServiceFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright (c) 2023, 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.common.factory; | ||
|
||
import org.springframework.beans.factory.config.AbstractFactoryBean; | ||
import org.wso2.carbon.context.PrivilegedCarbonContext; | ||
import org.wso2.carbon.identity.idle.account.identification.services.IdleAccountIdentificationService; | ||
|
||
/** | ||
* Factory Beans serve as a factory for creating other beans within the IOC container. This factory bean is used to | ||
* instantiate the IdleAccountIdentificationService type of object inside the container. | ||
*/ | ||
public class IdleAccountIdentificationOSGIServiceFactory extends AbstractFactoryBean<IdleAccountIdentificationService> { | ||
|
||
private IdleAccountIdentificationService idleAccountIdentificationService; | ||
|
||
@Override | ||
public Class<?> getObjectType() { | ||
|
||
return Object.class; | ||
} | ||
|
||
@Override | ||
protected IdleAccountIdentificationService createInstance() throws Exception { | ||
|
||
if (this.idleAccountIdentificationService == null) { | ||
IdleAccountIdentificationService taskOperationService = | ||
(IdleAccountIdentificationService) PrivilegedCarbonContext. | ||
getThreadLocalCarbonContext().getOSGiService(IdleAccountIdentificationService.class, null); | ||
|
||
if (taskOperationService == null) { | ||
throw new Exception("Unable to retrieve Idle account identification service."); | ||
} | ||
this.idleAccountIdentificationService = taskOperationService; | ||
} | ||
return this.idleAccountIdentificationService; | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
...ntity/api/idle/account/identification/common/util/IdleAccountIdentificationConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Copyright (c) 2023, 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.common.util; | ||
|
||
/** | ||
* Inactive users management related constant class. | ||
*/ | ||
public class IdleAccountIdentificationConstants { | ||
|
||
public static final String INACTIVE_USER_MANAGEMENT_SERVICE_ERROR_PREFIX = "IDLE_ACC-"; | ||
|
||
public static final String DATE_INACTIVE_AFTER = "inactiveAfter"; | ||
public static final String DATE_EXCLUDE_BEFORE = "excludeBefore"; | ||
public static final String DATE_FORMAT_REGEX = "^\\d{4}-\\d{2}-\\d{2}$"; | ||
|
||
/** | ||
* Enums for error messages. | ||
*/ | ||
public enum ErrorMessage { | ||
|
||
// Client errors 600xx. | ||
ERROR_REQUIRED_PARAMETER_MISSING("60001", | ||
"Required parameter is not provided.", | ||
"%s parameter is required and cannot be empty."), | ||
|
||
ERROR_DATE_REGEX_MISMATCH("60002", | ||
"Invalid date format provided.", | ||
"The value provided for %s parameter is invalid. Date format should be yyyy-mm-dd"), | ||
|
||
ERROR_INVALID_DATE("60003", | ||
"Invalid date provided.", | ||
"The date provided for %s parameter is invalid"), | ||
|
||
// Server errors 650xx. | ||
ERROR_RETRIEVING_INACTIVE_USERS("65001", | ||
"Error while retrieving inactive users.", | ||
"Error while retrieving inactive users for organization: %s."); | ||
|
||
private final String code; | ||
private final String message; | ||
private final String description; | ||
|
||
ErrorMessage(String code, String message, String description) { | ||
|
||
this.code = code; | ||
this.message = message; | ||
this.description = description; | ||
} | ||
|
||
public String getCode() { | ||
|
||
return INACTIVE_USER_MANAGEMENT_SERVICE_ERROR_PREFIX + code; | ||
} | ||
|
||
public String getMessage() { | ||
|
||
return message; | ||
} | ||
|
||
public String getDescription() { | ||
|
||
return description; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
|
||
return code + " | " + message; | ||
} | ||
} | ||
} |
Oops, something went wrong.