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/ActionResponse.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/ActionResponse.java index b29729d834..0cb5a5cc11 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/ActionResponse.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/ActionResponse.java @@ -22,7 +22,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.identity.api.server.action.management.v1.Endpoint; +import org.wso2.carbon.identity.api.server.action.management.v1.EndpointResponse; import javax.validation.constraints.*; @@ -104,7 +104,7 @@ public static StatusEnum fromValue(String value) { } private StatusEnum status; - private Endpoint endpoint; + private EndpointResponse endpoint; /** **/ @@ -198,7 +198,7 @@ public void setStatus(StatusEnum status) { /** **/ - public ActionResponse endpoint(Endpoint endpoint) { + public ActionResponse endpoint(EndpointResponse endpoint) { this.endpoint = endpoint; return this; @@ -207,10 +207,10 @@ public ActionResponse endpoint(Endpoint endpoint) { @ApiModelProperty(value = "") @JsonProperty("endpoint") @Valid - public Endpoint getEndpoint() { + public EndpointResponse getEndpoint() { return endpoint; } - public void setEndpoint(Endpoint endpoint) { + public void setEndpoint(EndpointResponse endpoint) { this.endpoint = endpoint; } 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/ActionUpdateModel.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/ActionUpdateModel.java new file mode 100644 index 0000000000..4869c18244 --- /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/ActionUpdateModel.java @@ -0,0 +1,140 @@ +/* + * 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 ActionUpdateModel { + + private String name; + private String description; + private String endpointUri; + + /** + **/ + public ActionUpdateModel name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "Access Token Pre Issue", value = "") + @JsonProperty("name") + @Valid + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + public ActionUpdateModel description(String description) { + + this.description = description; + return this; + } + + @ApiModelProperty(example = "This is the configuration of pre-action for issuing access token.", value = "") + @JsonProperty("description") + @Valid + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + + /** + **/ + public ActionUpdateModel endpointUri(String endpointUri) { + + this.endpointUri = endpointUri; + return this; + } + + @ApiModelProperty(example = "https://abcd.com/token", value = "") + @JsonProperty("endpointUri") + @Valid + public String getEndpointUri() { + return endpointUri; + } + public void setEndpointUri(String endpointUri) { + this.endpointUri = endpointUri; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ActionUpdateModel actionUpdateModel = (ActionUpdateModel) o; + return Objects.equals(this.name, actionUpdateModel.name) && + Objects.equals(this.description, actionUpdateModel.description) && + Objects.equals(this.endpointUri, actionUpdateModel.endpointUri); + } + + @Override + public int hashCode() { + return Objects.hash(name, description, endpointUri); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class ActionUpdateModel {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" endpointUri: ").append(toIndentedString(endpointUri)).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/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 5f7ade7dc4..0e9433dab0 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 @@ -28,6 +28,8 @@ import org.wso2.carbon.identity.api.server.action.management.v1.ActionModel; import org.wso2.carbon.identity.api.server.action.management.v1.ActionResponse; import org.wso2.carbon.identity.api.server.action.management.v1.ActionTypesResponseItem; +import org.wso2.carbon.identity.api.server.action.management.v1.ActionUpdateModel; +import org.wso2.carbon.identity.api.server.action.management.v1.AuthenticationTypeProperties; import org.wso2.carbon.identity.api.server.action.management.v1.Error; import org.wso2.carbon.identity.api.server.action.management.v1.ActionsApiService; @@ -51,7 +53,7 @@ public class ActionsApi { @Path("/{actionType}/{actionId}/activate") @Produces({ "application/json" }) - @ApiOperation(value = "Activates the action by given Id. ", notes = "This API provides the capability to activate an action by action Id.
Permission required:
* /permission/admin/manage/identity/actionmgt/update
Scope required:
* internal_action_mgt_update ", response = ActionBasicResponse.class, authorizations = { + @ApiOperation(value = "Activates the action by given Id. ", notes = "This API provides the capability to activate an action by action Id.
Scope required:
* internal_action_mgt_update ", response = ActionBasicResponse.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -65,7 +67,7 @@ public class ActionsApi { @ApiResponse(code = 404, message = "Not Found", response = Error.class), @ApiResponse(code = 500, message = "Server Error", response = Error.class) }) - public Response activateAction(@ApiParam(value = "Name of the Action Type.",required=true) @PathParam("actionType") String actionType, @ApiParam(value = "Id of the Action.",required=true) @PathParam("actionId") String actionId) { + public Response activateAction(@ApiParam(value = "Name of the Action Type.",required=true, allowableValues="PreIssueAccessToken, PreUpdatePassword, PreUpdateProfile, PreRegistration") @PathParam("actionType") String actionType, @ApiParam(value = "Id of the Action.",required=true) @PathParam("actionId") String actionId) { return delegate.activateAction(actionType, actionId ); } @@ -75,7 +77,7 @@ public Response activateAction(@ApiParam(value = "Name of the Action Type.",requ @Path("/{actionType}") @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Add action ", notes = "This API provides the capability to store the action information that is provided by users.
Permission required:
* /permission/admin/manage/identity/actionmgt/create
Scope required:
* internal_action_mgt_create ", response = ActionResponse.class, authorizations = { + @ApiOperation(value = "Add action ", notes = "This API provides the capability to store the action information that is provided by users.
Scope required:
* internal_action_mgt_create ", response = ActionResponse.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -90,7 +92,7 @@ public Response activateAction(@ApiParam(value = "Name of the Action Type.",requ @ApiResponse(code = 500, message = "Server Error", response = Error.class), @ApiResponse(code = 501, message = "Not Implemented", response = Error.class) }) - public Response createAction(@ApiParam(value = "Name of the Action Type.",required=true) @PathParam("actionType") String actionType, @ApiParam(value = "This represents the action to be created." ,required=true) @Valid ActionModel actionModel) { + public Response createAction(@ApiParam(value = "Name of the Action Type.",required=true, allowableValues="PreIssueAccessToken, PreUpdatePassword, PreUpdateProfile, PreRegistration") @PathParam("actionType") String actionType, @ApiParam(value = "This represents the action to be created." ,required=true) @Valid ActionModel actionModel) { return delegate.createAction(actionType, actionModel ); } @@ -100,7 +102,7 @@ public Response createAction(@ApiParam(value = "Name of the Action Type.",requir @Path("/{actionType}/{actionId}/deactivate") @Produces({ "application/json" }) - @ApiOperation(value = "Deactivates the action by given Id. ", notes = "This API provides the capability to deactivate an action by action Id.
Permission required:
* /permission/admin/manage/identity/actionmgt/update
Scope required:
* internal_action_mgt_update ", response = ActionBasicResponse.class, authorizations = { + @ApiOperation(value = "Deactivates the action by given Id. ", notes = "This API provides the capability to deactivate an action by action Id.
Scope required:
* internal_action_mgt_update ", response = ActionBasicResponse.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -114,7 +116,7 @@ public Response createAction(@ApiParam(value = "Name of the Action Type.",requir @ApiResponse(code = 404, message = "Not Found", response = Error.class), @ApiResponse(code = 500, message = "Server Error", response = Error.class) }) - public Response deactivateAction(@ApiParam(value = "Name of the Action Type.",required=true) @PathParam("actionType") String actionType, @ApiParam(value = "Id of the Action.",required=true) @PathParam("actionId") String actionId) { + public Response deactivateAction(@ApiParam(value = "Name of the Action Type.",required=true, allowableValues="PreIssueAccessToken, PreUpdatePassword, PreUpdateProfile, PreRegistration") @PathParam("actionType") String actionType, @ApiParam(value = "Id of the Action.",required=true) @PathParam("actionId") String actionId) { return delegate.deactivateAction(actionType, actionId ); } @@ -124,7 +126,7 @@ public Response deactivateAction(@ApiParam(value = "Name of the Action Type.",re @Path("/{actionType}/{actionId}") @Produces({ "application/json" }) - @ApiOperation(value = "Delete action by action type and action id. ", notes = "This API provides the capability to delete an action by action type.
Permission required:
* /permission/admin/manage/identity/actionmgt/delete
Scope required:
* internal_action_mgt_delete ", response = Void.class, authorizations = { + @ApiOperation(value = "Delete action by action type and action id. ", notes = "This API provides the capability to delete an action by action type.
Scope required:
* internal_action_mgt_delete ", response = Void.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -138,24 +140,24 @@ public Response deactivateAction(@ApiParam(value = "Name of the Action Type.",re @ApiResponse(code = 404, message = "Not Found", response = Error.class), @ApiResponse(code = 500, message = "Server Error", response = Error.class) }) - public Response deleteAction(@ApiParam(value = "Name of the Action Type.",required=true) @PathParam("actionType") String actionType, @ApiParam(value = "Id of the Action.",required=true) @PathParam("actionId") String actionId) { + public Response deleteAction(@ApiParam(value = "Name of the Action Type.",required=true, allowableValues="PreIssueAccessToken, PreUpdatePassword, PreUpdateProfile, PreRegistration") @PathParam("actionType") String actionType, @ApiParam(value = "Id of the Action.",required=true) @PathParam("actionId") String actionId) { return delegate.deleteAction(actionType, actionId ); } @Valid @GET - @Path("/{actionType}") + @Path("/types") @Produces({ "application/json" }) - @ApiOperation(value = "List action ", notes = "This API provides the capability to retrieve the action by action type.
Permission required:
* /permission/admin/manage/identity/actionmgt/view
Scope required:
* internal_action_mgt_view ", response = ActionResponse.class, responseContainer = "List", authorizations = { + @ApiOperation(value = "Detailed summary of the Action Types ", notes = "This API provides the capability to retrieve the detailed summary of the action types.
Scope required:
* internal_action_mgt_view ", response = ActionTypesResponseItem.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 = ActionTypesResponseItem.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), @@ -163,24 +165,24 @@ public Response deleteAction(@ApiParam(value = "Name of the Action Type.",requir @ApiResponse(code = 500, message = "Server Error", response = Error.class), @ApiResponse(code = 501, message = "Not Implemented", response = Error.class) }) - public Response getActionsByActionType(@ApiParam(value = "Name of the Action Type.",required=true) @PathParam("actionType") String actionType) { + public Response getActionTypes() { - return delegate.getActionsByActionType(actionType ); + return delegate.getActionTypes(); } @Valid @GET - @Path("/types") + @Path("/{actionType}") @Produces({ "application/json" }) - @ApiOperation(value = "Detailed summary of the Action Types ", notes = "This API provides the capability to retrieve the detailed summary of the action types.
Permission required:
* /permission/admin/manage/identity/actionmgt/view
Scope required:
* internal_action_mgt_view ", response = ActionTypesResponseItem.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 = ActionResponse.class, responseContainer = "List", authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { }) }, tags={ "Actions", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "OK", response = ActionTypesResponseItem.class, responseContainer = "List"), + @ApiResponse(code = 200, message = "OK", response = ActionResponse.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), @@ -188,17 +190,41 @@ public Response getActionsByActionType(@ApiParam(value = "Name of the Action Typ @ApiResponse(code = 500, message = "Server Error", response = Error.class), @ApiResponse(code = 501, message = "Not Implemented", response = Error.class) }) - public Response getActionTypes() { + public Response getActionsByActionType(@ApiParam(value = "Name of the Action Type.",required=true, allowableValues="PreIssueAccessToken, PreUpdatePassword, PreUpdateProfile, PreRegistration") @PathParam("actionType") String actionType) { - return delegate.getActionTypes(); + return delegate.getActionsByActionType(actionType ); } @Valid - @PUT + @PATCH @Path("/{actionType}/{actionId}") @Consumes({ "application/json" }) @Produces({ "application/json" }) - @ApiOperation(value = "Update action by action type and action id. ", notes = "This API provides the capability to update an action by action type.
Permission required:
* /permission/admin/manage/identity/actionmgt/update
Scope required:
* internal_action_mgt_update ", response = ActionResponse.class, authorizations = { + @ApiOperation(value = "Update Action information by given Id. ", notes = "This API provides the capability to update Action information by given Id.
Scope required:
* internal_action_mgt_update ", response = ActionResponse.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Actions", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK", response = ActionResponse.class), + @ApiResponse(code = 400, message = "Bad Request", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden", response = Void.class), + @ApiResponse(code = 404, message = "Not Found", response = Error.class), + @ApiResponse(code = 500, message = "Server Error", response = Error.class) + }) + public Response updateAction(@ApiParam(value = "Name of the Action Type.",required=true, allowableValues="PreIssueAccessToken, PreUpdatePassword, PreUpdateProfile, PreRegistration") @PathParam("actionType") String actionType, @ApiParam(value = "Id of the Action.",required=true) @PathParam("actionId") String actionId, @ApiParam(value = "This represents the action information to be updated." ,required=true) @Valid ActionUpdateModel actionUpdateModel) { + + return delegate.updateAction(actionType, actionId, actionUpdateModel ); + } + + @Valid + @PUT + @Path("/{actionType}/{actionId}/{authType}") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Update Action endpoint authentication information by given Id. ", notes = "This API provides the capability to update Action endpoint authentication information by given Id.
Scope required:
* internal_action_mgt_update ", response = ActionResponse.class, authorizations = { @Authorization(value = "BasicAuth"), @Authorization(value = "OAuth2", scopes = { @@ -210,12 +236,11 @@ public Response getActionTypes() { @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), @ApiResponse(code = 403, message = "Forbidden", response = Void.class), @ApiResponse(code = 404, message = "Not Found", response = Error.class), - @ApiResponse(code = 409, message = "Conflict", response = Error.class), @ApiResponse(code = 500, message = "Server Error", response = Error.class) }) - public Response updateAction(@ApiParam(value = "Name of the Action Type.",required=true) @PathParam("actionType") String actionType, @ApiParam(value = "Id of the Action.",required=true) @PathParam("actionId") String actionId, @ApiParam(value = "This represents the action to be updated." ,required=true) @Valid ActionModel actionModel) { + public Response updateActionEndpointAuthentication(@ApiParam(value = "Name of the Action Type.",required=true, allowableValues="PreIssueAccessToken, PreUpdatePassword, PreUpdateProfile, PreRegistration") @PathParam("actionType") String actionType, @ApiParam(value = "Id of the Action.",required=true) @PathParam("actionId") String actionId, @ApiParam(value = "Authentication Type of the Action Endpoint.",required=true, allowableValues="none, basic, apiKey, bearer") @PathParam("authType") String authType, @ApiParam(value = "This represents the action endpoint authentication to be updated." ,required=true) @Valid AuthenticationTypeProperties authenticationTypeProperties) { - return delegate.updateAction(actionType, actionId, actionModel ); + return delegate.updateActionEndpointAuthentication(actionType, actionId, authType, authenticationTypeProperties ); } } 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/ActionsApiService.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/ActionsApiService.java index 9494ee1333..3d0d3941e5 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/ActionsApiService.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/ActionsApiService.java @@ -28,6 +28,8 @@ import org.wso2.carbon.identity.api.server.action.management.v1.ActionModel; import org.wso2.carbon.identity.api.server.action.management.v1.ActionResponse; import org.wso2.carbon.identity.api.server.action.management.v1.ActionTypesResponseItem; +import org.wso2.carbon.identity.api.server.action.management.v1.ActionUpdateModel; +import org.wso2.carbon.identity.api.server.action.management.v1.AuthenticationTypeProperties; import org.wso2.carbon.identity.api.server.action.management.v1.Error; import javax.ws.rs.core.Response; @@ -42,9 +44,11 @@ public interface ActionsApiService { public Response deleteAction(String actionType, String actionId); + public Response getActionTypes(); + public Response getActionsByActionType(String actionType); - public Response getActionTypes(); + public Response updateAction(String actionType, String actionId, ActionUpdateModel actionUpdateModel); - public Response updateAction(String actionType, String actionId, ActionModel actionModel); + public Response updateActionEndpointAuthentication(String actionType, String actionId, String authType, AuthenticationTypeProperties authenticationTypeProperties); } 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/AuthenticationType.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/AuthenticationType.java index a9dd1ae24f..621104d224 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/AuthenticationType.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/AuthenticationType.java @@ -100,7 +100,7 @@ public AuthenticationType properties(Map properties) { return this; } - @ApiModelProperty(example = "{\"username\":\"auth_username\",\"password\":\"auth_username\"}", value = "") + @ApiModelProperty(example = "{\"username\":\"auth_username\",\"password\":\"auth_password\"}", value = "") @JsonProperty("properties") @Valid public Map getProperties() { 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/AuthenticationTypeProperties.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/AuthenticationTypeProperties.java new file mode 100644 index 0000000000..1d5f34bb2d --- /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/AuthenticationTypeProperties.java @@ -0,0 +1,111 @@ +/* + * 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 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 AuthenticationTypeProperties { + + private Map properties = null; + + + /** + **/ + public AuthenticationTypeProperties properties(Map properties) { + + this.properties = properties; + return this; + } + + @ApiModelProperty(example = "{\"username\":\"auth_username\",\"password\":\"auth_username\"}", value = "") + @JsonProperty("properties") + @Valid + public Map getProperties() { + return properties; + } + public void setProperties(Map properties) { + this.properties = properties; + } + + + public AuthenticationTypeProperties 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; + } + AuthenticationTypeProperties authenticationTypeProperties = (AuthenticationTypeProperties) o; + return Objects.equals(this.properties, authenticationTypeProperties.properties); + } + + @Override + public int hashCode() { + return Objects.hash(properties); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class AuthenticationTypeProperties {\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.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/action/management/v1/AuthenticationTypeResponse.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/AuthenticationTypeResponse.java new file mode 100644 index 0000000000..91056333bc --- /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/AuthenticationTypeResponse.java @@ -0,0 +1,133 @@ +/* + * 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 AuthenticationTypeResponse { + + +@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; + + /** + **/ + public AuthenticationTypeResponse 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; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AuthenticationTypeResponse authenticationTypeResponse = (AuthenticationTypeResponse) o; + return Objects.equals(this.type, authenticationTypeResponse.type); + } + + @Override + public int hashCode() { + return Objects.hash(type); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class AuthenticationTypeResponse {\n"); + + sb.append(" type: ").append(toIndentedString(type)).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/gen/java/org/wso2/carbon/identity/api/server/action/management/v1/EndpointResponse.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/EndpointResponse.java new file mode 100644 index 0000000000..4ff56cf3f0 --- /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/EndpointResponse.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.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 org.wso2.carbon.identity.api.server.action.management.v1.AuthenticationTypeResponse; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class EndpointResponse { + + private String uri; + private AuthenticationTypeResponse authentication; + + /** + **/ + public EndpointResponse 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.") + + public String getUri() { + return uri; + } + public void setUri(String uri) { + this.uri = uri; + } + + /** + **/ + public EndpointResponse authentication(AuthenticationTypeResponse authentication) { + + this.authentication = authentication; + return this; + } + + @ApiModelProperty(required = true, value = "") + @JsonProperty("authentication") + @Valid + @NotNull(message = "Property authentication cannot be null.") + + public AuthenticationTypeResponse getAuthentication() { + return authentication; + } + public void setAuthentication(AuthenticationTypeResponse 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; + } + EndpointResponse endpointResponse = (EndpointResponse) o; + return Objects.equals(this.uri, endpointResponse.uri) && + Objects.equals(this.authentication, endpointResponse.authentication); + } + + @Override + public int hashCode() { + return Objects.hash(uri, authentication); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class EndpointResponse {\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.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 72cbff0436..c936a13aae 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 @@ -38,7 +38,13 @@ public enum ErrorMessage { // Client errors. ERROR_INVALID_ACTION_ENDPOINT_AUTHENTICATION_PROPERTIES("60001", "Unable to perform the operation.", - "Required authentication properties are not provided or invalid."); + "Required authentication properties are not provided or invalid."), + ERROR_INVALID_ACTION_ENDPOINT_AUTH_TYPE("60002", + "Invalid Authentication Type for Action Endpoint.", + "Invalid authentication type used for path parameter."), + ERROR_EMPTY_ACTION_ENDPOINT_AUTHENTICATION_PROPERTIES("60003", + "Unable to perform the operation.", + "Authentication property values cannot be empty."); private final String code; private final String message; 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 892f914476..430707b434 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 @@ -18,11 +18,13 @@ package org.wso2.carbon.identity.api.server.action.management.v1.core; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.identity.action.management.exception.ActionMgtException; import org.wso2.carbon.identity.action.management.model.Action; +import org.wso2.carbon.identity.action.management.model.AuthProperty; import org.wso2.carbon.identity.action.management.model.AuthType; import org.wso2.carbon.identity.action.management.model.EndpointConfig; import org.wso2.carbon.identity.api.server.action.management.common.ActionManagementServiceHolder; @@ -30,14 +32,23 @@ import org.wso2.carbon.identity.api.server.action.management.v1.ActionModel; import org.wso2.carbon.identity.api.server.action.management.v1.ActionResponse; import org.wso2.carbon.identity.api.server.action.management.v1.ActionTypesResponseItem; -import org.wso2.carbon.identity.api.server.action.management.v1.AuthenticationType; -import org.wso2.carbon.identity.api.server.action.management.v1.Endpoint; +import org.wso2.carbon.identity.api.server.action.management.v1.ActionUpdateModel; +import org.wso2.carbon.identity.api.server.action.management.v1.AuthenticationTypeProperties; +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.util.ActionMgtEndpointUtil; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Map; +import javax.ws.rs.core.Response; + +import static org.wso2.carbon.identity.api.server.action.management.v1.constants.ActionMgtEndpointConstants.ErrorMessage.ERROR_EMPTY_ACTION_ENDPOINT_AUTHENTICATION_PROPERTIES; +import static org.wso2.carbon.identity.api.server.action.management.v1.constants.ActionMgtEndpointConstants.ErrorMessage.ERROR_INVALID_ACTION_ENDPOINT_AUTHENTICATION_PROPERTIES; +import static org.wso2.carbon.identity.api.server.action.management.v1.constants.ActionMgtEndpointConstants.ErrorMessage.ERROR_INVALID_ACTION_ENDPOINT_AUTH_TYPE; + /** * Server Action Management Service. */ @@ -73,11 +84,19 @@ public List getActionsByActionType(String actionType) { } } - public ActionResponse updateAction(String actionType, String actionId, ActionModel actionModel) { + public ActionResponse updateAction(String actionType, String actionId, ActionUpdateModel actionUpdateModel) { try { + Action updatingAction = new Action.ActionRequestBuilder() + .name(actionUpdateModel.getName()) + .description(actionUpdateModel.getDescription()) + .endpoint(new EndpointConfig.EndpointConfigBuilder() + .uri(actionUpdateModel.getEndpointUri()) + .build()) + .build(); + return buildActionResponse(ActionManagementServiceHolder.getActionManagementService() - .updateAction(actionType, actionId, buildAction(actionModel), + .updateAction(actionType, actionId, updatingAction, CarbonContext.getThreadLocalCarbonContext().getTenantDomain())); } catch (ActionMgtException e) { throw ActionMgtEndpointUtil.handleActionMgtException(e); @@ -86,7 +105,6 @@ public ActionResponse updateAction(String actionType, String actionId, ActionMod public void deleteAction(String actionType, String actionId) { - try { ActionManagementServiceHolder.getActionManagementService().deleteAction(actionType, actionId, CarbonContext.getThreadLocalCarbonContext().getTenantDomain()); @@ -143,6 +161,24 @@ public List getActionTypes() { } } + public ActionResponse updateActionEndpointAuthentication(String actionType, String actionId, String authType, + AuthenticationTypeProperties authenticationTypeProperties) { + + try { + String resolvedAuthType = getAuthTypeFromPath(authType); + AuthType authentication = new AuthType.AuthTypeBuilder() + .type(AuthType.AuthenticationType.valueOf(resolvedAuthType)) + .properties(getActionEndpointAuthProperties(resolvedAuthType, + authenticationTypeProperties.getProperties())) + .build(); + return buildActionResponse(ActionManagementServiceHolder.getActionManagementService() + .updateActionEndpointAuthentication(actionType, actionId, authentication, + CarbonContext.getThreadLocalCarbonContext().getTenantDomain())); + } catch (ActionMgtException e) { + throw ActionMgtEndpointUtil.handleActionMgtException(e); + } + } + /** * Build ActionResponse from Action. * @@ -157,12 +193,11 @@ private ActionResponse buildActionResponse(Action action) { .name(action.getName()) .description(action.getDescription()) .status(ActionResponse.StatusEnum.valueOf(action.getStatus().toString())) - .endpoint(new Endpoint() + .endpoint(new EndpointResponse() .uri(action.getEndpoint().getUri()) - .authentication(new AuthenticationType() - .type(AuthenticationType.TypeEnum.valueOf(action.getEndpoint() - .getAuthentication().getType().toString())) - .properties(action.getEndpoint().getAuthentication().getProperties()))); + .authentication(new AuthenticationTypeResponse() + .type(AuthenticationTypeResponse.TypeEnum.valueOf(action.getEndpoint() + .getAuthentication().getType().toString())))); } /** @@ -184,12 +219,11 @@ private ActionBasicResponse buildActionBasicResponse(Action activatedAction) { /** * Create Action from the Action model. * - * @param actionModel API model. + * @param actionModel Action model. * @return Action. */ private Action buildAction(ActionModel actionModel) { - ActionMgtEndpointUtil.validateActionEndpointAuthProperties(actionModel); Action.ActionRequestBuilder actionRequestBuilder = new Action.ActionRequestBuilder() .name(actionModel.getName()) .description(actionModel.getDescription()) @@ -198,10 +232,66 @@ private Action buildAction(ActionModel actionModel) { .authentication(new AuthType.AuthTypeBuilder() .type(AuthType.AuthenticationType.valueOf(actionModel.getEndpoint().getAuthentication() .getType().toString())) - .properties(actionModel.getEndpoint().getAuthentication().getProperties()) + .properties(getActionEndpointAuthProperties( + actionModel.getEndpoint().getAuthentication().getType().name(), + actionModel.getEndpoint().getAuthentication().getProperties())) .build()) .build()); return actionRequestBuilder.build(); } + + /** + * Build Action Endpoint Authentication properties. + * + * @param authType Authentication Type. + * @param authPropertiesMap Authentication properties. + * @return List of AuthProperty. + */ + private List getActionEndpointAuthProperties(String authType, Map authPropertiesMap) { + + List authProperties = new ArrayList<>(); + for (AuthType.AuthenticationType type: AuthType.AuthenticationType.values()) { + if (type.getType().equals(authType)) { + for (AuthType.AuthenticationType.AuthenticationProperty property: type.getProperties()) { + if (authPropertiesMap == null || !authPropertiesMap.containsKey(property.getName())) { + throw ActionMgtEndpointUtil.handleException(Response.Status.BAD_REQUEST, + ERROR_INVALID_ACTION_ENDPOINT_AUTHENTICATION_PROPERTIES); + } + String propValue = (String) authPropertiesMap.get(property.getName()); + if (StringUtils.isEmpty(propValue)) { + throw ActionMgtEndpointUtil.handleException(Response.Status.BAD_REQUEST, + ERROR_EMPTY_ACTION_ENDPOINT_AUTHENTICATION_PROPERTIES); + } + authProperties.add(new AuthProperty.AuthPropertyBuilder() + .name(property.getName()) + .value(propValue) + .isConfidential(property.getIsConfidential()).build()); + } + if (authPropertiesMap.size() > type.getProperties().size()) { + if (LOG.isDebugEnabled()) { + LOG.debug("Removing the given unnecessary properties from the Action Endpoint " + + "authentication properties of Authentication Type: " + authType); + } + } + } + } + return authProperties; + } + + /** + * Get AuthType from path. + * + * @param authType Authentication Type. + * @return Auth Type resolved from the path param. + */ + private String getAuthTypeFromPath(String authType) { + + return Arrays.stream(AuthType.AuthenticationType.values()) + .filter(type -> type.getPathParam().equals(authType)) + .map(AuthType.AuthenticationType::getType) + .findFirst() + .orElseThrow(() -> ActionMgtEndpointUtil.handleException(Response.Status.BAD_REQUEST, + ERROR_INVALID_ACTION_ENDPOINT_AUTH_TYPE)); + } } 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/impl/ActionsApiServiceImpl.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/impl/ActionsApiServiceImpl.java index 64f4f66c4e..682fa283ac 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/impl/ActionsApiServiceImpl.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/impl/ActionsApiServiceImpl.java @@ -21,7 +21,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.wso2.carbon.identity.api.server.action.management.v1.ActionModel; import org.wso2.carbon.identity.api.server.action.management.v1.ActionResponse; +import org.wso2.carbon.identity.api.server.action.management.v1.ActionUpdateModel; import org.wso2.carbon.identity.api.server.action.management.v1.ActionsApiService; +import org.wso2.carbon.identity.api.server.action.management.v1.AuthenticationTypeProperties; import org.wso2.carbon.identity.api.server.action.management.v1.constants.ActionMgtEndpointConstants; import org.wso2.carbon.identity.api.server.action.management.v1.core.ServerActionManagementService; import org.wso2.carbon.identity.api.server.common.ContextLoader; @@ -56,9 +58,9 @@ public Response getActionsByActionType(String actionType) { } @Override - public Response updateAction(String actionType, String actionId, ActionModel actionModel) { + public Response updateAction(String actionType, String actionId, ActionUpdateModel actionUpdateModel) { - return Response.ok().entity(serverActionManagementService.updateAction(actionType, actionId, actionModel)) + return Response.ok().entity(serverActionManagementService.updateAction(actionType, actionId, actionUpdateModel)) .build(); } @@ -86,4 +88,12 @@ public Response getActionTypes() { return Response.ok().entity(serverActionManagementService.getActionTypes()).build(); } + + @Override + public Response updateActionEndpointAuthentication(String actionType, String actionId, String authType, + AuthenticationTypeProperties authenticationTypeProperties) { + + return Response.ok().entity(serverActionManagementService.updateActionEndpointAuthentication(actionType, + actionId, authType, authenticationTypeProperties)).build(); + } } 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 7e4d49aea5..e1cc382a4d 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 @@ -23,22 +23,16 @@ import org.wso2.carbon.identity.action.management.exception.ActionMgtClientException; import org.wso2.carbon.identity.action.management.exception.ActionMgtException; import org.wso2.carbon.identity.action.management.model.Action; -import org.wso2.carbon.identity.action.management.model.AuthType; -import org.wso2.carbon.identity.api.server.action.management.v1.ActionModel; import org.wso2.carbon.identity.api.server.action.management.v1.constants.ActionMgtEndpointConstants; import org.wso2.carbon.identity.api.server.common.Constants; import org.wso2.carbon.identity.api.server.common.ContextLoader; import org.wso2.carbon.identity.api.server.common.error.APIError; import org.wso2.carbon.identity.api.server.common.error.ErrorDTO; -import java.util.HashMap; -import java.util.Map; - import javax.ws.rs.core.Response; import static org.wso2.carbon.identity.action.management.constant.ActionMgtConstants.ErrorMessages.ERROR_NO_ACTION_CONFIGURED_ON_GIVEN_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.ErrorMessage.ERROR_INVALID_ACTION_ENDPOINT_AUTHENTICATION_PROPERTIES; import static org.wso2.carbon.identity.api.server.action.management.v1.constants.ActionMgtEndpointConstants.PATH_CONSTANT; import static org.wso2.carbon.identity.api.server.common.Constants.ERROR_CODE_DELIMITER; @@ -51,33 +45,6 @@ public class ActionMgtEndpointUtil { private static final String ACTION_TYPE_LINK_FORMAT = Constants.V1_API_PATH_COMPONENT + ACTION_PATH_COMPONENT + PATH_CONSTANT; - public static void validateActionEndpointAuthProperties(ActionModel actionModel) { - - String authnType = actionModel.getEndpoint().getAuthentication().getType().toString(); - Map authnProperties = actionModel.getEndpoint().getAuthentication().getProperties(); - Map validatedAuthnProperties = new HashMap<>(); - - for (AuthType.AuthenticationType type: AuthType.AuthenticationType.values()) { - if (type.getType().equals(authnType)) { - for (String property: type.getProperties()) { - if (authnProperties == null || authnProperties.get(property) == null) { - throw handleException(Response.Status.BAD_REQUEST, - ERROR_INVALID_ACTION_ENDPOINT_AUTHENTICATION_PROPERTIES); - } - validatedAuthnProperties.put(property, authnProperties.get(property)); - } - if (authnProperties.size() > type.getProperties().length) { - if (LOG.isDebugEnabled()) { - LOG.debug("Removing the given unnecessary properties from the Action Endpoint " + - "authentication properties of Authentication Type: " + authnType); - } - actionModel.getEndpoint().getAuthentication().setProperties(validatedAuthnProperties); - } - return; - } - } - } - public static String buildURIForActionType(String actionType) { return ContextLoader.buildURIForBody(ACTION_TYPE_LINK_FORMAT + 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 08fd7ef0d2..c11c1b95d7 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 @@ -22,13 +22,11 @@ paths: get: tags: - Actions - operationId: getActions + operationId: getActionTypes summary: | Detailed summary of the Action Types description: | This API provides the capability to retrieve the detailed summary of the action types.
- Permission required:
- * /permission/admin/manage/identity/actionmgt/view
Scope required:
* internal_action_mgt_view responses: @@ -77,8 +75,6 @@ paths: description: > This API provides the capability to store the action information that is provided by users.
- Permission required:
- * /permission/admin/manage/identity/actionmgt/create
Scope required:
* internal_action_mgt_create parameters: @@ -87,7 +83,11 @@ paths: description: Name of the Action Type. required: true schema: - type: string + enum: + - preIssueAccessToken + - preUpdatePassword + - preUpdateProfile + - preRegistration requestBody: content: application/json: @@ -134,13 +134,11 @@ paths: get: tags: - Actions - operationId: getAction + operationId: getActionsByActionType summary: | List action description: | This API provides the capability to retrieve the action by action type.
- Permission required:
- * /permission/admin/manage/identity/actionmgt/view
Scope required:
* internal_action_mgt_view parameters: @@ -149,7 +147,11 @@ paths: description: Name of the Action Type. required: true schema: - type: string + enum: + - preIssueAccessToken + - preUpdatePassword + - preUpdateProfile + - preRegistration responses: '200': description: OK @@ -187,16 +189,14 @@ paths: $ref: '#/components/schemas/Error' /actions/{actionType}/{actionId}: - put: + patch: tags: - Actions summary: | - Update action by action type and action id. + Update Action information by given Id. operationId: updateAction description: | - This API provides the capability to update an action by action type.
- Permission required:
- * /permission/admin/manage/identity/actionmgt/update
+ This API provides the capability to update Action information by given Id.
Scope required:
* internal_action_mgt_update parameters: @@ -205,7 +205,11 @@ paths: description: Name of the Action Type. required: true schema: - type: string + enum: + - preIssueAccessToken + - preUpdatePassword + - preUpdateProfile + - preRegistration - name: actionId in: path description: Id of the Action. @@ -216,8 +220,8 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ActionModel' - description: This represents the action to be updated. + $ref: '#/components/schemas/ActionUpdateModel' + description: This represents the action information to be updated. required: true responses: '200': @@ -242,12 +246,6 @@ paths: application/json: schema: $ref: '#/components/schemas/Error' - '409': - description: Conflict - content: - application/json: - schema: - $ref: '#/components/schemas/Error' '500': description: Server Error content: @@ -263,8 +261,6 @@ paths: operationId: deleteAction description: | This API provides the capability to delete an action by action type.
- Permission required:
- * /permission/admin/manage/identity/actionmgt/delete
Scope required:
* internal_action_mgt_delete parameters: @@ -273,7 +269,11 @@ paths: description: Name of the Action Type. required: true schema: - type: string + enum: + - preIssueAccessToken + - preUpdatePassword + - preUpdateProfile + - preRegistration - name: actionId in: path description: Id of the Action. @@ -315,8 +315,6 @@ paths: operationId: activateAction description: | This API provides the capability to activate an action by action Id.
- Permission required:
- * /permission/admin/manage/identity/actionmgt/update
Scope required:
* internal_action_mgt_update parameters: @@ -325,7 +323,11 @@ paths: description: Name of the Action Type. required: true schema: - type: string + enum: + - preIssueAccessToken + - preUpdatePassword + - preUpdateProfile + - preRegistration - name: actionId in: path description: Id of the Action. @@ -371,8 +373,6 @@ paths: operationId: deactivateAction description: | This API provides the capability to deactivate an action by action Id.
- Permission required:
- * /permission/admin/manage/identity/actionmgt/update
Scope required:
* internal_action_mgt_update parameters: @@ -381,7 +381,11 @@ paths: description: Name of the Action Type. required: true schema: - type: string + enum: + - preIssueAccessToken + - preUpdatePassword + - preUpdateProfile + - preRegistration - name: actionId in: path description: Id of the Action. @@ -418,6 +422,81 @@ paths: schema: $ref: '#/components/schemas/Error' + /actions/{actionType}/{actionId}/{authType}: + put: + tags: + - Actions + summary: | + Update Action endpoint authentication information by given Id. + operationId: updateActionEndpointAuthentication + description: | + This API provides the capability to update Action endpoint authentication information by given Id.
+ Scope required:
+ * internal_action_mgt_update + parameters: + - name: actionType + in: path + description: Name of the Action Type. + required: true + schema: + enum: + - preIssueAccessToken + - preUpdatePassword + - preUpdateProfile + - preRegistration + - name: actionId + in: path + description: Id of the Action. + required: true + schema: + type: string + - name: authType + in: path + description: Authentication Type of the Action Endpoint. + required: true + schema: + enum: + - none + - basic + - apiKey + - bearer + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/AuthenticationTypeProperties' + description: This represents the action endpoint authentication to be updated. + required: true + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/ActionResponse' + '400': + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '401': + description: Unauthorized + '403': + description: Forbidden + '404': + description: Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '500': + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + components: securitySchemes: BasicAuth: @@ -459,6 +538,17 @@ components: authentication: $ref: '#/components/schemas/AuthenticationType' + EndpointResponse: + type: object + required: + - uri + - authentication + properties: + uri: + type: string + example: https://abc.com/token + authentication: + $ref: '#/components/schemas/AuthenticationTypeResponse' ActionResponse: type: object @@ -487,7 +577,7 @@ components: - ACTIVE - INACTIVE endpoint: - $ref: '#/components/schemas/Endpoint' + $ref: '#/components/schemas/EndpointResponse' ActionBasicResponse: type: object @@ -569,7 +659,44 @@ components: additionalProperties: true example: username: "auth_username" - password: "auth_username" + password: "auth_password" + + AuthenticationTypeProperties: + type: object + properties: + properties: + type: object + additionalProperties: true + example: + username: "auth_username" + password: "auth_password" + + AuthenticationTypeResponse: + type: object + required: + - type + properties: + type: + type: string + enum: + - NONE + - BEARER + - API_KEY + - BASIC + example: BASIC + + ActionUpdateModel: + type: object + properties: + name: + type: string + example: Access Token Pre Issue + description: + type: string + example: This is the configuration of pre-action for issuing access token. + endpointUri: + type: string + example: https://abcd.com/token Error: type: object @@ -593,4 +720,4 @@ servers: tenant-domain: default: "carbon.super" server-url: - default: "localhost:9443" \ No newline at end of file + default: "localhost:9443" diff --git a/pom.xml b/pom.xml index 9a7337238b..9ffd80ef34 100644 --- a/pom.xml +++ b/pom.xml @@ -803,7 +803,7 @@ 1.4 1.2.4 1.9.17 - 7.3.28 + 7.3.37 3.0.5 1.12.0 **/gen/**/*