-
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.
Add API Layer for Organization User Invitation MGT
- Loading branch information
1 parent
0446390
commit 165c10c
Showing
24 changed files
with
3,315 additions
and
40 deletions.
There are no files selected for viewing
109 changes: 109 additions & 0 deletions
109
...rg.wso2.carbon.identity.api.server.organization.user.invitation.management.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,109 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ 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. | ||
--> | ||
<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.server.organization.user.invitation.management</artifactId> | ||
<version>1.2.67-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>org.wso2.carbon.identity.api.server.organization.user.invitation.management.common</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.wso2.carbon.multitenancy</groupId> | ||
<artifactId>org.wso2.carbon.tenant.mgt</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.wso2.carbon.extension.identity.verification</groupId> | ||
<artifactId>org.wso2.carbon.extension.identity.verification.provider</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.wso2.carbon.identity.organization.management</groupId> | ||
<artifactId>org.wso2.carbon.identity.organization.user.invitation.management</artifactId> | ||
</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>javax.ws.rs</groupId> | ||
<artifactId>javax.ws.rs-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-web</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.jaxrs</groupId> | ||
<artifactId>jackson-jaxrs-json-provider</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.swagger</groupId> | ||
<artifactId>swagger-jaxrs</artifactId> | ||
<scope>provided</scope> | ||
<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> | ||
</dependencies> | ||
|
||
<properties> | ||
<maven.compiler.source>8</maven.compiler.source> | ||
<maven.compiler.target>8</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
</project> |
118 changes: 118 additions & 0 deletions
118
...api/server/organization/user/invitation/management/common/UserInvitationMgtConstants.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,118 @@ | ||
/* | ||
* 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.server.organization.user.invitation.management.common; | ||
|
||
/** | ||
* Holds the constants which the shared user invitation management API component is using. | ||
*/ | ||
public class UserInvitationMgtConstants { | ||
|
||
public static final String ERROR_PREFIX = "OUI-"; | ||
|
||
/** | ||
* Enum for shared user invitation management related errors. | ||
* Error Code - code to identify the error. | ||
* Error Message - What went wrong. | ||
* Error Description - Why it went wrong. | ||
*/ | ||
public enum ErrorMessage { | ||
|
||
// Client errors. | ||
ERROR_CODE_USER_NOT_FOUND("60000", | ||
"Invalid user identifier is provided.", | ||
"Invalid user identifier %s is provided."), | ||
ERROR_CODE_INVALID_INVITATION("60001", | ||
"Invalid invitation.", | ||
"Provided invitation with the id %s is invalid."), | ||
ERROR_CODE_INVALID_CONFIRMATION_CODE("60002", | ||
"Invalid confirmation code.", | ||
"Could not validate the confirmation code %s."), | ||
ERROR_CODE_MULTIPLE_INVITATIONS_FOR_USER("60003", | ||
"Unable to create the invitation.", | ||
"Multiple invitations found for the user %s."), | ||
ERROR_CODE_UNSUPPORTED_LIMIT("60004", | ||
"Unsupported param.", | ||
"Limit param is not supported yet."), | ||
ERROR_CODE_UNSUPPORTED_OFFSET("60005", | ||
"Unsupported param.", | ||
"Offset param is not supported yet."), | ||
ERROR_CODE_UNSUPPORTED_SORT_ORDER("60006", | ||
"Unsupported param.", | ||
"Sort order param is not supported yet."), | ||
ERROR_CODE_UNSUPPORTED_SORT_BY("60007", | ||
"Unsupported param.", | ||
"Sort order param is not supported yet."), | ||
ERROR_CODE_ACTIVE_INVITATION_AVAILABLE("60008", | ||
"Invitation already exists.", | ||
"An active invitation already exists for the user %s."), | ||
ERROR_CODE_INVALID_FILTER("60009", | ||
"Invalid filter.", | ||
"Provided filter %s is not valid."), | ||
|
||
// Server errors. | ||
ERROR_CODE_CREATE_INVITATION("65001", | ||
"Unable to create the invitation.", | ||
"Could not create the invitation to the user %s."), | ||
ERROR_CODE_GET_INVITATIONS("65002", | ||
"Unable to retrieve the invitations.", | ||
"Could not retrieve the invitations for the organization."), | ||
ERROR_CODE_VALIDATE_INVITATION("65003", | ||
"Unable to validate the invitation.", | ||
"Could not validate the invitation with the confirmation code %s."), | ||
ERROR_CODE_DELETE_INVITATION("65004", | ||
"Unable to delete the invitation.", | ||
"Could not delete the invitation with the id %s."), | ||
ERROR_CODE_NOT_IMPLEMENTED("65100", | ||
"Not Implemented.", | ||
"Method is not implemented."); | ||
|
||
|
||
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 ERROR_PREFIX + code; | ||
} | ||
|
||
public String getMessage() { | ||
|
||
return message; | ||
} | ||
|
||
public String getDescription() { | ||
|
||
return description; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
|
||
return code + " | " + message; | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...server/organization/user/invitation/management/common/UserInvitationMgtServiceHolder.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,49 @@ | ||
/* | ||
* 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.server.organization.user.invitation.management.common; | ||
|
||
import org.wso2.carbon.identity.organization.user.invitation.management.InvitationCoreService; | ||
|
||
/** | ||
* Holds the services which the shared user invitation management API component is using. | ||
*/ | ||
public class UserInvitationMgtServiceHolder { | ||
|
||
private static InvitationCoreService invitationCoreService; | ||
|
||
/** | ||
* Get Invitation Core osgi service. | ||
* | ||
* @return InvitationCoreService. | ||
*/ | ||
public static InvitationCoreService getInvitationCoreService() { | ||
|
||
return invitationCoreService; | ||
} | ||
|
||
/** | ||
* Set Invitation Core osgi service. | ||
* | ||
* @param invitationCoreService InvitationCoreService. | ||
*/ | ||
public static void setInvitationCoreService(InvitationCoreService invitationCoreService) { | ||
|
||
UserInvitationMgtServiceHolder.invitationCoreService = invitationCoreService; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
...zation/user/invitation/management/common/factory/UserInvitationMgtOSGIServiceFactory.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,53 @@ | ||
/* | ||
* 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.server.organization.user.invitation.management.common.factory; | ||
|
||
import org.springframework.beans.factory.config.AbstractFactoryBean; | ||
import org.wso2.carbon.context.PrivilegedCarbonContext; | ||
import org.wso2.carbon.identity.organization.user.invitation.management.InvitationCoreService; | ||
|
||
/** | ||
* Factory Beans serves as a factory for creating other beans within the IOC container. This factory bean is used to | ||
* instantiate the Invitation Core Service inside the container. | ||
*/ | ||
public class UserInvitationMgtOSGIServiceFactory extends AbstractFactoryBean<InvitationCoreService> { | ||
|
||
private InvitationCoreService invitationCoreService; | ||
|
||
@Override | ||
public Class<?> getObjectType() { | ||
|
||
return Object.class; | ||
} | ||
|
||
@Override | ||
protected InvitationCoreService createInstance() throws Exception { | ||
|
||
if (this.invitationCoreService == null) { | ||
InvitationCoreService invitationCoreService = (InvitationCoreService) | ||
PrivilegedCarbonContext.getThreadLocalCarbonContext() | ||
.getOSGiService(InvitationCoreService.class, null); | ||
if (invitationCoreService == null) { | ||
throw new Exception("Unable to retrieve InvitationCoreService."); | ||
} | ||
this.invitationCoreService = invitationCoreService; | ||
} | ||
return this.invitationCoreService; | ||
} | ||
} |
Oops, something went wrong.