diff --git a/components/org.wso2.carbon.identity.api.user.push/org.wso2.carbon.identity.rest.api.user.push.v1/src/gen/java/org/wso2/carbon/identity/rest/api/user/push/v1/DevicesApi.java b/components/org.wso2.carbon.identity.api.user.push/org.wso2.carbon.identity.rest.api.user.push.v1/src/gen/java/org/wso2/carbon/identity/rest/api/user/push/v1/DevicesApi.java index 101c65992..f00ce20e8 100644 --- a/components/org.wso2.carbon.identity.api.user.push/org.wso2.carbon.identity.rest.api.user.push.v1/src/gen/java/org/wso2/carbon/identity/rest/api/user/push/v1/DevicesApi.java +++ b/components/org.wso2.carbon.identity.api.user.push/org.wso2.carbon.identity.rest.api.user.push.v1/src/gen/java/org/wso2/carbon/identity/rest/api/user/push/v1/DevicesApi.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, WSO2 LLC. (http://www.wso2.com). + * Copyright (c) 2025-2026, 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 @@ -28,6 +28,7 @@ import org.wso2.carbon.identity.rest.api.user.push.v1.model.Error; import org.wso2.carbon.identity.rest.api.user.push.v1.model.RegistrationRequestDTO; import org.wso2.carbon.identity.rest.api.user.push.v1.model.RemoveRequestDTO; +import org.wso2.carbon.identity.rest.api.user.push.v1.model.UpdateRequestDTO; import org.wso2.carbon.identity.rest.api.user.push.v1.DevicesApiService; import javax.validation.Valid; @@ -144,4 +145,22 @@ public Response removeDeviceFromMobile(@ApiParam(value = "ID of the device to be return delegate.removeDeviceFromMobile(deviceId, removeRequestDTO ); } + @Valid + @POST + @Path("/{deviceId}/update") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Update a registered device from the mobile device.", notes = "This API is used to update a registered device through the mobile device. ", response = Void.class, tags={ "device" }) + @ApiResponses(value = { + @ApiResponse(code = 204, message = "The device was updated successfully.", response = Void.class), + @ApiResponse(code = 400, message = "Invalid input in the request.", response = Error.class), + @ApiResponse(code = 401, message = "Authentication information is missing or invalid.", response = Void.class), + @ApiResponse(code = 403, message = "Access forbidden.", response = Void.class), + @ApiResponse(code = 500, message = "Internal server error.", response = Error.class) + }) + public Response updateDeviceFromMobile(@ApiParam(value = "ID of the device to be updated",required=true) @PathParam("deviceId") String deviceId, @ApiParam(value = "Update request sent from the mobile device." ,required=true) @Valid UpdateRequestDTO updateRequestDTO) { + + return delegate.updateDeviceFromMobile(deviceId, updateRequestDTO ); + } + } diff --git a/components/org.wso2.carbon.identity.api.user.push/org.wso2.carbon.identity.rest.api.user.push.v1/src/gen/java/org/wso2/carbon/identity/rest/api/user/push/v1/DevicesApiService.java b/components/org.wso2.carbon.identity.api.user.push/org.wso2.carbon.identity.rest.api.user.push.v1/src/gen/java/org/wso2/carbon/identity/rest/api/user/push/v1/DevicesApiService.java index b2930cc82..88bb4ec45 100644 --- a/components/org.wso2.carbon.identity.api.user.push/org.wso2.carbon.identity.rest.api.user.push.v1/src/gen/java/org/wso2/carbon/identity/rest/api/user/push/v1/DevicesApiService.java +++ b/components/org.wso2.carbon.identity.api.user.push/org.wso2.carbon.identity.rest.api.user.push.v1/src/gen/java/org/wso2/carbon/identity/rest/api/user/push/v1/DevicesApiService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, WSO2 LLC. (http://www.wso2.com). + * Copyright (c) 2025-2026, 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 @@ -28,6 +28,7 @@ import org.wso2.carbon.identity.rest.api.user.push.v1.model.Error; import org.wso2.carbon.identity.rest.api.user.push.v1.model.RegistrationRequestDTO; import org.wso2.carbon.identity.rest.api.user.push.v1.model.RemoveRequestDTO; +import org.wso2.carbon.identity.rest.api.user.push.v1.model.UpdateRequestDTO; import javax.ws.rs.core.Response; @@ -42,4 +43,6 @@ public interface DevicesApiService { public Response registerDevice(RegistrationRequestDTO registrationRequestDTO); public Response removeDeviceFromMobile(String deviceId, RemoveRequestDTO removeRequestDTO); + + public Response updateDeviceFromMobile(String deviceId, UpdateRequestDTO updateRequestDTO); } diff --git a/components/org.wso2.carbon.identity.api.user.push/org.wso2.carbon.identity.rest.api.user.push.v1/src/gen/java/org/wso2/carbon/identity/rest/api/user/push/v1/model/UpdateRequestDTO.java b/components/org.wso2.carbon.identity.api.user.push/org.wso2.carbon.identity.rest.api.user.push.v1/src/gen/java/org/wso2/carbon/identity/rest/api/user/push/v1/model/UpdateRequestDTO.java new file mode 100644 index 000000000..2da4057b4 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.push/org.wso2.carbon.identity.rest.api.user.push.v1/src/gen/java/org/wso2/carbon/identity/rest/api/user/push/v1/model/UpdateRequestDTO.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2026, 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.rest.api.user.push.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.*; + +/** + * Update device request body sent from the mobile device + **/ + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; +@ApiModel(description = "Update device request body sent from the mobile device") +public class UpdateRequestDTO { + + private String token; + + /** + * JWT containing the device information to be updated signed with the unique private key + **/ + public UpdateRequestDTO token(String token) { + + this.token = token; + return this; + } + + @ApiModelProperty(example = "signedJWTToken", required = true, value = "JWT containing the device information to be updated signed with the unique private key") + @JsonProperty("token") + @Valid + @NotNull(message = "Property token cannot be null.") + + public String getToken() { + return token; + } + public void setToken(String token) { + this.token = token; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdateRequestDTO updateRequestDTO = (UpdateRequestDTO) o; + return Objects.equals(this.token, updateRequestDTO.token); + } + + @Override + public int hashCode() { + return Objects.hash(token); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class UpdateRequestDTO {\n"); + + sb.append(" token: ").append(toIndentedString(token)).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.user.push/org.wso2.carbon.identity.rest.api.user.push.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/push/v1/core/PushDeviceManagementService.java b/components/org.wso2.carbon.identity.api.user.push/org.wso2.carbon.identity.rest.api.user.push.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/push/v1/core/PushDeviceManagementService.java index ad3e5cd05..a44ae0681 100644 --- a/components/org.wso2.carbon.identity.api.user.push/org.wso2.carbon.identity.rest.api.user.push.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/push/v1/core/PushDeviceManagementService.java +++ b/components/org.wso2.carbon.identity.api.user.push/org.wso2.carbon.identity.rest.api.user.push.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/push/v1/core/PushDeviceManagementService.java @@ -149,6 +149,21 @@ public void removeDeviceFromMobile(String deviceId, String token) { } } + /** + * Update device from mobile. + * + * @param deviceId Device ID. + * @param token Token. + */ + public void updateDeviceFromMobile(String deviceId, String token) { + + try { + deviceHandlerService.editDeviceMobile(deviceId, token); + } catch (PushDeviceHandlerException e) { + throw handlePushDeviceHandlerException(e); + } + } + /** * Register a device. * diff --git a/components/org.wso2.carbon.identity.api.user.push/org.wso2.carbon.identity.rest.api.user.push.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/push/v1/impl/DevicesApiServiceImpl.java b/components/org.wso2.carbon.identity.api.user.push/org.wso2.carbon.identity.rest.api.user.push.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/push/v1/impl/DevicesApiServiceImpl.java index da4f09f19..398c2252d 100644 --- a/components/org.wso2.carbon.identity.api.user.push/org.wso2.carbon.identity.rest.api.user.push.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/push/v1/impl/DevicesApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.user.push/org.wso2.carbon.identity.rest.api.user.push.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/push/v1/impl/DevicesApiServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, WSO2 LLC. (http://www.wso2.com). + * Copyright (c) 2025-2026, 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 @@ -24,6 +24,7 @@ import org.wso2.carbon.identity.rest.api.user.push.v1.model.DeviceDTO; import org.wso2.carbon.identity.rest.api.user.push.v1.model.RegistrationRequestDTO; import org.wso2.carbon.identity.rest.api.user.push.v1.model.RemoveRequestDTO; +import org.wso2.carbon.identity.rest.api.user.push.v1.model.UpdateRequestDTO; import java.util.List; @@ -73,6 +74,14 @@ public Response registerDevice(RegistrationRequestDTO registrationRequestDTO) { return Response.status(Response.Status.CREATED).build(); } + @Override + public Response updateDeviceFromMobile(String deviceId, UpdateRequestDTO updateRequestDTO) { + + String token = updateRequestDTO.getToken(); + pushDeviceManagementService.updateDeviceFromMobile(deviceId, token); + return Response.noContent().build(); + } + @Override public Response removeDeviceFromMobile(String deviceId, RemoveRequestDTO removeRequestDTO) { diff --git a/components/org.wso2.carbon.identity.api.user.push/org.wso2.carbon.identity.rest.api.user.push.v1/src/main/resources/push.yaml b/components/org.wso2.carbon.identity.api.user.push/org.wso2.carbon.identity.rest.api.user.push.v1/src/main/resources/push.yaml index 38a018cde..25dfa4a57 100644 --- a/components/org.wso2.carbon.identity.api.user.push/org.wso2.carbon.identity.rest.api.user.push.v1/src/main/resources/push.yaml +++ b/components/org.wso2.carbon.identity.api.user.push/org.wso2.carbon.identity.rest.api.user.push.v1/src/main/resources/push.yaml @@ -147,6 +147,39 @@ paths: $ref: '#/components/responses/Forbidden' '500': $ref: '#/components/responses/ServerError' + /devices/{deviceId}/update: + post: + tags: + - device + description: | + This API is used to update a registered device through the mobile device. + summary: Update a registered device from the mobile device. + operationId: updateDeviceFromMobile + parameters: + - name: deviceId + in: path + description: ID of the device to be updated + required: true + schema: + type: string + requestBody: + description: Update request sent from the mobile device. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateRequestDTO' + responses: + '204': + description: The device was updated successfully. + '400': + $ref: '#/components/responses/BadRequest' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '500': + $ref: '#/components/responses/ServerError' /devices/{deviceId}/remove: post: tags: @@ -285,6 +318,16 @@ components: description: Provider metadata as key-value pairs additionalProperties: type: string + UpdateRequestDTO: + type: object + description: Update device request body sent from the mobile device + required: + - token + properties: + token: + type: string + description: JWT containing the device information to be updated signed with the unique private key + example: 'signedJWTToken' RemoveRequestDTO: type: object description: Remove device request body sent from the device