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 990d077b7d..56c4f6d3e8 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.258-SNAPSHOT + 1.3.11-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 a1532b11d2..2961593d51 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.258-SNAPSHOT + 1.3.11-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 df7a4339db..6411e12cab 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.258-SNAPSHOT + 1.3.11-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 9b68611b91..a7bd6396b7 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.258-SNAPSHOT + 1.3.11-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 aea6bcf1ce..ad99e75027 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.258-SNAPSHOT + 1.3.11-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 0685f97d86..8d8445fd9f 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.258-SNAPSHOT + 1.3.11-SNAPSHOT ../../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.common/pom.xml b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.common/pom.xml index bed7730b8b..9573dfd3e8 100644 --- a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.common/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.action.management - 1.2.258-SNAPSHOT + 1.3.11-SNAPSHOT ../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.common/src/main/java/org/wso2/carbon/identity/api/server/action/management/common/ActionManagementServiceHolder.java b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.common/src/main/java/org/wso2/carbon/identity/api/server/action/management/common/ActionManagementServiceHolder.java index f5cb787494..29b0acfadf 100644 --- a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.common/src/main/java/org/wso2/carbon/identity/api/server/action/management/common/ActionManagementServiceHolder.java +++ b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.common/src/main/java/org/wso2/carbon/identity/api/server/action/management/common/ActionManagementServiceHolder.java @@ -18,7 +18,7 @@ package org.wso2.carbon.identity.api.server.action.management.common; -import org.wso2.carbon.identity.action.management.ActionManagementService; +import org.wso2.carbon.identity.action.management.service.ActionManagementService; /** * Service holder class for action management. diff --git a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.common/src/main/java/org/wso2/carbon/identity/api/server/action/management/common/factory/ActionMgtOSGiServiceFactory.java b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.common/src/main/java/org/wso2/carbon/identity/api/server/action/management/common/factory/ActionMgtOSGiServiceFactory.java index 3cd4a9a4f3..0b9059d145 100644 --- a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.common/src/main/java/org/wso2/carbon/identity/api/server/action/management/common/factory/ActionMgtOSGiServiceFactory.java +++ b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.common/src/main/java/org/wso2/carbon/identity/api/server/action/management/common/factory/ActionMgtOSGiServiceFactory.java @@ -20,7 +20,7 @@ import org.springframework.beans.factory.config.AbstractFactoryBean; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.identity.action.management.ActionManagementService; +import org.wso2.carbon.identity.action.management.service.ActionManagementService; /** * Factory class for ActionManagementOSGiService. diff --git a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/pom.xml index 9f76464c8a..289bb8a1aa 100644 --- a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.action.management - 1.2.258-SNAPSHOT + 1.3.11-SNAPSHOT ../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/action/management/v1/ActionBasicResponse.java b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/action/management/v1/ActionBasicResponse.java index c031530a1e..283466df93 100644 --- a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/action/management/v1/ActionBasicResponse.java +++ b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/action/management/v1/ActionBasicResponse.java @@ -22,7 +22,10 @@ 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.action.management.v1.ActionType; +import org.wso2.carbon.identity.api.server.action.management.v1.Link; import javax.validation.constraints.*; @@ -71,6 +74,8 @@ public static StatusEnum fromValue(String value) { } private StatusEnum status; + private List links = null; + /** **/ @@ -162,7 +167,33 @@ public void setStatus(StatusEnum status) { this.status = status; } + /** + **/ + public ActionBasicResponse links(List links) { + this.links = links; + return this; + } + + @ApiModelProperty(example = "[{\"href\":\"/t/wso2.com/api/server/v1/actions/preIssueAccessToken/24f64d17-9824-4e28-8413-de45728d8e84\",\"method\":\"GET\",\"rel\":\"self\"}]", value = "") + @JsonProperty("links") + @Valid + public List getLinks() { + return links; + } + public void setLinks(List links) { + this.links = links; + } + + public ActionBasicResponse addLinksItem(Link linksItem) { + if (this.links == null) { + this.links = new ArrayList(); + } + this.links.add(linksItem); + return this; + } + + @Override public boolean equals(java.lang.Object o) { @@ -178,12 +209,13 @@ public boolean equals(java.lang.Object o) { Objects.equals(this.type, actionBasicResponse.type) && Objects.equals(this.name, actionBasicResponse.name) && Objects.equals(this.description, actionBasicResponse.description) && - Objects.equals(this.status, actionBasicResponse.status); + Objects.equals(this.status, actionBasicResponse.status) && + Objects.equals(this.links, actionBasicResponse.links); } @Override public int hashCode() { - return Objects.hash(id, type, name, description, status); + return Objects.hash(id, type, name, description, status, links); } @Override @@ -197,6 +229,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" description: ").append(toIndentedString(description)).append("\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" links: ").append(toIndentedString(links)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/action/management/v1/ActionsApi.java b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/action/management/v1/ActionsApi.java index aaf7b86748..288b185b9d 100644 --- a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/action/management/v1/ActionsApi.java +++ b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/action/management/v1/ActionsApi.java @@ -199,14 +199,14 @@ public Response getActionTypes() { @Path("/{actionType}") @Produces({ "application/json" }) - @ApiOperation(value = "List action ", notes = "This API provides the capability to retrieve the action by action type.
Scope required:
* internal_action_mgt_view ", response = ActionResponse.class, responseContainer = "List", authorizations = { + @ApiOperation(value = "List action ", notes = "This API provides the capability to retrieve the action by action type.
Scope required:
* internal_action_mgt_view ", response = ActionBasicResponse.class, responseContainer = "List", authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) }, tags={ "Actions", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "OK", response = ActionResponse.class, responseContainer = "List"), + @ApiResponse(code = 200, message = "OK", response = ActionBasicResponse.class, responseContainer = "List"), @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), diff --git a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/action/management/v1/Link.java b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/action/management/v1/Link.java new file mode 100644 index 0000000000..13bda75e41 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/action/management/v1/Link.java @@ -0,0 +1,176 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.action.management.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 Link { + + private String href; + +@XmlType(name="MethodEnum") +@XmlEnum(String.class) +public enum MethodEnum { + + @XmlEnumValue("GET") GET(String.valueOf("GET")); + + + private String value; + + MethodEnum(String v) { + value = v; + } + + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static MethodEnum fromValue(String value) { + for (MethodEnum b : MethodEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + + private MethodEnum method; + private String rel; + + /** + * Url of the endpoint. + **/ + public Link href(String href) { + + this.href = href; + return this; + } + + @ApiModelProperty(value = "Url of the endpoint.") + @JsonProperty("href") + @Valid + public String getHref() { + return href; + } + public void setHref(String href) { + this.href = href; + } + + /** + * Http method. + **/ + public Link method(MethodEnum method) { + + this.method = method; + return this; + } + + @ApiModelProperty(value = "Http method.") + @JsonProperty("method") + @Valid + public MethodEnum getMethod() { + return method; + } + public void setMethod(MethodEnum method) { + this.method = method; + } + + /** + * Relation to the resource. + **/ + public Link rel(String rel) { + + this.rel = rel; + return this; + } + + @ApiModelProperty(value = "Relation to the resource.") + @JsonProperty("rel") + @Valid + public String getRel() { + return rel; + } + public void setRel(String rel) { + this.rel = rel; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Link link = (Link) o; + return Objects.equals(this.href, link.href) && + Objects.equals(this.method, link.method) && + Objects.equals(this.rel, link.rel); + } + + @Override + public int hashCode() { + return Objects.hash(href, method, rel); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class Link {\n"); + + sb.append(" href: ").append(toIndentedString(href)).append("\n"); + sb.append(" method: ").append(toIndentedString(method)).append("\n"); + sb.append(" rel: ").append(toIndentedString(rel)).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.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/constants/ActionMgtEndpointConstants.java b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/constants/ActionMgtEndpointConstants.java index bdff584ecd..bbfc205c9e 100644 --- a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/constants/ActionMgtEndpointConstants.java +++ b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/constants/ActionMgtEndpointConstants.java @@ -28,7 +28,7 @@ private ActionMgtEndpointConstants() { public static final String ACTION_MANAGEMENT_PREFIX = "ACTION-"; public static final String ACTION_PATH_COMPONENT = "/actions"; - public static final String PATH_CONSTANT = "/"; + public static final String PATH_SEPARATOR = "/"; /** * Enum for error messages. diff --git a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/core/ServerActionManagementService.java b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/core/ServerActionManagementService.java index b10f734377..bf0989fe43 100644 --- a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/core/ServerActionManagementService.java +++ b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/core/ServerActionManagementService.java @@ -35,6 +35,8 @@ import org.wso2.carbon.identity.api.server.action.management.v1.ActionUpdateModel; import org.wso2.carbon.identity.api.server.action.management.v1.AuthenticationTypeResponse; import org.wso2.carbon.identity.api.server.action.management.v1.EndpointResponse; +import org.wso2.carbon.identity.api.server.action.management.v1.Link; +import org.wso2.carbon.identity.api.server.action.management.v1.constants.ActionMgtEndpointConstants; import org.wso2.carbon.identity.api.server.action.management.v1.util.ActionMgtEndpointUtil; import java.util.ArrayList; @@ -79,7 +81,7 @@ public ActionResponse createAction(String actionType, ActionModel actionModel) { } } - public List getActionsByActionType(String actionType) { + public List getActionsByActionType(String actionType) { try { validateActionType(actionType); @@ -87,11 +89,11 @@ public List getActionsByActionType(String actionType) { .getActionsByActionType(actionType, CarbonContext.getThreadLocalCarbonContext().getTenantDomain()); - List actionResponses = new ArrayList<>(); + List actionBasicResponses = new ArrayList<>(); for (Action action : actions) { - actionResponses.add(buildActionResponse(action)); + actionBasicResponses.add(buildActionBasicResponse(action)); } - return actionResponses; + return actionBasicResponses; } catch (ActionMgtException e) { throw ActionMgtEndpointUtil.handleActionMgtException(e); } @@ -226,7 +228,26 @@ private ActionBasicResponse buildActionBasicResponse(Action activatedAction) { .type(ActionType.valueOf(activatedAction.getType().toString())) .name(activatedAction.getName()) .description(activatedAction.getDescription()) - .status(ActionBasicResponse.StatusEnum.valueOf(activatedAction.getStatus().toString())); + .status(ActionBasicResponse.StatusEnum.valueOf(activatedAction.getStatus().toString())) + .links(buildLinks(activatedAction)); + } + + /** + * Build Links for the Action. + * + * @param activatedAction Action object. + * @return List of Links. + */ + private List buildLinks(Action activatedAction) { + + String baseUrl = ActionMgtEndpointUtil.buildURIForActionType(activatedAction.getType().getActionType()); + + List links = new ArrayList<>(); + links.add(new Link() + .href(baseUrl + ActionMgtEndpointConstants.PATH_SEPARATOR + activatedAction.getId()) + .rel("self") + .method(Link.MethodEnum.GET)); + return links; } /** diff --git a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/util/ActionMgtEndpointUtil.java b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/util/ActionMgtEndpointUtil.java index 9b530fac49..e2f854d9b2 100644 --- a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/util/ActionMgtEndpointUtil.java +++ b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/util/ActionMgtEndpointUtil.java @@ -31,9 +31,9 @@ import javax.ws.rs.core.Response; -import static org.wso2.carbon.identity.action.management.constant.ActionMgtConstants.ErrorMessages.ERROR_NO_ACTION_CONFIGURED_ON_GIVEN_ACTION_TYPE_AND_ID; +import static org.wso2.carbon.identity.action.management.constant.error.ErrorMessage.ERROR_NO_ACTION_CONFIGURED_ON_GIVEN_ACTION_TYPE_AND_ID; import static org.wso2.carbon.identity.api.server.action.management.v1.constants.ActionMgtEndpointConstants.ACTION_PATH_COMPONENT; -import static org.wso2.carbon.identity.api.server.action.management.v1.constants.ActionMgtEndpointConstants.PATH_CONSTANT; +import static org.wso2.carbon.identity.api.server.action.management.v1.constants.ActionMgtEndpointConstants.PATH_SEPARATOR; import static org.wso2.carbon.identity.api.server.common.Constants.ERROR_CODE_DELIMITER; /** @@ -43,7 +43,7 @@ public class ActionMgtEndpointUtil { private static final Log LOG = LogFactory.getLog(ActionMgtEndpointUtil.class); private static final String ACTION_TYPE_LINK_FORMAT = Constants.V1_API_PATH_COMPONENT + ACTION_PATH_COMPONENT - + PATH_CONSTANT; + + PATH_SEPARATOR; public static String buildURIForActionType(String actionType) { diff --git a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/resources/Actions.yaml b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/resources/Actions.yaml index d3f5c6e00d..87f66088c5 100644 --- a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/resources/Actions.yaml +++ b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/resources/Actions.yaml @@ -596,11 +596,34 @@ components: enum: - ACTIVE - INACTIVE + links: + type: array + items: + $ref: '#/components/schemas/Link' + example: + - href: "/t/wso2.com/api/server/v1/actions/preIssueAccessToken/24f64d17-9824-4e28-8413-de45728d8e84" + method: GET + rel: self + + Link: + type: object + properties: + href: + type: string + description: Url of the endpoint. + method: + type: string + enum: + - GET + description: Http method. + rel: + type: string + description: Relation to the resource. ActionResponseList: type: array items: - $ref: '#/components/schemas/ActionResponse' + $ref: '#/components/schemas/ActionBasicResponse' ActionTypesResponse: type: array diff --git a/components/org.wso2.carbon.identity.api.server.action.management/pom.xml b/components/org.wso2.carbon.identity.api.server.action.management/pom.xml index 5d66cb9092..8ecbd910b3 100644 --- a/components/org.wso2.carbon.identity.api.server.action.management/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.action.management/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.identity.server.api identity-api-server - 1.2.258-SNAPSHOT + 1.3.11-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 c8e77ae158..e82b10cae6 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.258-SNAPSHOT + 1.3.11-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 08b13c822f..f85069d7a3 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.258-SNAPSHOT + 1.3.11-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 6fcbb5a347..67d0ffd67a 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.258-SNAPSHOT + 1.3.11-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 index aa7a16e909..2ed8f65bd6 100644 --- 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 @@ -22,7 +22,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.api.resource - 1.2.258-SNAPSHOT + 1.3.11-SNAPSHOT ../pom.xml 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 index 557f568e41..c84fd02758 100644 --- 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 @@ -22,7 +22,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.api.resource - 1.2.258-SNAPSHOT + 1.3.11-SNAPSHOT ../pom.xml 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 index 67a082afcd..577f3c7127 100644 --- a/components/org.wso2.carbon.identity.api.server.api.resource/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.api.resource/pom.xml @@ -22,7 +22,7 @@ identity-api-server org.wso2.carbon.identity.server.api - 1.2.258-SNAPSHOT + 1.3.11-SNAPSHOT ../../pom.xml 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 0fe7be67ab..4128cb891c 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.258-SNAPSHOT + 1.3.11-SNAPSHOT ../pom.xml org.wso2.carbon.identity.api.server.application.management.common - 1.2.258-SNAPSHOT + 1.3.11-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 28fec6e551..b71380052b 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.258-SNAPSHOT + 1.3.11-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.258-SNAPSHOT + 1.3.11-SNAPSHOT jar 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 c828eeb27f..057ee43ef0 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.258-SNAPSHOT + 1.3.11-SNAPSHOT ../../pom.xml org.wso2.carbon.identity.api.server.application.management - 1.2.258-SNAPSHOT + 1.3.11-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 e00b4f1cb7..0d21ffd532 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.258-SNAPSHOT + 1.3.11-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 c2d4269338..5477a2a958 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.258-SNAPSHOT + 1.3.11-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 e3a90b0a52..52dddf732b 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.258-SNAPSHOT + 1.3.11-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 62c2d02995..c4ccf62d4e 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.258-SNAPSHOT + 1.3.11-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 0b9e826d8f..e31d0a5366 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.258-SNAPSHOT + 1.3.11-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 385138f486..586e8d1539 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.258-SNAPSHOT + 1.3.11-SNAPSHOT ../../pom.xml 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 a3c4213a32..5bbc34f800 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.258-SNAPSHOT + 1.3.11-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.api.server.claim.management.common/src/main/java/org/wso2/carbon/identity/api/server/claim/management/common/Constant.java b/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.api.server.claim.management.common/src/main/java/org/wso2/carbon/identity/api/server/claim/management/common/Constant.java index 75e33ecc37..b12bcd1022 100644 --- a/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.api.server.claim.management.common/src/main/java/org/wso2/carbon/identity/api/server/claim/management/common/Constant.java +++ b/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.api.server.claim.management.common/src/main/java/org/wso2/carbon/identity/api/server/claim/management/common/Constant.java @@ -278,4 +278,5 @@ public String toString() { public static final String PROP_REG_EX = "RegEx"; public static final String PROP_REQUIRED = "Required"; public static final String PROP_SUPPORTED_BY_DEFAULT = "SupportedByDefault"; + public static final String PROP_UNIQUENESS_SCOPE = "UniquenessScope"; } 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 925363ab81..2bf732e18c 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.258-SNAPSHOT + 1.3.11-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/gen/java/org/wso2/carbon/identity/rest/api/server/claim/management/v1/dto/LocalClaimReqDTO.java b/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/claim/management/v1/dto/LocalClaimReqDTO.java index 2f2edc432e..a459ac03e6 100644 --- a/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/claim/management/v1/dto/LocalClaimReqDTO.java +++ b/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/claim/management/v1/dto/LocalClaimReqDTO.java @@ -60,6 +60,12 @@ public class LocalClaimReqDTO { @Valid private Boolean supportedByDefault = null; + public enum UniquenessScopeEnum { + NONE, WITHIN_USERSTORE, ACROSS_USERSTORES, + }; + @Valid + private UniquenessScopeEnum uniquenessScope = null; + @Valid @NotNull(message = "Property attributeMapping cannot be null.") private List attributeMapping = new ArrayList(); @@ -163,6 +169,18 @@ public void setSupportedByDefault(Boolean supportedByDefault) { this.supportedByDefault = supportedByDefault; } + /** + * Specifies the scope of uniqueness validation for the claim value. + **/ + @ApiModelProperty(value = "Specifies the scope of uniqueness validation for the claim value.") + @JsonProperty("uniquenessScope") + public UniquenessScopeEnum getUniquenessScope() { + return uniquenessScope; + } + public void setUniquenessScope(UniquenessScopeEnum uniquenessScope) { + this.uniquenessScope = uniquenessScope; + } + /** * Userstore attribute mappings. **/ @@ -201,6 +219,7 @@ public String toString() { sb.append(" regEx: ").append(regEx).append("\n"); sb.append(" required: ").append(required).append("\n"); sb.append(" supportedByDefault: ").append(supportedByDefault).append("\n"); + sb.append(" uniquenessScope: ").append(uniquenessScope).append("\n"); sb.append(" attributeMapping: ").append(attributeMapping).append("\n"); sb.append(" properties: ").append(properties).append("\n"); diff --git a/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/claim/management/v1/dto/LocalClaimResDTO.java b/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/claim/management/v1/dto/LocalClaimResDTO.java index 99aeca5f84..3b576aeff0 100644 --- a/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/claim/management/v1/dto/LocalClaimResDTO.java +++ b/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/claim/management/v1/dto/LocalClaimResDTO.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.List; import org.wso2.carbon.identity.rest.api.server.claim.management.v1.dto.AttributeMappingDTO; +import org.wso2.carbon.identity.rest.api.server.claim.management.v1.dto.ClaimResDTO; import org.wso2.carbon.identity.rest.api.server.claim.management.v1.dto.PropertyDTO; import io.swagger.annotations.*; import com.fasterxml.jackson.annotation.*; @@ -64,6 +65,12 @@ public class LocalClaimResDTO extends ClaimResDTO { @Valid private Boolean supportedByDefault = null; + public enum UniquenessScopeEnum { + NONE, WITHIN_USERSTORE, ACROSS_USERSTORES, + }; + @Valid + private UniquenessScopeEnum uniquenessScope = null; + @Valid private List attributeMapping = new ArrayList(); @@ -190,6 +197,18 @@ public void setSupportedByDefault(Boolean supportedByDefault) { this.supportedByDefault = supportedByDefault; } + /** + * Specifies the scope of uniqueness validation for the claim value. + **/ + @ApiModelProperty(value = "Specifies the scope of uniqueness validation for the claim value.") + @JsonProperty("uniquenessScope") + public UniquenessScopeEnum getUniquenessScope() { + return uniquenessScope; + } + public void setUniquenessScope(UniquenessScopeEnum uniquenessScope) { + this.uniquenessScope = uniquenessScope; + } + /** * Userstore attribute mappings. **/ @@ -231,6 +250,7 @@ public String toString() { sb.append(" regEx: ").append(regEx).append("\n"); sb.append(" required: ").append(required).append("\n"); sb.append(" supportedByDefault: ").append(supportedByDefault).append("\n"); + sb.append(" uniquenessScope: ").append(uniquenessScope).append("\n"); sb.append(" attributeMapping: ").append(attributeMapping).append("\n"); sb.append(" properties: ").append(properties).append("\n"); 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 1afbe00801..c46f671351 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 @@ -130,6 +130,7 @@ import static org.wso2.carbon.identity.api.server.claim.management.common.Constant.PROP_REG_EX; import static org.wso2.carbon.identity.api.server.claim.management.common.Constant.PROP_REQUIRED; import static org.wso2.carbon.identity.api.server.claim.management.common.Constant.PROP_SUPPORTED_BY_DEFAULT; +import static org.wso2.carbon.identity.api.server.claim.management.common.Constant.PROP_UNIQUENESS_SCOPE; import static org.wso2.carbon.identity.api.server.common.Constants.JSON_FILE_EXTENSION; import static org.wso2.carbon.identity.api.server.common.Constants.MEDIA_TYPE_JSON; import static org.wso2.carbon.identity.api.server.common.Constants.MEDIA_TYPE_XML; @@ -1001,6 +1002,15 @@ private LocalClaimResDTO getLocalClaimResDTO(LocalClaim localClaim) { localClaimResDTO.setRequired(Boolean.valueOf(claimProperties.remove(PROP_REQUIRED))); localClaimResDTO.setSupportedByDefault(Boolean.valueOf(claimProperties.remove(PROP_SUPPORTED_BY_DEFAULT))); + String uniquenessScope = claimProperties.remove(PROP_UNIQUENESS_SCOPE); + if (StringUtils.isNotBlank(uniquenessScope)) { + try { + localClaimResDTO.setUniquenessScope(LocalClaimResDTO.UniquenessScopeEnum.valueOf(uniquenessScope)); + } catch (IllegalArgumentException e) { + localClaimResDTO.setUniquenessScope(LocalClaimResDTO.UniquenessScopeEnum.NONE); + } + } + List attributeMappingDTOs = new ArrayList<>(); for (AttributeMapping attributeMapping : localClaim.getMappedAttributes()) { AttributeMappingDTO attributeMappingDTO = new AttributeMappingDTO(); @@ -1049,6 +1059,10 @@ private LocalClaim createLocalClaim(LocalClaimReqDTO localClaimReqDTO) { claimProperties.put(PROP_DISPLAY_ORDER, "0"); } + if (localClaimReqDTO.getUniquenessScope() != null) { + claimProperties.put(PROP_UNIQUENESS_SCOPE, localClaimReqDTO.getUniquenessScope().toString()); + } + claimProperties.put(PROP_READ_ONLY, String.valueOf(localClaimReqDTO.getReadOnly())); claimProperties.put(PROP_REQUIRED, String.valueOf(localClaimReqDTO.getRequired())); claimProperties.put(PROP_SUPPORTED_BY_DEFAULT, String.valueOf(localClaimReqDTO.getSupportedByDefault())); diff --git a/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/src/main/resources/claim-management.yaml b/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/src/main/resources/claim-management.yaml index 6231037ef2..348a24bdad 100644 --- a/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/src/main/resources/claim-management.yaml +++ b/components/org.wso2.carbon.identity.api.server.claim.management/org.wso2.carbon.identity.rest.api.server.claim.management.v1/src/main/resources/claim-management.yaml @@ -736,6 +736,14 @@ definitions: type: boolean description: Specifies if the claim will be prompted during user registration and displayed on the user profile. example: true + uniquenessScope: + type: string + description: Specifies the scope of uniqueness validation for the claim value. + enum: + - NONE + - WITHIN_USERSTORE + - ACROSS_USERSTORES + example: "NONE" attributeMapping: type: array description: Userstore attribute mappings. @@ -796,6 +804,14 @@ definitions: type: boolean description: Specifies if the claim will be prompted during user registration and displayed on the user profile. example: true + uniquenessScope: + type: string + description: Specifies the scope of uniqueness validation for the claim value. + enum: + - NONE + - WITHIN_USERSTORE + - ACROSS_USERSTORES + example: "NONE" attributeMapping: type: array description: Userstore attribute mappings. 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 4201f68e96..3734e51114 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.258-SNAPSHOT + 1.3.11-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 1ac1a970c6..7c8c6fec45 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.258-SNAPSHOT + 1.3.11-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.common/src/main/java/org/wso2/carbon/identity/api/server/common/Util.java b/components/org.wso2.carbon.identity.api.server.common/src/main/java/org/wso2/carbon/identity/api/server/common/Util.java index 47cc7b0782..c62d3efa51 100644 --- a/components/org.wso2.carbon.identity.api.server.common/src/main/java/org/wso2/carbon/identity/api/server/common/Util.java +++ b/components/org.wso2.carbon.identity.api.server.common/src/main/java/org/wso2/carbon/identity/api/server/common/Util.java @@ -181,11 +181,17 @@ public static Map buildPaginationLinks(int limit, int currentOff private static int calculateOffsetForPreviousLink(int offset, int limit, int total) { + if (limit <= 0) { + // If limit is 0 or negative, consider it as 0 and build the previous page. + return offset; + } + int newOffset = (offset - limit); if (newOffset < total) { return newOffset; } + // If offset is greater than total, go back by the chunks of limit until a proper page is found. return calculateOffsetForPreviousLink(newOffset, limit, total); } 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 09f38c45aa..18065fa28b 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.258-SNAPSHOT + 1.3.11-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 6ca8bf7e5f..aef5cb2932 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.258-SNAPSHOT + 1.3.11-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 75b0e79cf0..d0f6bac5ca 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.258-SNAPSHOT + 1.3.11-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 db15ec28ec..d2118c9ca7 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.258-SNAPSHOT + 1.3.11-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 02955f20f3..a1efb7cb84 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.258-SNAPSHOT + 1.3.11-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 f0268b50f4..e0fa9b3f6a 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.258-SNAPSHOT + 1.3.11-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 d0c507b4d4..176e4ab12a 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.258-SNAPSHOT + 1.3.11-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 9a764f314f..6a2b1f0d77 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.258-SNAPSHOT + 1.3.11-SNAPSHOT ../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/pom.xml b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/pom.xml index d52c5bbaaf..6b5c564e5a 100644 --- a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.email.template - 1.2.258-SNAPSHOT + 1.3.11-SNAPSHOT 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/gen/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/EmailApi.java b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/gen/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/EmailApi.java index a45f9ac026..479479d70e 100644 --- a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/gen/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/EmailApi.java +++ b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/gen/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/EmailApi.java @@ -233,9 +233,9 @@ public Response getAllEmailTemplateTypes( @Valid @Min(0)@ApiParam(value = "Ma @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getAppEmailTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @Valid @Min(0)@ApiParam(value = "Maximum number of records to return. _This option is not yet supported._") @QueryParam("limit") Integer limit, @Valid @Min(0)@ApiParam(value = "Number of records to skip for pagination. _This option is not yet supported._") @QueryParam("offset") Integer offset, @Valid@ApiParam(value = "Define the order in which the retrieved records should be sorted. _This option is not yet supported._", allowableValues="asc, desc") @QueryParam("sortOrder") String sortOrder, @Valid@ApiParam(value = "Attribute by which the retrieved records should be sorted. _This option is not yet supported._") @QueryParam("sortBy") String sortBy) { + public Response getAppEmailTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @Valid@ApiParam(value = "Specifies whether to return resolved template/s throughout the ancestor organization hierarchy.", defaultValue="false") @DefaultValue("false") @QueryParam("resolve") Boolean resolve, @Valid @Min(0)@ApiParam(value = "Maximum number of records to return. _This option is not yet supported._") @QueryParam("limit") Integer limit, @Valid @Min(0)@ApiParam(value = "Number of records to skip for pagination. _This option is not yet supported._") @QueryParam("offset") Integer offset, @Valid@ApiParam(value = "Define the order in which the retrieved records should be sorted. _This option is not yet supported._", allowableValues="asc, desc") @QueryParam("sortOrder") String sortOrder, @Valid@ApiParam(value = "Attribute by which the retrieved records should be sorted. _This option is not yet supported._") @QueryParam("sortBy") String sortBy) { - return delegate.getAppEmailTemplate(templateTypeId, appUuid, locale, limit, offset, sortOrder, sortBy ); + return delegate.getAppEmailTemplate(templateTypeId, appUuid, locale, resolve, limit, offset, sortOrder, sortBy ); } @Valid @@ -257,9 +257,9 @@ public Response getAppEmailTemplate(@ApiParam(value = "Email Template Type ID.", @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getAppTemplatesListOfEmailTemplateType(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @Valid @Min(0)@ApiParam(value = "Maximum number of records to return. _This option is not yet supported._") @QueryParam("limit") Integer limit, @Valid @Min(0)@ApiParam(value = "Number of records to skip for pagination. _This option is not yet supported._") @QueryParam("offset") Integer offset, @Valid@ApiParam(value = "Define the order in which the retrieved records should be sorted. _This option is not yet supported._", allowableValues="asc, desc") @QueryParam("sortOrder") String sortOrder, @Valid@ApiParam(value = "Attribute by which the retrieved records should be sorted. _This option is not yet supported._") @QueryParam("sortBy") String sortBy) { + public Response getAppTemplatesListOfEmailTemplateType(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @Valid@ApiParam(value = "Specifies whether to return resolved template/s throughout the ancestor organization hierarchy.", defaultValue="false") @DefaultValue("false") @QueryParam("resolve") Boolean resolve, @Valid @Min(0)@ApiParam(value = "Maximum number of records to return. _This option is not yet supported._") @QueryParam("limit") Integer limit, @Valid @Min(0)@ApiParam(value = "Number of records to skip for pagination. _This option is not yet supported._") @QueryParam("offset") Integer offset, @Valid@ApiParam(value = "Define the order in which the retrieved records should be sorted. _This option is not yet supported._", allowableValues="asc, desc") @QueryParam("sortOrder") String sortOrder, @Valid@ApiParam(value = "Attribute by which the retrieved records should be sorted. _This option is not yet supported._") @QueryParam("sortBy") String sortBy) { - return delegate.getAppTemplatesListOfEmailTemplateType(templateTypeId, appUuid, limit, offset, sortOrder, sortBy ); + return delegate.getAppTemplatesListOfEmailTemplateType(templateTypeId, appUuid, resolve, limit, offset, sortOrder, sortBy ); } @Valid diff --git a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/gen/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/EmailApiService.java b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/gen/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/EmailApiService.java index d4ee3c4bf9..6bf416c7ce 100644 --- a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/gen/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/EmailApiService.java +++ b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/gen/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/EmailApiService.java @@ -49,9 +49,9 @@ public interface EmailApiService { public Response getAllEmailTemplateTypes(Integer limit, Integer offset, String sortOrder, String sortBy); - public Response getAppEmailTemplate(String templateTypeId, String appUuid, String locale, Integer limit, Integer offset, String sortOrder, String sortBy); + public Response getAppEmailTemplate(String templateTypeId, String appUuid, String locale, Boolean resolve, Integer limit, Integer offset, String sortOrder, String sortBy); - public Response getAppTemplatesListOfEmailTemplateType(String templateTypeId, String appUuid, Integer limit, Integer offset, String sortOrder, String sortBy); + public Response getAppTemplatesListOfEmailTemplateType(String templateTypeId, String appUuid, Boolean resolve, Integer limit, Integer offset, String sortOrder, String sortBy); public Response getEmailTemplateType(String templateTypeId); diff --git a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/core/ApplicationEmailTemplatesService.java b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/core/ApplicationEmailTemplatesService.java index 05ad5fc07d..7692fdd9c3 100644 --- a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/core/ApplicationEmailTemplatesService.java +++ b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/core/ApplicationEmailTemplatesService.java @@ -62,6 +62,7 @@ public class ApplicationEmailTemplatesService { * @param templateTypeId Email template type id. * @param templateId Email template id. * @param applicationUuid Application UUID. + * @param resolve Whether to retrieve the template resolved through the ancestor organization hierarchy. * @param limit Limit the number of email template types in the response. **Not supported at the moment** * @param offset Offset to be used with the limit parameter. **Not supported at the moment** * @param sortOrder Sort the response in ascending order or descending order. **Not supported at the moment** @@ -69,7 +70,7 @@ public class ApplicationEmailTemplatesService { * @return Email template identified by the given template-type-id and the template-id, 404 if not found. */ public EmailTemplateWithID getEmailTemplate(String templateTypeId, String templateId, String applicationUuid, - Integer limit, Integer offset, + boolean resolve, Integer limit, Integer offset, String sortOrder, String sortBy) { handleNotSupportedParameters(limit, offset, sortOrder, sortBy); @@ -79,7 +80,7 @@ public EmailTemplateWithID getEmailTemplate(String templateTypeId, String templa templateId = I18nEmailUtil.normalizeLocaleFormat(templateId); EmailTemplate internalEmailTemplate = EmailTemplatesServiceHolder.getEmailTemplateManager(). getEmailTemplate(templateTypeDisplayName, templateId, - getTenantDomainFromContext(), applicationUuid); + getTenantDomainFromContext(), applicationUuid, resolve); // EmailTemplateManager sends the default template if no matching template found. We need to check for // the locale specifically. if (!internalEmailTemplate.getLocale().equals(templateId)) { @@ -97,6 +98,8 @@ public EmailTemplateWithID getEmailTemplate(String templateTypeId, String templa * * @param templateTypeId Email template type id. * @param applicationUuid Application UUID. + * @param resolve Whether to retrieve templates resolved through the ancestor organization hierarchy, + * returning templates that are applicable across the tenant's organizational structure. * @param limit Limit the number of email template types in the response. **Not supported at the moment** * @param offset Offset to be used with the limit parameter. **Not supported at the moment** * @param sortOrder Sort the response in ascending order or descending order. **Not supported at the moment** @@ -104,6 +107,7 @@ public EmailTemplateWithID getEmailTemplate(String templateTypeId, String templa * @return List of SimpleEmailTemplate objects in the template type identified by the given id, 404 if not found. */ public List getTemplatesListOfEmailTemplateType(String templateTypeId, String applicationUuid, + boolean resolve, Integer limit, Integer offset, String sortOrder, String sortBy) { @@ -111,8 +115,9 @@ public List getTemplatesListOfEmailTemplateType(String temp String templateTypeDisplayName = decodeTemplateTypeId(templateTypeId); try { - List internalEmailTemplates = EmailTemplatesServiceHolder.getEmailTemplateManager(). - getEmailTemplateType(templateTypeDisplayName, getTenantDomainFromContext(), applicationUuid); + List internalEmailTemplates = + EmailTemplatesServiceHolder.getEmailTemplateManager().getEmailTemplateType( + templateTypeDisplayName, getTenantDomainFromContext(), applicationUuid, resolve); return buildSimpleEmailTemplatesList(internalEmailTemplates, templateTypeId, applicationUuid); } catch (I18nEmailMgtException e) { if (StringUtils.equals(I18nMgtConstants.ErrorCodes.EMAIL_TEMPLATE_TYPE_NOT_FOUND, e.getErrorCode())) { @@ -137,7 +142,7 @@ public SimpleEmailTemplate addEmailTemplate( try { boolean isTemplateExists = EmailTemplatesServiceHolder.getEmailTemplateManager() .isEmailTemplateExists(templateTypeDisplayName, emailTemplateWithID.getLocale(), - getTenantDomainFromContext(), applicationUuid); + getTenantDomainFromContext(), applicationUuid, false); if (!isTemplateExists) { // Email template is new, hence add to the system. addEmailTemplateToTheSystem(templateTypeDisplayName, emailTemplateWithID, applicationUuid); @@ -174,7 +179,7 @@ public void deleteEmailTemplate(String templateTypeId, String templateId, String } try { boolean isTemplateExists = EmailTemplatesServiceHolder.getEmailTemplateManager().isEmailTemplateExists( - templateTypeDisplayName, templateId, getTenantDomainFromContext(), applicationUuid); + templateTypeDisplayName, templateId, getTenantDomainFromContext(), applicationUuid, false); if (isTemplateExists) { EmailTemplatesServiceHolder.getEmailTemplateManager().deleteEmailTemplate(templateTypeDisplayName, templateId, getTenantDomainFromContext(), applicationUuid); @@ -224,9 +229,11 @@ public void updateEmailTemplate(String templateTypeId, String templateId, EmailT String templateTypeDisplayName = decodeTemplateTypeId(templateTypeId); try { - // Check whether the email template exists, first. + /* Check whether the email template exists, first. Here, resolve param is specified as true since + resolved org templates are returned in GET endpoint, by default. Therefore, resolved template existence + is checked before updating. */ boolean isTemplateExists = EmailTemplatesServiceHolder.getEmailTemplateManager().isEmailTemplateExists( - templateTypeDisplayName, templateId, getTenantDomainFromContext(), applicationUuid); + templateTypeDisplayName, templateId, getTenantDomainFromContext(), applicationUuid, true); if (isTemplateExists) { addEmailTemplateToTheSystem(templateTypeDisplayName, emailTemplateWithID, applicationUuid); } else { diff --git a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/impl/EmailApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/impl/EmailApiServiceImpl.java index 46f0788109..587346fb23 100644 --- a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/impl/EmailApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/impl/EmailApiServiceImpl.java @@ -113,19 +113,22 @@ public Response getAllEmailTemplateTypes(Integer limit, Integer offset, String s } @Override - public Response getAppEmailTemplate(String templateTypeId, String appUuid, String locale, + public Response getAppEmailTemplate(String templateTypeId, String appUuid, String locale, Boolean resolve, Integer limit, Integer offset, String sortOrder, String sortBy) { - return Response.ok().entity(applicationEmailTemplatesService. - getEmailTemplate(templateTypeId, locale, appUuid, limit, offset, sortOrder, sortBy)).build(); + return Response.ok() + .entity(applicationEmailTemplatesService.getEmailTemplate(templateTypeId, locale, appUuid, resolve, + limit, offset, sortOrder, sortBy)).build(); } @Override - public Response getAppTemplatesListOfEmailTemplateType( - String templateTypeId, String appUuid, Integer limit, Integer offset, String sortOrder, String sortBy) { + public Response getAppTemplatesListOfEmailTemplateType(String templateTypeId, String appUuid, Boolean resolve, + Integer limit, Integer offset, String sortOrder, + String sortBy) { - return Response.ok().entity(applicationEmailTemplatesService. - getTemplatesListOfEmailTemplateType(templateTypeId, appUuid, limit, offset, sortOrder, sortBy)).build(); + return Response.ok() + .entity(applicationEmailTemplatesService.getTemplatesListOfEmailTemplateType(templateTypeId, appUuid, + resolve, limit, offset, sortOrder, sortBy)).build(); } @Override diff --git a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/resources/email-template.yml b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/resources/email-template.yml index 0a22ce4e28..bc5907cd3a 100644 --- a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/resources/email-template.yml +++ b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/resources/email-template.yml @@ -260,6 +260,7 @@ paths: parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' + - $ref: '#/components/parameters/resolveQueryParam' - $ref: '#/components/parameters/limitQueryParam' - $ref: '#/components/parameters/offsetQueryParam' - $ref: '#/components/parameters/sortOrderQueryParam' @@ -442,6 +443,7 @@ paths: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' - $ref: '#/components/parameters/localePathParam' + - $ref: '#/components/parameters/resolveQueryParam' - $ref: '#/components/parameters/limitQueryParam' - $ref: '#/components/parameters/offsetQueryParam' - $ref: '#/components/parameters/sortOrderQueryParam' @@ -556,6 +558,14 @@ components: description: Application UUID. schema: type: string + resolveQueryParam: + in: query + name: resolve + required: false + description: Specifies whether to return resolved template/s throughout the ancestor organization hierarchy. + schema: + type: boolean + default: false offsetQueryParam: in: query name: offset 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 44f7c133cb..778de1dac9 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.258-SNAPSHOT + 1.3.11-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 3f0d3baabe..b0906f7a9e 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.258-SNAPSHOT + 1.3.11-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 6ff04e56d2..7de3658979 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.258-SNAPSHOT + 1.3.11-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 725f0ef9fa..e96df25740 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.258-SNAPSHOT + 1.3.11-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 e4ebc8e0d0..5ac932904a 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.258-SNAPSHOT + 1.3.11-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 99d83142f9..bb78b80dca 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.258-SNAPSHOT + 1.3.11-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 ab3bbc38ff..4d7e003aaa 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.258-SNAPSHOT + 1.3.11-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 f4aee60ab7..5cde9a7039 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.258-SNAPSHOT + 1.3.11-SNAPSHOT 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.common/src/main/java/org/wso2/carbon/identity/api/server/idp/common/Constants.java b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.common/src/main/java/org/wso2/carbon/identity/api/server/idp/common/Constants.java index 7d88182eb5..fe30c0eb24 100644 --- a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.common/src/main/java/org/wso2/carbon/identity/api/server/idp/common/Constants.java +++ b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.common/src/main/java/org/wso2/carbon/identity/api/server/idp/common/Constants.java @@ -146,6 +146,20 @@ public enum ErrorMessage { ERROR_CODE_ERROR_LISTING_TRUSTED_TOKEN_ISSUERS("60021", "Unable to list existing trusted token issuers.", "Server encountered an error while listing the trusted token issuers."), + ERROR_CODE_ENDPOINT_PROVIDED_FOR_SYSTEM_AUTH("60039", "No endpoint configuration is allowed.", + "No endpoint configuration must be " + + "provided for the system defined federated authenticators %s."), + ERROR_CODE_PROPERTIES_PROVIDED_FOR_USER_AUTH("60040", "No properties are allowed.", + "No properties must be provided for the user defined " + + "federated authenticators %s."), + ERROR_CODE_NO_ENDPOINT_PROVIDED("60041", "No endpoint provided.", "Endpoint " + + "configuration must be provided for the user defined federated authenticators %s."), + ERROR_CODE_NON_DECODABLE_AUTH_ID("60042", "Non-decodable authenticator ID.", + "Unable to decode the provided authenticator ID %s."), + ERROR_CODE_NO_SYSTEM_AUTHENTICATOR_FOUND("60043", "No system authenticator found.", + "No system authenticator found for the provided authenticator Id %s."), + ERROR_COED_MULTIPLE_USER_DEFINED_AUTHENTICATORS_FOUND("60044", "Multiple authenticators found.", + "Multiple user defined authenticators are not allowed."), // Server Error starting from 650xx. ERROR_CODE_ERROR_ADDING_IDP("65002", 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 5ac8bd6bca..79a3784286 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.258-SNAPSHOT + 1.3.11-SNAPSHOT 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/AuthenticationType.java b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/AuthenticationType.java new file mode 100644 index 0000000000..92dfec771b --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/AuthenticationType.java @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.idp.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.HashMap; +import java.util.List; +import java.util.Map; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class AuthenticationType { + + +@XmlType(name="TypeEnum") +@XmlEnum(String.class) +public enum TypeEnum { + + @XmlEnumValue("NONE") NONE(String.valueOf("NONE")), @XmlEnumValue("BEARER") BEARER(String.valueOf("BEARER")), @XmlEnumValue("API_KEY") API_KEY(String.valueOf("API_KEY")), @XmlEnumValue("BASIC") BASIC(String.valueOf("BASIC")); + + + private String value; + + TypeEnum(String v) { + value = v; + } + + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + + private TypeEnum type; + private Map properties = null; + + + /** + **/ + public AuthenticationType type(TypeEnum type) { + + this.type = type; + return this; + } + + @ApiModelProperty(example = "BASIC", required = true, value = "") + @JsonProperty("type") + @Valid + @NotNull(message = "Property type cannot be null.") + + public TypeEnum getType() { + return type; + } + public void setType(TypeEnum type) { + this.type = type; + } + + /** + **/ + public AuthenticationType properties(Map properties) { + + this.properties = properties; + return this; + } + + @ApiModelProperty(example = "{\"username\":\"auth_username\",\"password\":\"auth_password\"}", value = "") + @JsonProperty("properties") + @Valid + public Map getProperties() { + return properties; + } + public void setProperties(Map properties) { + this.properties = properties; + } + + + public AuthenticationType putPropertiesItem(String key, Object propertiesItem) { + if (this.properties == null) { + this.properties = new HashMap<>(); + } + this.properties.put(key, propertiesItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AuthenticationType authenticationType = (AuthenticationType) o; + return Objects.equals(this.type, authenticationType.type) && + Objects.equals(this.properties, authenticationType.properties); + } + + @Override + public int hashCode() { + return Objects.hash(type, properties); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class AuthenticationType {\n"); + + sb.append(" type: ").append(toIndentedString(type)).append("\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.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/Endpoint.java b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/Endpoint.java new file mode 100644 index 0000000000..9ce553d2ac --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/Endpoint.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.idp.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 org.wso2.carbon.identity.api.server.idp.v1.model.AuthenticationType; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class Endpoint { + + private String uri; + private AuthenticationType authentication; + + /** + **/ + public Endpoint uri(String uri) { + + this.uri = uri; + return this; + } + + @ApiModelProperty(example = "https://abc.com/token", required = true, value = "") + @JsonProperty("uri") + @Valid + @NotNull(message = "Property uri cannot be null.") + @Pattern(regexp="^https?://.+") + public String getUri() { + return uri; + } + public void setUri(String uri) { + this.uri = uri; + } + + /** + **/ + public Endpoint authentication(AuthenticationType authentication) { + + this.authentication = authentication; + return this; + } + + @ApiModelProperty(required = true, value = "") + @JsonProperty("authentication") + @Valid + @NotNull(message = "Property authentication cannot be null.") + + public AuthenticationType getAuthentication() { + return authentication; + } + public void setAuthentication(AuthenticationType authentication) { + this.authentication = authentication; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Endpoint endpoint = (Endpoint) o; + return Objects.equals(this.uri, endpoint.uri) && + Objects.equals(this.authentication, endpoint.authentication); + } + + @Override + public int hashCode() { + return Objects.hash(uri, authentication); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class Endpoint {\n"); + + sb.append(" uri: ").append(toIndentedString(uri)).append("\n"); + sb.append(" authentication: ").append(toIndentedString(authentication)).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.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/FederatedAuthenticator.java b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/FederatedAuthenticator.java index 5996d10619..6ceecbd085 100644 --- a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/FederatedAuthenticator.java +++ b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/FederatedAuthenticator.java @@ -22,6 +22,7 @@ import io.swagger.annotations.ApiModelProperty; import java.util.ArrayList; import java.util.List; +import org.wso2.carbon.identity.api.server.idp.v1.model.Endpoint; import org.wso2.carbon.identity.api.server.idp.v1.model.Property; import javax.validation.constraints.*; @@ -75,6 +76,7 @@ public static DefinedByEnum fromValue(String value) { private List properties = null; + private Endpoint endpoint; /** **/ @@ -220,7 +222,25 @@ public FederatedAuthenticator addPropertiesItem(Property propertiesItem) { return this; } + /** + **/ + public FederatedAuthenticator endpoint(Endpoint endpoint) { + + this.endpoint = endpoint; + return this; + } + @ApiModelProperty(value = "") + @JsonProperty("endpoint") + @Valid + public Endpoint getEndpoint() { + return endpoint; + } + public void setEndpoint(Endpoint endpoint) { + this.endpoint = endpoint; + } + + @Override public boolean equals(java.lang.Object o) { @@ -238,12 +258,13 @@ public boolean equals(java.lang.Object o) { Objects.equals(this.definedBy, federatedAuthenticator.definedBy) && Objects.equals(this.isDefault, federatedAuthenticator.isDefault) && Objects.equals(this.tags, federatedAuthenticator.tags) && - Objects.equals(this.properties, federatedAuthenticator.properties); + Objects.equals(this.properties, federatedAuthenticator.properties) && + Objects.equals(this.endpoint, federatedAuthenticator.endpoint); } @Override public int hashCode() { - return Objects.hash(authenticatorId, name, isEnabled, definedBy, isDefault, tags, properties); + return Objects.hash(authenticatorId, name, isEnabled, definedBy, isDefault, tags, properties, endpoint); } @Override @@ -259,6 +280,7 @@ public String toString() { sb.append(" isDefault: ").append(toIndentedString(isDefault)).append("\n"); sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); sb.append(" properties: ").append(toIndentedString(properties)).append("\n"); + sb.append(" endpoint: ").append(toIndentedString(endpoint)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/FederatedAuthenticatorPUTRequest.java b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/FederatedAuthenticatorPUTRequest.java index 685579c64a..db8b737efb 100644 --- a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/FederatedAuthenticatorPUTRequest.java +++ b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/FederatedAuthenticatorPUTRequest.java @@ -22,6 +22,7 @@ import io.swagger.annotations.ApiModelProperty; import java.util.ArrayList; import java.util.List; +import org.wso2.carbon.identity.api.server.idp.v1.model.Endpoint; import org.wso2.carbon.identity.api.server.idp.v1.model.Property; import javax.validation.constraints.*; @@ -73,6 +74,7 @@ public static DefinedByEnum fromValue(String value) { private DefinedByEnum definedBy; private List properties = null; + private Endpoint endpoint; /** **/ @@ -190,7 +192,25 @@ public FederatedAuthenticatorPUTRequest addPropertiesItem(Property propertiesIte return this; } + /** + **/ + public FederatedAuthenticatorPUTRequest endpoint(Endpoint endpoint) { + + this.endpoint = endpoint; + return this; + } + @ApiModelProperty(value = "") + @JsonProperty("endpoint") + @Valid + public Endpoint getEndpoint() { + return endpoint; + } + public void setEndpoint(Endpoint endpoint) { + this.endpoint = endpoint; + } + + @Override public boolean equals(java.lang.Object o) { @@ -207,12 +227,13 @@ public boolean equals(java.lang.Object o) { Objects.equals(this.isEnabled, federatedAuthenticatorPUTRequest.isEnabled) && Objects.equals(this.isDefault, federatedAuthenticatorPUTRequest.isDefault) && Objects.equals(this.definedBy, federatedAuthenticatorPUTRequest.definedBy) && - Objects.equals(this.properties, federatedAuthenticatorPUTRequest.properties); + Objects.equals(this.properties, federatedAuthenticatorPUTRequest.properties) && + Objects.equals(this.endpoint, federatedAuthenticatorPUTRequest.endpoint); } @Override public int hashCode() { - return Objects.hash(authenticatorId, name, isEnabled, isDefault, definedBy, properties); + return Objects.hash(authenticatorId, name, isEnabled, isDefault, definedBy, properties, endpoint); } @Override @@ -227,6 +248,7 @@ public String toString() { sb.append(" isDefault: ").append(toIndentedString(isDefault)).append("\n"); sb.append(" definedBy: ").append(toIndentedString(definedBy)).append("\n"); sb.append(" properties: ").append(toIndentedString(properties)).append("\n"); + sb.append(" endpoint: ").append(toIndentedString(endpoint)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/FederatedUserDefinedAuthenticator.java b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/FederatedUserDefinedAuthenticator.java new file mode 100644 index 0000000000..465eb5d546 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/FederatedUserDefinedAuthenticator.java @@ -0,0 +1,271 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.idp.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.idp.v1.model.Endpoint; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class FederatedUserDefinedAuthenticator { + + private String authenticatorId; + private String name; + private Boolean isEnabled = false; + +@XmlType(name="DefinedByEnum") +@XmlEnum(String.class) +public enum DefinedByEnum { + + @XmlEnumValue("USER") USER(String.valueOf("USER")); + + + private String value; + + DefinedByEnum(String v) { + value = v; + } + + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static DefinedByEnum fromValue(String value) { + for (DefinedByEnum b : DefinedByEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + + private DefinedByEnum definedBy; + private Boolean isDefault = false; + private List tags = null; + + private Endpoint endpoint; + + /** + **/ + public FederatedUserDefinedAuthenticator authenticatorId(String authenticatorId) { + + this.authenticatorId = authenticatorId; + return this; + } + + @ApiModelProperty(example = "Y3VzdG9tQXV0aGVudGljYXRvcg", required = true, value = "") + @JsonProperty("authenticatorId") + @Valid + @NotNull(message = "Property authenticatorId cannot be null.") + + public String getAuthenticatorId() { + return authenticatorId; + } + public void setAuthenticatorId(String authenticatorId) { + this.authenticatorId = authenticatorId; + } + + /** + **/ + public FederatedUserDefinedAuthenticator name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "customAuthenticator", value = "") + @JsonProperty("name") + @Valid + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + public FederatedUserDefinedAuthenticator isEnabled(Boolean isEnabled) { + + this.isEnabled = isEnabled; + return this; + } + + @ApiModelProperty(example = "true", value = "") + @JsonProperty("isEnabled") + @Valid + public Boolean getIsEnabled() { + return isEnabled; + } + public void setIsEnabled(Boolean isEnabled) { + this.isEnabled = isEnabled; + } + + /** + **/ + public FederatedUserDefinedAuthenticator definedBy(DefinedByEnum definedBy) { + + this.definedBy = definedBy; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("definedBy") + @Valid + public DefinedByEnum getDefinedBy() { + return definedBy; + } + public void setDefinedBy(DefinedByEnum definedBy) { + this.definedBy = definedBy; + } + + /** + **/ + public FederatedUserDefinedAuthenticator isDefault(Boolean isDefault) { + + this.isDefault = isDefault; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("isDefault") + @Valid + public Boolean getIsDefault() { + return isDefault; + } + public void setIsDefault(Boolean isDefault) { + this.isDefault = isDefault; + } + + /** + **/ + public FederatedUserDefinedAuthenticator tags(List tags) { + + this.tags = tags; + return this; + } + + @ApiModelProperty(example = "[\"Custom\"]", value = "") + @JsonProperty("tags") + @Valid + public List getTags() { + return tags; + } + public void setTags(List tags) { + this.tags = tags; + } + + public FederatedUserDefinedAuthenticator addTagsItem(String tagsItem) { + if (this.tags == null) { + this.tags = new ArrayList<>(); + } + this.tags.add(tagsItem); + return this; + } + + /** + **/ + public FederatedUserDefinedAuthenticator endpoint(Endpoint endpoint) { + + this.endpoint = endpoint; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("endpoint") + @Valid + public Endpoint getEndpoint() { + return endpoint; + } + public void setEndpoint(Endpoint endpoint) { + this.endpoint = endpoint; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FederatedUserDefinedAuthenticator federatedUserDefinedAuthenticator = (FederatedUserDefinedAuthenticator) o; + return Objects.equals(this.authenticatorId, federatedUserDefinedAuthenticator.authenticatorId) && + Objects.equals(this.name, federatedUserDefinedAuthenticator.name) && + Objects.equals(this.isEnabled, federatedUserDefinedAuthenticator.isEnabled) && + Objects.equals(this.definedBy, federatedUserDefinedAuthenticator.definedBy) && + Objects.equals(this.isDefault, federatedUserDefinedAuthenticator.isDefault) && + Objects.equals(this.tags, federatedUserDefinedAuthenticator.tags) && + Objects.equals(this.endpoint, federatedUserDefinedAuthenticator.endpoint); + } + + @Override + public int hashCode() { + return Objects.hash(authenticatorId, name, isEnabled, definedBy, isDefault, tags, endpoint); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class FederatedUserDefinedAuthenticator {\n"); + + sb.append(" authenticatorId: ").append(toIndentedString(authenticatorId)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" isEnabled: ").append(toIndentedString(isEnabled)).append("\n"); + sb.append(" definedBy: ").append(toIndentedString(definedBy)).append("\n"); + sb.append(" isDefault: ").append(toIndentedString(isDefault)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" endpoint: ").append(toIndentedString(endpoint)).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.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/FederatedUserDefinedAuthenticatorPUTRequest.java b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/FederatedUserDefinedAuthenticatorPUTRequest.java new file mode 100644 index 0000000000..5825ae4e4e --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/FederatedUserDefinedAuthenticatorPUTRequest.java @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.idp.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 org.wso2.carbon.identity.api.server.idp.v1.model.Endpoint; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class FederatedUserDefinedAuthenticatorPUTRequest { + + private String authenticatorId; + private Boolean isEnabled = false; + private Boolean isDefault = false; + private Endpoint endpoint; + + /** + **/ + public FederatedUserDefinedAuthenticatorPUTRequest authenticatorId(String authenticatorId) { + + this.authenticatorId = authenticatorId; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("authenticatorId") + @Valid + public String getAuthenticatorId() { + return authenticatorId; + } + public void setAuthenticatorId(String authenticatorId) { + this.authenticatorId = authenticatorId; + } + + /** + **/ + public FederatedUserDefinedAuthenticatorPUTRequest isEnabled(Boolean isEnabled) { + + this.isEnabled = isEnabled; + return this; + } + + @ApiModelProperty(example = "true", value = "") + @JsonProperty("isEnabled") + @Valid + public Boolean getIsEnabled() { + return isEnabled; + } + public void setIsEnabled(Boolean isEnabled) { + this.isEnabled = isEnabled; + } + + /** + **/ + public FederatedUserDefinedAuthenticatorPUTRequest isDefault(Boolean isDefault) { + + this.isDefault = isDefault; + return this; + } + + @ApiModelProperty(example = "false", value = "") + @JsonProperty("isDefault") + @Valid + public Boolean getIsDefault() { + return isDefault; + } + public void setIsDefault(Boolean isDefault) { + this.isDefault = isDefault; + } + + /** + **/ + public FederatedUserDefinedAuthenticatorPUTRequest endpoint(Endpoint endpoint) { + + this.endpoint = endpoint; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("endpoint") + @Valid + public Endpoint getEndpoint() { + return endpoint; + } + public void setEndpoint(Endpoint endpoint) { + this.endpoint = endpoint; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FederatedUserDefinedAuthenticatorPUTRequest federatedUserDefinedAuthenticatorPUTRequest = (FederatedUserDefinedAuthenticatorPUTRequest) o; + return Objects.equals(this.authenticatorId, federatedUserDefinedAuthenticatorPUTRequest.authenticatorId) && + Objects.equals(this.isEnabled, federatedUserDefinedAuthenticatorPUTRequest.isEnabled) && + Objects.equals(this.isDefault, federatedUserDefinedAuthenticatorPUTRequest.isDefault) && + Objects.equals(this.endpoint, federatedUserDefinedAuthenticatorPUTRequest.endpoint); + } + + @Override + public int hashCode() { + return Objects.hash(authenticatorId, isEnabled, isDefault, endpoint); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class FederatedUserDefinedAuthenticatorPUTRequest {\n"); + + sb.append(" authenticatorId: ").append(toIndentedString(authenticatorId)).append("\n"); + sb.append(" isEnabled: ").append(toIndentedString(isEnabled)).append("\n"); + sb.append(" isDefault: ").append(toIndentedString(isDefault)).append("\n"); + sb.append(" endpoint: ").append(toIndentedString(endpoint)).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.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 bac516e2d9..4a08eb348c 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 @@ -41,6 +41,7 @@ import org.wso2.carbon.identity.api.server.common.error.ErrorResponse; import org.wso2.carbon.identity.api.server.idp.common.Constants; import org.wso2.carbon.identity.api.server.idp.common.IdentityProviderServiceHolder; +import org.wso2.carbon.identity.api.server.idp.v1.impl.FederatedAuthenticatorConfigBuilderFactory; import org.wso2.carbon.identity.api.server.idp.v1.model.AssociationRequest; import org.wso2.carbon.identity.api.server.idp.v1.model.AssociationResponse; import org.wso2.carbon.identity.api.server.idp.v1.model.Certificate; @@ -93,6 +94,7 @@ import org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig; import org.wso2.carbon.identity.application.common.model.RoleMapping; import org.wso2.carbon.identity.application.common.model.SubProperty; +import org.wso2.carbon.identity.application.common.model.UserDefinedFederatedAuthenticatorConfig; import org.wso2.carbon.identity.application.common.util.IdentityApplicationConstants; import org.wso2.carbon.identity.base.AuthenticatorPropertyConstants.DefinedByType; import org.wso2.carbon.identity.claim.metadata.mgt.exception.ClaimMetadataException; @@ -594,6 +596,8 @@ public FederatedAuthenticatorListResponse getFederatedAuthenticators(String idpI listItem.setAuthenticatorId(fedAuthId); listItem.setName(config.getName()); listItem.setIsEnabled(config.isEnabled()); + listItem.setDefinedBy( + FederatedAuthenticatorListItem.DefinedByEnum.valueOf(config.getDefinedByType().toString())); FederatedAuthenticatorConfig federatedAuthenticatorConfig = ApplicationAuthenticatorService.getInstance().getFederatedAuthenticatorByName( config.getName()); @@ -1695,6 +1699,7 @@ private MetaFederatedAuthenticatorListItem createMetaFederatedAuthenticatorListI String authenticatorId = base64URLEncode(authenticatorConfig.getName()); metaFederatedAuthenticator.setName(authenticatorConfig.getName()); metaFederatedAuthenticator.setAuthenticatorId(authenticatorId); + metaFederatedAuthenticator.setDefinedBy(MetaFederatedAuthenticatorListItem.DefinedByEnum.SYSTEM); FederatedAuthenticatorConfig federatedAuthenticatorConfig = ApplicationAuthenticatorService.getInstance() .getFederatedAuthenticatorByName(authenticatorConfig.getName()); if (federatedAuthenticatorConfig != null) { @@ -1723,6 +1728,7 @@ private MetaFederatedAuthenticator createMetaFederatedAuthenticator(FederatedAut metaFederatedAuthenticator.setTags(Arrays.asList(tags)); } } + metaFederatedAuthenticator.setDefinedBy(MetaFederatedAuthenticator.DefinedByEnum.SYSTEM); Property[] properties = authenticatorConfig.getProperties(); List metaProperties = Arrays.stream(properties).map(propertyToExternalMeta).collect(Collectors .toList()); @@ -1758,7 +1764,8 @@ private MetaOutboundConnector createMetaOutboundConnector(ProvisioningConnectorC } private void updateFederatedAuthenticatorConfig(IdentityProvider idp, FederatedAuthenticatorRequest - federatedAuthenticatorRequest, boolean isNewFederatedAuthenticator) { + federatedAuthenticatorRequest, boolean isNewFederatedAuthenticator) + throws IdentityProviderManagementClientException { if (federatedAuthenticatorRequest != null) { List federatedAuthenticators = federatedAuthenticatorRequest.getAuthenticators(); @@ -1766,34 +1773,21 @@ private void updateFederatedAuthenticatorConfig(IdentityProvider idp, FederatedA FederatedAuthenticatorConfig defaultAuthConfig = null; List fedAuthConfigs = new ArrayList<>(); for (FederatedAuthenticator authenticator : federatedAuthenticators) { - FederatedAuthenticatorConfig authConfig = new FederatedAuthenticatorConfig(); - authConfig.setName(base64URLDecode(authenticator.getAuthenticatorId())); - authConfig.setDisplayName(getDisplayNameOfAuthenticator(authConfig.getName())); - authConfig.setEnabled(authenticator.getIsEnabled()); - - String definedByType = null; - if (authenticator.getDefinedBy() != null) { - definedByType = authenticator.getDefinedBy().toString(); - } - authConfig.setDefinedByType(resolveDefinedByType(authConfig.getName(), - definedByType, isNewFederatedAuthenticator)); - - List authProperties = - authenticator.getProperties(); - if (IdentityApplicationConstants.Authenticator.SAML2SSO.FED_AUTH_NAME.equals(authConfig.getName())) { - validateSamlMetadata(authProperties); + String authenticatorName = getDecodedAuthenticatorName(authenticator.getAuthenticatorId()); + DefinedByType definedByType; + if (isNewFederatedAuthenticator) { + definedByType = resolveDefinedByTypeToCreateFederatedAuthenticator( + authenticator.getDefinedBy()); + } else { + definedByType = resolveDefinedByTypeToUpdateFederatedAuthenticator(authenticatorName); } - if (authProperties != null) { - if (!areAllDistinct(authProperties)) { - throw handleException(Response.Status.BAD_REQUEST, - Constants.ErrorMessage.ERROR_CODE_INVALID_INPUT, " Duplicate properties are found in " + - "the request."); - } - List properties = authProperties.stream() - .map(propertyToInternal) - .collect(Collectors.toList()); - authConfig.setProperties(properties.toArray(new Property[0])); + if (definedByType == DefinedByType.USER && federatedAuthenticators.size() > 1) { + throw handleException(Response.Status.BAD_REQUEST, + Constants.ErrorMessage.ERROR_COED_MULTIPLE_USER_DEFINED_AUTHENTICATORS_FOUND, null); } + FederatedAuthenticatorConfig authConfig = FederatedAuthenticatorConfigBuilderFactory.build( + authenticator, authenticatorName, definedByType); + fedAuthConfigs.add(authConfig); if (StringUtils.equals(defaultAuthenticator, authenticator.getAuthenticatorId())) { @@ -1810,30 +1804,6 @@ private void updateFederatedAuthenticatorConfig(IdentityProvider idp, FederatedA } } - /** - * Returns the 'DisplayName' property of the federated authenticator identified by authenticator name. - * - * @param authenticatorName Federated authenticator name. - * @return Display name of authenticator. - */ - private String getDisplayNameOfAuthenticator(String authenticatorName) { - - try { - FederatedAuthenticatorConfig[] authenticatorConfigs = - IdentityProviderServiceHolder.getIdentityProviderManager() - .getAllFederatedAuthenticators(); - for (FederatedAuthenticatorConfig config : authenticatorConfigs) { - - if (StringUtils.equals(config.getName(), authenticatorName)) { - return config.getDisplayName(); - } - } - } catch (IdentityProviderManagementException e) { - throw handleIdPException(e, Constants.ErrorMessage.ERROR_CODE_ERROR_ADDING_IDP, null); - } - return null; - } - private void updateOutboundConnectorConfig(IdentityProvider idp, OutboundProvisioningRequest outboundProvisioningRequest) { @@ -2079,7 +2049,8 @@ private void updateGroups(IdentityProvider idp, List groups) { return apiProperty; }; - private IdentityProvider createIDP(IdentityProviderPOSTRequest identityProviderPOSTRequest) { + private IdentityProvider createIDP(IdentityProviderPOSTRequest identityProviderPOSTRequest) + throws IdentityProviderManagementClientException { String idpJWKSUri = null; IdentityProvider idp = new IdentityProvider(); @@ -2695,6 +2666,12 @@ private IdentityProvider createIdPClone(IdentityProvider idP) { Gson gson = new Gson(); IdentityProvider clonedIdentityProvider = gson.fromJson(gson.toJson(idP), IdentityProvider.class); + if (idP.getFederatedAuthenticatorConfigs().length == 1 && + idP.getFederatedAuthenticatorConfigs()[0].getDefinedByType() == DefinedByType.USER) { + UserDefinedFederatedAuthenticatorConfig clonedFedAuth = gson.fromJson(gson.toJson( + idP.getFederatedAuthenticatorConfigs()[0]), UserDefinedFederatedAuthenticatorConfig.class); + clonedIdentityProvider.setFederatedAuthenticatorConfigs(new FederatedAuthenticatorConfig[]{clonedFedAuth}); + } return clonedIdentityProvider; } @@ -2839,46 +2816,27 @@ private ProvisioningConnectorConfig createProvisioningConnectorConfig(String out * @return Federated authenticator config of the specified ID. */ private FederatedAuthenticatorConfig updateFederatedAuthenticatorConfig(String federatedAuthenticatorId, - FederatedAuthenticatorPUTRequest - authenticator) { - - FederatedAuthenticatorConfig authConfig = new FederatedAuthenticatorConfig(); - String authenticatorName = base64URLDecode(federatedAuthenticatorId); - authConfig.setName(authenticatorName); - authConfig.setDisplayName(getDisplayNameOfAuthenticator(authenticatorName)); - authConfig.setEnabled(authenticator.getIsEnabled()); + FederatedAuthenticatorPUTRequest authenticator) throws IdentityProviderManagementClientException { - String definedByType = null; - if (authenticator.getDefinedBy() != null) { - definedByType = authenticator.getDefinedBy().toString(); - } - authConfig.setDefinedByType(resolveDefinedByType(authenticatorName, definedByType, false)); + String authenticatorName = getDecodedAuthenticatorName(federatedAuthenticatorId); + DefinedByType definedByType = resolveDefinedByTypeToUpdateFederatedAuthenticator(authenticatorName); - List authProperties = authenticator.getProperties(); - if (IdentityApplicationConstants.Authenticator.SAML2SSO.FED_AUTH_NAME.equals(authenticatorName)) { - validateSamlMetadata(authProperties); - } - if (IdentityApplicationConstants.Authenticator.OIDC.FED_AUTH_NAME.equals(authenticatorName)) { - validateDuplicateOpenIDConnectScopes(authProperties); - validateDefaultOpenIDConnectScopes(authProperties); - } - List properties = authProperties.stream().map(propertyToInternal).collect(Collectors.toList()); - authConfig.setProperties(properties.toArray(new Property[0])); - return authConfig; + return FederatedAuthenticatorConfigBuilderFactory.build(authenticator, authenticatorName, definedByType); } - private DefinedByType resolveDefinedByType( - String authenticatorName, String definedByType, boolean isNewFederatedAuthenticator) { + private DefinedByType resolveDefinedByTypeToCreateFederatedAuthenticator( + FederatedAuthenticator.DefinedByEnum definedByType) { /* For new federated authenticators: If 'definedByType' is not null, use the value provided in the request payload. If not, default to SYSTEM. */ - if (isNewFederatedAuthenticator) { - if (definedByType != null) { - return DefinedByType.valueOf(definedByType); - } else { - return DefinedByType.SYSTEM; - } + if (definedByType != null) { + return DefinedByType.valueOf(definedByType.toString()); } + return DefinedByType.SYSTEM; + } + + private DefinedByType resolveDefinedByTypeToUpdateFederatedAuthenticator(String authenticatorName) { + /* For existing federated authenticators, disregard any value provided in the request payload. Instead, resolve and retrieve the 'definedBy' type of the corresponding existing authenticator. If the authenticator config is present in the ApplicationAuthenticatorService list, return its type, @@ -2891,105 +2849,6 @@ private DefinedByType resolveDefinedByType( return DefinedByType.USER; } - /** - * Verify if scopes have not been set in both Scopes field and Additional Query Parameters field - * - * @param oidcAuthenticatorProperties Authenticator properties of OIDC authenticator. - */ - private void validateDuplicateOpenIDConnectScopes(List - oidcAuthenticatorProperties) { - - if (oidcAuthenticatorProperties != null) { - boolean scopesFieldFilled = false; - boolean queryParamsScopesFilled = false; - for (org.wso2.carbon.identity.api.server.idp.v1 - .model.Property oidcAuthenticatorProperty : oidcAuthenticatorProperties) { - if (IdentityApplicationConstants.Authenticator.OIDC.SCOPES.equals(oidcAuthenticatorProperty.getKey()) && - StringUtils.isNotBlank(oidcAuthenticatorProperty.getValue())) { - scopesFieldFilled = true; - } - if (IdentityApplicationConstants.Authenticator.OIDC.QUERY_PARAMS.equals - (oidcAuthenticatorProperty.getKey()) - && oidcAuthenticatorProperty.getValue().contains("scope=")) { - queryParamsScopesFilled = true; - } - } - if (scopesFieldFilled && queryParamsScopesFilled) { - throw handleException(Response.Status.BAD_REQUEST, Constants.ErrorMessage - .ERROR_CODE_DUPLICATE_OIDC_SCOPES, null); - } - } - } - - /** - * Verify if scopes contain `openid`. - * - * @param oidcAuthenticatorProperties Authenticator properties of OIDC authenticator. - */ - private void validateDefaultOpenIDConnectScopes(List - oidcAuthenticatorProperties) { - - if (oidcAuthenticatorProperties != null) { - for (org.wso2.carbon.identity.api.server.idp.v1 - .model.Property oidcAuthenticatorProperty : oidcAuthenticatorProperties) { - if (IdentityApplicationConstants.Authenticator.OIDC.SCOPES.equals(oidcAuthenticatorProperty.getKey())) { - String scopes = oidcAuthenticatorProperty.getValue(); - if (StringUtils.isNotBlank(scopes) && !scopes.contains("openid")) { - throw handleException(Response.Status.BAD_REQUEST, Constants.ErrorMessage - .ERROR_CODE_INVALID_OIDC_SCOPES, null); - } - } - } - } - } - - /** - * If selectMode property is set as saml metadata file configuration mode, this function validates whether a - * valid base-64 encoded SAML metadata file content is provided with the property key 'meta_data_saml'. If found, - * it will decode the file content and update the value of 'meta_data_saml' property with decoded content. - * - * @param samlAuthenticatorProperties Authenticator properties of SAML authenticator. - */ - private void validateSamlMetadata(List - samlAuthenticatorProperties) { - - if (samlAuthenticatorProperties != null) { - for (org.wso2.carbon.identity.api.server.idp.v1.model.Property property : samlAuthenticatorProperties) { - - if (Constants.SELECT_MODE.equals(property.getKey()) && - Constants.SELECT_MODE_METADATA.equals(property.getValue())) { - // SAML metadata file configuration has been selected. Hence we need to validate whether valid SAML - // metadata (property with key = 'meta_data_saml') is sent. - - boolean validMetadataFound = false; - String encodedData = null; - int positionOfMetadataKey = -1; - - for (int i = 0; i < samlAuthenticatorProperties.size(); i++) { - if (Constants.META_DATA_SAML.equals(samlAuthenticatorProperties.get(i).getKey()) && - StringUtils.isNotBlank - (samlAuthenticatorProperties.get(i).getValue())) { - validMetadataFound = true; - encodedData = samlAuthenticatorProperties.get(i).getValue(); - positionOfMetadataKey = i; - } - } - if (validMetadataFound) { - String metadata = base64Decode(encodedData); - // Add decoded data to property list. - org.wso2.carbon.identity.api.server.idp.v1.model.Property metadataProperty = - samlAuthenticatorProperties.get(positionOfMetadataKey); - metadataProperty.setValue(metadata); - samlAuthenticatorProperties.set(positionOfMetadataKey, metadataProperty); - } else { - throw handleException(Response.Status.BAD_REQUEST, Constants.ErrorMessage - .ERROR_CODE_INVALID_SAML_METADATA, null); - } - } - } - } - } - /** * Verify whether the sent authenticatorId is a supported authenticator type by the server. * @@ -3046,7 +2905,7 @@ private int getExistingAuthConfigPosition(FederatedAuthenticatorConfig[] fedAuth * @return FederatedAuthenticator. */ private FederatedAuthenticator createFederatedAuthenticator(String authenticatorId, - IdentityProvider identityProvider) { + IdentityProvider identityProvider) throws IdentityProviderManagementServerException { FederatedAuthenticatorConfig[] authConfigs = identityProvider.getFederatedAuthenticatorConfigs(); if (ArrayUtils.isEmpty(authConfigs)) { @@ -3066,24 +2925,9 @@ private FederatedAuthenticator createFederatedAuthenticator(String authenticator } FederatedAuthenticator federatedAuthenticator = new FederatedAuthenticator(); if (config != null) { + federatedAuthenticator = FederatedAuthenticatorConfigBuilderFactory.build(config); federatedAuthenticator.setAuthenticatorId(authenticatorId); - federatedAuthenticator.setName(config.getName()); - federatedAuthenticator.setIsEnabled(config.isEnabled()); federatedAuthenticator.setIsDefault(isDefaultAuthenticator); - federatedAuthenticator.setDefinedBy(FederatedAuthenticator.DefinedByEnum.valueOf( - config.getDefinedByType().toString())); - FederatedAuthenticatorConfig federatedAuthenticatorConfig = - ApplicationAuthenticatorService.getInstance().getFederatedAuthenticatorByName( - config.getName()); - if (federatedAuthenticatorConfig != null) { - String[] tags = federatedAuthenticatorConfig.getTags(); - if (ArrayUtils.isNotEmpty(tags)) { - federatedAuthenticator.setTags(Arrays.asList(tags)); - } - } - List properties = - Arrays.stream(config.getProperties()).map(propertyToExternal).collect(Collectors.toList()); - federatedAuthenticator.setProperties(properties); } return federatedAuthenticator; } @@ -3418,6 +3262,10 @@ private APIError handleIdPException(IdentityProviderManagementException e, errorResponse = getErrorBuilder(errorEnum, data).build(log, e.getMessage()); } errorResponse.setDescription(e.getMessage()); + IdentityProviderManagementClientException clientException = (IdentityProviderManagementClientException) e; + if (StringUtils.isNotEmpty(clientException.getDescription())) { + errorResponse.setDescription(clientException.getDescription()); + } status = Response.Status.BAD_REQUEST; } else if (e instanceof IdentityProviderManagementServerException) { if (e.getErrorCode() != null) { @@ -3855,4 +3703,15 @@ private void validateSystemReservedIDP(String idpName) throws IdentityProviderMa "a system reserved name.", idpName)); } } + + private String getDecodedAuthenticatorName(String authId) throws IdentityProviderManagementClientException { + + try { + return base64URLDecode(authId); + } catch (IllegalArgumentException e) { + Constants.ErrorMessage error = Constants.ErrorMessage.ERROR_CODE_NON_DECODABLE_AUTH_ID; + throw new IdentityProviderManagementClientException(error.getCode(), + String.format(error.getDescription(), authId)); + } + } } 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/impl/FederatedAuthenticatorConfigBuilderFactory.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/impl/FederatedAuthenticatorConfigBuilderFactory.java new file mode 100644 index 0000000000..2223458692 --- /dev/null +++ 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/impl/FederatedAuthenticatorConfigBuilderFactory.java @@ -0,0 +1,460 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.idp.v1.impl; + +import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang.StringUtils; +import org.wso2.carbon.identity.api.server.idp.common.Constants; +import org.wso2.carbon.identity.api.server.idp.common.IdentityProviderServiceHolder; +import org.wso2.carbon.identity.api.server.idp.v1.model.AuthenticationType; +import org.wso2.carbon.identity.api.server.idp.v1.model.Endpoint; +import org.wso2.carbon.identity.api.server.idp.v1.model.FederatedAuthenticator; +import org.wso2.carbon.identity.api.server.idp.v1.model.FederatedAuthenticatorPUTRequest; +import org.wso2.carbon.identity.application.common.ApplicationAuthenticatorService; +import org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig; +import org.wso2.carbon.identity.application.common.model.Property; +import org.wso2.carbon.identity.application.common.model.UserDefinedAuthenticatorEndpointConfig; +import org.wso2.carbon.identity.application.common.model.UserDefinedFederatedAuthenticatorConfig; +import org.wso2.carbon.identity.application.common.util.IdentityApplicationConstants; +import org.wso2.carbon.identity.base.AuthenticatorPropertyConstants.DefinedByType; +import org.wso2.carbon.idp.mgt.IdentityProviderManagementClientException; +import org.wso2.carbon.idp.mgt.IdentityProviderManagementException; +import org.wso2.carbon.idp.mgt.IdentityProviderManagementServerException; + +import java.nio.charset.StandardCharsets; +import java.util.Arrays; +import java.util.Base64; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Optional; +import java.util.function.Function; +import java.util.stream.Collectors; + +import static org.wso2.carbon.identity.api.server.idp.common.Constants.GOOGLE_PRIVATE_KEY; + +/** + * The factory class for building federated authenticator configuration related models. + */ +public class FederatedAuthenticatorConfigBuilderFactory { + + /** + * Builds a FederatedAuthenticatorConfig instance based on the definedBy type for the + * given FederatedAuthenticatorPUTRequest. + * + * @param authenticator FederatedAuthenticatorPUTRequest instance. + * @param definedByType DefinedByType of the authenticator. + * @return FederatedAuthenticatorConfig instance. + * @throws IdentityProviderManagementClientException If an error occurs while building + * the FederatedAuthenticatorConfig. + */ + public static FederatedAuthenticatorConfig build(FederatedAuthenticatorPUTRequest authenticator, String + authenticatorName, DefinedByType definedByType) throws IdentityProviderManagementClientException { + + List properties = Optional.ofNullable(authenticator.getProperties()) + .map(props -> props.stream().map(propertyToInternal).collect(Collectors.toList())) + .orElse(null); + validateAuthPropForFederatedAuthenticatorPUTRequest(authenticatorName, properties); + FederatedAuthenticatorConfigBuilderFactory.Config config = + new FederatedAuthenticatorConfigBuilderFactory.Config(authenticatorName, + getDisplayNameOfAuthenticator(authenticatorName), + authenticator.getEndpoint(), properties, authenticator.getIsEnabled(), definedByType); + return FederatedAuthenticatorConfigBuilderFactory.createFederatedAuthenticatorConfig(config); + } + + /** + * Builds a FederatedAuthenticatorConfig instance based on the definedBy type for the given FederatedAuthenticator. + * + * @param authenticator FederatedAuthenticator instance. + * @param definedByType DefinedByType of the authenticator. + * @return FederatedAuthenticator instance. + * @throws IdentityProviderManagementClientException If an error occurs while building the + * FederatedAuthenticatorConfig. + */ + public static FederatedAuthenticatorConfig build(FederatedAuthenticator authenticator, String + authenticatorName, DefinedByType definedByType) throws IdentityProviderManagementClientException { + + List properties = Optional.ofNullable(authenticator.getProperties()) + .map(props -> props.stream().map(propertyToInternal).collect(Collectors.toList())) + .orElse(null); + validateAuthPropForFederatedAuthenticator(authenticatorName, properties); + FederatedAuthenticatorConfigBuilderFactory.Config config = + new FederatedAuthenticatorConfigBuilderFactory.Config(authenticatorName, + getDisplayNameOfAuthenticator(authenticatorName), + authenticator.getEndpoint(), properties, authenticator.getIsEnabled(), definedByType); + + return FederatedAuthenticatorConfigBuilderFactory.createFederatedAuthenticatorConfig(config); + } + + /** + * Builds a FederatedAuthenticatorConfig instance based on the definedBy type for the given + * FederatedAuthenticatorConfig. + * + * @param config FederatedAuthenticatorConfig instance. + * @return FederatedAuthenticator instance. + * @throws IdentityProviderManagementServerException If an error occurs while building the + * FederatedAuthenticator. + */ + public static FederatedAuthenticator build(FederatedAuthenticatorConfig config) + throws IdentityProviderManagementServerException { + + FederatedAuthenticator federatedAuthenticator = new FederatedAuthenticator(); + + federatedAuthenticator.setName(config.getName()); + federatedAuthenticator.setIsEnabled(config.isEnabled()); + + FederatedAuthenticatorConfig federatedAuthenticatorConfig = + ApplicationAuthenticatorService.getInstance().getFederatedAuthenticatorByName( + config.getName()); + if (federatedAuthenticatorConfig != null) { + String[] tags = federatedAuthenticatorConfig.getTags(); + if (ArrayUtils.isNotEmpty(tags)) { + federatedAuthenticator.setTags(Arrays.asList(tags)); + } + } + + if (DefinedByType.SYSTEM == config.getDefinedByType()) { + federatedAuthenticator.setDefinedBy(FederatedAuthenticator.DefinedByEnum.SYSTEM); + List properties = + Arrays.stream(config.getProperties()).map(propertyToExternal).collect(Collectors.toList()); + federatedAuthenticator.setProperties(properties); + } else { + federatedAuthenticator.setDefinedBy(FederatedAuthenticator.DefinedByEnum.USER); + resolveEndpointConfiguration(federatedAuthenticator, config); + } + + return federatedAuthenticator; + } + + private static FederatedAuthenticatorConfig createFederatedAuthenticatorConfig(Config config) + throws IdentityProviderManagementClientException { + + FederatedAuthenticatorConfig federatedAuthenticatorConfig; + if (DefinedByType.SYSTEM == config.definedByType) { + federatedAuthenticatorConfig = createSystemDefinedFederatedAuthenticator(config); + } else { + federatedAuthenticatorConfig = createUserDefinedFederatedAuthenticator(config); + } + + federatedAuthenticatorConfig.setName(config.authenticatorName); + federatedAuthenticatorConfig.setDisplayName(config.displayName); + federatedAuthenticatorConfig.setEnabled(config.isEnabled); + + return federatedAuthenticatorConfig; + } + + private static FederatedAuthenticatorConfig createSystemDefinedFederatedAuthenticator( + Config config) throws IdentityProviderManagementClientException { + + validateSystemDefinedFederatedAuthenticatorModel(config); + FederatedAuthenticatorConfig authConfig = new FederatedAuthenticatorConfig(); + authConfig.setDefinedByType(DefinedByType.SYSTEM); + authConfig.setProperties(config.properties.toArray(new Property[0])); + return authConfig; + } + + private static void validateSystemDefinedFederatedAuthenticatorModel(Config config) + throws IdentityProviderManagementClientException { + + // The System-defined authenticator configs must not have endpoint configurations; throw an error if they do. + if (config.endpoint != null) { + Constants.ErrorMessage error = Constants.ErrorMessage.ERROR_CODE_ENDPOINT_PROVIDED_FOR_SYSTEM_AUTH; + throw new IdentityProviderManagementClientException(error.getCode(), error.getMessage(), + String.format(error.getDescription(), config.authenticatorName)); + } + } + + private static UserDefinedFederatedAuthenticatorConfig createUserDefinedFederatedAuthenticator(Config config) + throws IdentityProviderManagementClientException { + + validateUserDefinedFederatedAuthenticatorModel(config); + + try { + UserDefinedFederatedAuthenticatorConfig authConfig = new UserDefinedFederatedAuthenticatorConfig(); + UserDefinedAuthenticatorEndpointConfig.UserDefinedAuthenticatorEndpointConfigBuilder endpointConfigBuilder = + new UserDefinedAuthenticatorEndpointConfig.UserDefinedAuthenticatorEndpointConfigBuilder(); + endpointConfigBuilder.uri(config.endpoint.getUri()); + endpointConfigBuilder.authenticationType(config.endpoint.getAuthentication().getType().toString()); + endpointConfigBuilder.authenticationProperties(config.endpoint.getAuthentication().getProperties() + .entrySet().stream().collect(Collectors.toMap( + Map.Entry::getKey, entry -> entry.getValue().toString()))); + authConfig.setEndpointConfig(endpointConfigBuilder.build()); + + return authConfig; + } catch (NoSuchElementException | IllegalArgumentException e) { + throw new IdentityProviderManagementClientException(Constants.ErrorMessage + .ERROR_CODE_INVALID_INPUT.getCode(), Constants.ErrorMessage.ERROR_CODE_INVALID_INPUT.getMessage(), + e.getMessage()); + } + } + + private static void validateUserDefinedFederatedAuthenticatorModel(Config config) + throws IdentityProviderManagementClientException { + + // The User-defined authenticator configs must not have properties configurations; throw an error if they do. + if (config.properties != null) { + Constants.ErrorMessage error = Constants.ErrorMessage.ERROR_CODE_PROPERTIES_PROVIDED_FOR_USER_AUTH; + throw new IdentityProviderManagementClientException(error.getCode(), error.getMessage(), + String.format(error.getDescription(), config.authenticatorName)); + } + + // The User-defined authenticator configs must have endpoint configurations; throw an error if they don't. + if (config.endpoint == null) { + Constants.ErrorMessage error = Constants.ErrorMessage.ERROR_CODE_NO_ENDPOINT_PROVIDED; + throw new IdentityProviderManagementClientException(error.getCode(), error.getMessage(), + String.format(error.getDescription(), config.authenticatorName)); + } + } + + private static void validateAuthPropForFederatedAuthenticator( + String authenticatorName, List properties) throws IdentityProviderManagementClientException { + + if (properties == null) { + return; + } + + if (IdentityApplicationConstants.Authenticator.SAML2SSO.FED_AUTH_NAME.equals(authenticatorName)) { + validateSamlMetadata(properties); + } + if (!areAllDistinct(properties)) { + Constants.ErrorMessage error = Constants.ErrorMessage.ERROR_CODE_INVALID_INPUT; + throw new IdentityProviderManagementClientException(error.getCode(), error.getMessage(), + String.format(error.getDescription(), " Duplicate properties are found in " + + "the request.")); + } + } + + private static void validateAuthPropForFederatedAuthenticatorPUTRequest( + String authenticatorName, List properties) throws IdentityProviderManagementClientException { + + if (properties == null) { + return; + } + + if (IdentityApplicationConstants.Authenticator.SAML2SSO.FED_AUTH_NAME.equals(authenticatorName)) { + validateSamlMetadata(properties); + } + if (IdentityApplicationConstants.Authenticator.OIDC.FED_AUTH_NAME.equals(authenticatorName)) { + validateDuplicateOpenIDConnectScopes(properties); + validateDefaultOpenIDConnectScopes(properties); + } + } + + /** + * If selectMode property is set as saml metadata file configuration mode, this function validates whether a + * valid base-64 encoded SAML metadata file content is provided with the property key 'meta_data_saml'. If found, + * it will decode the file content and update the value of 'meta_data_saml' property with decoded content. + * + * @param samlAuthenticatorProperties Authenticator properties of SAML authenticator. + */ + private static void validateSamlMetadata(List samlAuthenticatorProperties) + throws IdentityProviderManagementClientException { + + if (samlAuthenticatorProperties != null) { + for (Property property : samlAuthenticatorProperties) { + + if (Constants.SELECT_MODE.equals(property.getName()) && + Constants.SELECT_MODE_METADATA.equals(property.getValue())) { + // SAML metadata file configuration has been selected. Hence we need to validate whether valid SAML + // metadata (property with key = 'meta_data_saml') is sent. + + boolean validMetadataFound = false; + String encodedData = null; + int positionOfMetadataKey = -1; + + for (int i = 0; i < samlAuthenticatorProperties.size(); i++) { + if (Constants.META_DATA_SAML.equals(samlAuthenticatorProperties.get(i).getName()) && + StringUtils.isNotBlank + (samlAuthenticatorProperties.get(i).getValue())) { + validMetadataFound = true; + encodedData = samlAuthenticatorProperties.get(i).getValue(); + positionOfMetadataKey = i; + break; + } + } + if (validMetadataFound) { + String metadata = new String(Base64.getDecoder().decode(encodedData), (StandardCharsets.UTF_8)); + // Add decoded data to property list. + Property metadataProperty = samlAuthenticatorProperties.get(positionOfMetadataKey); + metadataProperty.setValue(metadata); + samlAuthenticatorProperties.set(positionOfMetadataKey, metadataProperty); + } else { + Constants.ErrorMessage error = Constants.ErrorMessage.ERROR_CODE_INVALID_SAML_METADATA; + throw new IdentityProviderManagementClientException(error.getCode(), error.getMessage(), + error.getDescription()); + } + } + } + } + } + + /** + * Verify if scopes have not been set in both Scopes field and Additional Query Parameters field + * + * @param oidcAuthenticatorProperties Authenticator properties of OIDC authenticator. + */ + private static void validateDuplicateOpenIDConnectScopes(List oidcAuthenticatorProperties) + throws IdentityProviderManagementClientException { + + if (oidcAuthenticatorProperties != null) { + boolean scopesFieldFilled = false; + boolean queryParamsScopesFilled = false; + for (Property oidcAuthenticatorProperty : oidcAuthenticatorProperties) { + if (IdentityApplicationConstants.Authenticator.OIDC.SCOPES.equals(oidcAuthenticatorProperty.getName()) + && StringUtils.isNotBlank(oidcAuthenticatorProperty.getValue())) { + scopesFieldFilled = true; + } + if (IdentityApplicationConstants.Authenticator.OIDC.QUERY_PARAMS.equals + (oidcAuthenticatorProperty.getName()) + && oidcAuthenticatorProperty.getValue().contains("scope=")) { + queryParamsScopesFilled = true; + } + } + if (scopesFieldFilled && queryParamsScopesFilled) { + Constants.ErrorMessage error = Constants.ErrorMessage.ERROR_CODE_DUPLICATE_OIDC_SCOPES; + throw new IdentityProviderManagementClientException(error.getCode(), error.getMessage(), + error.getDescription()); + } + } + } + + /** + * Verify if scopes contain `openid`. + * + * @param oidcAuthenticatorProperties Authenticator properties of OIDC authenticator. + */ + private static void validateDefaultOpenIDConnectScopes(List oidcAuthenticatorProperties) + throws IdentityProviderManagementClientException { + + if (oidcAuthenticatorProperties != null) { + for (Property oidcAuthenticatorProperty : oidcAuthenticatorProperties) { + if (IdentityApplicationConstants.Authenticator.OIDC.SCOPES.equals( + oidcAuthenticatorProperty.getName())) { + String scopes = oidcAuthenticatorProperty.getValue(); + if (StringUtils.isNotBlank(scopes) && !scopes.contains("openid")) { + Constants.ErrorMessage error = Constants.ErrorMessage.ERROR_CODE_INVALID_OIDC_SCOPES; + throw new IdentityProviderManagementClientException(error.getCode(), error.getMessage(), + error.getDescription()); + } + } + } + } + } + + static boolean areAllDistinct(List properties) { + return properties.stream() + .map(Property::getName) + .distinct().count() == properties.size(); + } + + private static Function propertyToInternal + = apiProperty -> { + + Property property = new Property(); + property.setName(apiProperty.getKey()); + property.setValue(apiProperty.getValue()); + if (StringUtils.equals(GOOGLE_PRIVATE_KEY, apiProperty.getKey())) { + property.setType(IdentityApplicationConstants.ConfigElements.PROPERTY_TYPE_BLOB); + } + return property; + }; + + private static Function propertyToExternal + = property -> { + + org.wso2.carbon.identity.api.server.idp.v1.model.Property apiProperty = new org.wso2.carbon.identity.api + .server.idp.v1.model.Property(); + apiProperty.setKey(property.getName()); + apiProperty.setValue(property.getValue()); + return apiProperty; + }; + + /** + * Returns the 'DisplayName' property of the federated authenticator identified by authenticator name. + * + * @param authenticatorName Federated authenticator name. + * @return Display name of authenticator. + */ + private static String getDisplayNameOfAuthenticator(String authenticatorName) + throws IdentityProviderManagementClientException { + + try { + FederatedAuthenticatorConfig[] authenticatorConfigs = + IdentityProviderServiceHolder.getIdentityProviderManager() + .getAllFederatedAuthenticators(); + for (FederatedAuthenticatorConfig config : authenticatorConfigs) { + + if (StringUtils.equals(config.getName(), authenticatorName)) { + return config.getDisplayName(); + } + } + } catch (IdentityProviderManagementException e) { + Constants.ErrorMessage error = Constants.ErrorMessage.ERROR_CODE_ERROR_ADDING_IDP; + throw new IdentityProviderManagementClientException(error.getCode(), error.getMessage(), + error.getDescription()); + } + return null; + } + + private static void resolveEndpointConfiguration(FederatedAuthenticator authenticator, + FederatedAuthenticatorConfig config) throws IdentityProviderManagementServerException { + + try { + UserDefinedFederatedAuthenticatorConfig userDefinedConfig = + (UserDefinedFederatedAuthenticatorConfig) config; + UserDefinedAuthenticatorEndpointConfig endpointConfig = userDefinedConfig.getEndpointConfig(); + + AuthenticationType authenticationType = new AuthenticationType(); + authenticationType.setType(AuthenticationType.TypeEnum.fromValue(endpointConfig.getEndpointConfig() + .getAuthentication().getType().toString())); + authenticationType.setProperties(null); + + Endpoint endpoint = new Endpoint(); + endpoint.setUri(endpointConfig.getEndpointConfig().getUri()); + endpoint.setAuthentication(authenticationType); + authenticator.setEndpoint(endpoint); + } catch (ClassCastException e) { + throw new IdentityProviderManagementServerException(String.format("Error occurred while resolving" + + " endpoint configuration of the authenticator %s.", authenticator.getName()), e); + } + } + + /** + * Config class to build FederatedAuthenticatorConfig. + */ + public static class Config { + private final DefinedByType definedByType; + private final String authenticatorName; + private final String displayName; + private final Endpoint endpoint; + private final List properties; + private final Boolean isEnabled; + + public Config(String authenticatorName, String displayName, Endpoint endpoint, + List properties, Boolean isEnabled, DefinedByType definedByType) { + + this.authenticatorName = authenticatorName; + this.displayName = displayName; + this.endpoint = endpoint; + this.properties = properties; + this.isEnabled = isEnabled; + this.definedByType = definedByType; + } + } +} diff --git a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/main/resources/idp.yaml b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/main/resources/idp.yaml index 9e0df2e09d..e05b96d189 100644 --- a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/main/resources/idp.yaml +++ b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/main/resources/idp.yaml @@ -2877,6 +2877,39 @@ components: type: array items: $ref: '#/components/schemas/Property' + endpoint: + $ref: '#/components/schemas/Endpoint' + Endpoint: + type: object + required: + - uri + - authentication + properties: + uri: + type: string + example: https://abc.com/token + pattern: '^https?://.+' + authentication: + $ref: '#/components/schemas/AuthenticationType' + AuthenticationType: + type: object + required: + - type + properties: + type: + type: string + enum: + - NONE + - BEARER + - API_KEY + - BASIC + example: BASIC + properties: + type: object + additionalProperties: true + example: + username: "auth_username" + password: "auth_password" FederatedAuthenticatorPUTRequest: type: object properties: @@ -2905,6 +2938,8 @@ components: type: array items: $ref: '#/components/schemas/Property' + endpoint: + $ref: '#/components/schemas/Endpoint' FederatedAuthenticatorListResponse: type: object properties: 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 13c31a0a14..3ef9f9543d 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.258-SNAPSHOT + 1.3.11-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 2581eae630..c1ab5e3124 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.258-SNAPSHOT + 1.3.11-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 d4bce0eff2..39e9f4254a 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.258-SNAPSHOT + 1.3.11-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 a43ee5b32d..deb7fc12cd 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.258-SNAPSHOT + 1.3.11-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 39730116c9..083f03ee35 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.258-SNAPSHOT + 1.3.11-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 5e913ae6b5..46880901e7 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.258-SNAPSHOT + 1.3.11-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.258-SNAPSHOT + 1.3.11-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 aaba59e525..891054cdfe 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.258-SNAPSHOT + 1.3.11-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 b1854896a6..7b479eb6e6 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.258-SNAPSHOT + 1.3.11-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 e28e26661f..e4defc44bf 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.258-SNAPSHOT + 1.3.11-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 a98b31d4cb..168387a172 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.258-SNAPSHOT + 1.3.11-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 c61027503f..faf852d9d4 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.258-SNAPSHOT + 1.3.11-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 c12a50d784..2b20115712 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.258-SNAPSHOT + 1.3.11-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 267437c3a7..80d9ef57d1 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.258-SNAPSHOT + 1.3.11-SNAPSHOT ../../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/pom.xml b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/pom.xml index d4b50ca227..9c9a5c4d27 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.notification.template - 1.2.258-SNAPSHOT + 1.3.11-SNAPSHOT ../pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/pom.xml index 2c53b41333..b2647da5e4 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.notification.template - 1.2.258-SNAPSHOT + 1.3.11-SNAPSHOT 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java index 59c6729372..ae8915b0f9 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java @@ -361,9 +361,9 @@ public Response deleteSMSTemplateType(@ApiParam(value = "Template Type ID.",requ @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getAllAppTemplatesOfEmailTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid) { + public Response getAllAppTemplatesOfEmailTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @Valid@ApiParam(value = "Specifies whether to return resolved template/s throughout the ancestor organization hierarchy.", defaultValue="false") @DefaultValue("false") @QueryParam("resolve") Boolean resolve) { - return delegate.getAllAppTemplatesOfEmailTemplateType(templateTypeId, appUuid ); + return delegate.getAllAppTemplatesOfEmailTemplateType(templateTypeId, appUuid, resolve ); } @Valid @@ -385,9 +385,9 @@ public Response getAllAppTemplatesOfEmailTemplateType(@ApiParam(value = "Templat @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getAllAppTemplatesOfSMSTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid) { + public Response getAllAppTemplatesOfSMSTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @Valid@ApiParam(value = "Specifies whether to return resolved template/s throughout the ancestor organization hierarchy.", defaultValue="false") @DefaultValue("false") @QueryParam("resolve") Boolean resolve) { - return delegate.getAllAppTemplatesOfSMSTemplateType(templateTypeId, appUuid ); + return delegate.getAllAppTemplatesOfSMSTemplateType(templateTypeId, appUuid, resolve ); } @Valid @@ -432,9 +432,9 @@ public Response getAllEmailTemplateTypes() { @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getAllOrgTemplatesOfEmailTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + public Response getAllOrgTemplatesOfEmailTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @Valid@ApiParam(value = "Specifies whether to return resolved template/s throughout the ancestor organization hierarchy.", defaultValue="false") @DefaultValue("false") @QueryParam("resolve") Boolean resolve) { - return delegate.getAllOrgTemplatesOfEmailTemplateType(templateTypeId ); + return delegate.getAllOrgTemplatesOfEmailTemplateType(templateTypeId, resolve ); } @Valid @@ -456,9 +456,9 @@ public Response getAllOrgTemplatesOfEmailTemplateType(@ApiParam(value = "Templat @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getAllOrgTemplatesOfSMSTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + public Response getAllOrgTemplatesOfSMSTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @Valid@ApiParam(value = "Specifies whether to return resolved template/s throughout the ancestor organization hierarchy.", defaultValue="false") @DefaultValue("false") @QueryParam("resolve") Boolean resolve) { - return delegate.getAllOrgTemplatesOfSMSTemplateType(templateTypeId ); + return delegate.getAllOrgTemplatesOfSMSTemplateType(templateTypeId, resolve ); } @Valid @@ -551,9 +551,9 @@ public Response getAllSystemTemplatesOfSMSTemplateType(@ApiParam(value = "Templa @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getAppEmailTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + public Response getAppEmailTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @Valid@ApiParam(value = "Specifies whether to return resolved template/s throughout the ancestor organization hierarchy.", defaultValue="false") @DefaultValue("false") @QueryParam("resolve") Boolean resolve) { - return delegate.getAppEmailTemplate(templateTypeId, appUuid, locale ); + return delegate.getAppEmailTemplate(templateTypeId, appUuid, locale, resolve ); } @Valid @@ -575,9 +575,9 @@ public Response getAppEmailTemplate(@ApiParam(value = "Template Type ID.",requir @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getAppSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + public Response getAppSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @Valid@ApiParam(value = "Specifies whether to return resolved template/s throughout the ancestor organization hierarchy.", defaultValue="false") @DefaultValue("false") @QueryParam("resolve") Boolean resolve) { - return delegate.getAppSMSTemplate(templateTypeId, appUuid, locale ); + return delegate.getAppSMSTemplate(templateTypeId, appUuid, locale, resolve ); } @Valid @@ -623,9 +623,9 @@ public Response getEmailTemplateType(@ApiParam(value = "Template Type ID.",requi @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getOrgEmailTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + public Response getOrgEmailTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @Valid@ApiParam(value = "Specifies whether to return resolved template/s throughout the ancestor organization hierarchy.", defaultValue="false") @DefaultValue("false") @QueryParam("resolve") Boolean resolve) { - return delegate.getOrgEmailTemplate(templateTypeId, locale ); + return delegate.getOrgEmailTemplate(templateTypeId, locale, resolve ); } @Valid @@ -647,9 +647,9 @@ public Response getOrgEmailTemplate(@ApiParam(value = "Template Type ID.",requir @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getOrgSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + public Response getOrgSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @Valid@ApiParam(value = "Specifies whether to return resolved template/s throughout the ancestor organization hierarchy.", defaultValue="false") @DefaultValue("false") @QueryParam("resolve") Boolean resolve) { - return delegate.getOrgSMSTemplate(templateTypeId, locale ); + return delegate.getOrgSMSTemplate(templateTypeId, locale, resolve ); } @Valid diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java index feb3334c4d..76b0b20420 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java @@ -62,15 +62,15 @@ public interface NotificationApiService { public Response deleteSMSTemplateType(String templateTypeId); - public Response getAllAppTemplatesOfEmailTemplateType(String templateTypeId, String appUuid); + public Response getAllAppTemplatesOfEmailTemplateType(String templateTypeId, String appUuid, Boolean resolve); - public Response getAllAppTemplatesOfSMSTemplateType(String templateTypeId, String appUuid); + public Response getAllAppTemplatesOfSMSTemplateType(String templateTypeId, String appUuid, Boolean resolve); public Response getAllEmailTemplateTypes(); - public Response getAllOrgTemplatesOfEmailTemplateType(String templateTypeId); + public Response getAllOrgTemplatesOfEmailTemplateType(String templateTypeId, Boolean resolve); - public Response getAllOrgTemplatesOfSMSTemplateType(String templateTypeId); + public Response getAllOrgTemplatesOfSMSTemplateType(String templateTypeId, Boolean resolve); public Response getAllSMSTemplateTypes(); @@ -78,15 +78,15 @@ public interface NotificationApiService { public Response getAllSystemTemplatesOfSMSTemplateType(String templateTypeId); - public Response getAppEmailTemplate(String templateTypeId, String appUuid, String locale); + public Response getAppEmailTemplate(String templateTypeId, String appUuid, String locale, Boolean resolve); - public Response getAppSMSTemplate(String templateTypeId, String appUuid, String locale); + public Response getAppSMSTemplate(String templateTypeId, String appUuid, String locale, Boolean resolve); public Response getEmailTemplateType(String templateTypeId); - public Response getOrgEmailTemplate(String templateTypeId, String locale); + public Response getOrgEmailTemplate(String templateTypeId, String locale, Boolean resolve); - public Response getOrgSMSTemplate(String templateTypeId, String locale); + public Response getOrgSMSTemplate(String templateTypeId, String locale, Boolean resolve); public Response getSMSTemplateType(String templateTypeId); diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplatesService.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplatesService.java index 22a5b8d575..bb0097c73c 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplatesService.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplatesService.java @@ -134,29 +134,36 @@ public SimpleTemplate addSMSTemplate(String templateTypeId, SMSTemplateWithID sm /** * Retrieves the list of organization email templates of the given template type. * - * @param templateTypeId Template type ID. + * @param templateTypeId Template type ID. + * @param notificationChannel Notification channel. + * @param resolve Whether to retrieve templates resolved through the ancestor organization hierarchy, + * returning templates that are applicable across the tenant's organizational structure. * @return List of email templates. */ - public List getAllTemplatesOfTemplateType(String templateTypeId, String notificationChannel) { + public List getAllTemplatesOfTemplateType(String templateTypeId, String notificationChannel, + boolean resolve) { - return getAllTemplatesOfTemplateType(templateTypeId, null, notificationChannel); + return getAllTemplatesOfTemplateType(templateTypeId, null, notificationChannel, resolve); } /** * Retrieves the list of application email templates of the given template type. * - * @param templateTypeId Template type ID. - * @param applicationUuid Application UUID. + * @param templateTypeId Template type ID. + * @param applicationUuid Application UUID. + * @param notificationChannel Notification channel. + * @param resolve Whether to retrieve templates resolved through the ancestor organization hierarchy, + * returning templates that are applicable across the tenant's organizational structure. * @return List of email templates. */ public List getAllTemplatesOfTemplateType(String templateTypeId, String applicationUuid, - String notificationChannel) { + String notificationChannel, boolean resolve) { String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); try { List templates = TemplatesServiceHolder.getNotificationTemplateManager() .getNotificationTemplatesOfType(notificationChannel, templateTypeDisplayName, - getTenantDomainFromContext(), applicationUuid); + getTenantDomainFromContext(), applicationUuid, resolve); String templateOwner = StringUtils.isNotBlank(applicationUuid) ? Constants.NOTIFICATION_TEMPLATE_OWNER_APP : Constants.NOTIFICATION_TEMPLATE_OWNER_ORG; return Util.buildSimpleTemplateList(templates, applicationUuid, templateOwner, notificationChannel); @@ -192,11 +199,12 @@ public List getAllSystemTemplatesOfTemplateType(String templateT * * @param templateTypeId Template type ID. * @param templateId Template ID. + * @param resolve Whether to retrieve the template resolved through the ancestor organization hierarchy. * @return Email template. */ - public EmailTemplateWithID getEmailTemplate(String templateTypeId, String templateId) { + public EmailTemplateWithID getEmailTemplate(String templateTypeId, String templateId, boolean resolve) { - return getEmailTemplate(templateTypeId, templateId, null); + return getEmailTemplate(templateTypeId, templateId, null, resolve); } /** @@ -205,15 +213,17 @@ public EmailTemplateWithID getEmailTemplate(String templateTypeId, String templa * @param templateTypeId Template type ID. * @param templateId Template ID. * @param applicationUuid Application UUID. + * @param resolve Whether to retrieve the template resolved through the ancestor organization hierarchy. * @return Email template. */ - public EmailTemplateWithID getEmailTemplate(String templateTypeId, String templateId, String applicationUuid) { + public EmailTemplateWithID getEmailTemplate(String templateTypeId, String templateId, String applicationUuid, + boolean resolve) { try { String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); NotificationTemplate internalEmailTemplate = TemplatesServiceHolder.getNotificationTemplateManager(). getNotificationTemplate(Constants.NOTIFICATION_CHANNEL_EMAIL, templateTypeDisplayName, templateId, - getTenantDomainFromContext(), applicationUuid); + getTenantDomainFromContext(), applicationUuid, resolve); // NotificationTemplateManager sends the default template if no matching template found. // We need to check for the locale specifically. if (!internalEmailTemplate.getLocale().equals(templateId)) { @@ -230,13 +240,14 @@ public EmailTemplateWithID getEmailTemplate(String templateTypeId, String templa /** * Retrieves the organization SMS template of the given template type and locale. * - * @param templateTypeId Template type ID. - * @param templateId Template ID. + * @param templateTypeId Template type ID. + * @param templateId Template ID. + * @param resolve Whether to retrieve the template resolved through the ancestor organization hierarchy. * @return SMS template. */ - public SMSTemplateWithID getSMSTemplate(String templateTypeId, String templateId) { + public SMSTemplateWithID getSMSTemplate(String templateTypeId, String templateId, boolean resolve) { - return getSMSTemplate(templateTypeId, templateId, null); + return getSMSTemplate(templateTypeId, templateId, null, resolve); } /** @@ -245,15 +256,17 @@ public SMSTemplateWithID getSMSTemplate(String templateTypeId, String templateId * @param templateTypeId Template type ID. * @param templateId Template ID. * @param applicationUuid Application UUID. + * @param resolve Whether to retrieve the template resolved through the ancestor organization hierarchy. * @return SMS template. */ - public SMSTemplateWithID getSMSTemplate(String templateTypeId, String templateId, String applicationUuid) { + public SMSTemplateWithID getSMSTemplate(String templateTypeId, String templateId, String applicationUuid, + boolean resolve) { try { String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); NotificationTemplate internalEmailTemplate = TemplatesServiceHolder.getNotificationTemplateManager(). getNotificationTemplate(Constants.NOTIFICATION_CHANNEL_SMS, templateTypeDisplayName, templateId, - getTenantDomainFromContext(), applicationUuid); + getTenantDomainFromContext(), applicationUuid, resolve); // NotificationTemplateManager sends the default template if no matching template found. // We need to check for the locale specifically. if (!internalEmailTemplate.getLocale().equals(templateId)) { diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java index e83134c6a7..c60b08778f 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java @@ -174,19 +174,19 @@ public Response deleteSMSTemplateType(String templateTypeId) { } @Override - public Response getAllAppTemplatesOfEmailTemplateType(String templateTypeId, String appUuid) { + public Response getAllAppTemplatesOfEmailTemplateType(String templateTypeId, String appUuid, Boolean resolve) { return Response.ok().entity( templatesService.getAllTemplatesOfTemplateType(templateTypeId, appUuid, - Constants.NOTIFICATION_CHANNEL_EMAIL)).build(); + Constants.NOTIFICATION_CHANNEL_EMAIL, resolve)).build(); } @Override - public Response getAllAppTemplatesOfSMSTemplateType(String templateTypeId, String appUuid) { + public Response getAllAppTemplatesOfSMSTemplateType(String templateTypeId, String appUuid, Boolean resolve) { return Response.ok().entity( templatesService.getAllTemplatesOfTemplateType(templateTypeId, appUuid, - Constants.NOTIFICATION_CHANNEL_SMS)).build(); + Constants.NOTIFICATION_CHANNEL_SMS, resolve)).build(); } @Override @@ -197,17 +197,17 @@ public Response getAllEmailTemplateTypes() { } @Override - public Response getAllOrgTemplatesOfEmailTemplateType(String templateTypeId) { + public Response getAllOrgTemplatesOfEmailTemplateType(String templateTypeId, Boolean resolve) { return Response.ok().entity(templatesService.getAllTemplatesOfTemplateType(templateTypeId, - Constants.NOTIFICATION_CHANNEL_EMAIL)).build(); + Constants.NOTIFICATION_CHANNEL_EMAIL, resolve)).build(); } @Override - public Response getAllOrgTemplatesOfSMSTemplateType(String templateTypeId) { + public Response getAllOrgTemplatesOfSMSTemplateType(String templateTypeId, Boolean resolve) { return Response.ok().entity(templatesService.getAllTemplatesOfTemplateType(templateTypeId, - Constants.NOTIFICATION_CHANNEL_SMS)).build(); + Constants.NOTIFICATION_CHANNEL_SMS, resolve)).build(); } @Override @@ -232,16 +232,16 @@ public Response getAllSystemTemplatesOfSMSTemplateType(String templateTypeId) { } @Override - public Response getAppEmailTemplate(String templateTypeId, String appUuid, String locale) { + public Response getAppEmailTemplate(String templateTypeId, String appUuid, String locale, Boolean resolve) { - return Response.ok().entity(templatesService.getEmailTemplate(templateTypeId, locale, appUuid)) + return Response.ok().entity(templatesService.getEmailTemplate(templateTypeId, locale, appUuid, resolve)) .build(); } @Override - public Response getAppSMSTemplate(String templateTypeId, String appUuid, String locale) { + public Response getAppSMSTemplate(String templateTypeId, String appUuid, String locale, Boolean resolve) { - return Response.ok().entity(templatesService.getSMSTemplate(templateTypeId, locale, appUuid)) + return Response.ok().entity(templatesService.getSMSTemplate(templateTypeId, locale, appUuid, resolve)) .build(); } @@ -253,15 +253,15 @@ public Response getEmailTemplateType(String templateTypeId) { } @Override - public Response getOrgEmailTemplate(String templateTypeId, String locale) { + public Response getOrgEmailTemplate(String templateTypeId, String locale, Boolean resolve) { - return Response.ok().entity(templatesService.getEmailTemplate(templateTypeId, locale)).build(); + return Response.ok().entity(templatesService.getEmailTemplate(templateTypeId, locale, resolve)).build(); } @Override - public Response getOrgSMSTemplate(String templateTypeId, String locale) { + public Response getOrgSMSTemplate(String templateTypeId, String locale, Boolean resolve) { - return Response.ok().entity(templatesService.getSMSTemplate(templateTypeId, locale)).build(); + return Response.ok().entity(templatesService.getSMSTemplate(templateTypeId, locale, resolve)).build(); } @Override diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml index 0e05a947bb..f0704c7b57 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml @@ -194,6 +194,7 @@ paths: * internal_email_mgt_view / internal_template_mgt_view
parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/resolveQueryParam' responses: '200': description: Search results matching the given criteria. @@ -270,6 +271,7 @@ paths: parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' + - $ref: '#/components/parameters/resolveQueryParam' responses: '200': description: Search results matching the given criteria. @@ -347,6 +349,7 @@ paths: parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/localePathParam' + - $ref: '#/components/parameters/resolveQueryParam' responses: '200': description: Search results matching the given criteria. @@ -500,6 +503,7 @@ paths: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' - $ref: '#/components/parameters/localePathParam' + - $ref: '#/components/parameters/resolveQueryParam' responses: '200': description: Search results matching the given criteria. @@ -718,6 +722,7 @@ paths: parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' + - $ref: '#/components/parameters/resolveQueryParam' responses: '200': description: Search results matching the given criteria. @@ -796,6 +801,7 @@ paths: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' - $ref: '#/components/parameters/localePathParam' + - $ref: '#/components/parameters/resolveQueryParam' responses: '200': description: Search results matching the given criteria. @@ -886,6 +892,7 @@ paths: * internal_template_mgt_view
parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/resolveQueryParam' responses: '200': description: Search results matching the given criteria. @@ -962,6 +969,7 @@ paths: parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/localePathParam' + - $ref: '#/components/parameters/resolveQueryParam' responses: '200': description: Search results matching the given criteria. @@ -1131,6 +1139,14 @@ components: description: Application UUID. schema: type: string + resolveQueryParam: + in: query + name: resolve + required: false + description: Specifies whether to return resolved template/s throughout the ancestor organization hierarchy. + schema: + type: boolean + default: false responses: NotFound: description: The specified resource is not found. diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/pom.xml b/components/org.wso2.carbon.identity.api.server.notification.template/pom.xml index bdf80ea827..d688417d03 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.notification.template/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.server.api identity-api-server - 1.2.258-SNAPSHOT + 1.3.11-SNAPSHOT ../../pom.xml 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.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 d9ac6a09a7..30bfd592fe 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.258-SNAPSHOT + 1.3.11-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 6369465eda..4fdddbbc10 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.258-SNAPSHOT + 1.3.11-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 a0694aa139..3a0c93ea3a 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.258-SNAPSHOT + 1.3.11-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 index 6c361e5d0a..84ce83c4cc 100644 --- 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 @@ -22,7 +22,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.organization.configs - 1.2.258-SNAPSHOT + 1.3.11-SNAPSHOT org.wso2.carbon.identity.api.server.organization.configs.common 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 index cadfb95995..bc795da152 100644 --- 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 @@ -22,7 +22,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.organization.configs - 1.2.258-SNAPSHOT + 1.3.11-SNAPSHOT org.wso2.carbon.identity.api.server.organization.configs.v1 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 index a07166cb4c..7e7528086c 100644 --- a/components/org.wso2.carbon.identity.api.server.organization.configs/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.organization.configs/pom.xml @@ -21,7 +21,7 @@ identity-api-server org.wso2.carbon.identity.server.api - 1.2.258-SNAPSHOT + 1.3.11-SNAPSHOT ../../pom.xml 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 3fa5d6ea1c..434d6d3fef 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.258-SNAPSHOT + 1.3.11-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 c1dbf1a30b..dea256d4d0 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.258-SNAPSHOT + 1.3.11-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 baf7c61906..7fd5ccf63e 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.258-SNAPSHOT + 1.3.11-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 5b1657bed8..3f4a66aeb5 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.258-SNAPSHOT + 1.3.11-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 eafde1631e..acf596ab97 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.258-SNAPSHOT + 1.3.11-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 8911932339..1d10bf2f82 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.258-SNAPSHOT + 1.3.11-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.organization.selfservice/org.wso2.carbon.identity.api.server.organization.selfservice.common/pom.xml b/components/org.wso2.carbon.identity.api.server.organization.selfservice/org.wso2.carbon.identity.api.server.organization.selfservice.common/pom.xml index 47d0706491..41a43b77da 100644 --- a/components/org.wso2.carbon.identity.api.server.organization.selfservice/org.wso2.carbon.identity.api.server.organization.selfservice.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.organization.selfservice/org.wso2.carbon.identity.api.server.organization.selfservice.common/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.organization.selfservice ../pom.xml - 1.2.258-SNAPSHOT + 1.3.11-SNAPSHOT 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.organization.selfservice/org.wso2.carbon.identity.api.server.organization.selfservice.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.organization.selfservice/org.wso2.carbon.identity.api.server.organization.selfservice.v1/pom.xml index 0b091bd183..0b0b03aee9 100644 --- a/components/org.wso2.carbon.identity.api.server.organization.selfservice/org.wso2.carbon.identity.api.server.organization.selfservice.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.organization.selfservice/org.wso2.carbon.identity.api.server.organization.selfservice.v1/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.organization.selfservice ../pom.xml - 1.2.258-SNAPSHOT + 1.3.11-SNAPSHOT 4.0.0 org.wso2.carbon.identity.api.server.organization.selfservice.v1 diff --git a/components/org.wso2.carbon.identity.api.server.organization.selfservice/pom.xml b/components/org.wso2.carbon.identity.api.server.organization.selfservice/pom.xml index 38393db1c2..c9b4f89987 100644 --- a/components/org.wso2.carbon.identity.api.server.organization.selfservice/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.organization.selfservice/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.server.api identity-api-server - 1.2.258-SNAPSHOT + 1.3.11-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 f3dc8c384b..8e5bcf4353 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.258-SNAPSHOT + 1.3.11-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 4cf908dd64..e3004cbc9e 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.258-SNAPSHOT + 1.3.11-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 4f950a5b60..768d385c03 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.258-SNAPSHOT + 1.3.11-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 cedd89aa73..4362d8a854 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.258-SNAPSHOT + 1.3.11-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 9a1c6d7479..cd56dcd261 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.258-SNAPSHOT + 1.3.11-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 f49ecaebbd..e5ef9910bd 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.258-SNAPSHOT + 1.3.11-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.common/pom.xml b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.common/pom.xml new file mode 100644 index 0000000000..19798fc5d8 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.common/pom.xml @@ -0,0 +1,68 @@ + + + + + 4.0.0 + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.rule.metadata + 1.3.11-SNAPSHOT + ../pom.xml + + + org.wso2.carbon.identity.api.server.rule.metadata.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 + org.wso2.carbon.utils + provided + + + org.wso2.carbon.identity.framework + org.wso2.carbon.identity.rule.metadata + provided + + + diff --git a/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.common/src/main/java/org/wso2/carbon/identity/api/server/rule/metadata/common/RuleMetadataServiceHolder.java b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.common/src/main/java/org/wso2/carbon/identity/api/server/rule/metadata/common/RuleMetadataServiceHolder.java new file mode 100644 index 0000000000..58e087c34c --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.common/src/main/java/org/wso2/carbon/identity/api/server/rule/metadata/common/RuleMetadataServiceHolder.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.rule.metadata.common; + +import org.wso2.carbon.identity.rule.metadata.service.RuleMetadataService; + +/** + * Service holder class for Rule Metadata Service. + */ +public class RuleMetadataServiceHolder { + + private static RuleMetadataService ruleMetadataService; + + public static RuleMetadataService getRuleMetadataService() { + + return ruleMetadataService; + } + + public static void setRuleMetadataService(RuleMetadataService ruleMetadataService) { + + RuleMetadataServiceHolder.ruleMetadataService = ruleMetadataService; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.common/src/main/java/org/wso2/carbon/identity/api/server/rule/metadata/common/factory/RuleMetaOSGiServiceFactory.java b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.common/src/main/java/org/wso2/carbon/identity/api/server/rule/metadata/common/factory/RuleMetaOSGiServiceFactory.java new file mode 100644 index 0000000000..9594c90ebb --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.common/src/main/java/org/wso2/carbon/identity/api/server/rule/metadata/common/factory/RuleMetaOSGiServiceFactory.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.rule.metadata.common.factory; + +import org.springframework.beans.factory.config.AbstractFactoryBean; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.identity.rule.metadata.service.RuleMetadataService; + +/** + * Factory bean used to instantiate the RuleMetadataService type of object inside the container. + */ +public class RuleMetaOSGiServiceFactory extends AbstractFactoryBean { + + private RuleMetadataService ruleMetadataService; + + @Override + public Class getObjectType() { + + return Object.class; + } + + @Override + protected RuleMetadataService createInstance() throws Exception { + + if (this.ruleMetadataService == null) { + ruleMetadataService = (RuleMetadataService) PrivilegedCarbonContext. + getThreadLocalCarbonContext().getOSGiService(RuleMetadataService.class, null); + if (ruleMetadataService == null) { + throw new Exception("Rule Metadata Service is not available."); + } + } + return this.ruleMetadataService; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/pom.xml new file mode 100644 index 0000000000..7b73942c1d --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/pom.xml @@ -0,0 +1,200 @@ + + + + + 4.0.0 + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.rule.metadata + 1.3.11-SNAPSHOT + ../pom.xml + + + WSO2 Identity Server - Rule Metadata Rest API + WSO2 Identity Server - Rule Metadata Rest API + org.wso2.carbon.identity.api.server.rule.metadata.v1 + jar + + + + org.wso2.carbon.identity.framework + org.wso2.carbon.identity.rule.metadata + provided + + + com.fasterxml.jackson.jaxrs + jackson-jaxrs-json-provider + provided + + + org.apache.cxf + cxf-rt-frontend-jaxrs + 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 + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.common + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.rule.metadata.common + + + + + + + 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 + + + + + + + org.codehaus.mojo + findbugs-maven-plugin + ${maven.findbugsplugin.version} + + Max + Low + true + ${project.build.directory}/findbugs + + ../../../findbugs-exclude-filter.xml + + + com.h3xstream.findsecbugs + findsecbugs-plugin + ${findsecbugs-plugin.version} + + + + + + analyze-compile + compile + + check + + + + + + + diff --git a/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/gen/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/RulesApi.java b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/gen/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/RulesApi.java new file mode 100644 index 0000000000..d1b14bf807 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/gen/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/RulesApi.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.rule.metadata.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.rule.metadata.v1.model.Error; +import org.wso2.carbon.identity.api.server.rule.metadata.v1.model.FieldDefinition; +import org.wso2.carbon.identity.api.server.rule.metadata.v1.RulesApiService; + +import javax.validation.Valid; +import javax.ws.rs.*; +import javax.ws.rs.core.Response; +import io.swagger.annotations.*; + +import javax.validation.constraints.*; + +@Path("/rules") +@Api(description = "The rules API") + +public class RulesApi { + + @Autowired + private RulesApiService delegate; + + @Valid + @GET + @Path("/metadata") + + @Produces({ "application/json" }) + @ApiOperation(value = "Get metadata for rule configuration.", notes = "This API provides a list of fields, associated metadata, and applicable operators for each field based on the specified flow type. This information is used to populate the UI for rule configuration. Scope (Permission) required: ``internal_rule_metadata_view`` ", response = FieldDefinition.class, responseContainer = "List", authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Metadata" }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Applicable fields and operators", response = FieldDefinition.class, responseContainer = "List"), + @ApiResponse(code = 400, message = "Bad Request", response = Void.class), + @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), + @ApiResponse(code = 500, message = "Server Error", response = Error.class) + }) + public Response getExpressionMeta( @Valid @NotNull(message = "Property cannot be null.") @ApiParam(value = "Specifies the flow to retrieve rule metadata. This ensures that the metadata returned is relevant to the given flow. Note: At present, only the 'preIssueAccessToken' flow is supported. ",required=true, allowableValues="preIssueAccessToken, prePasswordUpdate, preProfileUpdate, preLogin, postLogin, inLogin, preRegistration, inRegistration, inPasswordExpiry") @QueryParam("flow") String flow) { + + return delegate.getExpressionMeta(flow ); + } + +} diff --git a/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/gen/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/RulesApiService.java b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/gen/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/RulesApiService.java new file mode 100644 index 0000000000..7a502541af --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/gen/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/RulesApiService.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.rule.metadata.v1; + +import org.wso2.carbon.identity.api.server.rule.metadata.v1.*; +import org.wso2.carbon.identity.api.server.rule.metadata.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.rule.metadata.v1.model.Error; +import org.wso2.carbon.identity.api.server.rule.metadata.v1.model.FieldDefinition; +import javax.ws.rs.core.Response; + + +public interface RulesApiService { + + public Response getExpressionMeta(String flow); +} diff --git a/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/gen/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/factories/RulesApiServiceFactory.java b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/gen/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/factories/RulesApiServiceFactory.java new file mode 100644 index 0000000000..8050fa7d72 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/gen/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/factories/RulesApiServiceFactory.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.rule.metadata.v1.factories; + +import org.wso2.carbon.identity.api.server.rule.metadata.v1.RulesApiService; +import org.wso2.carbon.identity.api.server.rule.metadata.v1.impl.RulesApiServiceImpl; + +public class RulesApiServiceFactory { + + private final static RulesApiService service = new RulesApiServiceImpl(); + + public static RulesApiService getRulesApi() + { + return service; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/gen/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/model/Error.java b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/gen/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/model/Error.java new file mode 100644 index 0000000000..d99fbc5d07 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/gen/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/model/Error.java @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.rule.metadata.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.*; +import com.fasterxml.jackson.annotation.JsonValue; + +public class Error { + + private String code; + private String message; + private String description; + private String traceId; + + /** + * Error code + **/ + public Error code(String code) { + + this.code = code; + return this; + } + + @ApiModelProperty(example = "RMS-00000", value = "Error code") + @JsonProperty("code") + @Valid + public String getCode() { + return code; + } + public void setCode(String code) { + this.code = code; + } + + /** + * Error message. + **/ + public Error message(String message) { + + this.message = message; + return this; + } + + @ApiModelProperty(example = "Some error message.", value = "Error message.") + @JsonProperty("message") + @Valid + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + + /** + * Detailed error description. + **/ + public Error description(String description) { + + this.description = description; + return this; + } + + @ApiModelProperty(example = "Some error description.", value = "Detailed error description.") + @JsonProperty("description") + @Valid + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + + /** + * Trace identifier to refer at troubleshooting logs to troubleshoot the problem. + **/ + public Error traceId(String traceId) { + + this.traceId = traceId; + return this; + } + + @ApiModelProperty(example = "e0fbcfeb-3617-43c4-8dd0-7b7d38e13047", value = "Trace identifier to refer at troubleshooting logs to troubleshoot the problem.") + @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.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/gen/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/model/Field.java b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/gen/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/model/Field.java new file mode 100644 index 0000000000..2c216a913b --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/gen/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/model/Field.java @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.rule.metadata.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 javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; +import com.fasterxml.jackson.annotation.JsonValue; + +public class Field { + + private String name; + private String displayName; + private List dependantFields = null; + + + /** + * Name of the field. This is an immutable attribute and uniquely identifies the field allowed in the rule. + **/ + public Field name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "role", value = "Name of the field. This is an immutable attribute and uniquely identifies the field allowed in the rule.") + @JsonProperty("name") + @Valid + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + * Display name of the field. Use as a user friendly label of the field to show in UI. + **/ + public Field displayName(String displayName) { + + this.displayName = displayName; + return this; + } + + @ApiModelProperty(example = "user.role", value = "Display name of the field. Use as a user friendly label of the field to show in UI.") + @JsonProperty("displayName") + @Valid + public String getDisplayName() { + return displayName; + } + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + /** + * Lists the names of fields on which this field depends for its display or selection in the next expression. + **/ + public Field dependantFields(List dependantFields) { + + this.dependantFields = dependantFields; + return this; + } + + @ApiModelProperty(example = "[]", value = "Lists the names of fields on which this field depends for its display or selection in the next expression.") + @JsonProperty("dependantFields") + @Valid + public List getDependantFields() { + return dependantFields; + } + public void setDependantFields(List dependantFields) { + this.dependantFields = dependantFields; + } + + public Field addDependantFieldsItem(String dependantFieldsItem) { + if (this.dependantFields == null) { + this.dependantFields = new ArrayList(); + } + this.dependantFields.add(dependantFieldsItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Field field = (Field) o; + return Objects.equals(this.name, field.name) && + Objects.equals(this.displayName, field.displayName) && + Objects.equals(this.dependantFields, field.dependantFields); + } + + @Override + public int hashCode() { + return Objects.hash(name, displayName, dependantFields); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class Field {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); + sb.append(" dependantFields: ").append(toIndentedString(dependantFields)).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.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/gen/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/model/FieldDefinition.java b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/gen/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/model/FieldDefinition.java new file mode 100644 index 0000000000..bd96e86632 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/gen/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/model/FieldDefinition.java @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.rule.metadata.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.rule.metadata.v1.model.Field; +import org.wso2.carbon.identity.api.server.rule.metadata.v1.model.Operator; +import org.wso2.carbon.identity.api.server.rule.metadata.v1.model.Value; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; +import com.fasterxml.jackson.annotation.JsonValue; + +public class FieldDefinition { + + private Field field; + private List operators = null; + + private Value value; + + /** + **/ + public FieldDefinition field(Field field) { + + this.field = field; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("field") + @Valid + public Field getField() { + return field; + } + public void setField(Field field) { + this.field = field; + } + + /** + * Specifies the list of valid operators that can be applied to this field in rule expressions. Each operator defines a comparison or matching condition (e.g., \\\"equals\\\", \\\"contains\\\", \\\"greaterThan\\\") that determines how the field's value will be evaluated within a rule. + **/ + public FieldDefinition operators(List operators) { + + this.operators = operators; + return this; + } + + @ApiModelProperty(value = "Specifies the list of valid operators that can be applied to this field in rule expressions. Each operator defines a comparison or matching condition (e.g., \\\"equals\\\", \\\"contains\\\", \\\"greaterThan\\\") that determines how the field's value will be evaluated within a rule. ") + @JsonProperty("operators") + @Valid + public List getOperators() { + return operators; + } + public void setOperators(List operators) { + this.operators = operators; + } + + public FieldDefinition addOperatorsItem(Operator operatorsItem) { + if (this.operators == null) { + this.operators = new ArrayList(); + } + this.operators.add(operatorsItem); + return this; + } + + /** + **/ + public FieldDefinition value(Value value) { + + this.value = value; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("value") + @Valid + public Value getValue() { + return value; + } + public void setValue(Value 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; + } + FieldDefinition fieldDefinition = (FieldDefinition) o; + return Objects.equals(this.field, fieldDefinition.field) && + Objects.equals(this.operators, fieldDefinition.operators) && + Objects.equals(this.value, fieldDefinition.value); + } + + @Override + public int hashCode() { + return Objects.hash(field, operators, value); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class FieldDefinition {\n"); + + sb.append(" field: ").append(toIndentedString(field)).append("\n"); + sb.append(" operators: ").append(toIndentedString(operators)).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.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/gen/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/model/Link.java b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/gen/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/model/Link.java new file mode 100644 index 0000000000..7a09c10f62 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/gen/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/model/Link.java @@ -0,0 +1,212 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.rule.metadata.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.*; +import com.fasterxml.jackson.annotation.JsonValue; + +public class Link { + + private String href; + +@XmlType(name="MethodEnum") +@XmlEnum(String.class) +public enum MethodEnum { + + @XmlEnumValue("GET") GET(String.valueOf("GET")); + + + private String value; + + MethodEnum(String v) { + value = v; + } + + @JsonValue + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static MethodEnum fromValue(String value) { + for (MethodEnum b : MethodEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + + private MethodEnum method; + +@XmlType(name="RelEnum") +@XmlEnum(String.class) +public enum RelEnum { + + @XmlEnumValue("values") VALUES(String.valueOf("values")), @XmlEnumValue("filter") FILTER(String.valueOf("filter")); + + + private String value; + + RelEnum(String v) { + value = v; + } + + @JsonValue + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static RelEnum fromValue(String value) { + for (RelEnum b : RelEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + + private RelEnum rel; + + /** + * Url of the endpoint. + **/ + public Link href(String href) { + + this.href = href; + return this; + } + + @ApiModelProperty(value = "Url of the endpoint.") + @JsonProperty("href") + @Valid + public String getHref() { + return href; + } + public void setHref(String href) { + this.href = href; + } + + /** + * Http method. + **/ + public Link method(MethodEnum method) { + + this.method = method; + return this; + } + + @ApiModelProperty(value = "Http method.") + @JsonProperty("method") + @Valid + public MethodEnum getMethod() { + return method; + } + public void setMethod(MethodEnum method) { + this.method = method; + } + + /** + * Indicates the endpoint’s relation to retrieving or filtering field values. + **/ + public Link rel(RelEnum rel) { + + this.rel = rel; + return this; + } + + @ApiModelProperty(value = "Indicates the endpoint’s relation to retrieving or filtering field values.") + @JsonProperty("rel") + @Valid + public RelEnum getRel() { + return rel; + } + public void setRel(RelEnum rel) { + this.rel = rel; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Link link = (Link) o; + return Objects.equals(this.href, link.href) && + Objects.equals(this.method, link.method) && + Objects.equals(this.rel, link.rel); + } + + @Override + public int hashCode() { + return Objects.hash(href, method, rel); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class Link {\n"); + + sb.append(" href: ").append(toIndentedString(href)).append("\n"); + sb.append(" method: ").append(toIndentedString(method)).append("\n"); + sb.append(" rel: ").append(toIndentedString(rel)).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.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/gen/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/model/Operator.java b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/gen/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/model/Operator.java new file mode 100644 index 0000000000..083eaca19a --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/gen/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/model/Operator.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.rule.metadata.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.*; +import com.fasterxml.jackson.annotation.JsonValue; + +public class Operator { + + private String name; + private String displayName; + + /** + * Name of the operator. The immutable identifier of the operator referenced within the rule expression. + **/ + public Operator name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(value = "Name of the operator. The immutable identifier of the operator referenced within the rule expression.") + @JsonProperty("name") + @Valid + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + * Display name of the operator. Use as a user friendly label of the operator to show in UI. + **/ + public Operator displayName(String displayName) { + + this.displayName = displayName; + return this; + } + + @ApiModelProperty(value = "Display name of the operator. Use as a user friendly label of the operator to show in UI.") + @JsonProperty("displayName") + @Valid + public String getDisplayName() { + return displayName; + } + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Operator operator = (Operator) o; + return Objects.equals(this.name, operator.name) && + Objects.equals(this.displayName, operator.displayName); + } + + @Override + public int hashCode() { + return Objects.hash(name, displayName); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class Operator {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" displayName: ").append(toIndentedString(displayName)).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.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/gen/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/model/Value.java b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/gen/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/model/Value.java new file mode 100644 index 0000000000..b87b76dd8d --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/gen/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/model/Value.java @@ -0,0 +1,300 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.rule.metadata.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.rule.metadata.v1.model.Link; +import org.wso2.carbon.identity.api.server.rule.metadata.v1.model.ValueObject; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; +import com.fasterxml.jackson.annotation.JsonValue; + +public class Value { + + +@XmlType(name="InputTypeEnum") +@XmlEnum(String.class) +public enum InputTypeEnum { + + @XmlEnumValue("input") INPUT(String.valueOf("input")), @XmlEnumValue("options") OPTIONS(String.valueOf("options")); + + + private String value; + + InputTypeEnum(String v) { + value = v; + } + + @JsonValue + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static InputTypeEnum fromValue(String value) { + for (InputTypeEnum b : InputTypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + + private InputTypeEnum inputType; + +@XmlType(name="ValueTypeEnum") +@XmlEnum(String.class) +public enum ValueTypeEnum { + + @XmlEnumValue("string") STRING(String.valueOf("string")), @XmlEnumValue("number") NUMBER(String.valueOf("number")), @XmlEnumValue("boolean") BOOLEAN(String.valueOf("boolean")), @XmlEnumValue("date") DATE(String.valueOf("date")), @XmlEnumValue("reference") REFERENCE(String.valueOf("reference")); + + + private String value; + + ValueTypeEnum(String v) { + value = v; + } + + @JsonValue + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static ValueTypeEnum fromValue(String value) { + for (ValueTypeEnum b : ValueTypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + + private ValueTypeEnum valueType; + private String valueReferenceAttribute; + private String valueDisplayAttribute; + private List links = null; + + private List values = null; + + + /** + * Defines how the field should be presented and populated in the rule configuration UI. This property indicates whether the field allows direct user input or if the values are selected from predefined options. Possible types include: - \"input\": Allows for direct user entry, such as text or numeric input. - \"options\": Provides a list of selectable values, often fetched from an external data source, enabling users to pick from predefined choices. + **/ + public Value inputType(InputTypeEnum inputType) { + + this.inputType = inputType; + return this; + } + + @ApiModelProperty(value = "Defines how the field should be presented and populated in the rule configuration UI. This property indicates whether the field allows direct user input or if the values are selected from predefined options. Possible types include: - \"input\": Allows for direct user entry, such as text or numeric input. - \"options\": Provides a list of selectable values, often fetched from an external data source, enabling users to pick from predefined choices. ") + @JsonProperty("inputType") + @Valid + public InputTypeEnum getInputType() { + return inputType; + } + public void setInputType(InputTypeEnum inputType) { + this.inputType = inputType; + } + + /** + * Specifies the expected data type for the field’s value within a rule expression. This property defines how the field's value should be interpreted when used in rule conditions. Possible types include: - \"string\": Text value. - \"number\": Numerical value. - \"boolean\": True or false. - \"date\": Date value. - \"reference\": A reference to an external identifier, often used with options-type fields to indicate that the value is an ID or a unique attribute from related data.\" + **/ + public Value valueType(ValueTypeEnum valueType) { + + this.valueType = valueType; + return this; + } + + @ApiModelProperty(value = "Specifies the expected data type for the field’s value within a rule expression. This property defines how the field's value should be interpreted when used in rule conditions. Possible types include: - \"string\": Text value. - \"number\": Numerical value. - \"boolean\": True or false. - \"date\": Date value. - \"reference\": A reference to an external identifier, often used with options-type fields to indicate that the value is an ID or a unique attribute from related data.\" ") + @JsonProperty("valueType") + @Valid + public ValueTypeEnum getValueType() { + return valueType; + } + public void setValueType(ValueTypeEnum valueType) { + this.valueType = valueType; + } + + /** + * The key attribute in the options data (e.g., 'id') used to represent the option's selected value in rule expressions. Only available when 'valueType' is 'reference'. + **/ + public Value valueReferenceAttribute(String valueReferenceAttribute) { + + this.valueReferenceAttribute = valueReferenceAttribute; + return this; + } + + @ApiModelProperty(example = "id", value = "The key attribute in the options data (e.g., 'id') used to represent the option's selected value in rule expressions. Only available when 'valueType' is 'reference'.") + @JsonProperty("valueReferenceAttribute") + @Valid + public String getValueReferenceAttribute() { + return valueReferenceAttribute; + } + public void setValueReferenceAttribute(String valueReferenceAttribute) { + this.valueReferenceAttribute = valueReferenceAttribute; + } + + /** + * The attribute to show as the label for each option in the dropdown (e.g., 'name') when listing options. Only available when 'valueType' is 'reference'. + **/ + public Value valueDisplayAttribute(String valueDisplayAttribute) { + + this.valueDisplayAttribute = valueDisplayAttribute; + return this; + } + + @ApiModelProperty(example = "name", value = "The attribute to show as the label for each option in the dropdown (e.g., 'name') when listing options. Only available when 'valueType' is 'reference'.") + @JsonProperty("valueDisplayAttribute") + @Valid + public String getValueDisplayAttribute() { + return valueDisplayAttribute; + } + public void setValueDisplayAttribute(String valueDisplayAttribute) { + this.valueDisplayAttribute = valueDisplayAttribute; + } + + /** + * Endpoints to retrieve or search for options dynamically. Included only when 'valueType' is 'reference'. + **/ + public Value links(List links) { + + this.links = links; + return this; + } + + @ApiModelProperty(example = "[{\"href\":\"/scim2/roles?offset=0&limit=10\",\"method\":\"GET\",\"rel\":\"values\"},{\"href\":\"/scim2/roles/.search\",\"method\":\"GET\",\"rel\":\"filter\"}]", value = "Endpoints to retrieve or search for options dynamically. Included only when 'valueType' is 'reference'.") + @JsonProperty("links") + @Valid + public List getLinks() { + return links; + } + public void setLinks(List links) { + this.links = links; + } + + public Value addLinksItem(Link linksItem) { + if (this.links == null) { + this.links = new ArrayList(); + } + this.links.add(linksItem); + return this; + } + + /** + * List of selectable values for options fields when 'valueType' is 'string', 'number', 'boolean', or 'date'. + **/ + public Value values(List values) { + + this.values = values; + return this; + } + + @ApiModelProperty(value = "List of selectable values for options fields when 'valueType' is 'string', 'number', 'boolean', or 'date'.") + @JsonProperty("values") + @Valid + public List getValues() { + return values; + } + public void setValues(List values) { + this.values = values; + } + + public Value addValuesItem(ValueObject valuesItem) { + if (this.values == null) { + this.values = new ArrayList(); + } + this.values.add(valuesItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Value value = (Value) o; + return Objects.equals(this.inputType, value.inputType) && + Objects.equals(this.valueType, value.valueType) && + Objects.equals(this.valueReferenceAttribute, value.valueReferenceAttribute) && + Objects.equals(this.valueDisplayAttribute, value.valueDisplayAttribute) && + Objects.equals(this.links, value.links) && + Objects.equals(this.values, value.values); + } + + @Override + public int hashCode() { + return Objects.hash(inputType, valueType, valueReferenceAttribute, valueDisplayAttribute, links, values); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class Value {\n"); + + sb.append(" inputType: ").append(toIndentedString(inputType)).append("\n"); + sb.append(" valueType: ").append(toIndentedString(valueType)).append("\n"); + sb.append(" valueReferenceAttribute: ").append(toIndentedString(valueReferenceAttribute)).append("\n"); + sb.append(" valueDisplayAttribute: ").append(toIndentedString(valueDisplayAttribute)).append("\n"); + sb.append(" links: ").append(toIndentedString(links)).append("\n"); + sb.append(" values: ").append(toIndentedString(values)).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.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/gen/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/model/ValueObject.java b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/gen/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/model/ValueObject.java new file mode 100644 index 0000000000..c82099ea52 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/gen/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/model/ValueObject.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.rule.metadata.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.*; +import com.fasterxml.jackson.annotation.JsonValue; + +public class ValueObject { + + private String name; + private String displayName; + + /** + * The name that uniquely identifies the option. + **/ + public ValueObject name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(value = "The name that uniquely identifies the option.") + @JsonProperty("name") + @Valid + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + * The display name for the option. + **/ + public ValueObject displayName(String displayName) { + + this.displayName = displayName; + return this; + } + + @ApiModelProperty(value = "The display name for the option.") + @JsonProperty("displayName") + @Valid + public String getDisplayName() { + return displayName; + } + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ValueObject valueObject = (ValueObject) o; + return Objects.equals(this.name, valueObject.name) && + Objects.equals(this.displayName, valueObject.displayName); + } + + @Override + public int hashCode() { + return Objects.hash(name, displayName); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class ValueObject {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" displayName: ").append(toIndentedString(displayName)).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.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/main/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/core/ServerRuleMetadataService.java b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/main/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/core/ServerRuleMetadataService.java new file mode 100644 index 0000000000..5b09f05f51 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/main/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/core/ServerRuleMetadataService.java @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.rule.metadata.v1.core; + +import org.wso2.carbon.context.CarbonContext; +import org.wso2.carbon.identity.api.server.rule.metadata.common.RuleMetadataServiceHolder; +import org.wso2.carbon.identity.api.server.rule.metadata.v1.model.Field; +import org.wso2.carbon.identity.api.server.rule.metadata.v1.model.Link; +import org.wso2.carbon.identity.api.server.rule.metadata.v1.util.RuleMetadataAPIErrorBuilder; +import org.wso2.carbon.identity.rule.metadata.exception.RuleMetadataException; +import org.wso2.carbon.identity.rule.metadata.model.FieldDefinition; +import org.wso2.carbon.identity.rule.metadata.model.FlowType; +import org.wso2.carbon.identity.rule.metadata.model.InputValue; +import org.wso2.carbon.identity.rule.metadata.model.Operator; +import org.wso2.carbon.identity.rule.metadata.model.OptionsInputValue; +import org.wso2.carbon.identity.rule.metadata.model.OptionsReferenceValue; +import org.wso2.carbon.identity.rule.metadata.model.OptionsValue; +import org.wso2.carbon.identity.rule.metadata.model.Value; + +import java.util.ArrayList; +import java.util.List; + +/** + * Service class for Rule Metadata Service. + */ +public class ServerRuleMetadataService { + + /** + * Get the expression metadata for the given flow. + * @param flow Flow type + * @return List of field definitions + */ + public List getExpressionMeta( + String flow) { + + try { + FlowType flowType = FlowType.valueOfFlowAlias(flow); + + List fieldDefinitions = + RuleMetadataServiceHolder.getRuleMetadataService().getExpressionMeta(flowType, + CarbonContext.getThreadLocalCarbonContext().getTenantDomain()); + + List + fieldDefinitionResponseList = new ArrayList<>(); + for (FieldDefinition fieldDefinition : fieldDefinitions) { + fieldDefinitionResponseList.add(buildFieldDefinitionResponse(fieldDefinition)); + } + + return fieldDefinitionResponseList; + } catch (RuleMetadataException e) { + throw RuleMetadataAPIErrorBuilder.buildAPIError(e); + } + } + + private org.wso2.carbon.identity.api.server.rule.metadata.v1.model.FieldDefinition buildFieldDefinitionResponse( + FieldDefinition fieldDefinition) { + + org.wso2.carbon.identity.api.server.rule.metadata.v1.model.FieldDefinition fieldDefinitionResponse = + new org.wso2.carbon.identity.api.server.rule.metadata.v1.model.FieldDefinition(); + + Field field = new Field().name(fieldDefinition.getField().getName()) + .displayName(fieldDefinition.getField().getDisplayName()); + fieldDefinitionResponse.setField(field); + + setOperators(fieldDefinition, fieldDefinitionResponse); + setValue(fieldDefinition, fieldDefinitionResponse); + + return fieldDefinitionResponse; + } + + private void setOperators(FieldDefinition fieldDefinition, + org.wso2.carbon.identity.api.server.rule.metadata.v1.model.FieldDefinition + fieldDefinitionResponse) { + + List operators = fieldDefinition.getOperators(); + for (Operator operator : operators) { + org.wso2.carbon.identity.api.server.rule.metadata.v1.model.Operator operatorItem = + new org.wso2.carbon.identity.api.server.rule.metadata.v1.model.Operator().name(operator.getName()) + .displayName(operator.getDisplayName()); + fieldDefinitionResponse.addOperatorsItem(operatorItem); + } + } + + private void setValue(FieldDefinition fieldDefinition, + org.wso2.carbon.identity.api.server.rule.metadata.v1.model.FieldDefinition + fieldDefinitionResponse) { + + Value value = fieldDefinition.getValue(); + if (value instanceof InputValue) { + setInputValue((InputValue) value, fieldDefinitionResponse); + } else if (value instanceof OptionsInputValue) { + setOptionsInputValue((OptionsInputValue) value, fieldDefinitionResponse); + } else if (value instanceof OptionsReferenceValue) { + setOptionsReferenceValue((OptionsReferenceValue) value, fieldDefinitionResponse); + } + } + + private void setInputValue( + InputValue value, + org.wso2.carbon.identity.api.server.rule.metadata.v1.model.FieldDefinition fieldDefinitionResponse) { + + org.wso2.carbon.identity.api.server.rule.metadata.v1.model.Value valueItem = + new org.wso2.carbon.identity.api.server.rule.metadata.v1.model.Value().inputType( + org.wso2.carbon.identity.api.server.rule.metadata.v1.model.Value.InputTypeEnum.valueOf( + value.getInputType().name())) + .valueType( + org.wso2.carbon.identity.api.server.rule.metadata.v1.model.Value.ValueTypeEnum.valueOf( + value.getValueType().name())); + fieldDefinitionResponse.value(valueItem); + } + + private void setOptionsInputValue(OptionsInputValue optionsInputValue, + org.wso2.carbon.identity.api.server.rule.metadata.v1.model.FieldDefinition + fieldDefinitionResponse) { + + org.wso2.carbon.identity.api.server.rule.metadata.v1.model.Value valueItem = + new org.wso2.carbon.identity.api.server.rule.metadata.v1.model.Value().inputType( + org.wso2.carbon.identity.api.server.rule.metadata.v1.model.Value.InputTypeEnum.valueOf( + optionsInputValue.getInputType().name())) + .valueType( + org.wso2.carbon.identity.api.server.rule.metadata.v1.model.Value.ValueTypeEnum.valueOf( + optionsInputValue.getValueType().name())); + for (OptionsValue optionsValue : optionsInputValue.getValues()) { + org.wso2.carbon.identity.api.server.rule.metadata.v1.model.ValueObject valueObjectItem = + new org.wso2.carbon.identity.api.server.rule.metadata.v1.model.ValueObject() + .displayName(optionsValue.getDisplayName()).name(optionsValue.getName()); + valueItem.addValuesItem(valueObjectItem); + } + fieldDefinitionResponse.value(valueItem); + } + + private void setOptionsReferenceValue(OptionsReferenceValue optionsReferenceValue, + org.wso2.carbon.identity.api.server.rule.metadata.v1.model.FieldDefinition + fieldDefinitionResponse) { + + org.wso2.carbon.identity.api.server.rule.metadata.v1.model.Value valueItem = + new org.wso2.carbon.identity.api.server.rule.metadata.v1.model.Value().inputType( + org.wso2.carbon.identity.api.server.rule.metadata.v1.model.Value.InputTypeEnum.valueOf( + optionsReferenceValue.getInputType().name())) + .valueType( + org.wso2.carbon.identity.api.server.rule.metadata.v1.model.Value.ValueTypeEnum.valueOf( + optionsReferenceValue.getValueType().name())) + .valueDisplayAttribute(optionsReferenceValue.getValueDisplayAttribute()) + .valueReferenceAttribute(optionsReferenceValue.getValueReferenceAttribute()); + for (org.wso2.carbon.identity.rule.metadata.model.Link link : optionsReferenceValue.getLinks()) { + org.wso2.carbon.identity.api.server.rule.metadata.v1.model.Link linkItem = + new org.wso2.carbon.identity.api.server.rule.metadata.v1.model.Link().href(link.getHref()) + .rel(Link.RelEnum.fromValue(link.getRel())) + .method(Link.MethodEnum.fromValue(link.getMethod())); + valueItem.addLinksItem(linkItem); + } + fieldDefinitionResponse.value(valueItem); + } +} diff --git a/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/main/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/impl/RulesApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/main/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/impl/RulesApiServiceImpl.java new file mode 100644 index 0000000000..19cc9fadbd --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/main/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/impl/RulesApiServiceImpl.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.rule.metadata.v1.impl; + +import org.springframework.beans.factory.annotation.Autowired; +import org.wso2.carbon.identity.api.server.rule.metadata.v1.RulesApiService; +import org.wso2.carbon.identity.api.server.rule.metadata.v1.core.ServerRuleMetadataService; + +import javax.ws.rs.core.Response; + +/** + * Implementation of the Rules Metadata REST API. + */ +public class RulesApiServiceImpl implements RulesApiService { + + @Autowired + private ServerRuleMetadataService serverRuleMetadataService; + + @Override + public Response getExpressionMeta(String flow) { + + return Response.ok().entity(serverRuleMetadataService.getExpressionMeta(flow)).build(); + } +} diff --git a/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/main/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/util/RuleMetadataAPIErrorBuilder.java b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/main/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/util/RuleMetadataAPIErrorBuilder.java new file mode 100644 index 0000000000..0df20d0157 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/main/java/org/wso2/carbon/identity/api/server/rule/metadata/v1/util/RuleMetadataAPIErrorBuilder.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.rule.metadata.v1.util; + +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.ErrorDTO; +import org.wso2.carbon.identity.rule.metadata.exception.RuleMetadataClientException; +import org.wso2.carbon.identity.rule.metadata.exception.RuleMetadataException; + +import javax.ws.rs.core.Response; + +/** + * Class that handles exceptions and builds API error object. + */ +public class RuleMetadataAPIErrorBuilder { + + private static final String ERROR_CODE_DELIMITER = "-"; + private static final String ERROR_CODE_PREFIX = "RULEMETA" + ERROR_CODE_DELIMITER; + private static final Log LOG = LogFactory.getLog(RuleMetadataAPIErrorBuilder.class); + + private RuleMetadataAPIErrorBuilder() { + + } + + public static APIError buildAPIError(RuleMetadataException exception) { + + Response.Status status = Response.Status.INTERNAL_SERVER_ERROR; + if (exception instanceof RuleMetadataClientException) { + LOG.debug(exception.getMessage(), exception); + status = Response.Status.BAD_REQUEST; + } else { + LOG.error(exception.getMessage(), exception); + } + + String errorCode = exception.getErrorCode(); + errorCode = errorCode.contains(ERROR_CODE_DELIMITER) ? errorCode : + ERROR_CODE_PREFIX + errorCode; + return buildAPIError(status, errorCode, exception.getMessage(), exception.getDescription()); + } + + private static APIError buildAPIError(Response.Status status, String errorCode, + String message, String description) { + + return new APIError(status, getError(errorCode, message, description)); + } + + private 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.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/main/resources/META-INF/cxf/rule-metadata-server-v1-cxf.xml b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/main/resources/META-INF/cxf/rule-metadata-server-v1-cxf.xml new file mode 100644 index 0000000000..cb6f995fcf --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/main/resources/META-INF/cxf/rule-metadata-server-v1-cxf.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/main/resources/rule-metadata.yaml b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/main/resources/rule-metadata.yaml new file mode 100644 index 0000000000..2fc73a4665 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/main/resources/rule-metadata.yaml @@ -0,0 +1,378 @@ +openapi: 3.0.1 +info: + title: WSO2 Identity Server Rule Metadata REST API + description: "The Rule Metadata API provides the essential metadata required to configure rules dynamically based on the flow context. \nThe metadata retrieved by this API is designed to support rule configuration in the user interface (UI) by delivering information about each configurable field, the set of applicable comparison operators (e.g., equals, contains) for each field, and lists of possible values or options for fields.\n" + contact: + name: WSO2 + url: https://wso2.com/identity-and-access-management/ + license: + name: Apache 2.0 + url: https://www.apache.org/licenses/LICENSE-2.0.html + version: v1 +servers: +- url: "https://{server-url}/t/{tenant-domain}/api/server/v1" + variables: + tenant-domain: + default: carbon.super + server-url: + default: localhost:9443 +security: +- OAuth2: [] +- BasicAuth: [] +paths: + /rules/metadata: + get: + tags: + - Metadata + summary: Get metadata for rule configuration. + description: |+ + This API provides a list of fields, associated metadata, and applicable operators for each field based on the specified flow type. This information is used to populate the UI for rule configuration. + + Scope (Permission) required: ``internal_rule_metadata_view`` + + operationId: getExpressionMeta + parameters: + - name: flow + in: query + description: | + Specifies the flow to retrieve rule metadata. This ensures that the metadata returned is relevant to the given flow. + + Note: At present, only the 'preIssueAccessToken' flow is supported. + required: true + style: form + explode: true + schema: + type: string + enum: + - preIssueAccessToken + - prePasswordUpdate + - preProfileUpdate + - preLogin + - postLogin + - inLogin + - preRegistration + - inRegistration + - inPasswordExpiry + responses: + "200": + description: Applicable fields and operators + content: + application/json: + schema: + $ref: '#/components/schemas/ExpressionMeta' + examples: + preIssueAccessToken: + summary: Sample response for pre-issue access token flow + value: + - field: + name: application + displayName: application + operators: + - name: equals + displayName: equals + - name: notEquals + displayName: not equals + value: + inputType: options + valueType: reference + valueReferenceAttribute: id + valueDisplayAttribute: name + links: + - href: /applications?offset=0&limit=10 + method: GET + rel: values + - href: /applications?filter=name+eq+*&limit=10 + method: GET + rel: filter + - field: + name: grantType + displayName: grant type + operators: + - name: equals + displayName: equals + - name: notEquals + displayName: not equals + value: + inputType: options + valueType: string + values: + - name: authorization_code + displayName: authorization code + - name: password + displayName: password + - name: refresh_token + displayName: refresh token + - name: client_credentials + displayName: client credentials + - name: urn:ietf:params:oauth:grant-type:token-exchange + displayName: token exchange + prePasswordUpdate: + summary: Sample response for pre-password update flow + value: + - field: + name: initiator + displayName: initiator + operators: + - name: equals + displayName: equals + - name: notEquals + displayName: not equals + value: + inputType: options + valueType: string + values: + - name: user + displayName: user + - name: admin + displayName: admin + - name: application + displayName: application + - field: + name: flow + displayName: flow + dependentFileds: + - initiator + operators: + - name: equals + displayName: equals + - name: notEquals + displayName: not equals + value: + inputType: options + valueType: string + values: + - name: reset + displayName: reset + - name: update + displayName: update + inLogin: + summary: Sample response for login flow + value: + - field: + name: role + displayName: user.role + operators: + - name: equals + displayName: equals + - name: notEquals + displayName: not equals + value: + inputType: options + valueType: reference + valueReferenceAttribute: id + valueDisplayAttribute: name + links: + - href: /scim2/Roles?offset=0&limit=10 + method: GET + rel: values + - href: /scim2/Roles?filter=name+eq+*&limit=10 + method: GET + rel: filter + - field: + name: group + displayName: user.group + operators: + - name: equals + displayName: equals + - name: notEquals + displayName: not equals + value: + inputType: options + valueType: reference + valueReferenceAttribute: id + valueDisplayAttribute: name + links: + - href: /scim2/Groups?offset=0&limit=10 + method: GET + rel: values + - href: /scim2/Groups?filter=name+eq+*&limit=10 + method: GET + rel: filter + - field: + name: email + displayName: user.email + operators: + - name: equals + displayName: equals + - name: notEquals + displayName: not equals + - name: startsWith + displayName: starts with + - name: endsWith + displayName: ends with + - name: contains + displayName: contains + value: + inputType: input + valueType: string + "400": + description: Bad Request + "401": + description: Unauthorized + "500": + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + x-codeSamples: + - lang: Curl + source: | + curl --location 'https://localhost:9443/api/server/v1/rules/metadata?flow=preIssueAccessToken' \ + --header 'Authorization: Basic YWRtaW46YWRtaW4=' +components: + schemas: + ExpressionMeta: + type: array + description: Represents the metadata for rule expressions. It includes field definitions and associated operators. + items: + $ref: '#/components/schemas/FieldDefinition' + FieldDefinition: + type: object + properties: + field: + $ref: '#/components/schemas/Field' + operators: + type: array + description: | + Specifies the list of valid operators that can be applied to this field in rule expressions. Each operator defines a comparison or matching condition (e.g., \"equals\", \"contains\", \"greaterThan\") that determines how the field's value will be evaluated within a rule. + items: + $ref: '#/components/schemas/Operator' + value: + $ref: '#/components/schemas/Value' + Field: + type: object + properties: + name: + type: string + description: Name of the field. This is an immutable attribute and uniquely identifies the field allowed in the rule. + example: role + displayName: + type: string + description: Display name of the field. Use as a user friendly label of the field to show in UI. + example: user.role + dependantFields: + type: array + description: Lists the names of fields on which this field depends for its display or selection in the next expression. + example: [] + items: + type: string + Value: + type: object + properties: + inputType: + type: string + description: | + Defines how the field should be presented and populated in the rule configuration UI. This property indicates whether the field allows direct user input or if the values are selected from predefined options. Possible types include: + + - "input": Allows for direct user entry, such as text or numeric input. + - "options": Provides a list of selectable values, often fetched from an external data source, enabling users to pick from predefined choices. + enum: + - input + - options + valueType: + type: string + description: | + Specifies the expected data type for the field’s value within a rule expression. This property defines how the field's value should be interpreted when used in rule conditions. Possible types include: + - "string": Text value. + - "number": Numerical value. + - "boolean": True or false. + - "date": Date value. + - "reference": A reference to an external identifier, often used with options-type fields to indicate that the value is an ID or a unique attribute from related data." + enum: + - string + - number + - boolean + - date + - reference + valueReferenceAttribute: + type: string + description: "The key attribute in the options data (e.g., 'id') used to represent the option's selected value in rule expressions. Only available when 'valueType' is 'reference'." + example: id + valueDisplayAttribute: + type: string + description: "The attribute to show as the label for each option in the dropdown (e.g., 'name') when listing options. Only available when 'valueType' is 'reference'." + example: name + links: + type: array + description: Endpoints to retrieve or search for options dynamically. Included only when 'valueType' is 'reference'. + example: + - href: /scim2/roles?offset=0&limit=10 + method: GET + rel: values + - href: /scim2/roles/.search + method: GET + rel: filter + items: + $ref: '#/components/schemas/Link' + values: + type: array + description: "List of selectable values for options fields when 'valueType' is 'string', 'number', 'boolean', or 'date'." + items: + $ref: '#/components/schemas/ValueObject' + Operator: + type: object + properties: + name: + type: string + description: Name of the operator. The immutable identifier of the operator referenced within the rule expression. + displayName: + type: string + description: Display name of the operator. Use as a user friendly label of the operator to show in UI. + ValueObject: + type: object + properties: + name: + type: string + description: The name that uniquely identifies the option. + displayName: + type: string + description: The display name for the option. + Link: + type: object + properties: + href: + type: string + description: Url of the endpoint. + method: + type: string + description: Http method. + enum: + - GET + rel: + type: string + description: Indicates the endpoint’s relation to retrieving or filtering field values. + enum: + - values + - filter + Error: + type: object + properties: + code: + type: string + description: Error code + example: RMS-00000 + message: + type: string + description: Error message. + example: Some error message. + description: + type: string + description: Detailed error description. + example: Some error description. + traceId: + type: string + description: Trace identifier to refer at troubleshooting logs to troubleshoot the problem. + example: e0fbcfeb-3617-43c4-8dd0-7b7d38e13047 + securitySchemes: + BasicAuth: + type: http + scheme: basic + OAuth2: + type: oauth2 + flows: + authorizationCode: + authorizationUrl: https://localhost:9443/oauth2/authorize + tokenUrl: http://localhost:9763/oauth2/token + scopes: + read: internal_rule_metadata_view diff --git a/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/main/resources/templates/enumClass.mustache b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/main/resources/templates/enumClass.mustache new file mode 100644 index 0000000000..19d0ee218b --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/main/resources/templates/enumClass.mustache @@ -0,0 +1,34 @@ +@XmlType(name="{{datatypeWithEnum}}") +@XmlEnum({{dataType}}.class) +public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} { + + {{#allowableValues}} + {{#enumVars}}@XmlEnumValue({{^isString}}"{{/isString}}{{{value}}}{{^isString}}"{{/isString}}) {{name}}({{dataType}}.valueOf({{{value}}})){{^-last}}, {{/-last}}{{#-last}};{{/-last}}{{/enumVars}} + {{/allowableValues}} + + + private {{dataType}} value; + + {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}({{dataType}} v) { + value = v; + } + + @JsonValue + public {{dataType}} value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue({{dataType}} value) { + for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) { + if (b.value.equals(value)) { + return b; + } + } + {{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/isNullable}} + } +} diff --git a/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/main/resources/templates/pojo.mustache b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/main/resources/templates/pojo.mustache new file mode 100644 index 0000000000..3787e0a751 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.rule.metadata/org.wso2.carbon.identity.api.server.rule.metadata.v1/src/main/resources/templates/pojo.mustache @@ -0,0 +1,117 @@ +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; +import com.fasterxml.jackson.annotation.JsonValue; +{{#description}}@ApiModel(description = "{{{description}}}"){{/description}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}} +public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}}{ + {{#vars}}{{#isEnum}}{{^isContainer}} + +{{>enumClass}}{{/isContainer}}{{#isContainer}}{{#mostInnerItems}} + +{{>enumClass}}{{/mostInnerItems}}{{/isContainer}}{{/isEnum}} +{{#isContainer}} + private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}}; +{{/isContainer}} +{{^isContainer}} + private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};{{/isContainer}}{{/vars}} + + {{#vars}} + /** + {{#description}} + * {{description}} + {{/description}} + {{#minimum}} + * minimum: {{minimum}} + {{/minimum}} + {{#maximum}} + * maximum: {{maximum}} + {{/maximum}} + **/ + public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) { + + this.{{name}} = {{name}}; + return this; + } + {{#vendorExtensions.extraAnnotation}}{{{vendorExtensions.extraAnnotation}}}{{/vendorExtensions.extraAnnotation}} + @ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}") + @JsonProperty("{{baseName}}"){{#useBeanValidation}} + {{>beanValidation}}{{/useBeanValidation}} + public {{{datatypeWithEnum}}} {{getter}}() { + return {{name}}; + } + public void {{setter}}({{{datatypeWithEnum}}} {{name}}) { + this.{{name}} = {{name}}; + } + + {{#isListContainer}} + public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) { + {{^required}} + if (this.{{name}} == null) { + this.{{name}} = {{{defaultValue}}}; + } + {{/required}} + this.{{name}}.add({{name}}Item); + return this; + } + + {{/isListContainer}}{{#isMapContainer}} + public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) { + {{^required}} + if (this.{{name}} == null) { + this.{{name}} = {{{defaultValue}}}; + } + {{/required}} + this.{{name}}.put(key, {{name}}Item); + return this; + } + + {{/isMapContainer}}{{/vars}} + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + }{{#parent}} + if (!super.equals(o)) { + return false; + } + {{/parent}}{{#hasVars}} + {{classname}} {{classVarName}} = ({{classname}}) o; + return {{#vars}}Objects.equals(this.{{name}}, {{classVarName}}.{{name}}){{#hasMore}} && + {{/hasMore}}{{^hasMore}};{{/hasMore}}{{/vars}}{{/hasVars}}{{^hasVars}} + return true;{{/hasVars}} + } + + @Override + public int hashCode() { + return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class {{classname}} {\n"); + {{#parent}}sb.append(" ").append(toIndentedString(super.toString())).append("\n");{{/parent}} + {{#vars}}sb.append(" {{name}}: ").append(toIndentedString({{name}})).append("\n"); + {{/vars}}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.rule.metadata/pom.xml b/components/org.wso2.carbon.identity.api.server.rule.metadata/pom.xml new file mode 100644 index 0000000000..901769a6d5 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.rule.metadata/pom.xml @@ -0,0 +1,37 @@ + + + + + 4.0.0 + + + org.wso2.carbon.identity.server.api + identity-api-server + 1.3.11-SNAPSHOT + ../../pom.xml + + + org.wso2.carbon.identity.api.server.rule.metadata + pom + + + org.wso2.carbon.identity.api.server.rule.metadata.common + org.wso2.carbon.identity.api.server.rule.metadata.v1 + + 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 7b57e7ac85..7840205a05 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.258-SNAPSHOT + 1.3.11-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 489315111c..30f9b81975 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.258-SNAPSHOT + 1.3.11-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 abfe3fcb74..c8e89423ce 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.258-SNAPSHOT + 1.3.11-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 645cefc9f7..af2131b149 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.258-SNAPSHOT + 1.3.11-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 6b5d17dde3..a195579856 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.258-SNAPSHOT + 1.3.11-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 79f73d6f4a..1bbf27ebc3 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.258-SNAPSHOT + 1.3.11-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 959e6c98f7..d856911ae3 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.258-SNAPSHOT + 1.3.11-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 75ed5a843b..8ec57f196e 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.258-SNAPSHOT + 1.3.11-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 8a0da21a73..2ce6c43ad0 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.258-SNAPSHOT + 1.3.11-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 706308ab99..c15f799104 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.258-SNAPSHOT + 1.3.11-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 0ae161126f..c6366663f7 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.258-SNAPSHOT + 1.3.11-SNAPSHOT 4.0.0 org.wso2.carbon.identity.api.server.userstore.v1 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 bb2083a404..aac9bde226 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.258-SNAPSHOT + 1.3.11-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/pom.xml b/pom.xml index 9bebe05be0..d68616f2e8 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ 4.0.0 identity-api-server pom - 1.2.258-SNAPSHOT + 1.3.11-SNAPSHOT WSO2 Identity Server - Server API Module @@ -239,6 +239,12 @@ ${carbon.identity.framework.version} provided + + org.wso2.carbon.identity.framework + org.wso2.carbon.identity.rule.metadata + ${carbon.identity.framework.version} + provided + org.springframework spring-context @@ -418,6 +424,12 @@ ${project.version} provided + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.rule.metadata.common + ${project.version} + provided + org.wso2.carbon org.wso2.carbon.user.api @@ -808,12 +820,12 @@ 2.3.1.wso2v1 1.4 1.2.4 - 1.11.11 - 7.6.9 + 1.11.21 + 7.7.24 3.0.5 1.12.0 **/gen/**/* - 1.9.12 + 1.9.28 7.0.169 5.11.44 1.9.4 @@ -882,6 +894,7 @@ components/org.wso2.carbon.identity.api.server.organization.selfservice components/org.wso2.carbon.identity.api.server.action.management components/org.wso2.carbon.identity.api.server.notification.template + components/org.wso2.carbon.identity.api.server.rule.metadata