diff --git a/components/org.wso2.carbon.identity.api.expired.password.identification/org.wso2.carbon.identity.api.expired.password.identification.common/pom.xml b/components/org.wso2.carbon.identity.api.expired.password.identification/org.wso2.carbon.identity.api.expired.password.identification.common/pom.xml index 6225c90db9..4b64872bef 100644 --- a/components/org.wso2.carbon.identity.api.expired.password.identification/org.wso2.carbon.identity.api.expired.password.identification.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.expired.password.identification/org.wso2.carbon.identity.api.expired.password.identification.common/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.expired.password.identification - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../pom.xml diff --git a/components/org.wso2.carbon.identity.api.expired.password.identification/org.wso2.carbon.identity.api.expired.password.identification.v1/pom.xml b/components/org.wso2.carbon.identity.api.expired.password.identification/org.wso2.carbon.identity.api.expired.password.identification.v1/pom.xml index 451edb8873..74ac7e9815 100644 --- a/components/org.wso2.carbon.identity.api.expired.password.identification/org.wso2.carbon.identity.api.expired.password.identification.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.expired.password.identification/org.wso2.carbon.identity.api.expired.password.identification.v1/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.expired.password.identification - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../pom.xml diff --git a/components/org.wso2.carbon.identity.api.expired.password.identification/pom.xml b/components/org.wso2.carbon.identity.api.expired.password.identification/pom.xml index 0e888b3cde..abfc423d02 100644 --- a/components/org.wso2.carbon.identity.api.expired.password.identification/pom.xml +++ b/components/org.wso2.carbon.identity.api.expired.password.identification/pom.xml @@ -20,7 +20,7 @@ identity-api-server org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../pom.xml diff --git a/components/org.wso2.carbon.identity.api.idle.account.identification/org.wso2.carbon.identity.api.idle.account.identification.common/pom.xml b/components/org.wso2.carbon.identity.api.idle.account.identification/org.wso2.carbon.identity.api.idle.account.identification.common/pom.xml index 512e3e4161..5c29d11927 100644 --- a/components/org.wso2.carbon.identity.api.idle.account.identification/org.wso2.carbon.identity.api.idle.account.identification.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.idle.account.identification/org.wso2.carbon.identity.api.idle.account.identification.common/pom.xml @@ -19,7 +19,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.idle.account.identification - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../pom.xml diff --git a/components/org.wso2.carbon.identity.api.idle.account.identification/org.wso2.carbon.identity.api.idle.account.identification.v1/pom.xml b/components/org.wso2.carbon.identity.api.idle.account.identification/org.wso2.carbon.identity.api.idle.account.identification.v1/pom.xml index 5a4a360cb0..5a1c2c22ca 100644 --- a/components/org.wso2.carbon.identity.api.idle.account.identification/org.wso2.carbon.identity.api.idle.account.identification.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.idle.account.identification/org.wso2.carbon.identity.api.idle.account.identification.v1/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.idle.account.identification - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../pom.xml diff --git a/components/org.wso2.carbon.identity.api.idle.account.identification/pom.xml b/components/org.wso2.carbon.identity.api.idle.account.identification/pom.xml index 5046ea302e..7f6273335b 100644 --- a/components/org.wso2.carbon.identity.api.idle.account.identification/pom.xml +++ b/components/org.wso2.carbon.identity.api.idle.account.identification/pom.xml @@ -20,7 +20,7 @@ identity-api-server org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.common/pom.xml b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.common/pom.xml index 3e2e7b4369..a05f099074 100644 --- a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.common/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.identity.api.server.admin.advisory.management org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../pom.xml 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/pom.xml index 7afb07eb6a..55463b896b 100644 --- a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.identity.api.server.admin.advisory.management org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/pom.xml b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/pom.xml index 4e7582ab77..ecf03e2bb7 100644 --- a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/pom.xml @@ -20,7 +20,7 @@ identity-api-server org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.common/pom.xml b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.common/pom.xml new file mode 100644 index 0000000000..ca41a3d0d4 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.common/pom.xml @@ -0,0 +1,72 @@ + + + + 4.0.0 + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.api.resource + 1.2.85-SNAPSHOT + ../pom.xml + + + org.wso2.carbon.identity.api.server.api.resource.common + jar + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + + + + org.springframework + spring-web + provided + + + javax.ws.rs + javax.ws.rs-api + provided + + + org.wso2.carbon.identity.framework + org.wso2.carbon.identity.application.mgt + provided + + + org.wso2.carbon.identity.framework + org.wso2.carbon.identity.api.resource.mgt + provided + + + org.wso2.carbon.identity.inbound.auth.oauth2 + org.wso2.carbon.identity.oauth + provided + + + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.common/src/main/java/org/wso2/carbon/identity/api/server/api/resource/common/APIResourceManagementServiceHolder.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.common/src/main/java/org/wso2/carbon/identity/api/server/api/resource/common/APIResourceManagementServiceHolder.java new file mode 100644 index 0000000000..01042f8d08 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.common/src/main/java/org/wso2/carbon/identity/api/server/api/resource/common/APIResourceManagementServiceHolder.java @@ -0,0 +1,71 @@ +/* + * 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.api.resource.common; + +import org.wso2.carbon.identity.api.resource.mgt.APIResourceManager; +import org.wso2.carbon.identity.oauth.OAuthAdminServiceImpl; + +/** + * Service holder class for api resource management. + */ +public class APIResourceManagementServiceHolder { + + private static APIResourceManager apiResourceManager; + private static OAuthAdminServiceImpl oAuthAdminServiceImpl; + + /** + * Get APIResourceManager osgi service. + * + * @return APIResourceManager. + */ + public static APIResourceManager getApiResourceManager() { + + return apiResourceManager; + } + + /** + * Set APIResourceManager osgi service. + * + * @param apiResourceManager APIResourceManager. + */ + public static void setApiResourceManager(APIResourceManager apiResourceManager) { + + APIResourceManagementServiceHolder.apiResourceManager = apiResourceManager; + } + + /** + * Get OAuthAdminServiceImpl instance. + * + * @return OAuthAdminServiceImpl instance. + */ + public static OAuthAdminServiceImpl getOAuthAdminServiceImpl() { + + return oAuthAdminServiceImpl; + } + + /** + * Set OAuthAdminServiceImpl instance. + * + * @param oAuthAdminServiceImpl OAuthAdminServiceImpl instance. + */ + public static void setOAuthAdminServiceImpl(OAuthAdminServiceImpl oAuthAdminServiceImpl) { + + APIResourceManagementServiceHolder.oAuthAdminServiceImpl = oAuthAdminServiceImpl; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.common/src/main/java/org/wso2/carbon/identity/api/server/api/resource/common/factory/APIResourceMgtOSGiServiceFactory.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.common/src/main/java/org/wso2/carbon/identity/api/server/api/resource/common/factory/APIResourceMgtOSGiServiceFactory.java new file mode 100644 index 0000000000..953bd1cfd5 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.common/src/main/java/org/wso2/carbon/identity/api/server/api/resource/common/factory/APIResourceMgtOSGiServiceFactory.java @@ -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.server.api.resource.common.factory; + +import org.springframework.beans.factory.config.AbstractFactoryBean; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.identity.api.resource.mgt.APIResourceManager; + +/** + * Factory class for APIResourceManagementOSGiService. + */ +public class APIResourceMgtOSGiServiceFactory extends AbstractFactoryBean { + + private APIResourceManager apiResourceManager; + + @Override + public Class getObjectType() { + + return Object.class; + } + + @Override + protected APIResourceManager createInstance() throws Exception { + + if (this.apiResourceManager == null) { + apiResourceManager = (APIResourceManager) PrivilegedCarbonContext. + getThreadLocalCarbonContext().getOSGiService(APIResourceManager.class, null); + if (apiResourceManager == null) { + throw new Exception("Unable to retrieve APIResourceManager service."); + } + } + return this.apiResourceManager; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.common/src/main/java/org/wso2/carbon/identity/api/server/api/resource/common/factory/OAuthAdminOSGiServiceFactory.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.common/src/main/java/org/wso2/carbon/identity/api/server/api/resource/common/factory/OAuthAdminOSGiServiceFactory.java new file mode 100644 index 0000000000..e160b1eb4b --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.common/src/main/java/org/wso2/carbon/identity/api/server/api/resource/common/factory/OAuthAdminOSGiServiceFactory.java @@ -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.api.resource.common.factory; + +import org.springframework.beans.factory.config.AbstractFactoryBean; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.identity.oauth.OAuthAdminServiceImpl; + +/** + * Factory Beans serves as a factory for creating other beans within the IOC container. This factory bean is used to + * instantiate the OAuthAdminServiceImpl type of object inside the container. + */ +public class OAuthAdminOSGiServiceFactory extends AbstractFactoryBean { + + private OAuthAdminServiceImpl oauthAdminService; + + @Override + public Class getObjectType() { + + return Object.class; + } + + @Override + protected OAuthAdminServiceImpl createInstance() throws Exception { + + if (this.oauthAdminService == null) { + oauthAdminService = (OAuthAdminServiceImpl) PrivilegedCarbonContext + .getThreadLocalCarbonContext().getOSGiService(OAuthAdminServiceImpl.class, null); + + if (oauthAdminService == null) { + throw new Exception("Unable to retrieve OAuthAdminServiceImpl service."); + } + } + return this.oauthAdminService; + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/pom.xml new file mode 100644 index 0000000000..13f580bb47 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/pom.xml @@ -0,0 +1,192 @@ + + + + 4.0.0 + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.api.resource + 1.2.85-SNAPSHOT + ../pom.xml + + + WSO2 Identity Server - API Resource Rest API + WSO2 Identity Server - API Resource Rest API + org.wso2.carbon.identity.api.server.api.resource.v1 + jar + + + + org.wso2.carbon.identity.organization.management.core + org.wso2.carbon.identity.organization.management.service + provided + + + org.apache.cxf + cxf-rt-frontend-jaxrs + provided + + + org.apache.cxf + cxf-rt-rs-service-description + provided + + + javax.ws.rs + javax.ws.rs-api + provided + + + io.swagger + swagger-jaxrs + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.core + jackson-annotations + + + com.fasterxml.jackson.core + jackson-core + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + + + javax.ws.rs + jsr311-api + + + com.google.guava + guava + + + + + org.springframework + spring-web + provided + + + com.fasterxml.jackson.jaxrs + jackson-jaxrs-json-provider + provided + + + org.wso2.carbon.identity.framework + org.wso2.carbon.identity.api.resource.mgt + provided + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.common + + + org.apache.cxf + cxf-rt-rs-extension-search + provided + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.api.resource.common + + + org.wso2.carbon.identity.framework + org.wso2.carbon.identity.application.common + provided + + + org.wso2.carbon.identity.inbound.auth.oauth2 + org.wso2.carbon.identity.oauth + provided + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven.compiler.plugin.version} + + 1.8 + 1.8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.8 + + + add-source + generate-sources + + add-source + + + + src/gen/java + + + + + + + + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/APIResourceCreationModel.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/APIResourceCreationModel.java new file mode 100644 index 0000000000..3e60430092 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/APIResourceCreationModel.java @@ -0,0 +1,198 @@ +/* + * 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.api.resource.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import org.wso2.carbon.identity.api.server.api.resource.v1.ScopeCreationModel; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class APIResourceCreationModel { + + private String name; + private String identifier; + private String description; + private Boolean requiresAuthorization; + private List scopes = null; + + + /** + **/ + public APIResourceCreationModel name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "Greetings API", required = true, value = "") + @JsonProperty("name") + @Valid + @NotNull(message = "Property name cannot be null.") + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + public APIResourceCreationModel identifier(String identifier) { + + this.identifier = identifier; + return this; + } + + @ApiModelProperty(example = "greetings_api", required = true, value = "") + @JsonProperty("identifier") + @Valid + @NotNull(message = "Property identifier cannot be null.") + + public String getIdentifier() { + return identifier; + } + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + **/ + public APIResourceCreationModel description(String description) { + + this.description = description; + return this; + } + + @ApiModelProperty(example = "Greetings API representation", value = "") + @JsonProperty("description") + @Valid + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + + /** + **/ + public APIResourceCreationModel requiresAuthorization(Boolean requiresAuthorization) { + + this.requiresAuthorization = requiresAuthorization; + return this; + } + + @ApiModelProperty(example = "true", value = "") + @JsonProperty("requiresAuthorization") + @Valid + public Boolean getRequiresAuthorization() { + return requiresAuthorization; + } + public void setRequiresAuthorization(Boolean requiresAuthorization) { + this.requiresAuthorization = requiresAuthorization; + } + + /** + **/ + public APIResourceCreationModel scopes(List scopes) { + + this.scopes = scopes; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("scopes") + @Valid + public List getScopes() { + return scopes; + } + public void setScopes(List scopes) { + this.scopes = scopes; + } + + public APIResourceCreationModel addScopesItem(ScopeCreationModel scopesItem) { + if (this.scopes == null) { + this.scopes = new ArrayList(); + } + this.scopes.add(scopesItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + APIResourceCreationModel apIResourceCreationModel = (APIResourceCreationModel) o; + return Objects.equals(this.name, apIResourceCreationModel.name) && + Objects.equals(this.identifier, apIResourceCreationModel.identifier) && + Objects.equals(this.description, apIResourceCreationModel.description) && + Objects.equals(this.requiresAuthorization, apIResourceCreationModel.requiresAuthorization) && + Objects.equals(this.scopes, apIResourceCreationModel.scopes); + } + + @Override + public int hashCode() { + return Objects.hash(name, identifier, description, requiresAuthorization, scopes); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class APIResourceCreationModel {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" identifier: ").append(toIndentedString(identifier)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" requiresAuthorization: ").append(toIndentedString(requiresAuthorization)).append("\n"); + sb.append(" scopes: ").append(toIndentedString(scopes)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/APIResourceListItem.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/APIResourceListItem.java new file mode 100644 index 0000000000..ef343a122c --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/APIResourceListItem.java @@ -0,0 +1,211 @@ +/* + * 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.api.resource.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class APIResourceListItem { + + private String id; + private String name; + private String identifier; + private String type; + private Boolean requiresAuthorization; + private String self; + + /** + **/ + public APIResourceListItem id(String id) { + + this.id = id; + return this; + } + + @ApiModelProperty(example = "gh43-jk34-vb34-df67", required = true, value = "") + @JsonProperty("id") + @Valid + @NotNull(message = "Property id cannot be null.") + + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + + /** + **/ + public APIResourceListItem name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "Greetings API", required = true, value = "") + @JsonProperty("name") + @Valid + @NotNull(message = "Property name cannot be null.") + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + public APIResourceListItem identifier(String identifier) { + + this.identifier = identifier; + return this; + } + + @ApiModelProperty(example = "greetings_api", required = true, value = "") + @JsonProperty("identifier") + @Valid + @NotNull(message = "Property identifier cannot be null.") + + public String getIdentifier() { + return identifier; + } + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + **/ + public APIResourceListItem type(String type) { + + this.type = type; + return this; + } + + @ApiModelProperty(example = "SYSTEM", value = "") + @JsonProperty("type") + @Valid + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + + /** + **/ + public APIResourceListItem requiresAuthorization(Boolean requiresAuthorization) { + + this.requiresAuthorization = requiresAuthorization; + return this; + } + + @ApiModelProperty(example = "true", value = "") + @JsonProperty("requiresAuthorization") + @Valid + public Boolean getRequiresAuthorization() { + return requiresAuthorization; + } + public void setRequiresAuthorization(Boolean requiresAuthorization) { + this.requiresAuthorization = requiresAuthorization; + } + + /** + **/ + public APIResourceListItem self(String self) { + + this.self = self; + return this; + } + + @ApiModelProperty(example = "/t/carbon.super/api/server/v1/api-resources/eDUwOUNlcnRpZmljYXRlQXV0aGVudGljYXRvcg", required = true, value = "") + @JsonProperty("self") + @Valid + @NotNull(message = "Property self cannot be null.") + + public String getSelf() { + return self; + } + public void setSelf(String self) { + this.self = self; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + APIResourceListItem apIResourceListItem = (APIResourceListItem) o; + return Objects.equals(this.id, apIResourceListItem.id) && + Objects.equals(this.name, apIResourceListItem.name) && + Objects.equals(this.identifier, apIResourceListItem.identifier) && + Objects.equals(this.type, apIResourceListItem.type) && + Objects.equals(this.requiresAuthorization, apIResourceListItem.requiresAuthorization) && + Objects.equals(this.self, apIResourceListItem.self); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, identifier, type, requiresAuthorization, self); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class APIResourceListItem {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" identifier: ").append(toIndentedString(identifier)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" requiresAuthorization: ").append(toIndentedString(requiresAuthorization)).append("\n"); + sb.append(" self: ").append(toIndentedString(self)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/APIResourceListResponse.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/APIResourceListResponse.java new file mode 100644 index 0000000000..3fcf0ec56e --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/APIResourceListResponse.java @@ -0,0 +1,161 @@ +/* + * 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.api.resource.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import org.wso2.carbon.identity.api.server.api.resource.v1.APIResourceListItem; +import org.wso2.carbon.identity.api.server.api.resource.v1.PaginationLink; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class APIResourceListResponse { + + private Integer totalResults; + private List links = new ArrayList(); + + private List apiResources = null; + + + /** + **/ + public APIResourceListResponse totalResults(Integer totalResults) { + + this.totalResults = totalResults; + return this; + } + + @ApiModelProperty(example = "1", value = "") + @JsonProperty("totalResults") + @Valid + public Integer getTotalResults() { + return totalResults; + } + public void setTotalResults(Integer totalResults) { + this.totalResults = totalResults; + } + + /** + **/ + public APIResourceListResponse links(List links) { + + this.links = links; + return this; + } + + @ApiModelProperty(required = true, value = "") + @JsonProperty("links") + @Valid + @NotNull(message = "Property links cannot be null.") + + public List getLinks() { + return links; + } + public void setLinks(List links) { + this.links = links; + } + + public APIResourceListResponse addLinksItem(PaginationLink linksItem) { + this.links.add(linksItem); + return this; + } + + /** + **/ + public APIResourceListResponse apiResources(List apiResources) { + + this.apiResources = apiResources; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("apiResources") + @Valid + public List getApiResources() { + return apiResources; + } + public void setApiResources(List apiResources) { + this.apiResources = apiResources; + } + + public APIResourceListResponse addApiResourcesItem(APIResourceListItem apiResourcesItem) { + if (this.apiResources == null) { + this.apiResources = new ArrayList(); + } + this.apiResources.add(apiResourcesItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + APIResourceListResponse apIResourceListResponse = (APIResourceListResponse) o; + return Objects.equals(this.totalResults, apIResourceListResponse.totalResults) && + Objects.equals(this.links, apIResourceListResponse.links) && + Objects.equals(this.apiResources, apIResourceListResponse.apiResources); + } + + @Override + public int hashCode() { + return Objects.hash(totalResults, links, apiResources); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class APIResourceListResponse {\n"); + + sb.append(" totalResults: ").append(toIndentedString(totalResults)).append("\n"); + sb.append(" links: ").append(toIndentedString(links)).append("\n"); + sb.append(" apiResources: ").append(toIndentedString(apiResources)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/APIResourcePatchModel.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/APIResourcePatchModel.java new file mode 100644 index 0000000000..ba00307b2e --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/APIResourcePatchModel.java @@ -0,0 +1,183 @@ +/* + * 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.api.resource.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import org.wso2.carbon.identity.api.server.api.resource.v1.ScopeCreationModel; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class APIResourcePatchModel { + + private String name; + private String description; + private List addedScopes = null; + + private List removedScopes = null; + + + /** + **/ + public APIResourcePatchModel name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "Greetings API", value = "") + @JsonProperty("name") + @Valid + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + public APIResourcePatchModel description(String description) { + + this.description = description; + return this; + } + + @ApiModelProperty(example = "Greetings API representation", value = "") + @JsonProperty("description") + @Valid + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + + /** + **/ + public APIResourcePatchModel addedScopes(List addedScopes) { + + this.addedScopes = addedScopes; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("addedScopes") + @Valid + public List getAddedScopes() { + return addedScopes; + } + public void setAddedScopes(List addedScopes) { + this.addedScopes = addedScopes; + } + + public APIResourcePatchModel addAddedScopesItem(ScopeCreationModel addedScopesItem) { + if (this.addedScopes == null) { + this.addedScopes = new ArrayList(); + } + this.addedScopes.add(addedScopesItem); + return this; + } + + /** + * This field is not supported yet. + **/ + public APIResourcePatchModel removedScopes(List removedScopes) { + + this.removedScopes = removedScopes; + return this; + } + + @ApiModelProperty(value = "This field is not supported yet.") + @JsonProperty("removedScopes") + @Valid + public List getRemovedScopes() { + return removedScopes; + } + public void setRemovedScopes(List removedScopes) { + this.removedScopes = removedScopes; + } + + public APIResourcePatchModel addRemovedScopesItem(String removedScopesItem) { + if (this.removedScopes == null) { + this.removedScopes = new ArrayList(); + } + this.removedScopes.add(removedScopesItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + APIResourcePatchModel apIResourcePatchModel = (APIResourcePatchModel) o; + return Objects.equals(this.name, apIResourcePatchModel.name) && + Objects.equals(this.description, apIResourcePatchModel.description) && + Objects.equals(this.addedScopes, apIResourcePatchModel.addedScopes) && + Objects.equals(this.removedScopes, apIResourcePatchModel.removedScopes); + } + + @Override + public int hashCode() { + return Objects.hash(name, description, addedScopes, removedScopes); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class APIResourcePatchModel {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" addedScopes: ").append(toIndentedString(addedScopes)).append("\n"); + sb.append(" removedScopes: ").append(toIndentedString(removedScopes)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/APIResourceResponse.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/APIResourceResponse.java new file mode 100644 index 0000000000..22b3d7b93e --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/APIResourceResponse.java @@ -0,0 +1,296 @@ +/* + * 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.api.resource.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import org.wso2.carbon.identity.api.server.api.resource.v1.ScopeGetModel; +import org.wso2.carbon.identity.api.server.api.resource.v1.SubscribedApplicationGetModel; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class APIResourceResponse { + + private String id; + private String name; + private String description; + private String identifier; + private String type; + private Boolean requiresAuthorization; + private List scopes = null; + + private List subscribedApplications = null; + + private String self; + + /** + **/ + public APIResourceResponse id(String id) { + + this.id = id; + return this; + } + + @ApiModelProperty(example = "gh43-jk34-vb34-df67", required = true, value = "") + @JsonProperty("id") + @Valid + @NotNull(message = "Property id cannot be null.") + + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + + /** + **/ + public APIResourceResponse name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "Greetings API", required = true, value = "") + @JsonProperty("name") + @Valid + @NotNull(message = "Property name cannot be null.") + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + public APIResourceResponse description(String description) { + + this.description = description; + return this; + } + + @ApiModelProperty(example = "Greeting API representation", value = "") + @JsonProperty("description") + @Valid + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + + /** + **/ + public APIResourceResponse identifier(String identifier) { + + this.identifier = identifier; + return this; + } + + @ApiModelProperty(example = "greetings_api", required = true, value = "") + @JsonProperty("identifier") + @Valid + @NotNull(message = "Property identifier cannot be null.") + + public String getIdentifier() { + return identifier; + } + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + **/ + public APIResourceResponse type(String type) { + + this.type = type; + return this; + } + + @ApiModelProperty(example = "SYSTEM", value = "") + @JsonProperty("type") + @Valid + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + + /** + **/ + public APIResourceResponse requiresAuthorization(Boolean requiresAuthorization) { + + this.requiresAuthorization = requiresAuthorization; + return this; + } + + @ApiModelProperty(example = "true", value = "") + @JsonProperty("requiresAuthorization") + @Valid + public Boolean getRequiresAuthorization() { + return requiresAuthorization; + } + public void setRequiresAuthorization(Boolean requiresAuthorization) { + this.requiresAuthorization = requiresAuthorization; + } + + /** + **/ + public APIResourceResponse scopes(List scopes) { + + this.scopes = scopes; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("scopes") + @Valid + public List getScopes() { + return scopes; + } + public void setScopes(List scopes) { + this.scopes = scopes; + } + + public APIResourceResponse addScopesItem(ScopeGetModel scopesItem) { + if (this.scopes == null) { + this.scopes = new ArrayList(); + } + this.scopes.add(scopesItem); + return this; + } + + /** + **/ + public APIResourceResponse subscribedApplications(List subscribedApplications) { + + this.subscribedApplications = subscribedApplications; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("subscribedApplications") + @Valid + public List getSubscribedApplications() { + return subscribedApplications; + } + public void setSubscribedApplications(List subscribedApplications) { + this.subscribedApplications = subscribedApplications; + } + + public APIResourceResponse addSubscribedApplicationsItem(SubscribedApplicationGetModel subscribedApplicationsItem) { + if (this.subscribedApplications == null) { + this.subscribedApplications = new ArrayList(); + } + this.subscribedApplications.add(subscribedApplicationsItem); + return this; + } + + /** + **/ + public APIResourceResponse self(String self) { + + this.self = self; + return this; + } + + @ApiModelProperty(example = "/t/carbon.super/api/server/v1/api-resources/eDUwOUNlcnRpZmljYXRlQXV0aGVudGljYXRvcg", required = true, value = "") + @JsonProperty("self") + @Valid + @NotNull(message = "Property self cannot be null.") + + public String getSelf() { + return self; + } + public void setSelf(String self) { + this.self = self; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + APIResourceResponse apIResourceResponse = (APIResourceResponse) o; + return Objects.equals(this.id, apIResourceResponse.id) && + Objects.equals(this.name, apIResourceResponse.name) && + Objects.equals(this.description, apIResourceResponse.description) && + Objects.equals(this.identifier, apIResourceResponse.identifier) && + Objects.equals(this.type, apIResourceResponse.type) && + Objects.equals(this.requiresAuthorization, apIResourceResponse.requiresAuthorization) && + Objects.equals(this.scopes, apIResourceResponse.scopes) && + Objects.equals(this.subscribedApplications, apIResourceResponse.subscribedApplications) && + Objects.equals(this.self, apIResourceResponse.self); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, description, identifier, type, requiresAuthorization, scopes, subscribedApplications, self); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class APIResourceResponse {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" identifier: ").append(toIndentedString(identifier)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" requiresAuthorization: ").append(toIndentedString(requiresAuthorization)).append("\n"); + sb.append(" scopes: ").append(toIndentedString(scopes)).append("\n"); + sb.append(" subscribedApplications: ").append(toIndentedString(subscribedApplications)).append("\n"); + sb.append(" self: ").append(toIndentedString(self)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourcesApi.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourcesApi.java new file mode 100644 index 0000000000..0bc88af4c9 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourcesApi.java @@ -0,0 +1,224 @@ +/* + * 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.api.resource.v1; + +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.List; + +import javax.validation.Valid; +import javax.ws.rs.*; +import javax.ws.rs.core.Response; +import io.swagger.annotations.*; + +@Path("/api-resources") +@Api(description = "The api-resources API") + +public class ApiResourcesApi { + + @Autowired + private ApiResourcesApiService delegate; + + @Valid + @POST + + @Consumes({ "application/json" }) + @Produces({ "application/json", "application/xml", }) + @ApiOperation(value = "Add a new API resource", notes = "Add a new API resource", response = APIResourceResponse.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "API Resources", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK", response = APIResourceResponse.class), + @ApiResponse(code = 400, message = "Bad Request", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden", response = Void.class), + @ApiResponse(code = 404, message = "Not Found", response = Error.class), + @ApiResponse(code = 409, message = "Conflict", response = Error.class), + @ApiResponse(code = 500, message = "Server Error", response = Error.class) + }) + public Response addAPIResource(@ApiParam(value = "This represents the API resource to be created." ,required=true) @Valid APIResourceCreationModel apIResourceCreationModel) { + + return delegate.addAPIResource(apIResourceCreationModel ); + } + + @Valid + @DELETE + @Path("/{apiResourceId}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Delete API resource specified by the id", notes = "Delete API resource specified by the id", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "API Resources", }) + @ApiResponses(value = { + @ApiResponse(code = 204, message = "No Content", response = Void.class), + @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden", response = Void.class), + @ApiResponse(code = 500, message = "Server Error", response = Error.class) + }) + public Response apiResourcesApiResourceIdDelete(@ApiParam(value = "ID of the API Resource.",required=true) @PathParam("apiResourceId") String apiResourceId) { + + return delegate.apiResourcesApiResourceIdDelete(apiResourceId ); + } + + @Valid + @GET + @Path("/{apiResourceId}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Get API resource specified by the id", notes = "Get API resource specified by the id", response = APIResourceResponse.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "API Resources", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK", response = APIResourceResponse.class), + @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden", response = Void.class), + @ApiResponse(code = 500, message = "Server Error", response = Error.class) + }) + public Response apiResourcesApiResourceIdGet(@ApiParam(value = "ID of the API Resource.",required=true) @PathParam("apiResourceId") String apiResourceId) { + + return delegate.apiResourcesApiResourceIdGet(apiResourceId ); + } + + @Valid + @PATCH + @Path("/{apiResourceId}") + @Consumes({ "application/json" }) + @Produces({ "application/json", "application/xml", }) + @ApiOperation(value = "Patch API resource specified by the id", notes = "Patch API resource specified by the id. Patch operation only supports \"name\", \"description\" updating and \"addedScopes\" fields at the moment.", response = APIResourceResponse.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "API Resources", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK", response = APIResourceResponse.class), + @ApiResponse(code = 400, message = "Bad Request", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden", response = Void.class), + @ApiResponse(code = 404, message = "Not Found", response = Error.class), + @ApiResponse(code = 409, message = "Conflict", response = Error.class), + @ApiResponse(code = 500, message = "Server Error", response = Error.class), + @ApiResponse(code = 501, message = "Not Implemented", response = Error.class) + }) + public Response apiResourcesApiResourceIdPatch(@ApiParam(value = "ID of the API Resource.",required=true) @PathParam("apiResourceId") String apiResourceId, @ApiParam(value = "This represents the API resource to be patched." ,required=true) @Valid APIResourcePatchModel apIResourcePatchModel) { + + return delegate.apiResourcesApiResourceIdPatch(apiResourceId, apIResourcePatchModel ); + } + + @Valid + @GET + @Path("/{apiResourceId}/scopes") + + @Produces({ "application/json" }) + @ApiOperation(value = "Get API resource scopes", notes = "Get API resource scopes specified by the id", response = ScopeGetModel.class, responseContainer = "List", authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "API Resource Scopes", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK", response = ScopeGetModel.class, responseContainer = "List"), + @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden", response = Void.class), + @ApiResponse(code = 404, message = "Not Found", response = Error.class), + @ApiResponse(code = 500, message = "Server Error", response = Error.class) + }) + public Response apiResourcesApiResourceIdScopesGet(@ApiParam(value = "ID of the API Resource.",required=true) @PathParam("apiResourceId") String apiResourceId) { + + return delegate.apiResourcesApiResourceIdScopesGet(apiResourceId ); + } + + @Valid + @PUT + @Path("/{apiResourceId}/scopes") + @Consumes({ "application/json" }) + @Produces({ "application/json", "application/xml", }) + @ApiOperation(value = "Add scopes to API resource", notes = "Put scopes API resource specified by the id", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "API Resource Scopes", }) + @ApiResponses(value = { + @ApiResponse(code = 204, message = "No Content", response = Void.class), + @ApiResponse(code = 400, message = "Bad Request", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden", response = Void.class), + @ApiResponse(code = 404, message = "Not Found", response = Error.class), + @ApiResponse(code = 409, message = "Conflict", response = Error.class), + @ApiResponse(code = 500, message = "Server Error", response = Error.class) + }) + public Response apiResourcesApiResourceIdScopesPut(@ApiParam(value = "ID of the API Resource.",required=true) @PathParam("apiResourceId") String apiResourceId, @ApiParam(value = "This represents the API resource to be patched." ,required=true) @Valid List scopeCreationModel) { + + return delegate.apiResourcesApiResourceIdScopesPut(apiResourceId, scopeCreationModel ); + } + + @Valid + @DELETE + @Path("/{apiResourceId}/scopes/{scopeId}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Delete API resource specified by the id", notes = "Delete API resource specified by the id", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "API Resource Scopes", }) + @ApiResponses(value = { + @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden", response = Void.class), + @ApiResponse(code = 500, message = "Server Error", response = Error.class) + }) + public Response apiResourcesApiResourceIdScopesScopeIdDelete(@ApiParam(value = "ID of the API Resource.",required=true) @PathParam("apiResourceId") String apiResourceId, @ApiParam(value = "ID of the Scope.",required=true) @PathParam("scopeId") String scopeId) { + + return delegate.apiResourcesApiResourceIdScopesScopeNameDelete(apiResourceId, scopeId ); + } + + @Valid + @GET + + + @Produces({ "application/json" }) + @ApiOperation(value = "List all API resources in the server", notes = "List all API resources in the server", response = APIResourceListResponse.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "API Resources", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK", response = APIResourceListResponse.class), + @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden", response = Void.class), + @ApiResponse(code = 500, message = "Server Error", response = Error.class) + }) + public Response getAPIResources( @Valid@ApiParam(value = "Base64 encoded cursor value for backward pagination. ") @QueryParam("before") String before, @Valid@ApiParam(value = "Base64 encoded cursor value for forward pagination. ") @QueryParam("after") String after, @Valid@ApiParam(value = "Condition to filter the retrieval of records. Supports 'sw', 'co', 'ew' and 'eq' operations. ") @QueryParam("filter") String filter, @Valid@ApiParam(value = "Maximum number of records to return. ") @QueryParam("limit") Integer limit, @Valid@ApiParam(value = "Specifies the required parameters in the response. This parameter is not supported yet") @QueryParam("requiredAttributes") String requiredAttributes) { + + return delegate.getAPIResources(before, after, filter, limit, requiredAttributes ); + } + +} diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourcesApiService.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourcesApiService.java new file mode 100644 index 0000000000..d7d087d2d5 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ApiResourcesApiService.java @@ -0,0 +1,43 @@ +/* + * 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.api.resource.v1; + +import java.util.List; + +import javax.ws.rs.core.Response; + + +public interface ApiResourcesApiService { + + public Response addAPIResource(APIResourceCreationModel apIResourceCreationModel); + + public Response apiResourcesApiResourceIdDelete(String apiResourceId); + + public Response apiResourcesApiResourceIdGet(String apiResourceId); + + public Response apiResourcesApiResourceIdPatch(String apiResourceId, APIResourcePatchModel apIResourcePatchModel); + + public Response apiResourcesApiResourceIdScopesGet(String apiResourceId); + + public Response apiResourcesApiResourceIdScopesPut(String apiResourceId, List scopeCreationModel); + + public Response apiResourcesApiResourceIdScopesScopeNameDelete(String apiResourceId, String scopeName); + + public Response getAPIResources(String before, String after, String filter, Integer limit, String requiredAttributes); +} diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/Error.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/Error.java new file mode 100644 index 0000000000..5fe989b98e --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/Error.java @@ -0,0 +1,161 @@ +/* + * 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.api.resource.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class Error { + + private String code; + private String message; + private String description; + private String traceId; + + /** + **/ + public Error code(String code) { + + this.code = code; + return this; + } + + @ApiModelProperty(example = "AAA-00000", value = "") + @JsonProperty("code") + @Valid + public String getCode() { + return code; + } + public void setCode(String code) { + this.code = code; + } + + /** + **/ + public Error message(String message) { + + this.message = message; + return this; + } + + @ApiModelProperty(example = "Some Error Message", value = "") + @JsonProperty("message") + @Valid + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + + /** + **/ + public Error description(String description) { + + this.description = description; + return this; + } + + @ApiModelProperty(example = "Some Error Description", value = "") + @JsonProperty("description") + @Valid + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + + /** + **/ + public Error traceId(String traceId) { + + this.traceId = traceId; + return this; + } + + @ApiModelProperty(example = "e0fbcfeb-3617-43c4-8dd0-7b7d38e13047", value = "") + @JsonProperty("traceId") + @Valid + public String getTraceId() { + return traceId; + } + public void setTraceId(String traceId) { + this.traceId = traceId; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Error error = (Error) o; + return Objects.equals(this.code, error.code) && + Objects.equals(this.message, error.message) && + Objects.equals(this.description, error.description) && + Objects.equals(this.traceId, error.traceId); + } + + @Override + public int hashCode() { + return Objects.hash(code, message, description, traceId); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class Error {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" traceId: ").append(toIndentedString(traceId)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/PaginationLink.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/PaginationLink.java new file mode 100644 index 0000000000..3403c2f707 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/PaginationLink.java @@ -0,0 +1,119 @@ +/* + * 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.api.resource.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class PaginationLink { + + private String rel; + private String href; + + /** + **/ + public PaginationLink rel(String rel) { + + this.rel = rel; + return this; + } + + @ApiModelProperty(example = "before", value = "") + @JsonProperty("rel") + @Valid + public String getRel() { + return rel; + } + public void setRel(String rel) { + this.rel = rel; + } + + /** + **/ + public PaginationLink href(String href) { + + this.href = href; + return this; + } + + @ApiModelProperty(example = "/o/orgName/api-resources?after=NDoy", value = "") + @JsonProperty("href") + @Valid + public String getHref() { + return href; + } + public void setHref(String href) { + this.href = href; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PaginationLink paginationLink = (PaginationLink) o; + return Objects.equals(this.rel, paginationLink.rel) && + Objects.equals(this.href, paginationLink.href); + } + + @Override + public int hashCode() { + return Objects.hash(rel, href); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class PaginationLink {\n"); + + sb.append(" rel: ").append(toIndentedString(rel)).append("\n"); + sb.append(" href: ").append(toIndentedString(href)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ScopeCreationModel.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ScopeCreationModel.java new file mode 100644 index 0000000000..d269682d48 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ScopeCreationModel.java @@ -0,0 +1,142 @@ +/* + * 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.api.resource.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class ScopeCreationModel { + + private String name; + private String displayName; + private String description; + + /** + **/ + public ScopeCreationModel name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "greetings:write", required = true, value = "") + @JsonProperty("name") + @Valid + @NotNull(message = "Property name cannot be null.") + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + public ScopeCreationModel displayName(String displayName) { + + this.displayName = displayName; + return this; + } + + @ApiModelProperty(example = "Write Greetings", value = "") + @JsonProperty("displayName") + @Valid + public String getDisplayName() { + return displayName; + } + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + /** + **/ + public ScopeCreationModel description(String description) { + + this.description = description; + return this; + } + + @ApiModelProperty(example = "Allows writing greetings", value = "") + @JsonProperty("description") + @Valid + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ScopeCreationModel scopeCreationModel = (ScopeCreationModel) o; + return Objects.equals(this.name, scopeCreationModel.name) && + Objects.equals(this.displayName, scopeCreationModel.displayName) && + Objects.equals(this.description, scopeCreationModel.description); + } + + @Override + public int hashCode() { + return Objects.hash(name, displayName, description); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class ScopeCreationModel {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ScopeGetModel.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ScopeGetModel.java new file mode 100644 index 0000000000..b357201c91 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ScopeGetModel.java @@ -0,0 +1,167 @@ +/* + * 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.api.resource.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class ScopeGetModel { + + private String id; + private String displayName; + private String name; + private String description; + + /** + **/ + public ScopeGetModel id(String id) { + + this.id = id; + return this; + } + + @ApiModelProperty(example = "sf23-fg34-fy53-hj23", required = true, value = "") + @JsonProperty("id") + @Valid + @NotNull(message = "Property id cannot be null.") + + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + + /** + **/ + public ScopeGetModel displayName(String displayName) { + + this.displayName = displayName; + return this; + } + + @ApiModelProperty(example = "Write", required = true, value = "") + @JsonProperty("displayName") + @Valid + @NotNull(message = "Property displayName cannot be null.") + + public String getDisplayName() { + return displayName; + } + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + /** + **/ + public ScopeGetModel name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "greetings:write", required = true, value = "") + @JsonProperty("name") + @Valid + @NotNull(message = "Property name cannot be null.") + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + public ScopeGetModel description(String description) { + + this.description = description; + return this; + } + + @ApiModelProperty(example = "Allow writing greetings", value = "") + @JsonProperty("description") + @Valid + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ScopeGetModel scopeGetModel = (ScopeGetModel) o; + return Objects.equals(this.id, scopeGetModel.id) && + Objects.equals(this.displayName, scopeGetModel.displayName) && + Objects.equals(this.name, scopeGetModel.name) && + Objects.equals(this.description, scopeGetModel.description); + } + + @Override + public int hashCode() { + return Objects.hash(id, displayName, name, description); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class ScopeGetModel {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ScopesApi.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ScopesApi.java new file mode 100644 index 0000000000..e44caef832 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ScopesApi.java @@ -0,0 +1,69 @@ +/* + * 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.api.resource.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.api.resource.v1.Error; +import org.wso2.carbon.identity.api.server.api.resource.v1.ScopeGetModel; +import org.wso2.carbon.identity.api.server.api.resource.v1.ScopesApiService; + +import javax.validation.Valid; +import javax.ws.rs.*; +import javax.ws.rs.core.Response; +import io.swagger.annotations.*; + +import javax.validation.constraints.*; + +@Path("/scopes") +@Api(description = "The scopes API") + +public class ScopesApi { + + @Autowired + private ScopesApiService delegate; + + @Valid + @GET + + + @Produces({ "application/json" }) + @ApiOperation(value = "Get all scopes in the tenant", notes = "Get all scopes in the tenant", response = ScopeGetModel.class, responseContainer = "List", authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "API Resource Scopes" }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK", response = ScopeGetModel.class, responseContainer = "List"), + @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden", response = Void.class), + @ApiResponse(code = 404, message = "Not Found", response = Error.class), + @ApiResponse(code = 500, message = "Server Error", response = Error.class) + }) + public Response scopesGet( @Valid@ApiParam(value = "Condition to filter the retrieval of records. Supports 'sw', 'co', 'ew' and 'eq' operations. ") @QueryParam("filter") String filter) { + + return delegate.scopesGet(filter ); + } + +} diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ScopesApiService.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ScopesApiService.java new file mode 100644 index 0000000000..3880555282 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/ScopesApiService.java @@ -0,0 +1,35 @@ +/* + * 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.api.resource.v1; + +import org.wso2.carbon.identity.api.server.api.resource.v1.*; +import org.wso2.carbon.identity.api.server.api.resource.v1.*; +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.api.resource.v1.Error; +import org.wso2.carbon.identity.api.server.api.resource.v1.ScopeGetModel; +import javax.ws.rs.core.Response; + + +public interface ScopesApiService { + + public Response scopesGet(String filter); +} diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/SubscribedApplicationGetModel.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/SubscribedApplicationGetModel.java new file mode 100644 index 0000000000..7705c673ad --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/SubscribedApplicationGetModel.java @@ -0,0 +1,119 @@ +/* + * 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.api.resource.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class SubscribedApplicationGetModel { + + private String name; + private String id; + + /** + **/ + public SubscribedApplicationGetModel name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "Application1", value = "") + @JsonProperty("name") + @Valid + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + public SubscribedApplicationGetModel id(String id) { + + this.id = id; + return this; + } + + @ApiModelProperty(example = "23fd-23gd-54vv-sdhf", value = "") + @JsonProperty("id") + @Valid + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SubscribedApplicationGetModel subscribedApplicationGetModel = (SubscribedApplicationGetModel) o; + return Objects.equals(this.name, subscribedApplicationGetModel.name) && + Objects.equals(this.id, subscribedApplicationGetModel.id); + } + + @Override + public int hashCode() { + return Objects.hash(name, id); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class SubscribedApplicationGetModel {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/factories/ApiResourcesApiServiceFactory.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/factories/ApiResourcesApiServiceFactory.java new file mode 100644 index 0000000000..1d89750b24 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/factories/ApiResourcesApiServiceFactory.java @@ -0,0 +1,32 @@ +/* + * 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.api.resource.v1.factories; + +import org.wso2.carbon.identity.api.server.api.resource.v1.ApiResourcesApiService; +import org.wso2.carbon.identity.api.server.api.resource.v1.impl.ApiResourcesApiServiceImpl; + +public class ApiResourcesApiServiceFactory { + + private final static ApiResourcesApiService service = new ApiResourcesApiServiceImpl(); + + public static ApiResourcesApiService getApiResourcesApi() + { + return service; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/factories/ScopesApiServiceFactory.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/factories/ScopesApiServiceFactory.java new file mode 100644 index 0000000000..cb91296d06 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/gen/java/org/wso2/carbon/identity/api/server/api/resource/v1/factories/ScopesApiServiceFactory.java @@ -0,0 +1,32 @@ +/* + * 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.api.resource.v1.factories; + +import org.wso2.carbon.identity.api.server.api.resource.v1.ScopesApiService; +import org.wso2.carbon.identity.api.server.api.resource.v1.impl.ScopesApiServiceImpl; + +public class ScopesApiServiceFactory { + + private final static ScopesApiService service = new ScopesApiServiceImpl(); + + public static ScopesApiService getScopesApi() + { + return service; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/constants/APIResourceMgtEndpointConstants.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/constants/APIResourceMgtEndpointConstants.java new file mode 100644 index 0000000000..6e212893ae --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/constants/APIResourceMgtEndpointConstants.java @@ -0,0 +1,122 @@ +/* + * 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.api.resource.v1.constants; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * Constants related to API resource management. + */ +public class APIResourceMgtEndpointConstants { + + private APIResourceMgtEndpointConstants() { + } + + public static final String API_RESOURCE_TYPE = "BUSINESS"; + public static final String API_RESOURCE_MANAGEMENT_PREFIX = "API-RESOURCE-"; + public static final String API_RESOURCE_PATH_COMPONENT = "/api-resources"; + private static final List allowedAttributeList = new ArrayList<>(); + public static final List ALLOWED_SEARCH_ATTRIBUTES = Collections.unmodifiableList(allowedAttributeList); + public static final String RESTRICTED_OAUTH2_SCOPES = "OAuth.RestrictedScopes.RestrictedScope"; + public static final Integer DEFAULT_LIMIT = 10; + public static final String ASC_SORT_ORDER = "ASC"; + public static final String DESC_SORT_ORDER = "DESC"; + + static { + allowedAttributeList.add("description"); + allowedAttributeList.add("type"); + allowedAttributeList.add("requires_authorization"); + allowedAttributeList.add("scopes"); + } + + /** + * Enum for error messages. + */ + public enum ErrorMessage { + + // Client errors. + ERROR_CODE_API_RESOURCE_LIMIT_REACHED("60001", + "Unable to create an API resource.", + "Maximum number of allowed API resources have been reached."), + ERROR_CODE_API_RESOURCE_NOT_FOUND("60002", + "Unable to find the API resource.", + "Unable to find the API resource with the id: %s in the tenant domain."), + ERROR_CODE_INVALID_API_RESOURCE_NAME("60003", + "Invalid API resource name provided.", "API resource name is required."), + ERROR_CODE_INVALID_API_RESOURCE_IDENTIFIER("60004", + "Invalid API resource identifier provided.", "API resource identifier is required."), + ERROR_CODE_INVALID_SCOPE_NAME("60005", + "Invalid scope name provided.", "Scope name is required."), + ERROR_CODE_REMOVED_SCOPES_PATCH_NOT_SUPPORTED("60006", + "Removed scopes patching is not supported yet.", + "Removed scopes patching is not supported yet for API resources."), + ERROR_CODE_INVALID_SEARCH_ATTRIBUTE("60007", + "Invalid search attribute.", + "Invalid search attribute: %s."), + ERROR_CODE_RESTRICTED_SCOPE_NAME("60008", + "Restricted scope name provided.", "Scope name is restricted."), + ERROR_CODE_RESTRICTED_OIDC_SCOPES("60009", "Existing OIDC scope name provided.", + "Provided scopes name is already exists in the system as an OIDC scope."), + ERROR_CODE_INVALID_LIMIT("60010", "Invalid limit provided.", + "Limit should be a positive integer."), + ERROR_CODE_BOTH_BEFORE_AFTER_PROVIDED("60011", "Invalid before/after provided.", + "Both before and after parameters cannot be provided at the same time."), + + // Server errors. + ERROR_CODE_ADD_API_RESOURCE("65001", "Error while adding api resource.", "Server encountered an error while " + + "adding the api resource."), + + ERROR_CODE_VALIDATE_SCOPES("65002", "Error while validating scopes.", "Server encountered an error while " + + "validating the scopes."), + ; + 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 API_RESOURCE_MANAGEMENT_PREFIX + code; + } + + public String getMessage() { + + return message; + } + + public String getDescription() { + + return description; + } + + @Override + public String toString() { + + return code + " | " + message; + } + } +} diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/core/ServerAPIResourceManagementService.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/core/ServerAPIResourceManagementService.java new file mode 100644 index 0000000000..68652684dc --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/core/ServerAPIResourceManagementService.java @@ -0,0 +1,457 @@ +/* + * 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.api.resource.v1.core; + +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.CarbonContext; +import org.wso2.carbon.identity.api.resource.mgt.APIResourceMgtException; +import org.wso2.carbon.identity.api.resource.mgt.model.APIResourceSearchResult; +import org.wso2.carbon.identity.api.server.api.resource.common.APIResourceManagementServiceHolder; +import org.wso2.carbon.identity.api.server.api.resource.v1.APIResourceCreationModel; +import org.wso2.carbon.identity.api.server.api.resource.v1.APIResourceListItem; +import org.wso2.carbon.identity.api.server.api.resource.v1.APIResourceListResponse; +import org.wso2.carbon.identity.api.server.api.resource.v1.APIResourcePatchModel; +import org.wso2.carbon.identity.api.server.api.resource.v1.APIResourceResponse; +import org.wso2.carbon.identity.api.server.api.resource.v1.PaginationLink; +import org.wso2.carbon.identity.api.server.api.resource.v1.ScopeCreationModel; +import org.wso2.carbon.identity.api.server.api.resource.v1.ScopeGetModel; +import org.wso2.carbon.identity.api.server.api.resource.v1.constants.APIResourceMgtEndpointConstants; +import org.wso2.carbon.identity.api.server.api.resource.v1.constants.APIResourceMgtEndpointConstants.ErrorMessage; +import org.wso2.carbon.identity.api.server.api.resource.v1.util.APIResourceMgtEndpointUtil; +import org.wso2.carbon.identity.api.server.common.ContextLoader; +import org.wso2.carbon.identity.api.server.common.error.APIError; +import org.wso2.carbon.identity.application.common.model.APIResource; +import org.wso2.carbon.identity.application.common.model.Scope; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Base64; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +import javax.ws.rs.core.Response; + +import static org.wso2.carbon.identity.api.server.api.resource.v1.constants.APIResourceMgtEndpointConstants.ASC_SORT_ORDER; +import static org.wso2.carbon.identity.api.server.api.resource.v1.constants.APIResourceMgtEndpointConstants.DEFAULT_LIMIT; +import static org.wso2.carbon.identity.api.server.api.resource.v1.constants.APIResourceMgtEndpointConstants.DESC_SORT_ORDER; +import static org.wso2.carbon.identity.api.server.common.Constants.V1_API_PATH_COMPONENT; + +/** + * Server API Resource Management Service. + */ +public class ServerAPIResourceManagementService { + + private static final Log LOG = LogFactory.getLog(ServerAPIResourceManagementService.class); + + /** + * Add API resource. + * + * @param apIResourceCreationModel API resource creation model. + * @return Response. + */ + public APIResourceResponse addAPIResourceWithResourceId(APIResourceCreationModel apIResourceCreationModel) { + + if (LOG.isDebugEnabled()) { + LOG.debug("Adding API resource with resource id: " + apIResourceCreationModel.getIdentifier()); + } + try { + APIResource apiResource = createAPIResource(apIResourceCreationModel); + APIResource createdAPIResource = APIResourceManagementServiceHolder.getApiResourceManager() + .addAPIResource(apiResource, CarbonContext.getThreadLocalCarbonContext().getTenantDomain()); + if (createdAPIResource == null) { + LOG.error(ErrorMessage.ERROR_CODE_ADD_API_RESOURCE.getDescription()); + throw APIResourceMgtEndpointUtil.handleException(Response.Status.INTERNAL_SERVER_ERROR, + ErrorMessage.ERROR_CODE_ADD_API_RESOURCE); + } + return buildAPIResourceResponse(createdAPIResource); + } catch (APIResourceMgtException e) { + throw APIResourceMgtEndpointUtil.handleAPIResourceMgtException(e); + } + } + + /** + * Get API Resources. + * + * @param before before parameter for cursor based pagination. + * @param after after parameter for cursor based pagination. + * @param filter filter parameter. + * @return Response with API Resources list. + */ + public APIResourceListResponse getAPIResources(String before, String after, String filter, Integer limit) { + + APIResourceListResponse apiResourceListResponse = new APIResourceListResponse(); + + try { + // Set default values if the parameters are not set. + limit = validatedLimit(limit); + + // Validate before and after parameters. + if (StringUtils.isNotBlank(before) && StringUtils.isNotBlank(after)) { + throw APIResourceMgtEndpointUtil.handleException(Response.Status.BAD_REQUEST, + APIResourceMgtEndpointConstants.ErrorMessage.ERROR_CODE_BOTH_BEFORE_AFTER_PROVIDED); + } + + // Set the pagination sort order. + String paginationSortOrder = StringUtils.isNotBlank(before) ? DESC_SORT_ORDER : ASC_SORT_ORDER; + + APIResourceSearchResult apiResourceSearchResult = APIResourceManagementServiceHolder.getApiResourceManager() + .getAPIResources(before, after, limit + 1, filter, paginationSortOrder, + CarbonContext.getThreadLocalCarbonContext().getTenantDomain()); + List apiResources = apiResourceSearchResult.getAPIResources(); + + if (CollectionUtils.isNotEmpty(apiResources)) { + boolean hasMoreItems = apiResources.size() > limit; + boolean needsReverse = StringUtils.isNotBlank(before); + boolean isFirstPage = (StringUtils.isBlank(before) && StringUtils.isBlank(after)) || + (StringUtils.isNotBlank(before) && !hasMoreItems); + boolean isLastPage = !hasMoreItems && (StringUtils.isNotBlank(after) || StringUtils.isBlank(before)); + + String url = "?limit=" + limit; + + if (StringUtils.isNotBlank(filter)) { + try { + url += "&filter=" + URLEncoder.encode(filter, StandardCharsets.UTF_8.name()); + } catch (UnsupportedEncodingException e) { + LOG.error("Server encountered an error while building pagination URL for the response.", e); + } + } + + if (hasMoreItems) { + apiResources.remove(apiResources.size() - 1); + } + if (needsReverse) { + Collections.reverse(apiResources); + } + if (!isFirstPage) { + String encodedString = Base64.getEncoder().encodeToString(apiResources.get(0).getCursorKey() + .toString().getBytes(StandardCharsets.UTF_8)); + apiResourceListResponse.addLinksItem(buildPaginationLink(url + "&before=" + encodedString, + "previous")); + } + if (!isLastPage) { + String encodedString = Base64.getEncoder().encodeToString(apiResources.get(apiResources.size() - 1) + .getCursorKey().toString().getBytes(StandardCharsets.UTF_8)); + apiResourceListResponse.addLinksItem(buildPaginationLink(url + "&after=" + encodedString, "next")); + } + } + if (apiResources == null || apiResources.isEmpty()) { + apiResourceListResponse.setTotalResults(0); + apiResourceListResponse.setApiResources(new ArrayList<>()); + return apiResourceListResponse; + } + apiResourceListResponse.setTotalResults(apiResourceSearchResult.getTotalCount()); + apiResourceListResponse.setApiResources(apiResourceSearchResult.getAPIResources().stream() + .map(this::buildAPIResourceListItem).collect(Collectors.toList())); + } catch (APIResourceMgtException e) { + throw APIResourceMgtEndpointUtil.handleAPIResourceMgtException(e); + } + return apiResourceListResponse; + } + + /** + * Get API Resource by ID. + * + * @param apiResourceID API Resource ID. + * @return API Resource. + */ + public APIResource getAPIResourceById(String apiResourceID) { + + try { + APIResource apiResource = APIResourceManagementServiceHolder.getApiResourceManager() + .getAPIResourceById(apiResourceID, CarbonContext.getThreadLocalCarbonContext().getTenantDomain()); + if (apiResource == null) { + throw APIResourceMgtEndpointUtil.handleException(Response.Status.NOT_FOUND, + APIResourceMgtEndpointConstants.ErrorMessage.ERROR_CODE_API_RESOURCE_NOT_FOUND, apiResourceID); + } + return apiResource; + } catch (APIResourceMgtException e) { + throw APIResourceMgtEndpointUtil.handleAPIResourceMgtException(e); + } + } + + /** + * Patch API Resource by ID. + * + * @param apiResourceID API Resource ID. + * @param apiResourcePatchModel API Resource Patch Model. + */ + public void patchAPIResourceById(String apiResourceID, APIResourcePatchModel apiResourcePatchModel) { + + try { + APIResource currentAPIResource = getAPIResourceById(apiResourceID); + + if (apiResourcePatchModel.getRemovedScopes() != null) { + LOG.debug("Removed scopes field is not supported in patch operation."); + throw APIResourceMgtEndpointUtil.handleException(Response.Status.NOT_IMPLEMENTED, + APIResourceMgtEndpointConstants.ErrorMessage.ERROR_CODE_REMOVED_SCOPES_PATCH_NOT_SUPPORTED); + } + + String displayName = apiResourcePatchModel.getName() == null ? currentAPIResource.getName() : + apiResourcePatchModel.getName(); + String description = apiResourcePatchModel.getDescription() == null ? currentAPIResource.getDescription() : + apiResourcePatchModel.getDescription(); + List addedScopes = createScopes(apiResourcePatchModel.getAddedScopes()); + // Creating an empty list of removed scope names since operation is not supported. + List removedScopeNames = new ArrayList<>(); + + APIResource.APIResourceBuilder apiResourceBuilder = new APIResource.APIResourceBuilder() + .name(displayName) + .id(apiResourceID) + .description(description); + APIResource apiResource = apiResourceBuilder.build(); + APIResourceManagementServiceHolder.getApiResourceManager().updateAPIResource(apiResource, addedScopes, + removedScopeNames, CarbonContext.getThreadLocalCarbonContext().getTenantDomain()); + } catch (APIResourceMgtException e) { + throw APIResourceMgtEndpointUtil.handleAPIResourceMgtException(e); + } + } + + /** + * Delete API Resource by ID. + * + * @param apiResourceID API Resource ID. + */ + public void deleteAPIResource(String apiResourceID) { + + try { + if (LOG.isDebugEnabled()) { + LOG.debug("Deleting API Resource with ID: " + apiResourceID); + } + APIResourceManagementServiceHolder.getApiResourceManager().deleteAPIResourceById(apiResourceID, + CarbonContext.getThreadLocalCarbonContext().getTenantDomain()); + } catch (APIResourceMgtException e) { + throw APIResourceMgtEndpointUtil.handleAPIResourceMgtException(e); + } + } + + /** + * Get scopes by API ID. + * + * @param apiResourceId API resource id. + * @return List of scopes. + */ + public List getScopesByAPIId(String apiResourceId) { + + try { + APIResource apiResource = APIResourceManagementServiceHolder.getApiResourceManager() + .getAPIResourceById(apiResourceId, CarbonContext.getThreadLocalCarbonContext().getTenantDomain()); + if (apiResource == null) { + throw APIResourceMgtEndpointUtil.handleException(Response.Status.NOT_FOUND, + APIResourceMgtEndpointConstants.ErrorMessage.ERROR_CODE_API_RESOURCE_NOT_FOUND, apiResourceId); + } + return apiResource.getScopes(); + } catch (APIResourceMgtException e) { + throw APIResourceMgtEndpointUtil.handleAPIResourceMgtException(e); + } + } + + /** + * Put scopes by API ID. This replaces existing scopes. + * + * @param apiResourceId API resource id. + * @param scopeCreationModels Scope creation models. + */ + public void putScopesByAPIId(String apiResourceId, List scopeCreationModels) { + + try { + APIResource apiResource = APIResourceManagementServiceHolder.getApiResourceManager() + .getAPIResourceById(apiResourceId, CarbonContext.getThreadLocalCarbonContext().getTenantDomain()); + if (apiResource == null) { + throw APIResourceMgtEndpointUtil.handleException(Response.Status.NOT_FOUND, + APIResourceMgtEndpointConstants.ErrorMessage.ERROR_CODE_API_RESOURCE_NOT_FOUND, apiResourceId); + } + List scopes = createScopes(scopeCreationModels); + APIResourceManagementServiceHolder.getApiResourceManager().putScopes(apiResourceId, apiResource.getScopes(), + scopes, CarbonContext.getThreadLocalCarbonContext().getTenantDomain()); + } catch (APIResourceMgtException e) { + throw APIResourceMgtEndpointUtil.handleAPIResourceMgtException(e); + } + } + + /** + * Delete scopes by the scope ID. + * + * @param apiResourceId API Resource ID. + * @param scopeName Scope Name. + */ + public void deleteScopeByScopeName(String apiResourceId, String scopeName) { + + try { + if (LOG.isDebugEnabled()) { + LOG.debug("Deleting scope with ID: " + scopeName + " of API Resource ID: " + apiResourceId); + } + APIResourceManagementServiceHolder.getApiResourceManager() + .deleteAPIScopeByScopeName(apiResourceId, scopeName, + CarbonContext.getThreadLocalCarbonContext().getTenantDomain()); + } catch (APIResourceMgtException e) { + throw APIResourceMgtEndpointUtil.handleAPIResourceMgtException(e); + } + } + + /** + * Search Scopes registered in the tenant. + * + * @param filter Filter query. + * @return List of scopes. + */ + public List getScopesByTenant(String filter) { + + try { + return APIResourceManagementServiceHolder.getApiResourceManager() + .getScopesByTenantDomain(CarbonContext.getThreadLocalCarbonContext().getTenantDomain(), filter); + } catch (APIResourceMgtException e) { + throw APIResourceMgtEndpointUtil.handleAPIResourceMgtException(e); + } + } + + /** + * Build APIResourceResponse from APIResource. + * + * @param apiResource APIResource object. + * @return APIResourceResponse object. + */ + private APIResourceResponse buildAPIResourceResponse(APIResource apiResource) { + + return new APIResourceResponse() + .id(apiResource.getId()) + .name(apiResource.getName()) + .identifier(apiResource.getIdentifier()) + .description(apiResource.getDescription()) + .scopes(apiResource.getScopes().stream().map(this::buildScopeGetResponse) + .collect(Collectors.toList())) + .requiresAuthorization(apiResource.isRequiresAuthorization()); + } + + /** + * Build ScopeGetModel from Scope. + * + * @param scope Scope object. + * @return ScopeGetModel object. + */ + private ScopeGetModel buildScopeGetResponse(Scope scope) { + + return new ScopeGetModel() + .id(scope.getId()) + .name(scope.getName()) + .displayName(scope.getDisplayName()) + .description(scope.getDescription()); + } + + /** + * Create API resource from the API resource creation model. + * + * @param apIResourceCreationModel API resource creation model. + * @return API resource. + */ + private APIResource createAPIResource(APIResourceCreationModel apIResourceCreationModel) + throws APIResourceMgtException { + + APIResourceMgtEndpointUtil.validateAPIResource(apIResourceCreationModel); + APIResource.APIResourceBuilder apiResourceBuilder = new APIResource.APIResourceBuilder() + .name(apIResourceCreationModel.getName()) + .identifier(apIResourceCreationModel.getIdentifier()) + .description(apIResourceCreationModel.getDescription()) + .scopes(createScopes(apIResourceCreationModel.getScopes())) + .requiresAuthorization(apIResourceCreationModel.getRequiresAuthorization() != null ? + apIResourceCreationModel.getRequiresAuthorization() : true) + .type(APIResourceMgtEndpointConstants.API_RESOURCE_TYPE); + return apiResourceBuilder.build(); + } + + /** + * Create scopes from the scope creation models. + * + * @param scopeCreationModels Scope creation models. + * @return List of scopes. + */ + private List createScopes(List scopeCreationModels) + throws APIResourceMgtException { + + APIResourceMgtEndpointUtil.validateScopes(scopeCreationModels); + List scopes = new ArrayList<>(); + if (scopeCreationModels == null) { + return scopes; + } + for (ScopeCreationModel scopeCreationModel : scopeCreationModels) { + Scope.ScopeBuilder scopeBuilder = new Scope.ScopeBuilder() + .name(scopeCreationModel.getName()) + .displayName(scopeCreationModel.getDisplayName() != null ? scopeCreationModel.getDisplayName() : + scopeCreationModel.getName()) + .description(scopeCreationModel.getDescription()); + scopes.add(scopeBuilder.build()); + } + return scopes; + } + + /** + * Build API Resource List Item from API Resource. + * + * @param apiResource API Resource. + * @return API Resource List Item. + */ + private APIResourceListItem buildAPIResourceListItem(APIResource apiResource) { + + return new APIResourceListItem() + .id(apiResource.getId()) + .name(apiResource.getName()) + .identifier(apiResource.getIdentifier()) + .type(apiResource.getType()) + .requiresAuthorization(apiResource.isRequiresAuthorization()) + .self(V1_API_PATH_COMPONENT + APIResourceMgtEndpointConstants.API_RESOURCE_PATH_COMPONENT + "/" + + apiResource.getId()); + } + + /** + * Build Pagination Link. + * + * @param url URL + * @param rel Rel + * @return Pagination Link + */ + private PaginationLink buildPaginationLink(String url, String rel) { + + return new PaginationLink() + .href(ContextLoader.buildURIForHeader(V1_API_PATH_COMPONENT + + APIResourceMgtEndpointConstants.API_RESOURCE_PATH_COMPONENT + url).toString()) + .rel(rel); + } + + /** + * Validate limit parameter. + * + * @param limit Limit parameter. + * @return Validated limit. + * @throws APIError if the limit is invalid. + */ + private static Integer validatedLimit(Integer limit) throws APIError { + + limit = limit == null ? DEFAULT_LIMIT : limit; + if (limit <= 0) { + throw APIResourceMgtEndpointUtil.handleException(Response.Status.BAD_REQUEST, + ErrorMessage.ERROR_CODE_INVALID_LIMIT); + } + return limit; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/impl/ApiResourcesApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/impl/ApiResourcesApiServiceImpl.java new file mode 100644 index 0000000000..8a32305721 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/impl/ApiResourcesApiServiceImpl.java @@ -0,0 +1,103 @@ +/* + * 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.api.resource.v1.impl; + +import org.springframework.beans.factory.annotation.Autowired; +import org.wso2.carbon.identity.api.server.api.resource.v1.APIResourceCreationModel; +import org.wso2.carbon.identity.api.server.api.resource.v1.APIResourcePatchModel; +import org.wso2.carbon.identity.api.server.api.resource.v1.APIResourceResponse; +import org.wso2.carbon.identity.api.server.api.resource.v1.ApiResourcesApiService; +import org.wso2.carbon.identity.api.server.api.resource.v1.ScopeCreationModel; +import org.wso2.carbon.identity.api.server.api.resource.v1.constants.APIResourceMgtEndpointConstants; +import org.wso2.carbon.identity.api.server.api.resource.v1.core.ServerAPIResourceManagementService; +import org.wso2.carbon.identity.api.server.common.ContextLoader; + +import java.net.URI; +import java.util.List; + +import javax.ws.rs.core.Response; + +import static org.wso2.carbon.identity.api.server.common.Constants.V1_API_PATH_COMPONENT; + +/** + * Implementation of the Api resources REST Api. + */ +public class ApiResourcesApiServiceImpl implements ApiResourcesApiService { + + @Autowired + ServerAPIResourceManagementService serverAPIResourceManagementService; + + @Override + public Response addAPIResource(APIResourceCreationModel apIResourceCreationModel) { + + APIResourceResponse apiResourceResponse = + serverAPIResourceManagementService.addAPIResourceWithResourceId(apIResourceCreationModel); + URI location = ContextLoader.buildURIForHeader(V1_API_PATH_COMPONENT + + APIResourceMgtEndpointConstants.API_RESOURCE_PATH_COMPONENT + "/" + apiResourceResponse.getId()); + return Response.created(location).entity(apiResourceResponse).build(); + } + + @Override + public Response apiResourcesApiResourceIdDelete(String apiResourceId) { + + serverAPIResourceManagementService.deleteAPIResource(apiResourceId); + return Response.noContent().build(); + } + + @Override + public Response apiResourcesApiResourceIdGet(String apiResourceId) { + + return Response.ok().entity(serverAPIResourceManagementService.getAPIResourceById(apiResourceId)).build(); + } + + @Override + public Response apiResourcesApiResourceIdPatch(String apiResourceId, APIResourcePatchModel apIResourcePatchModel) { + + serverAPIResourceManagementService.patchAPIResourceById(apiResourceId, apIResourcePatchModel); + return Response.noContent().build(); + } + + @Override + public Response apiResourcesApiResourceIdScopesGet(String apiResourceId) { + + return Response.ok().entity(serverAPIResourceManagementService.getScopesByAPIId(apiResourceId)).build(); + } + + @Override + public Response apiResourcesApiResourceIdScopesPut(String apiResourceId, + List scopeCreationModel) { + + serverAPIResourceManagementService.putScopesByAPIId(apiResourceId, scopeCreationModel); + return Response.noContent().build(); + } + + @Override + public Response apiResourcesApiResourceIdScopesScopeNameDelete(String apiResourceId, String scopeName) { + + serverAPIResourceManagementService.deleteScopeByScopeName(apiResourceId, scopeName); + return Response.noContent().build(); + } + + @Override + public Response getAPIResources(String before, String after, String filter, Integer limit, String sortOrder) { + + return Response.ok().entity(serverAPIResourceManagementService.getAPIResources(before, after, filter, limit)) + .build(); + } +} diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/impl/ScopesApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/impl/ScopesApiServiceImpl.java new file mode 100644 index 0000000000..808d70d219 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/impl/ScopesApiServiceImpl.java @@ -0,0 +1,40 @@ +/* + * 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.api.resource.v1.impl; + +import org.springframework.beans.factory.annotation.Autowired; +import org.wso2.carbon.identity.api.server.api.resource.v1.ScopesApiService; +import org.wso2.carbon.identity.api.server.api.resource.v1.core.ServerAPIResourceManagementService; + +import javax.ws.rs.core.Response; + +/** + * Implementation of scopes API. + */ +public class ScopesApiServiceImpl implements ScopesApiService { + + @Autowired + ServerAPIResourceManagementService serverAPIResourceManagementService; + + @Override + public Response scopesGet(String filter) { + + return Response.ok().entity(serverAPIResourceManagementService.getScopesByTenant(filter)).build(); + } +} diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/util/APIResourceMgtEndpointUtil.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/util/APIResourceMgtEndpointUtil.java new file mode 100644 index 0000000000..e039b5b17c --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/util/APIResourceMgtEndpointUtil.java @@ -0,0 +1,185 @@ +/* + * 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.api.resource.v1.util; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.identity.api.resource.mgt.APIResourceMgtClientException; +import org.wso2.carbon.identity.api.resource.mgt.APIResourceMgtException; +import org.wso2.carbon.identity.api.server.api.resource.common.APIResourceManagementServiceHolder; +import org.wso2.carbon.identity.api.server.api.resource.v1.APIResourceCreationModel; +import org.wso2.carbon.identity.api.server.api.resource.v1.ScopeCreationModel; +import org.wso2.carbon.identity.api.server.api.resource.v1.constants.APIResourceMgtEndpointConstants; +import org.wso2.carbon.identity.api.server.common.ContextLoader; +import org.wso2.carbon.identity.api.server.common.error.APIError; +import org.wso2.carbon.identity.api.server.common.error.ErrorDTO; +import org.wso2.carbon.identity.core.util.IdentityUtil; +import org.wso2.carbon.identity.oauth.IdentityOAuthAdminException; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + +import javax.ws.rs.core.Response; + +import static org.wso2.carbon.identity.api.resource.mgt.constant.APIResourceManagementConstants.ErrorMessages.ERROR_CODE_API_RESOURCE_ALREADY_EXISTS; +import static org.wso2.carbon.identity.api.resource.mgt.constant.APIResourceManagementConstants.ErrorMessages.ERROR_CODE_SCOPE_ALREADY_EXISTS; +import static org.wso2.carbon.identity.api.server.api.resource.v1.constants.APIResourceMgtEndpointConstants.ErrorMessage.ERROR_CODE_INVALID_API_RESOURCE_IDENTIFIER; +import static org.wso2.carbon.identity.api.server.api.resource.v1.constants.APIResourceMgtEndpointConstants.ErrorMessage.ERROR_CODE_INVALID_API_RESOURCE_NAME; +import static org.wso2.carbon.identity.api.server.api.resource.v1.constants.APIResourceMgtEndpointConstants.ErrorMessage.ERROR_CODE_INVALID_SCOPE_NAME; +import static org.wso2.carbon.identity.api.server.api.resource.v1.constants.APIResourceMgtEndpointConstants.ErrorMessage.ERROR_CODE_INVALID_SEARCH_ATTRIBUTE; +import static org.wso2.carbon.identity.api.server.api.resource.v1.constants.APIResourceMgtEndpointConstants.ErrorMessage.ERROR_CODE_RESTRICTED_OIDC_SCOPES; +import static org.wso2.carbon.identity.api.server.api.resource.v1.constants.APIResourceMgtEndpointConstants.ErrorMessage.ERROR_CODE_RESTRICTED_SCOPE_NAME; +import static org.wso2.carbon.identity.api.server.api.resource.v1.constants.APIResourceMgtEndpointConstants.ErrorMessage.ERROR_CODE_VALIDATE_SCOPES; +import static org.wso2.carbon.identity.api.server.common.Constants.ERROR_CODE_DELIMITER; + +/** + * Utility class for API resource management endpoint. + */ +public class APIResourceMgtEndpointUtil { + + private static final Log LOG = LogFactory.getLog(APIResourceMgtEndpointUtil.class); + + public static void validateAPIResource(APIResourceCreationModel apiResource) { + + if (StringUtils.isBlank(apiResource.getName())) { + throw handleException(Response.Status.BAD_REQUEST, ERROR_CODE_INVALID_API_RESOURCE_NAME); + } + if (StringUtils.isBlank(apiResource.getIdentifier())) { + throw handleException(Response.Status.BAD_REQUEST, ERROR_CODE_INVALID_API_RESOURCE_IDENTIFIER); + } + } + + public static void validateScopes(List scopes) { + + if (scopes == null) { + return; + } + for (ScopeCreationModel scope : scopes) { + // Validate scope name. + if (StringUtils.isBlank(scope.getName())) { + throw handleException(Response.Status.BAD_REQUEST, ERROR_CODE_INVALID_SCOPE_NAME); + } + // Validate restricted scope names. + List restrictedScopes = + IdentityUtil.getPropertyAsList(APIResourceMgtEndpointConstants.RESTRICTED_OAUTH2_SCOPES); + for (String restrictedScope : restrictedScopes) { + if (scope.getName().startsWith(restrictedScope)) { + throw handleException(Response.Status.BAD_REQUEST, ERROR_CODE_RESTRICTED_SCOPE_NAME); + } + } + + // Validate OIDC scopes. + try { + List registeredOIDCScopes = APIResourceManagementServiceHolder.getOAuthAdminServiceImpl() + .getRegisteredOIDCScope(ContextLoader.getTenantDomainFromContext()); + if (registeredOIDCScopes != null) { + if (registeredOIDCScopes.contains(scope.getName())) { + throw handleException(Response.Status.BAD_REQUEST, ERROR_CODE_RESTRICTED_OIDC_SCOPES); + } + } + } catch (IdentityOAuthAdminException e) { + throw handleException(Response.Status.INTERNAL_SERVER_ERROR, ERROR_CODE_VALIDATE_SCOPES); + } + } + } + + /** + * Validate the attributes provided for search. + * + * @param attributes List of attributes to be validated. + * @return List of validated attributes. + */ + public static List validateAndConvertToLowerCase(List attributes) { + + List validatedAttributes = new ArrayList<>(); + + if (attributes == null) { + return validatedAttributes; + } + + for (String attribute : attributes) { + String lowerCaseAttribute = attribute.toLowerCase(Locale.ENGLISH); + if (!APIResourceMgtEndpointConstants.ALLOWED_SEARCH_ATTRIBUTES.contains(lowerCaseAttribute)) { + throw handleException(Response.Status.BAD_REQUEST, ERROR_CODE_INVALID_SEARCH_ATTRIBUTE); + } + validatedAttributes.add(lowerCaseAttribute); + } + return validatedAttributes; + } + + public static APIError handleException(Response.Status status, + APIResourceMgtEndpointConstants.ErrorMessage error) { + + return new APIError(status, getError(error.getCode(), error.getMessage(), + error.getDescription())); + } + + public static APIError handleException(Response.Status status, + APIResourceMgtEndpointConstants.ErrorMessage error, + String data) { + + return new APIError(status, getError(error.getCode(), error.getMessage(), + String.format(error.getDescription(), data))); + } + + public static APIError handleException(Response.Status status, String errorCode, + String message, String description) { + + return new APIError(status, getError(errorCode, message, description)); + } + + public static APIError handleAPIResourceMgtException(APIResourceMgtException e) { + + Response.Status status = Response.Status.INTERNAL_SERVER_ERROR; + if (e instanceof APIResourceMgtClientException) { + LOG.debug(e.getMessage(), e); + if (ERROR_CODE_API_RESOURCE_ALREADY_EXISTS.getCode().equals(e.getErrorCode()) || + ERROR_CODE_SCOPE_ALREADY_EXISTS.getCode().equals(e.getErrorCode())) { + status = Response.Status.CONFLICT; + } else { + status = Response.Status.BAD_REQUEST; + } + } else { + LOG.error(e.getMessage(), e); + } + String errorCode = e.getErrorCode(); + errorCode = errorCode.contains(ERROR_CODE_DELIMITER) ? errorCode : + APIResourceMgtEndpointConstants.API_RESOURCE_MANAGEMENT_PREFIX + errorCode; + return handleException(status, errorCode, e.getMessage(), e.getDescription()); + } + + /** + * Returns a generic error object. + * + * @param errorCode Error code. + * @param errorMessage Error message. + * @param errorDescription Error description. + * @return A generic error with the specified details. + */ + public static ErrorDTO getError(String errorCode, String errorMessage, String errorDescription) { + + ErrorDTO error = new ErrorDTO(); + error.setCode(errorCode); + error.setMessage(errorMessage); + error.setDescription(errorDescription); + return error; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/resources/APIResources.yaml b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/resources/APIResources.yaml new file mode 100644 index 0000000000..aae71fe967 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/resources/APIResources.yaml @@ -0,0 +1,776 @@ +openapi: 3.0.0 +info: + description: > + This document specifies an **API Resource Management RESTful API** for **WSO2 + Identity Server**. + version: "v1" + title: WSO2 Identity Server - API Resource Management Rest API + termsOfService: 'http://swagger.io/terms/' + contact: + name: WSO2 + url: 'http://wso2.com/products/identity-server/' + email: architecture@wso2.org + license: + name: Apache 2.0 + url: 'http://www.apache.org/licenses/LICENSE-2.0.html' + +security: + - OAuth2: [] + - BasicAuth: [] + +servers: + - url: 'https://{server-url}/t/{tenant-domain}/api/server/v1' + variables: + tenant-domain: + default: "carbon.super" + server-url: + default: "localhost:9443" + +paths: + /api-resources: + post: + tags: + - API Resources + operationId: addAPIResource + summary: Add a new API resource + description: > + Add a new API resource + Permission required:
+ * /permission/admin/manage/identity/apiresourcemgt/create
+ Scope required:
+ * internal_api_resource_create + responses: + 200: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/APIResourceResponse' + 400: + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 401: + description: Unauthorized + 403: + description: Forbidden + 404: + description: Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 409: + description: Conflict + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + application/xml: + schema: + $ref: '#/components/schemas/Error' + 500: + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/APIResourceCreationModel' + description: This represents the API resource to be created. + required: true + get: + tags: + - API Resources + summary: List all API resources in the server + description: > + List all API resources in the server + Permission required:
+ * /permission/admin/manage/identity/apiresourcemgt/view
+ Scope required:
+ * internal_api_resource_view + operationId: getAPIResources + parameters: + - $ref: '#/components/parameters/before' + - $ref: '#/components/parameters/after' + - $ref: '#/components/parameters/filter' + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/requiredAttributes' + responses: + 200: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/APIResourceListResponse' + 401: + description: Unauthorized + 403: + description: Forbidden + 500: + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + + /api-resources/{apiResourceId}: + get: + tags: + - API Resources + summary: Get API resource specified by the id + description: > + Get API resource specified by the id + Permission required:
+ * /permission/admin/manage/identity/apiresourcemgt/view
+ Scope required:
+ * internal_api_resource_view + parameters: + - $ref: '#/components/parameters/apiResourceId' + responses: + 200: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/APIResourceResponse' + 401: + description: Unauthorized + 403: + description: Forbidden + 500: + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + + patch: + tags: + - API Resources + summary: Patch API resource specified by the id + description: > + Patch API resource specified by the id. Patch operation only supports "name", "description" updating and "addedScopes" fields at the moment. + Permission required:
+ * /permission/admin/manage/identity/apiresourcemgt/update
+ Scope required:
+ * internal_api_resource_update + parameters: + - $ref: '#/components/parameters/apiResourceId' + responses: + 204: + description: Not Content + 400: + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 401: + description: Unauthorized + 403: + description: Forbidden + 404: + description: Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 409: + description: Conflict + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + application/xml: + schema: + $ref: '#/components/schemas/Error' + 500: + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 501: + description: Not Implemented + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/APIResourcePatchModel' + description: This represents the API resource to be patched. + required: true + delete: + tags: + - API Resources + summary: Delete API resource specified by the id + description: > + Delete API resource specified by the id + Permission required:
+ * /permission/admin/manage/identity/apiresourcemgt/delete
+ Scope required:
+ * internal_api_resource_delete + parameters: + - $ref: '#/components/parameters/apiResourceId' + responses: + 204: + description: No Content + 401: + description: Unauthorized + 403: + description: Forbidden + 500: + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + + /api-resources/{apiResourceId}/scopes: + get: + tags: + - API Resource Scopes + summary: Get API resource scopes + description: > + Get API resource scopes specified by the id + Permission required:
+ * /permission/admin/manage/identity/apiresourcemgt/view
+ Scope required:
+ * internal_api_resource_view + parameters: + - $ref: '#/components/parameters/apiResourceId' + responses: + 200: + description: OK + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/ScopeGetModel' + 401: + description: Unauthorized + 403: + description: Forbidden + 404: + description: Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 500: + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + + put: + tags: + - API Resource Scopes + summary: Add scopes to API resource + description: > + Put scopes API resource specified by the id + Permission required:
+ * /permission/admin/manage/identity/apiresourcemgt/update
+ Scope required:
+ * internal_api_resource_update + parameters: + - $ref: '#/components/parameters/apiResourceId' + responses: + 204: + description: No Content + 400: + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 401: + description: Unauthorized + 403: + description: Forbidden + 404: + description: Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 409: + description: Conflict + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + application/xml: + schema: + $ref: '#/components/schemas/Error' + 500: + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + + requestBody: + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/ScopeCreationModel' + description: This represents the API resource to be patched. + required: true + + /api-resources/{apiResourceId}/scopes/{scopeName}: + delete: + tags: + - API Resource Scopes + summary: Delete API scope specified by the name + description: > + Delete API scope specified by the name + Permission required:
+ * /permission/admin/manage/identity/apiresourcemgt/delete
+ Scope required:
+ * internal_api_resource_delete + parameters: + - $ref: '#/components/parameters/apiResourceId' + - $ref: '#/components/parameters/scopeName' + responses: + 401: + description: Unauthorized + 403: + description: Forbidden + 500: + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + + /scopes: + get: + tags: + - API Resource Scopes + summary: Get all scopes in the tenant + description: > + Get all scopes in the tenant + Permission required:
+ * /permission/admin/manage/identity/apiresourcemgt/view
+ Scope required:
+ * internal_api_resource_view + parameters: + - $ref: '#/components/parameters/filter' + responses: + 200: + description: OK + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/ScopeGetModel' + 401: + description: Unauthorized + 403: + description: Forbidden + 404: + description: Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + 500: + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + +components: + parameters: + organizationId: + in: path + name: organizationId + description: uuid of the org. + required: true + schema: + type: string + example: "1234-4567-4567" + + apiResourceId: + name: apiResourceId + in: path + description: ID of the API Resource. + required: true + schema: + type: string + example: er34-gf23-bv54-vb90 + + scopeName: + name: scopeName + in: path + description: Name of the Scope. + required: true + schema: + type: string + + applicationId: + name: applicationId + in: path + description: ID of the Application. + required: true + schema: + type: string + + authorizationId: + name: authorizationId + in: path + description: ID of the authorization. + required: true + schema: + type: string + + before: + name: before + in: query + required: false + description: | + Base64 encoded cursor value for backward pagination. + schema: + type: string + example: Ng== + + after: + name: after + in: query + required: false + description: | + Base64 encoded cursor value for forward pagination. + schema: + type: string + example: Ng== + + filter: + name: filter + in: query + required: false + description: | + Condition to filter the retrieval of records. Supports 'sw', 'co', 'ew' and 'eq' operations. + schema: + type: string + example: identifier+eq+greetings + + limit: + name: limit + in: query + required: false + description: | + Maximum number of records to return. + schema: + type: integer + example: 10 + + requiredAttributes: + name: requiredAttributes + in: query + required: false + description: Specifies the required parameters in the response. This parameter is not supported yet + schema: + type: string + + schemas: + Error: + type: object + properties: + code: + type: string + example: AAA-00000 + message: + type: string + example: Some Error Message + description: + type: string + example: Some Error Description + traceId: + type: string + example: e0fbcfeb-3617-43c4-8dd0-7b7d38e13047 + + APIResourceListItem: + type: object + required: + - id + - name + - identifier + - self + properties: + id: + type: string + example: gh43-jk34-vb34-df67 + name: + type: string + example: Greetings API + identifier: + type: string + example: greetings_api + type: + type: string + example: SYSTEM + requiresAuthorization: + type: boolean + example: true + self: + type: string + example: /t/carbon.super/api/server/v1/api-resources/eDUwOUNlcnRpZmljYXRlQXV0aGVudGljYXRvcg + + APIResourceResponse: + type: object + required: + - id + - name + - identifier + - self + properties: + id: + type: string + example: gh43-jk34-vb34-df67 + name: + type: string + example: Greetings API + description: + type: string + example: Greeting API representation + identifier: + type: string + example: greetings_api + type: + type: string + example: SYSTEM + requiresAuthorization: + type: boolean + example: true + scopes: + type: array + items: + $ref: '#/components/schemas/ScopeGetModel' + subscribedApplications: + type: array + items: + $ref: '#/components/schemas/SubscribedApplicationGetModel' + self: + type: string + example: /t/carbon.super/api/server/v1/api-resources/eDUwOUNlcnRpZmljYXRlQXV0aGVudGljYXRvcg + + APIResourceCreationModel: + type: object + required: + - identifier + - name + properties: + name: + type: string + example: Greetings API + identifier: + type: string + example: greetings_api + description: + type: string + example: Greetings API representation + requiresAuthorization: + type: boolean + example: true + scopes: + type: array + items: + $ref: '#/components/schemas/ScopeCreationModel' + + APIResourcePatchModel: + type: object + properties: + name: + type: string + example: Greetings API + description: + type: string + example: Greetings API representation + addedScopes: + type: array + items: + $ref: '#/components/schemas/ScopeCreationModel' + removedScopes: + type: array + items: + type: string + description: This field is not supported yet. + + PaginationLink: + type: object + properties: + rel: + type: string + example: before + href: + type: string + example: /o/orgName/api-resources?after=NDoy + + APIResourceListResponse: + type: object + required: + - links + properties: + totalResults: + type: integer + example: 1 + links: + type: array + items: + $ref: '#/components/schemas/PaginationLink' + APIResources: + type: array + items: + $ref: '#/components/schemas/APIResourceListItem' + + ScopeGetModel: + type: object + required: + - id + - displayName + - name + properties: + id: + type: string + example: sf23-fg34-fy53-hj23 + displayName: + type: string + example: Write + name: + type: string + example: greetings:write + description: + type: string + example: Allow writing greetings + + ScopeCreationModel: + type: object + required: + - name + properties: + name: + type: string + example: 'greetings:write' + displayName: + type: string + example: "Write Greetings" + description: + type: string + example: "Allows writing greetings" + + SubscribedApplicationGetModel: + type: object + properties: + name: + type: string + example: Application1 + id: + type: string + example: 23fd-23gd-54vv-sdhf + + responses: + BadRequest: + description: Bad Request. Invalid request or validation error. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: 400 + message: Bad Request + description: Invalid request or validation error + + Conflict: + description: Conflict. Specified resource already exists. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: 409 + message: Conflict + description: Specified resource already exists + moreInfo: '' + error: [] + Forbidden: + description: >- + Forbidden. The request must be conditional but no condition has been + specified. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: 403 + message: Forbidden + description: >- + The request must be conditional but no condition has been + specified + InternalServerError: + description: Internal Server Error. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: 500 + message: Internal Server Error + description: >- + The server encountered an internal error. Please contact + administrator. + moreInfo: '' + error: [] + NotFound: + description: Not Found. The specified resource does not exist. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: 404 + message: Not Found + description: The specified resource does not exist + moreInfo: '' + error: [] + + Unauthorized: + description: Unauthorized. The user is not authorized. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + example: + code: 401 + message: Unauthorized + description: The user is not authorized + moreInfo: '' + error: [] + + securitySchemes: + BasicAuth: + type: http + scheme: basic + OAuth2: + type: oauth2 + flows: + authorizationCode: + authorizationUrl: 'https://localhost:9443/oauth2/authorize' + tokenUrl: 'http://localhost:9443/oauth2/token' + scopes: {} diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/resources/META-INF/cxf/api-resource-server-v1-cxf.xml b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/resources/META-INF/cxf/api-resource-server-v1-cxf.xml new file mode 100644 index 0000000000..d0e3e969ba --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/resources/META-INF/cxf/api-resource-server-v1-cxf.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/pom.xml b/components/org.wso2.carbon.identity.api.server.api.resource/pom.xml new file mode 100644 index 0000000000..8ed94a3753 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.api.resource/pom.xml @@ -0,0 +1,37 @@ + + + + 4.0.0 + + + identity-api-server + org.wso2.carbon.identity.server.api + 1.2.85-SNAPSHOT + ../../pom.xml + + + org.wso2.carbon.identity.api.server.api.resource + pom + + + org.wso2.carbon.identity.api.server.api.resource.common + org.wso2.carbon.identity.api.server.api.resource.v1 + + + diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.common/pom.xml b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.common/pom.xml index 71a764c371..91e51b11de 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.common/pom.xml @@ -22,12 +22,12 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.application.management - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../pom.xml org.wso2.carbon.identity.api.server.application.management.common - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT jar diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/pom.xml index 25b06f9c32..f2bafd467c 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.application.management - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../pom.xml WSO2 Identity Server - Applications Rest API WSO2 Identity Server - Applications Rest API org.wso2.carbon.identity.api.server.application.management.v1 - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT jar diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ServerApplicationManagementService.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ServerApplicationManagementService.java index 7f4f9560e0..52c3698f9d 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ServerApplicationManagementService.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/ServerApplicationManagementService.java @@ -131,6 +131,8 @@ import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.constructor.Constructor; import org.yaml.snakeyaml.error.YAMLException; +import org.yaml.snakeyaml.inspector.TagInspector; +import org.yaml.snakeyaml.inspector.TrustedPrefixesTagInspector; import java.io.IOException; import java.io.InputStream; @@ -715,7 +717,16 @@ private ServiceProvider parseServiceProviderFromYaml(SpFileContent spFileContent throws IdentityApplicationManagementException { try { - Yaml yaml = new Yaml(new Constructor(ServiceProvider.class, new LoaderOptions())); + // Add trusted tags included in the SP YAML file. + List trustedTagList = new ArrayList<>(); + trustedTagList.add(ServiceProvider.class.getName()); + trustedTagList.add(OAuthAppDO.class.getName()); + trustedTagList.add(SAMLSSOServiceProviderDTO.class.getName()); + + LoaderOptions loaderOptions = new LoaderOptions(); + TagInspector tagInspector = new TrustedPrefixesTagInspector(trustedTagList); + loaderOptions.setTagInspector(tagInspector); + Yaml yaml = new Yaml(new Constructor(ServiceProvider.class, loaderOptions)); return yaml.loadAs(spFileContent.getContent(), ServiceProvider.class); } catch (YAMLException e) { throw new IdentityApplicationManagementException(String.format("Error in reading YAML Service Provider " + diff --git a/components/org.wso2.carbon.identity.api.server.application.management/pom.xml b/components/org.wso2.carbon.identity.api.server.application.management/pom.xml index 1a5cfeba77..27a91a0408 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.application.management/pom.xml @@ -22,12 +22,12 @@ identity-api-server org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../pom.xml org.wso2.carbon.identity.api.server.application.management - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT pom diff --git a/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.common/pom.xml b/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.common/pom.xml index 0bc7b28500..9382f5a38a 100644 --- a/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.common/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.authenticators - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT org.wso2.carbon.identity.api.server.authenticators.common diff --git a/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.v1/pom.xml index abdf873403..c408521b88 100644 --- a/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.v1/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.authenticators - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT org.wso2.carbon.identity.api.server.authenticators.v1 diff --git a/components/org.wso2.carbon.identity.api.server.authenticators/pom.xml b/components/org.wso2.carbon.identity.api.server.authenticators/pom.xml index 83b5f638c4..b26778133e 100644 --- a/components/org.wso2.carbon.identity.api.server.authenticators/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.authenticators/pom.xml @@ -21,7 +21,7 @@ identity-api-server org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.common/pom.xml b/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.common/pom.xml index 509e9bc062..ee38552860 100644 --- a/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.common/pom.xml @@ -24,7 +24,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.branding.preference.management ../pom.xml - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT org.wso2.carbon.identity.server.api diff --git a/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.v1/pom.xml index 7aab644482..7225f0700e 100644 --- a/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.v1/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.identity.api.server.branding.preference.management org.wso2.carbon.identity.server.api ../pom.xml - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.branding.preference.management/pom.xml b/components/org.wso2.carbon.identity.api.server.branding.preference.management/pom.xml index 5037d25d8f..6d3a465553 100644 --- a/components/org.wso2.carbon.identity.api.server.branding.preference.management/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.branding.preference.management/pom.xml @@ -22,7 +22,7 @@ identity-api-server org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.challenge/org.wso2.carbon.identity.api.server.challenge.common/pom.xml b/components/org.wso2.carbon.identity.api.server.challenge/org.wso2.carbon.identity.api.server.challenge.common/pom.xml index d5074e08e2..755f7e317a 100644 --- a/components/org.wso2.carbon.identity.api.server.challenge/org.wso2.carbon.identity.api.server.challenge.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.challenge/org.wso2.carbon.identity.api.server.challenge.common/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.identity.api.server.challenge org.wso2.carbon.identity.server.api ../pom.xml - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT 4.0.0 org.wso2.carbon.identity.api.server.challenge.common diff --git a/components/org.wso2.carbon.identity.api.server.challenge/org.wso2.carbon.identity.rest.api.server.challenge.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.challenge/org.wso2.carbon.identity.rest.api.server.challenge.v1/pom.xml index bfd9a56865..6a4844e48d 100644 --- a/components/org.wso2.carbon.identity.api.server.challenge/org.wso2.carbon.identity.rest.api.server.challenge.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.challenge/org.wso2.carbon.identity.rest.api.server.challenge.v1/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.challenge ../pom.xml - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT 4.0.0 org.wso2.carbon.identity.rest.api.server.challenge.v1 diff --git a/components/org.wso2.carbon.identity.api.server.challenge/pom.xml b/components/org.wso2.carbon.identity.api.server.challenge/pom.xml index a54e116059..3282122c3a 100644 --- a/components/org.wso2.carbon.identity.api.server.challenge/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.challenge/pom.xml @@ -21,7 +21,7 @@ identity-api-server org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.api.server.claim.management.common/pom.xml b/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.api.server.claim.management.common/pom.xml index 1ff0ff4010..25e8e7cb74 100644 --- a/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.api.server.claim.management.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.api.server.claim.management.common/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.identity.api.server.claim.management org.wso2.carbon.identity.server.api ../pom.xml - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT 4.0.0 org.wso2.carbon.identity.api.server.claim.management.common diff --git a/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/pom.xml index 8107a83d12..3ae82b772c 100644 --- a/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.claim.management ../pom.xml - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT 4.0.0 org.wso2.carbon.identity.rest.api.server.claim.management.v1 diff --git a/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/claim/management/v1/core/ServerClaimManagementService.java b/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/claim/management/v1/core/ServerClaimManagementService.java index 97ca0dc8df..51369de3a1 100644 --- a/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/claim/management/v1/core/ServerClaimManagementService.java +++ b/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/claim/management/v1/core/ServerClaimManagementService.java @@ -62,6 +62,8 @@ import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.constructor.Constructor; import org.yaml.snakeyaml.error.YAMLException; +import org.yaml.snakeyaml.inspector.TagInspector; +import org.yaml.snakeyaml.inspector.TrustedPrefixesTagInspector; import java.io.IOException; import java.io.InputStream; @@ -1155,7 +1157,16 @@ private ClaimDialectConfiguration parseClaimDialectFromJson(FileContent fileCont private ClaimDialectConfiguration parseClaimDialectFromYaml(FileContent fileContent) throws ClaimMetadataException { try { - Yaml yaml = new Yaml(new Constructor(ClaimDialectConfiguration.class, new LoaderOptions())); + // Add trusted tags included in the Claims YAML files. + List trustedTagList = new ArrayList<>(); + trustedTagList.add(ClaimDialectConfiguration.class.getName()); + trustedTagList.add(ExternalClaimResDTO.class.getName()); + trustedTagList.add(LocalClaimResDTO.class.getName()); + + LoaderOptions loaderOptions = new LoaderOptions(); + TagInspector tagInspector = new TrustedPrefixesTagInspector(trustedTagList); + loaderOptions.setTagInspector(tagInspector); + Yaml yaml = new Yaml(new Constructor(ClaimDialectConfiguration.class, loaderOptions)); return yaml.loadAs(fileContent.getContent(), ClaimDialectConfiguration.class); } catch (YAMLException e) { throw new ClaimMetadataException(String.format( diff --git a/components/org.wso2.carbon.identity.api.server.claim.management/pom.xml b/components/org.wso2.carbon.identity.api.server.claim.management/pom.xml index 784fa99b15..9ae2a7cb5a 100644 --- a/components/org.wso2.carbon.identity.api.server.claim.management/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.claim.management/pom.xml @@ -21,7 +21,7 @@ identity-api-server org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.common/pom.xml b/components/org.wso2.carbon.identity.api.server.common/pom.xml index 8d7d4337f4..0ac90bc34d 100644 --- a/components/org.wso2.carbon.identity.api.server.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.common/pom.xml @@ -19,7 +19,7 @@ identity-api-server org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.common/pom.xml b/components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.common/pom.xml index 08adae3e23..a93ec2f1c6 100644 --- a/components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.common/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.configs - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT org.wso2.carbon.identity.api.server.configs.common diff --git a/components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/pom.xml index 27a6f36696..68bad736cb 100644 --- a/components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.configs - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT org.wso2.carbon.identity.api.server.configs.v1 diff --git a/components/org.wso2.carbon.identity.api.server.configs/pom.xml b/components/org.wso2.carbon.identity.api.server.configs/pom.xml index b94b19f523..be1526b877 100644 --- a/components/org.wso2.carbon.identity.api.server.configs/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.configs/pom.xml @@ -21,7 +21,7 @@ identity-api-server org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.cors/org.wso2.carbon.identity.api.server.cors.common/pom.xml b/components/org.wso2.carbon.identity.api.server.cors/org.wso2.carbon.identity.api.server.cors.common/pom.xml index 602f08740e..a3d9a88a46 100644 --- a/components/org.wso2.carbon.identity.api.server.cors/org.wso2.carbon.identity.api.server.cors.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.cors/org.wso2.carbon.identity.api.server.cors.common/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.cors - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT org.wso2.carbon.identity.api.server.cors.common diff --git a/components/org.wso2.carbon.identity.api.server.cors/org.wso2.carbon.identity.api.server.cors.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.cors/org.wso2.carbon.identity.api.server.cors.v1/pom.xml index e812493f6d..c1db535ab2 100644 --- a/components/org.wso2.carbon.identity.api.server.cors/org.wso2.carbon.identity.api.server.cors.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.cors/org.wso2.carbon.identity.api.server.cors.v1/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.cors - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT org.wso2.carbon.identity.api.server.cors.v1 diff --git a/components/org.wso2.carbon.identity.api.server.cors/pom.xml b/components/org.wso2.carbon.identity.api.server.cors/pom.xml index 19d1551788..ceb1012201 100644 --- a/components/org.wso2.carbon.identity.api.server.cors/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.cors/pom.xml @@ -21,7 +21,7 @@ identity-api-server org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.api.server.email.template.common/pom.xml b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.api.server.email.template.common/pom.xml index efa7453715..1db1a5250d 100644 --- a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.api.server.email.template.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.api.server.email.template.common/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.email.template - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v1/pom.xml index 255e43de01..434b55e3c3 100644 --- a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v1/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.email.template - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.email.template/pom.xml b/components/org.wso2.carbon.identity.api.server.email.template/pom.xml index c9ae192df3..8756dbe13e 100644 --- a/components/org.wso2.carbon.identity.api.server.email.template/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.email.template/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.server.api identity-api-server - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.extension.management/org.wso2.carbon.identity.api.server.extension.management.common/pom.xml b/components/org.wso2.carbon.identity.api.server.extension.management/org.wso2.carbon.identity.api.server.extension.management.common/pom.xml index c0239b3997..85e779aa42 100644 --- a/components/org.wso2.carbon.identity.api.server.extension.management/org.wso2.carbon.identity.api.server.extension.management.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.extension.management/org.wso2.carbon.identity.api.server.extension.management.common/pom.xml @@ -19,7 +19,7 @@ org.wso2.carbon.identity.api.server.extension.management org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.extension.management/org.wso2.carbon.identity.api.server.extension.management.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.extension.management/org.wso2.carbon.identity.api.server.extension.management.v1/pom.xml index 3a6dc09b43..1d91fbb723 100644 --- a/components/org.wso2.carbon.identity.api.server.extension.management/org.wso2.carbon.identity.api.server.extension.management.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.extension.management/org.wso2.carbon.identity.api.server.extension.management.v1/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.extension.management - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT org.wso2.carbon.identity.api.server.extension.management.v1 diff --git a/components/org.wso2.carbon.identity.api.server.extension.management/pom.xml b/components/org.wso2.carbon.identity.api.server.extension.management/pom.xml index 68d1df9c0f..52deac3de1 100644 --- a/components/org.wso2.carbon.identity.api.server.extension.management/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.extension.management/pom.xml @@ -19,7 +19,7 @@ identity-api-server org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.fetch.remote/org.wso2.carbon.identity.api.server.fetch.remote.common/pom.xml b/components/org.wso2.carbon.identity.api.server.fetch.remote/org.wso2.carbon.identity.api.server.fetch.remote.common/pom.xml index cfd32d247e..e77d069e93 100644 --- a/components/org.wso2.carbon.identity.api.server.fetch.remote/org.wso2.carbon.identity.api.server.fetch.remote.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.fetch.remote/org.wso2.carbon.identity.api.server.fetch.remote.common/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.fetch.remote - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.fetch.remote/org.wso2.carbon.identity.api.server.fetch.remote.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.fetch.remote/org.wso2.carbon.identity.api.server.fetch.remote.v1/pom.xml index 949b6d82f4..5db03d0675 100644 --- a/components/org.wso2.carbon.identity.api.server.fetch.remote/org.wso2.carbon.identity.api.server.fetch.remote.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.fetch.remote/org.wso2.carbon.identity.api.server.fetch.remote.v1/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.fetch.remote - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.fetch.remote/pom.xml b/components/org.wso2.carbon.identity.api.server.fetch.remote/pom.xml index c6e29f47f6..7309bd15d0 100644 --- a/components/org.wso2.carbon.identity.api.server.fetch.remote/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.fetch.remote/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.server.api identity-api-server - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.identity.governance/org.wso2.carbon.identity.api.server.identity.governance.common/pom.xml b/components/org.wso2.carbon.identity.api.server.identity.governance/org.wso2.carbon.identity.api.server.identity.governance.common/pom.xml index 4aba601351..4fe141a1f6 100644 --- a/components/org.wso2.carbon.identity.api.server.identity.governance/org.wso2.carbon.identity.api.server.identity.governance.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.identity.governance/org.wso2.carbon.identity.api.server.identity.governance.common/pom.xml @@ -18,7 +18,7 @@ org.wso2.carbon.identity.api.server.identity.governance org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.identity.governance/org.wso2.carbon.identity.api.server.identity.governance.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.identity.governance/org.wso2.carbon.identity.api.server.identity.governance.v1/pom.xml index 08b3510c34..543bc98eac 100644 --- a/components/org.wso2.carbon.identity.api.server.identity.governance/org.wso2.carbon.identity.api.server.identity.governance.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.identity.governance/org.wso2.carbon.identity.api.server.identity.governance.v1/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.identity.governance ../pom.xml - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT 4.0.0 org.wso2.carbon.identity.api.server.identity.governance.v1 diff --git a/components/org.wso2.carbon.identity.api.server.identity.governance/pom.xml b/components/org.wso2.carbon.identity.api.server.identity.governance/pom.xml index 490ba72bbe..5267bf2edf 100644 --- a/components/org.wso2.carbon.identity.api.server.identity.governance/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.identity.governance/pom.xml @@ -21,7 +21,7 @@ identity-api-server org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.common/pom.xml b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.common/pom.xml index e0eeeaf768..0a1f7b3590 100644 --- a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.common/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.api.server.idp org.wso2.carbon.identity.server.api ../pom.xml - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/pom.xml index f96d8c5a19..8a86394661 100644 --- a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.idp ../pom.xml - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/main/java/org/wso2/carbon/identity/api/server/idp/v1/core/ServerIdpManagementService.java b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/main/java/org/wso2/carbon/identity/api/server/idp/v1/core/ServerIdpManagementService.java index 30f1f70d0d..6d3fcb5fb2 100644 --- a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/main/java/org/wso2/carbon/identity/api/server/idp/v1/core/ServerIdpManagementService.java +++ b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/main/java/org/wso2/carbon/identity/api/server/idp/v1/core/ServerIdpManagementService.java @@ -118,6 +118,8 @@ import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.constructor.Constructor; import org.yaml.snakeyaml.error.YAMLException; +import org.yaml.snakeyaml.inspector.TagInspector; +import org.yaml.snakeyaml.inspector.TrustedPrefixesTagInspector; import org.yaml.snakeyaml.representer.Representer; import java.io.IOException; @@ -3696,7 +3698,14 @@ private IdentityProvider parseIdpFromYaml(FileContent fileContent) throws IdentityProviderManagementClientException { try { - Yaml yaml = new Yaml(new Constructor(IdentityProvider.class, new LoaderOptions())); + // Add trusted tags included in the IDP YAML files. + List trustedTagList = new ArrayList<>(); + trustedTagList.add(IdentityProvider.class.getName()); + + LoaderOptions loaderOptions = new LoaderOptions(); + TagInspector tagInspector = new TrustedPrefixesTagInspector(trustedTagList); + loaderOptions.setTagInspector(tagInspector); + Yaml yaml = new Yaml(new Constructor(IdentityProvider.class, loaderOptions)); return yaml.loadAs(fileContent.getContent(), IdentityProvider.class); } catch (YAMLException e) { throw new IdentityProviderManagementClientException(String.format("Error in reading YAML file " + diff --git a/components/org.wso2.carbon.identity.api.server.idp/pom.xml b/components/org.wso2.carbon.identity.api.server.idp/pom.xml index 99c7bc8594..780a95bc68 100644 --- a/components/org.wso2.carbon.identity.api.server.idp/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.idp/pom.xml @@ -21,7 +21,7 @@ identity-api-server org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.idv.provider/org.wso2.carbon.identity.api.server.idv.provider.common/pom.xml b/components/org.wso2.carbon.identity.api.server.idv.provider/org.wso2.carbon.identity.api.server.idv.provider.common/pom.xml index 49f5f52dba..46c619e5da 100644 --- a/components/org.wso2.carbon.identity.api.server.idv.provider/org.wso2.carbon.identity.api.server.idv.provider.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.idv.provider/org.wso2.carbon.identity.api.server.idv.provider.common/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.idv.provider ../pom.xml - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT org.wso2.carbon.identity.api.server.idv.provider.common diff --git a/components/org.wso2.carbon.identity.api.server.idv.provider/org.wso2.carbon.identity.api.server.idv.provider.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.idv.provider/org.wso2.carbon.identity.api.server.idv.provider.v1/pom.xml index b6e61e8f33..2f268efc96 100644 --- a/components/org.wso2.carbon.identity.api.server.idv.provider/org.wso2.carbon.identity.api.server.idv.provider.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.idv.provider/org.wso2.carbon.identity.api.server.idv.provider.v1/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.idv.provider ../pom.xml - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT org.wso2.carbon.identity.api.server.idv.provider.v1 diff --git a/components/org.wso2.carbon.identity.api.server.idv.provider/pom.xml b/components/org.wso2.carbon.identity.api.server.idv.provider/pom.xml index 90585faf40..861ab83cc4 100644 --- a/components/org.wso2.carbon.identity.api.server.idv.provider/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.idv.provider/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.server.api identity-api-server - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.input.validation/org.wso2.carbon.identity.api.server.input.validation.common/pom.xml b/components/org.wso2.carbon.identity.api.server.input.validation/org.wso2.carbon.identity.api.server.input.validation.common/pom.xml index 24f78e1002..df0d191e45 100644 --- a/components/org.wso2.carbon.identity.api.server.input.validation/org.wso2.carbon.identity.api.server.input.validation.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.input.validation/org.wso2.carbon.identity.api.server.input.validation.common/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.api.server.input.validation org.wso2.carbon.identity.server.api ../pom.xml - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.input.validation/org.wso2.carbon.identity.api.server.input.validation.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.input.validation/org.wso2.carbon.identity.api.server.input.validation.v1/pom.xml index 597a7938e6..34d6cdbbfa 100644 --- a/components/org.wso2.carbon.identity.api.server.input.validation/org.wso2.carbon.identity.api.server.input.validation.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.input.validation/org.wso2.carbon.identity.api.server.input.validation.v1/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.input.validation - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../pom.xml WSO2 Identity Server - Input Validation Rest API WSO2 Identity Server - Validation Rest API org.wso2.carbon.identity.api.server.input.validation.v1 - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT jar diff --git a/components/org.wso2.carbon.identity.api.server.input.validation/pom.xml b/components/org.wso2.carbon.identity.api.server.input.validation/pom.xml index 86d9164506..a778ee7e38 100644 --- a/components/org.wso2.carbon.identity.api.server.input.validation/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.input.validation/pom.xml @@ -22,7 +22,7 @@ identity-api-server org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.keystore.management/org.wso2.carbon.identity.api.server.keystore.management.common/pom.xml b/components/org.wso2.carbon.identity.api.server.keystore.management/org.wso2.carbon.identity.api.server.keystore.management.common/pom.xml index c0d612416a..7b934181fc 100644 --- a/components/org.wso2.carbon.identity.api.server.keystore.management/org.wso2.carbon.identity.api.server.keystore.management.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.keystore.management/org.wso2.carbon.identity.api.server.keystore.management.common/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.keystore.management ../pom.xml - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT 4.0.0 org.wso2.carbon.identity.api.server.keystore.management.common diff --git a/components/org.wso2.carbon.identity.api.server.keystore.management/org.wso2.carbon.identity.api.server.keystore.management.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.keystore.management/org.wso2.carbon.identity.api.server.keystore.management.v1/pom.xml index 3863c4e4aa..879d83dac5 100644 --- a/components/org.wso2.carbon.identity.api.server.keystore.management/org.wso2.carbon.identity.api.server.keystore.management.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.keystore.management/org.wso2.carbon.identity.api.server.keystore.management.v1/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.keystore.management ../pom.xml - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT 4.0.0 org.wso2.carbon.identity.api.server.keystore.management.v1 diff --git a/components/org.wso2.carbon.identity.api.server.keystore.management/pom.xml b/components/org.wso2.carbon.identity.api.server.keystore.management/pom.xml index e8fbfbedc1..72081d5fee 100644 --- a/components/org.wso2.carbon.identity.api.server.keystore.management/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.keystore.management/pom.xml @@ -20,7 +20,7 @@ identity-api-server org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.common/pom.xml b/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.common/pom.xml index c5c78a94b5..562df05043 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.common/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.api.server.notification.sender org.wso2.carbon.identity.server.api ../pom.xml - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/pom.xml index f35fa70e74..7b2d098bf2 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.api.server.notification.sender org.wso2.carbon.identity.server.api ../pom.xml - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.notification.sender/pom.xml b/components/org.wso2.carbon.identity.api.server.notification.sender/pom.xml index 1fa1a4db33..1d71bdae52 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.sender/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.notification.sender/pom.xml @@ -21,7 +21,7 @@ identity-api-server org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.oidc.scope.management/org.wso2.carbon.identity.api.server.oidc.scope.management.common/pom.xml b/components/org.wso2.carbon.identity.api.server.oidc.scope.management/org.wso2.carbon.identity.api.server.oidc.scope.management.common/pom.xml index f431d212d2..caa59d89ec 100644 --- a/components/org.wso2.carbon.identity.api.server.oidc.scope.management/org.wso2.carbon.identity.api.server.oidc.scope.management.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.oidc.scope.management/org.wso2.carbon.identity.api.server.oidc.scope.management.common/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.oidc.scope.management ../pom.xml - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.oidc.scope.management/org.wso2.carbon.identity.api.server.oidc.scope.management.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.oidc.scope.management/org.wso2.carbon.identity.api.server.oidc.scope.management.v1/pom.xml index d5451b340c..a5b56cb51e 100644 --- a/components/org.wso2.carbon.identity.api.server.oidc.scope.management/org.wso2.carbon.identity.api.server.oidc.scope.management.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.oidc.scope.management/org.wso2.carbon.identity.api.server.oidc.scope.management.v1/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.oidc.scope.management ../pom.xml - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT 4.0.0 org.wso2.carbon.identity.api.server.oidc.scope.management.v1 diff --git a/components/org.wso2.carbon.identity.api.server.oidc.scope.management/pom.xml b/components/org.wso2.carbon.identity.api.server.oidc.scope.management/pom.xml index 4214098884..ce5b1ee626 100644 --- a/components/org.wso2.carbon.identity.api.server.oidc.scope.management/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.oidc.scope.management/pom.xml @@ -20,7 +20,7 @@ identity-api-server org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.common/pom.xml b/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.common/pom.xml new file mode 100644 index 0000000000..b95ed37f22 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.common/pom.xml @@ -0,0 +1,57 @@ + + + + 4.0.0 + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.organization.configs + 1.2.85-SNAPSHOT + + + org.wso2.carbon.identity.api.server.organization.configs.common + jar + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + + + + org.wso2.carbon.identity.organization.management + org.wso2.carbon.identity.organization.config.service + provided + + + org.springframework + spring-web + provided + + + + diff --git a/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.common/src/main/java/org/wso2/carbon/identity/api/server/organization/configs/common/OrganizationConfigsServiceHolder.java b/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.common/src/main/java/org/wso2/carbon/identity/api/server/organization/configs/common/OrganizationConfigsServiceHolder.java new file mode 100644 index 0000000000..dc1005a888 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.common/src/main/java/org/wso2/carbon/identity/api/server/organization/configs/common/OrganizationConfigsServiceHolder.java @@ -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.configs.common; + +import org.wso2.carbon.identity.organization.config.service.OrganizationConfigManager; + +/** + * Service holder class for organization configuration management. + */ +public class OrganizationConfigsServiceHolder { + + private static OrganizationConfigManager organizationConfigManager; + + /** + * Get OrganizationConfigManager OSGi service. + * + * @return OrganizationConfigManager. + */ + public static OrganizationConfigManager getOrganizationConfigManager() { + + return organizationConfigManager; + } + + /** + * Set OrganizationConfigManager OSGi service. + * + * @param organizationConfigManager OrganizationConfigManager. + */ + public static void setOrganizationConfigManager(OrganizationConfigManager organizationConfigManager) { + + OrganizationConfigsServiceHolder.organizationConfigManager = organizationConfigManager; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.common/src/main/java/org/wso2/carbon/identity/api/server/organization/configs/common/factory/OrganizationConfigManagerOSGIServiceFactory.java b/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.common/src/main/java/org/wso2/carbon/identity/api/server/organization/configs/common/factory/OrganizationConfigManagerOSGIServiceFactory.java new file mode 100644 index 0000000000..99bfd0aebd --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.common/src/main/java/org/wso2/carbon/identity/api/server/organization/configs/common/factory/OrganizationConfigManagerOSGIServiceFactory.java @@ -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.configs.common.factory; + +import org.springframework.beans.factory.config.AbstractFactoryBean; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.identity.organization.config.service.OrganizationConfigManager; + +/** + * Factory Beans serves as a factory for creating other beans within the IOC container. This factory bean is used to + * instantiate the OrganizationConfigManager type of object inside the container. + */ +public class OrganizationConfigManagerOSGIServiceFactory extends AbstractFactoryBean { + + private OrganizationConfigManager organizationConfigManager; + + @Override + public Class getObjectType() { + + return Object.class; + } + + @Override + protected OrganizationConfigManager createInstance() throws Exception { + + if (this.organizationConfigManager == null) { + OrganizationConfigManager organizationConfigManagerService = + (OrganizationConfigManager) PrivilegedCarbonContext.getThreadLocalCarbonContext() + .getOSGiService(OrganizationConfigManager.class, null); + if (organizationConfigManagerService == null) { + throw new Exception("Unable to retrieve OrganizationConfigManager service."); + } + this.organizationConfigManager = organizationConfigManagerService; + } + return this.organizationConfigManager; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/pom.xml new file mode 100644 index 0000000000..736dc2dfe3 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/pom.xml @@ -0,0 +1,170 @@ + + + + 4.0.0 + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.organization.configs + 1.2.85-SNAPSHOT + + + org.wso2.carbon.identity.api.server.organization.configs.v1 + jar + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.8 + + + add-source + generate-sources + + add-source + + + + src/gen/java + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven.compiler.plugin.version} + + 1.8 + 1.8 + + + + + + + + org.apache.cxf + cxf-rt-frontend-jaxrs + provided + + + org.apache.cxf + cxf-rt-rs-service-description + provided + + + org.springframework + spring-web + provided + + + javax.ws.rs + javax.ws.rs-api + provided + + + io.swagger + swagger-jaxrs + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.core + jackson-annotations + + + com.fasterxml.jackson.core + jackson-core + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + + + javax.ws.rs + jsr311-api + + + com.google.guava + guava + + + + + com.fasterxml.jackson.jaxrs + jackson-jaxrs-json-provider + provided + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.common + provided + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.organization.configs.common + provided + + + org.wso2.carbon.identity.organization.management + org.wso2.carbon.identity.organization.config.service + provided + + + + diff --git a/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/organization/configs/v1/OrganizationConfigsApi.java b/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/organization/configs/v1/OrganizationConfigsApi.java new file mode 100644 index 0000000000..d3048edb14 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/organization/configs/v1/OrganizationConfigsApi.java @@ -0,0 +1,115 @@ +/* + * 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.configs.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.organization.configs.v1.model.Config; +import org.wso2.carbon.identity.api.server.organization.configs.v1.model.Error; +import org.wso2.carbon.identity.api.server.organization.configs.v1.OrganizationConfigsApiService; + +import javax.validation.Valid; +import javax.ws.rs.*; +import javax.ws.rs.core.Response; +import io.swagger.annotations.*; + +import javax.validation.constraints.*; + +@Path("/organization-configs") +@Api(description = "The organization-configs API") + +public class OrganizationConfigsApi { + + @Autowired + private OrganizationConfigsApiService delegate; + + @Valid + @POST + @Path("/discovery") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Add organization discovery configuration.", notes = "This API provides the capability to add discovery configuration for the primary organization.
Permission required:
* /permission/admin/manage/identity/configmgt/add
Scope required:
* internal_config_mgt_add ", response = Config.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Discovery", }) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Successful Response", response = Config.class), + @ApiResponse(code = 400, message = "Invalid input in the request.", response = Error.class), + @ApiResponse(code = 401, message = "Authentication information is missing or invalid.", response = Void.class), + @ApiResponse(code = 403, message = "Access forbidden.", response = Void.class), + @ApiResponse(code = 409, message = "Resource already exists.", response = Error.class), + @ApiResponse(code = 500, message = "Internal server error.", response = Error.class) + }) + public Response createDiscoveryConfig(@ApiParam(value = "" ) @Valid Config config) { + + return delegate.createDiscoveryConfig(config ); + } + + @Valid + @DELETE + @Path("/discovery") + + @Produces({ "application/json" }) + @ApiOperation(value = "Delete organization discovery configuration.", notes = "This API provides the capability to delete discovery configuration of the primary organization.
Permission required:
* /permission/admin/manage/identity/configmgt/delete
Scope required:
* internal_config_mgt_delete ", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Discovery", }) + @ApiResponses(value = { + @ApiResponse(code = 204, message = "No content.", response = Void.class), + @ApiResponse(code = 401, message = "Authentication information is missing or invalid.", response = Void.class), + @ApiResponse(code = 403, message = "Access forbidden.", response = Void.class), + @ApiResponse(code = 500, message = "Internal server error.", response = Error.class) + }) + public Response deleteDiscoveryConfig() { + + return delegate.deleteDiscoveryConfig(); + } + + @Valid + @GET + @Path("/discovery") + + @Produces({ "application/json" }) + @ApiOperation(value = "Get organization discovery configuration.", notes = "This API facilitates the retrieval of discovery configuration of the primary organization.
Permission required:
* /permission/admin/manage/identity/configmgt/view
Scope required:
* internal_config_mgt_view ", response = Config.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Discovery" }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Successful response.", response = Config.class), + @ApiResponse(code = 401, message = "Authentication information is missing or invalid.", response = Void.class), + @ApiResponse(code = 403, message = "Access forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "Requested resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal server error.", response = Error.class) + }) + public Response getDiscoveryConfig() { + + return delegate.getDiscoveryConfig(); + } + +} diff --git a/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/organization/configs/v1/OrganizationConfigsApiService.java b/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/organization/configs/v1/OrganizationConfigsApiService.java new file mode 100644 index 0000000000..50ebed2842 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/organization/configs/v1/OrganizationConfigsApiService.java @@ -0,0 +1,39 @@ +/* + * 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.configs.v1; + +import org.wso2.carbon.identity.api.server.organization.configs.v1.*; +import org.wso2.carbon.identity.api.server.organization.configs.v1.model.*; +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.organization.configs.v1.model.Config; +import org.wso2.carbon.identity.api.server.organization.configs.v1.model.Error; +import javax.ws.rs.core.Response; + + +public interface OrganizationConfigsApiService { + + public Response createDiscoveryConfig(Config config); + + public Response deleteDiscoveryConfig(); + + public Response getDiscoveryConfig(); +} diff --git a/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/organization/configs/v1/factories/OrganizationConfigsApiServiceFactory.java b/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/organization/configs/v1/factories/OrganizationConfigsApiServiceFactory.java new file mode 100644 index 0000000000..ca10ec7642 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/organization/configs/v1/factories/OrganizationConfigsApiServiceFactory.java @@ -0,0 +1,32 @@ +/* + * 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.configs.v1.factories; + +import org.wso2.carbon.identity.api.server.organization.configs.v1.OrganizationConfigsApiService; +import org.wso2.carbon.identity.api.server.organization.configs.v1.impl.OrganizationConfigsApiServiceImpl; + +public class OrganizationConfigsApiServiceFactory { + + private final static OrganizationConfigsApiService service = new OrganizationConfigsApiServiceImpl(); + + public static OrganizationConfigsApiService getOrganizationConfigsApi() + { + return service; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/organization/configs/v1/model/Config.java b/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/organization/configs/v1/model/Config.java new file mode 100644 index 0000000000..85dd410826 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/organization/configs/v1/model/Config.java @@ -0,0 +1,109 @@ +/* + * 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.configs.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import org.wso2.carbon.identity.api.server.organization.configs.v1.model.Properties; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class Config { + + private List properties = new ArrayList<>(); + + + /** + **/ + public Config properties(List properties) { + + this.properties = properties; + return this; + } + + @ApiModelProperty(required = true, value = "") + @JsonProperty("properties") + @Valid + @NotNull(message = "Property properties cannot be null.") + + public List getProperties() { + return properties; + } + public void setProperties(List properties) { + this.properties = properties; + } + + public Config addPropertiesItem(Properties propertiesItem) { + this.properties.add(propertiesItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Config config = (Config) o; + return Objects.equals(this.properties, config.properties); + } + + @Override + public int hashCode() { + return Objects.hash(properties); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class Config {\n"); + + sb.append(" properties: ").append(toIndentedString(properties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/organization/configs/v1/model/Error.java b/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/organization/configs/v1/model/Error.java new file mode 100644 index 0000000000..97b40a27ce --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/organization/configs/v1/model/Error.java @@ -0,0 +1,169 @@ +/* + * 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.configs.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class Error { + + private String code; + private String message; + private String description; + private String traceId; + + /** + * An error code. + **/ + public Error code(String code) { + + this.code = code; + return this; + } + + @ApiModelProperty(example = "OCM-00000", required = true, value = "An error code.") + @JsonProperty("code") + @Valid + @NotNull(message = "Property code cannot be null.") + + public String getCode() { + return code; + } + public void setCode(String code) { + this.code = code; + } + + /** + * An error message. + **/ + public Error message(String message) { + + this.message = message; + return this; + } + + @ApiModelProperty(example = "Some Error Message", required = true, value = "An error message.") + @JsonProperty("message") + @Valid + @NotNull(message = "Property message cannot be null.") + + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + + /** + * An error description. + **/ + public Error description(String description) { + + this.description = description; + return this; + } + + @ApiModelProperty(example = "Some Error Description", value = "An error description.") + @JsonProperty("description") + @Valid + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + + /** + * An error trace identifier. + **/ + public Error traceId(String traceId) { + + this.traceId = traceId; + return this; + } + + @ApiModelProperty(example = "e0fbcfeb-3617-43c4-8dd0-7b7d38e13047", value = "An error trace identifier.") + @JsonProperty("traceId") + @Valid + public String getTraceId() { + return traceId; + } + public void setTraceId(String traceId) { + this.traceId = traceId; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Error error = (Error) o; + return Objects.equals(this.code, error.code) && + Objects.equals(this.message, error.message) && + Objects.equals(this.description, error.description) && + Objects.equals(this.traceId, error.traceId); + } + + @Override + public int hashCode() { + return Objects.hash(code, message, description, traceId); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class Error {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" traceId: ").append(toIndentedString(traceId)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/organization/configs/v1/model/Properties.java b/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/organization/configs/v1/model/Properties.java new file mode 100644 index 0000000000..3e01c3f9b9 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/organization/configs/v1/model/Properties.java @@ -0,0 +1,123 @@ +/* + * 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.configs.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class Properties { + + private String key; + private String value; + + /** + **/ + public Properties key(String key) { + + this.key = key; + return this; + } + + @ApiModelProperty(example = "emailDomain.enable", required = true, value = "") + @JsonProperty("key") + @Valid + @NotNull(message = "Property key cannot be null.") + + public String getKey() { + return key; + } + public void setKey(String key) { + this.key = key; + } + + /** + **/ + public Properties value(String value) { + + this.value = value; + return this; + } + + @ApiModelProperty(example = "true", required = true, value = "") + @JsonProperty("value") + @Valid + @NotNull(message = "Property value cannot be null.") + + public String getValue() { + return value; + } + public void setValue(String value) { + this.value = value; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Properties properties = (Properties) o; + return Objects.equals(this.key, properties.key) && + Objects.equals(this.value, properties.value); + } + + @Override + public int hashCode() { + return Objects.hash(key, value); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class Properties {\n"); + + sb.append(" key: ").append(toIndentedString(key)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/organization/configs/v1/core/OrganizationConfigsService.java b/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/organization/configs/v1/core/OrganizationConfigsService.java new file mode 100644 index 0000000000..a9d1d68f19 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/organization/configs/v1/core/OrganizationConfigsService.java @@ -0,0 +1,136 @@ +/* + * 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.configs.v1.core; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +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.organization.configs.common.OrganizationConfigsServiceHolder; +import org.wso2.carbon.identity.api.server.organization.configs.v1.model.Config; +import org.wso2.carbon.identity.api.server.organization.configs.v1.model.Properties; +import org.wso2.carbon.identity.organization.config.service.exception.OrganizationConfigClientException; +import org.wso2.carbon.identity.organization.config.service.exception.OrganizationConfigException; +import org.wso2.carbon.identity.organization.config.service.model.ConfigProperty; +import org.wso2.carbon.identity.organization.config.service.model.DiscoveryConfig; + +import java.util.List; +import java.util.stream.Collectors; + +import javax.ws.rs.core.Response; + +import static org.wso2.carbon.identity.organization.config.service.constant.OrganizationConfigConstants.ErrorMessages.ERROR_CODE_DISCOVERY_CONFIG_CONFLICT; +import static org.wso2.carbon.identity.organization.config.service.constant.OrganizationConfigConstants.ErrorMessages.ERROR_CODE_DISCOVERY_CONFIG_NOT_EXIST; + +/** + * Perform organization configuration management related operations. + */ +public class OrganizationConfigsService { + + private static final Log LOG = LogFactory.getLog(OrganizationConfigsService.class); + + /** + * Add the organization discovery configuration in the primary organization. + * + * @param config The organization discovery configuration. + */ + public void addDiscoveryConfiguration(Config config) { + + List configProperties = config.getProperties().stream() + .map(property -> new ConfigProperty(property.getKey(), property.getValue())) + .collect(Collectors.toList()); + try { + OrganizationConfigsServiceHolder.getOrganizationConfigManager().addDiscoveryConfiguration + (new DiscoveryConfig(configProperties)); + } catch (OrganizationConfigException e) { + throw handleException(e); + } + } + + /** + * Fetch organization discovery configuration. + * + * @return The organization discovery configuration. + */ + public Config getDiscoveryConfiguration() { + + try { + DiscoveryConfig discoveryConfig = OrganizationConfigsServiceHolder.getOrganizationConfigManager() + .getDiscoveryConfiguration(); + + List properties = discoveryConfig.getConfigProperties().stream() + .map(configProperty -> { + Properties prop = new Properties(); + prop.setKey(configProperty.getKey()); + prop.setValue(configProperty.getValue()); + return prop; + }).collect(Collectors.toList()); + Config config = new Config(); + config.setProperties(properties); + return config; + } catch (OrganizationConfigException e) { + throw handleException(e); + } + } + + /** + * Delete the organization discovery configuration. + */ + public void deleteDiscoveryConfiguration() { + + try { + OrganizationConfigsServiceHolder.getOrganizationConfigManager().deleteDiscoveryConfiguration(); + } catch (OrganizationConfigException e) { + throw handleException(e); + } + } + + private APIError handleException(OrganizationConfigException e) { + + if (e instanceof OrganizationConfigClientException) { + throw buildClientError(e); + } + throw buildServerError(e); + } + + private APIError buildClientError(OrganizationConfigException e) { + + String errorCode = e.getErrorCode(); + ErrorResponse errorResponse = new ErrorResponse.Builder().withCode(e.getErrorCode()).withMessage(e.getMessage()) + .withDescription(e.getDescription()).build(LOG, e.getMessage()); + + Response.Status status = Response.Status.BAD_REQUEST; + if (ERROR_CODE_DISCOVERY_CONFIG_CONFLICT.getCode().equals(errorCode)) { + status = Response.Status.CONFLICT; + } else if (ERROR_CODE_DISCOVERY_CONFIG_NOT_EXIST.getCode().equals(errorCode)) { + status = Response.Status.NOT_FOUND; + } + return new APIError(status, errorResponse); + } + + private APIError buildServerError(OrganizationConfigException e) { + + String errorCode = e.getErrorCode(); + ErrorResponse errorResponse = new ErrorResponse.Builder().withCode(errorCode).withMessage(e.getMessage()) + .withDescription(e.getDescription()).build(LOG, e, e.getMessage()); + + Response.Status status = Response.Status.INTERNAL_SERVER_ERROR; + return new APIError(status, errorResponse); + } +} diff --git a/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/organization/configs/v1/impl/OrganizationConfigsApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/organization/configs/v1/impl/OrganizationConfigsApiServiceImpl.java new file mode 100644 index 0000000000..91451087d0 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/organization/configs/v1/impl/OrganizationConfigsApiServiceImpl.java @@ -0,0 +1,55 @@ +/* + * 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.configs.v1.impl; + +import org.springframework.beans.factory.annotation.Autowired; +import org.wso2.carbon.identity.api.server.organization.configs.v1.OrganizationConfigsApiService; +import org.wso2.carbon.identity.api.server.organization.configs.v1.core.OrganizationConfigsService; +import org.wso2.carbon.identity.api.server.organization.configs.v1.model.Config; + +import javax.ws.rs.core.Response; + +/** + * Implementation of the organization configuration REST API. + */ +public class OrganizationConfigsApiServiceImpl implements OrganizationConfigsApiService { + + @Autowired + private OrganizationConfigsService organizationConfigsService; + + @Override + public Response createDiscoveryConfig(Config config) { + + organizationConfigsService.addDiscoveryConfiguration(config); + return Response.status(Response.Status.CREATED).entity(config).build(); + } + + @Override + public Response deleteDiscoveryConfig() { + + organizationConfigsService.deleteDiscoveryConfiguration(); + return Response.noContent().build(); + } + + @Override + public Response getDiscoveryConfig() { + + return Response.ok().entity(organizationConfigsService.getDiscoveryConfiguration()).build(); + } +} diff --git a/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/src/main/resources/META-INF/cxf/organization-configs-server-v1-cxf.xml b/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/src/main/resources/META-INF/cxf/organization-configs-server-v1-cxf.xml new file mode 100644 index 0000000000..a9f987b127 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/src/main/resources/META-INF/cxf/organization-configs-server-v1-cxf.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + diff --git a/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/src/main/resources/organization-configs.yaml b/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/src/main/resources/organization-configs.yaml new file mode 100644 index 0000000000..32550834c2 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.organization.configs/org.wso2.carbon.identity.api.server.organization.configs.v1/src/main/resources/organization-configs.yaml @@ -0,0 +1,193 @@ +openapi: 3.0.0 +info: + title: WSO2 Identity Server - Organization Configuration API Definition + description: This document specifies a **RESTful API** for **WSO2 Identity Server Organization Configurations** + contact: + name: WSO2 + url: http://wso2.com/products/identity-server/ + email: iam-dev@wso2.org + license: + name: Apache 2.0 + url: http://www.apache.org/licenses/LICENSE-2.0.html + version: "v1" +servers: + - url: 'https://localhost:9443/o/{organization-domain}/api/server/v1' + variables: + organization-domain: + default: 10084a8d-113f-4211-a0d5-efe36b082211 +security: + - OAuth2: [] + - BasicAuth: [] + +paths: + /organization-configs/discovery: + get: + tags: + - Discovery + summary: Get organization discovery configuration. + description: | + This API facilitates the retrieval of discovery configuration of the primary organization.
+ Permission required:
+ * /permission/admin/manage/identity/configmgt/view
+ Scope required:
+ * internal_config_mgt_view + operationId: getDiscoveryConfig + responses: + '200': + description: Successful response. + content: + application/json: + schema: + $ref: '#/components/schemas/Config' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + post: + tags: + - Discovery + summary: Add organization discovery configuration. + description: | + This API provides the capability to add discovery configuration for the primary organization.
+ Permission required:
+ * /permission/admin/manage/identity/configmgt/add
+ Scope required:
+ * internal_config_mgt_add + operationId: createDiscoveryConfig + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Config' + responses: + '201': + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/Config' + '400': + $ref: '#/components/responses/BadRequest' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '409': + $ref: '#/components/responses/Conflict' + '500': + $ref: '#/components/responses/ServerError' + delete: + tags: + - Discovery + summary: Delete organization discovery configuration. + description: | + This API provides the capability to delete discovery configuration of the primary organization.
+ Permission required:
+ * /permission/admin/manage/identity/configmgt/delete
+ Scope required:
+ * internal_config_mgt_delete + operationId: deleteDiscoveryConfig + responses: + '204': + $ref: '#/components/responses/NoContent' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '500': + $ref: '#/components/responses/ServerError' + +components: + schemas: + Error: + type: object + required: + - code + - message + properties: + code: + type: string + example: OCM-00000 + description: An error code. + message: + type: string + example: Some Error Message + description: An error message. + description: + type: string + example: Some Error Description + description: An error description. + traceId: + type: string + example: e0fbcfeb-3617-43c4-8dd0-7b7d38e13047 + description: An error trace identifier. + + Config: + type: object + required: + - properties + properties: + properties: + type: array + items: + $ref: '#/components/schemas/Properties' + Properties: + required: + - key + - value + type: object + properties: + key: + type: string + example: emailDomain.enable + value: + type: string + example: true + + responses: + BadRequest: + description: Invalid input in the request. + content: + 'application/json': + schema: + $ref: '#/components/schemas/Error' + NotFound: + description: Requested resource is not found. + content: + 'application/json': + schema: + $ref: '#/components/schemas/Error' + Conflict: + description: Resource already exists. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + NoContent: + description: No content. + Unauthorized: + description: Authentication information is missing or invalid. + Forbidden: + description: Access forbidden. + ServerError: + description: Internal server error. + content: + 'application/json': + schema: + $ref: '#/components/schemas/Error' + + securitySchemes: + BasicAuth: + type: http + scheme: basic + OAuth2: + type: oauth2 + flows: + authorizationCode: + authorizationUrl: https://localhost:9443/oauth2/authorize + tokenUrl: https://localhost:9443/oauth2/token + scopes: {} diff --git a/components/org.wso2.carbon.identity.api.server.organization.configs/pom.xml b/components/org.wso2.carbon.identity.api.server.organization.configs/pom.xml new file mode 100644 index 0000000000..a87da65a8e --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.organization.configs/pom.xml @@ -0,0 +1,37 @@ + + + + + + identity-api-server + org.wso2.carbon.identity.server.api + 1.2.85-SNAPSHOT + ../../pom.xml + + + 4.0.0 + org.wso2.carbon.identity.api.server.organization.configs + + pom + + + org.wso2.carbon.identity.api.server.organization.configs.common + org.wso2.carbon.identity.api.server.organization.configs.v1 + + diff --git a/components/org.wso2.carbon.identity.api.server.organization.management/org.wso2.carbon.identity.api.server.organization.management.common/pom.xml b/components/org.wso2.carbon.identity.api.server.organization.management/org.wso2.carbon.identity.api.server.organization.management.common/pom.xml index 0612e3636b..3caca39bac 100644 --- a/components/org.wso2.carbon.identity.api.server.organization.management/org.wso2.carbon.identity.api.server.organization.management.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.organization.management/org.wso2.carbon.identity.api.server.organization.management.common/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.organization.management - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.organization.management/org.wso2.carbon.identity.api.server.organization.management.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.organization.management/org.wso2.carbon.identity.api.server.organization.management.v1/pom.xml index 4ae7bd7944..5fdbc3e9d3 100644 --- a/components/org.wso2.carbon.identity.api.server.organization.management/org.wso2.carbon.identity.api.server.organization.management.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.organization.management/org.wso2.carbon.identity.api.server.organization.management.v1/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.organization.management - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.organization.management/pom.xml b/components/org.wso2.carbon.identity.api.server.organization.management/pom.xml index 41a27c50bc..a62c7c8874 100644 --- a/components/org.wso2.carbon.identity.api.server.organization.management/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.organization.management/pom.xml @@ -21,7 +21,7 @@ identity-api-server org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.organization.role.management/org.wso2.carbon.identity.api.server.organization.role.management.common/pom.xml b/components/org.wso2.carbon.identity.api.server.organization.role.management/org.wso2.carbon.identity.api.server.organization.role.management.common/pom.xml index 3e4f0d0f58..be831c71b6 100644 --- a/components/org.wso2.carbon.identity.api.server.organization.role.management/org.wso2.carbon.identity.api.server.organization.role.management.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.organization.role.management/org.wso2.carbon.identity.api.server.organization.role.management.common/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.organization.role.management - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.organization.role.management/org.wso2.carbon.identity.api.server.organization.role.management.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.organization.role.management/org.wso2.carbon.identity.api.server.organization.role.management.v1/pom.xml index dd0e2a878a..252ff3f6eb 100644 --- a/components/org.wso2.carbon.identity.api.server.organization.role.management/org.wso2.carbon.identity.api.server.organization.role.management.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.organization.role.management/org.wso2.carbon.identity.api.server.organization.role.management.v1/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.organization.role.management - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.organization.role.management/pom.xml b/components/org.wso2.carbon.identity.api.server.organization.role.management/pom.xml index b0910d334a..9768caf213 100644 --- a/components/org.wso2.carbon.identity.api.server.organization.role.management/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.organization.role.management/pom.xml @@ -21,7 +21,7 @@ identity-api-server org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.organization.user.invitation.management/org.wso2.carbon.identity.api.server.organization.user.invitation.management.common/pom.xml b/components/org.wso2.carbon.identity.api.server.organization.user.invitation.management/org.wso2.carbon.identity.api.server.organization.user.invitation.management.common/pom.xml index c7a8f7ccb7..b6f75f5b74 100644 --- a/components/org.wso2.carbon.identity.api.server.organization.user.invitation.management/org.wso2.carbon.identity.api.server.organization.user.invitation.management.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.organization.user.invitation.management/org.wso2.carbon.identity.api.server.organization.user.invitation.management.common/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.organization.user.invitation.management - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.organization.user.invitation.management/org.wso2.carbon.identity.api.server.organization.user.invitation.management.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.organization.user.invitation.management/org.wso2.carbon.identity.api.server.organization.user.invitation.management.v1/pom.xml index 8e029b805c..a34a5c7c3d 100644 --- a/components/org.wso2.carbon.identity.api.server.organization.user.invitation.management/org.wso2.carbon.identity.api.server.organization.user.invitation.management.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.organization.user.invitation.management/org.wso2.carbon.identity.api.server.organization.user.invitation.management.v1/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.organization.user.invitation.management - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.organization.user.invitation.management/pom.xml b/components/org.wso2.carbon.identity.api.server.organization.user.invitation.management/pom.xml index 9274a2a1c1..123999696e 100644 --- a/components/org.wso2.carbon.identity.api.server.organization.user.invitation.management/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.organization.user.invitation.management/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.identity.server.api identity-api-server - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.permission.management/org.wso2.carbon.identity.api.server.permission.management.common/pom.xml b/components/org.wso2.carbon.identity.api.server.permission.management/org.wso2.carbon.identity.api.server.permission.management.common/pom.xml index 77753e7187..080b723189 100644 --- a/components/org.wso2.carbon.identity.api.server.permission.management/org.wso2.carbon.identity.api.server.permission.management.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.permission.management/org.wso2.carbon.identity.api.server.permission.management.common/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.permission.management ../pom.xml - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT WSO2 Identity Server - Common Permission Management WSO2 Identity Server - PCommon Permission Management diff --git a/components/org.wso2.carbon.identity.api.server.permission.management/org.wso2.carbon.identity.api.server.permission.management.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.permission.management/org.wso2.carbon.identity.api.server.permission.management.v1/pom.xml index bd52d77bf8..313954fd12 100644 --- a/components/org.wso2.carbon.identity.api.server.permission.management/org.wso2.carbon.identity.api.server.permission.management.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.permission.management/org.wso2.carbon.identity.api.server.permission.management.v1/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.permission.management ../pom.xml - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT 4.0.0 org.wso2.carbon.identity.api.server.permission.management.v1 diff --git a/components/org.wso2.carbon.identity.api.server.permission.management/pom.xml b/components/org.wso2.carbon.identity.api.server.permission.management/pom.xml index b7db6e5130..24f0dcf7eb 100644 --- a/components/org.wso2.carbon.identity.api.server.permission.management/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.permission.management/pom.xml @@ -21,7 +21,7 @@ identity-api-server org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.script.library/org.wso2.carbon.identity.api.server.script.library.common/pom.xml b/components/org.wso2.carbon.identity.api.server.script.library/org.wso2.carbon.identity.api.server.script.library.common/pom.xml index 4aa9df1666..df67a20d33 100644 --- a/components/org.wso2.carbon.identity.api.server.script.library/org.wso2.carbon.identity.api.server.script.library.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.script.library/org.wso2.carbon.identity.api.server.script.library.common/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.identity.api.server.script.library org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.script.library/org.wso2.carbon.identity.api.server.script.library.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.script.library/org.wso2.carbon.identity.api.server.script.library.v1/pom.xml index 9f88c19816..5f736c7f08 100644 --- a/components/org.wso2.carbon.identity.api.server.script.library/org.wso2.carbon.identity.api.server.script.library.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.script.library/org.wso2.carbon.identity.api.server.script.library.v1/pom.xml @@ -20,7 +20,7 @@ identity-api-server org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.script.library/pom.xml b/components/org.wso2.carbon.identity.api.server.script.library/pom.xml index c37a6886de..1e0453588a 100644 --- a/components/org.wso2.carbon.identity.api.server.script.library/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.script.library/pom.xml @@ -20,7 +20,7 @@ identity-api-server org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.secret.management/org.wso2.carbon.identity.api.server.secret.management.common/pom.xml b/components/org.wso2.carbon.identity.api.server.secret.management/org.wso2.carbon.identity.api.server.secret.management.common/pom.xml index 72d592edc5..b9ef9ad503 100644 --- a/components/org.wso2.carbon.identity.api.server.secret.management/org.wso2.carbon.identity.api.server.secret.management.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.secret.management/org.wso2.carbon.identity.api.server.secret.management.common/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.secret.management - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.secret.management/org.wso2.carbon.identity.api.server.secret.management.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.secret.management/org.wso2.carbon.identity.api.server.secret.management.v1/pom.xml index 808a484b6c..ac55fbc855 100644 --- a/components/org.wso2.carbon.identity.api.server.secret.management/org.wso2.carbon.identity.api.server.secret.management.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.secret.management/org.wso2.carbon.identity.api.server.secret.management.v1/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.secret.management - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.secret.management/pom.xml b/components/org.wso2.carbon.identity.api.server.secret.management/pom.xml index be7addcc36..2229aa7b29 100644 --- a/components/org.wso2.carbon.identity.api.server.secret.management/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.secret.management/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.server.api identity-api-server - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.tenant.management/org.wso2.carbon.identity.api.server.tenant.management.common/pom.xml b/components/org.wso2.carbon.identity.api.server.tenant.management/org.wso2.carbon.identity.api.server.tenant.management.common/pom.xml index 951297580a..96bf4b0094 100644 --- a/components/org.wso2.carbon.identity.api.server.tenant.management/org.wso2.carbon.identity.api.server.tenant.management.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.tenant.management/org.wso2.carbon.identity.api.server.tenant.management.common/pom.xml @@ -18,7 +18,7 @@ org.wso2.carbon.identity.api.server.tenant.management org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.tenant.management/org.wso2.carbon.identity.api.server.tenant.management.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.tenant.management/org.wso2.carbon.identity.api.server.tenant.management.v1/pom.xml index 84637dc3e2..b33bbd5744 100644 --- a/components/org.wso2.carbon.identity.api.server.tenant.management/org.wso2.carbon.identity.api.server.tenant.management.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.tenant.management/org.wso2.carbon.identity.api.server.tenant.management.v1/pom.xml @@ -18,7 +18,7 @@ identity-api-server org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.tenant.management/pom.xml b/components/org.wso2.carbon.identity.api.server.tenant.management/pom.xml index fb516fb02f..dfc74461c7 100644 --- a/components/org.wso2.carbon.identity.api.server.tenant.management/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.tenant.management/pom.xml @@ -18,7 +18,7 @@ identity-api-server org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.userstore/org.wso2.carbon.identity.api.server.userstore.common/pom.xml b/components/org.wso2.carbon.identity.api.server.userstore/org.wso2.carbon.identity.api.server.userstore.common/pom.xml index 35eab550c6..cbde43c307 100644 --- a/components/org.wso2.carbon.identity.api.server.userstore/org.wso2.carbon.identity.api.server.userstore.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.userstore/org.wso2.carbon.identity.api.server.userstore.common/pom.xml @@ -18,7 +18,7 @@ org.wso2.carbon.identity.api.server.userstore org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.userstore/org.wso2.carbon.identity.api.server.userstore.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.userstore/org.wso2.carbon.identity.api.server.userstore.v1/pom.xml index 94341e475b..5f0dc61e5d 100644 --- a/components/org.wso2.carbon.identity.api.server.userstore/org.wso2.carbon.identity.api.server.userstore.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.userstore/org.wso2.carbon.identity.api.server.userstore.v1/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.userstore ../pom.xml - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT 4.0.0 org.wso2.carbon.identity.api.server.userstore.v1 diff --git a/components/org.wso2.carbon.identity.api.server.userstore/org.wso2.carbon.identity.api.server.userstore.v1/src/main/java/org/wso2/carbon/identity/api/server/userstore/v1/core/ServerUserStoreService.java b/components/org.wso2.carbon.identity.api.server.userstore/org.wso2.carbon.identity.api.server.userstore.v1/src/main/java/org/wso2/carbon/identity/api/server/userstore/v1/core/ServerUserStoreService.java index 2fea6c2b1c..f4726e3218 100644 --- a/components/org.wso2.carbon.identity.api.server.userstore/org.wso2.carbon.identity.api.server.userstore.v1/src/main/java/org/wso2/carbon/identity/api/server/userstore/v1/core/ServerUserStoreService.java +++ b/components/org.wso2.carbon.identity.api.server.userstore/org.wso2.carbon.identity.api.server.userstore.v1/src/main/java/org/wso2/carbon/identity/api/server/userstore/v1/core/ServerUserStoreService.java @@ -80,6 +80,8 @@ import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.constructor.Constructor; import org.yaml.snakeyaml.error.YAMLException; +import org.yaml.snakeyaml.inspector.TagInspector; +import org.yaml.snakeyaml.inspector.TrustedPrefixesTagInspector; import java.io.IOException; import java.io.InputStream; @@ -1661,7 +1663,14 @@ private UserStoreConfigurations parseUserStoreFromXml(FileContent fileContent) t private UserStoreConfigurations parseUserStoreFromYaml(FileContent fileContent) throws UserStoreException { try { - Yaml yaml = new Yaml(new Constructor(UserStoreConfigurations.class, new LoaderOptions())); + // Add trusted tags included in the Userstore YAML files. + List trustedTagList = new ArrayList<>(); + trustedTagList.add(UserStoreConfigurations.class.getName()); + + LoaderOptions loaderOptions = new LoaderOptions(); + TagInspector tagInspector = new TrustedPrefixesTagInspector(trustedTagList); + loaderOptions.setTagInspector(tagInspector); + Yaml yaml = new Yaml(new Constructor(UserStoreConfigurations.class, loaderOptions)); return yaml.loadAs(fileContent.getContent(), UserStoreConfigurations.class); } catch (YAMLException e) { throw new UserStoreException(String.format("Error in reading YAML file " + diff --git a/components/org.wso2.carbon.identity.api.server.userstore/pom.xml b/components/org.wso2.carbon.identity.api.server.userstore/pom.xml index 8d2cd35f46..209a632b3b 100644 --- a/components/org.wso2.carbon.identity.api.server.userstore/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.userstore/pom.xml @@ -21,7 +21,7 @@ identity-api-server org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.workflow.engine/org.wso2.carbon.identity.rest.api.server.workflow.engine.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.workflow.engine/org.wso2.carbon.identity.rest.api.server.workflow.engine.v1/pom.xml index 267edc8345..f9dbe4e215 100644 --- a/components/org.wso2.carbon.identity.api.server.workflow.engine/org.wso2.carbon.identity.rest.api.server.workflow.engine.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.workflow.engine/org.wso2.carbon.identity.rest.api.server.workflow.engine.v1/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.workflow.engine ../pom.xml - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.workflow.engine/pom.xml b/components/org.wso2.carbon.identity.api.server.workflow.engine/pom.xml index d795402818..afea4930f4 100644 --- a/components/org.wso2.carbon.identity.api.server.workflow.engine/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.workflow.engine/pom.xml @@ -19,7 +19,7 @@ identity-api-server org.wso2.carbon.identity.server.api - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/pom.xml b/pom.xml index a2faff35d3..a66b3a1bf1 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ 4.0.0 identity-api-server pom - 1.2.81-SNAPSHOT + 1.2.85-SNAPSHOT WSO2 Identity Server - Server API Module @@ -191,6 +191,12 @@ ${carbon.identity.framework.version} provided + + org.wso2.carbon.identity.framework + org.wso2.carbon.identity.api.resource.mgt + ${carbon.identity.framework.version} + provided + org.wso2.carbon.identity.framework org.wso2.carbon.identity.application.tag.mgt @@ -402,7 +408,7 @@ org.wso2.carbon.identity.server.api - org.wso2.carbon.identity.api.server.application.tag.management.common + ${project.version} provided @@ -555,6 +561,12 @@ ${org.wso2.carbon.identity.organization.management.version} provided + + org.wso2.carbon.identity.organization.management + org.wso2.carbon.identity.organization.config.service + ${org.wso2.carbon.identity.organization.management.version} + provided + org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.organization.management.common @@ -610,6 +622,12 @@ org.wso2.carbon.identity.api.idle.account.identification.common ${project.version} + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.organization.configs.common + ${project.version} + provided + org.apache.felix org.apache.felix.scr.ds-annotations @@ -747,7 +765,7 @@ - 1.3.61 + 1.3.70 @@ -787,8 +805,9 @@ components/org.wso2.carbon.identity.api.idle.account.identification components/org.wso2.carbon.identity.api.expired.password.identification components/org.wso2.carbon.identity.api.server.organization.user.invitation.management + components/org.wso2.carbon.identity.api.server.api.resource + components/org.wso2.carbon.identity.api.server.organization.configs components/org.wso2.carbon.identity.api.server.application.tag.management - components/AAAXtra