diff --git a/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/pom.xml b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/pom.xml new file mode 100644 index 00000000..c3365450 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/pom.xml @@ -0,0 +1,189 @@ + + + + + + org.wso2.carbon.identity.api.user.recovery + org.wso2.carbon.identity.user.api + 1.3.20-SNAPSHOT + ../pom.xml + + 4.0.0 + + org.wso2.carbon.identity.rest.api.user.recovery.v2 + jar + WSO2 Identity Server - User Account Recovery Rest API + WSO2 Identity Server - User Account Recovery Rest API + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.8 + + + add-source + generate-sources + + add-source + + + + src/gen/java + + + + + + + + + + + org.apache.cxf + cxf-rt-frontend-jaxrs + provided + + + org.apache.cxf + cxf-rt-rs-service-description + provided + + + org.springframework + spring-web + provided + + + javax.ws.rs + javax.ws.rs-api + provided + + + io.swagger + swagger-jaxrs + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.core + jackson-annotations + + + com.fasterxml.jackson.core + jackson-core + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + + + javax.ws.rs + jsr311-api + + + com.google.guava + guava + + + + + com.fasterxml.jackson.jaxrs + jackson-jaxrs-json-provider + provided + + + org.wso2.carbon.identity.governance + org.wso2.carbon.identity.recovery + provided + + + javax.ws.rs + jsr311-api + + + + + org.wso2.carbon.identity.governance + org.wso2.carbon.identity.governance + provided + + + javax.ws.rs + jsr311-api + + + + + org.wso2.carbon.identity.user.api + org.wso2.carbon.identity.api.user.common + provided + + + org.wso2.carbon.identity.user.api + org.wso2.carbon.identity.api.user.recovery.commons + provided + + + diff --git a/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/RecoveryApi.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/RecoveryApi.java new file mode 100644 index 00000000..2f317d88 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/RecoveryApi.java @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.user.recovery.v2; + +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.rest.api.user.recovery.v2.model.AccountRecoveryType; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.ConfirmRequest; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.ErrorResponse; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.InitRequest; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.PasswordRecoveryExternalNotifyResponse; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.PasswordRecoveryInternalNotifyResponse; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.PasswordResetResponse; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.RecoveryRequest; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.ResendConfirmationCodeExternalResponse; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.ResendConfirmationCodeInternalResponse; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.ResendConfirmationRequest; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.ResetCodeResponse; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.ResetRequest; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.RetryErrorResponse; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.UsernameRecoveryNotifyResponse; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.RecoveryApiService; + +import javax.validation.Valid; +import javax.ws.rs.*; +import javax.ws.rs.core.Response; +import io.swagger.annotations.*; + +import javax.validation.constraints.*; + +@Path("/recovery") +@Api(description = "The recovery API") + +public class RecoveryApi { + + @Autowired + private RecoveryApiService delegate; + + @Valid + @POST + @Path("/password/confirm") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Confirm password recovery ", notes = "- This API is used to validate the __confirmationCode__/__otp__ given at password recovery. - Use the returned __reset code__ with the __password reset API__ to reset the password. - The API will return the next API call. ", response = ResetCodeResponse.class, tags={ "Password Recovery", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "- Password reset confirmed. - `resetCode` is returned. ", response = ResetCodeResponse.class), + @ApiResponse(code = 400, message = "Bad Request. Request cannot be processed by the server.", response = ErrorResponse.class), + @ApiResponse(code = 404, message = "Confirmation code is not found.", response = ErrorResponse.class), + @ApiResponse(code = 406, message = "Confirmation code given in the request is not valid or expired. ", response = ErrorResponse.class), + @ApiResponse(code = 500, message = "Server Error.", response = ErrorResponse.class) + }) + public Response confirmRecovery(@ApiParam(value = "- Request to confirm the password recovery. - `confirmationCode` is `REQUIRED`. - `otp` is required only for OTP based password recovery. The __flowConfirmationCode__ returned from the password recovery request should be set as the `confirmationCode` for OTP based recovery. " ,required=true) @Valid ConfirmRequest confirmRequest) { + + return delegate.confirmRecovery(confirmRequest ); + } + + @Valid + @POST + @Path("/password/init") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Initiate password recovery ", notes = "- This API is used to initiate password recovery by user. The API will return recovery information for password recovery with challenge questions and password recovery with notifications. - `mode` __recoverWithNotifications__ contains recovery flow confirmation code, available communication channels and a recovery code for password recovery with notifications. The next API call will be returned in the response. - If `password recovery with notifications` is not enabled, the response will not contain __recoverWithNotifications__ mode. - __recoverWithChallengeQuestions__ contains the next API call to begin the recovery process via challenge questions. - If `password recovery with challenge questions` is not enabled, the response will not contain __recoverWithChallengeQuestions__ mode. ", response = AccountRecoveryType.class, responseContainer = "List", tags={ "Password Recovery", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "User is successfully identified for the given claims and returning available notification channels for the user.", response = AccountRecoveryType.class, responseContainer = "List"), + @ApiResponse(code = 400, message = "Bad Request. The request cannot be processed by the server.", response = ErrorResponse.class), + @ApiResponse(code = 404, message = "No user found for the given set of claims or no recovery channels are availabe for the user.", response = ErrorResponse.class), + @ApiResponse(code = 409, message = "Mutiple users found for the given claims.", response = ErrorResponse.class), + @ApiResponse(code = 500, message = "Server Error.", response = ErrorResponse.class) + }) + public Response initiatePasswordRecovery(@ApiParam(value = "Request to initate password recovery process. The request should contain the claims to identify the user. User claims are `REQUIRED`." ,required=true) @Valid InitRequest initRequest) { + + return delegate.initiatePasswordRecovery(initRequest ); + } + + @Valid + @POST + @Path("/username/init") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Initiate Username Recovery", notes = "- This API is used to initiate username recovery by user. The API will return available recovery information for username recovery with notifications. - Use the returned __recoveryCode__ and the __channelId__ with __username recover api__ to confirm the the username recovery and to recieve recovery notifications via the channel specified by the user. ", response = AccountRecoveryType.class, responseContainer = "List", tags={ "Username Recovery", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "User is successfully identified for the given claims and returning available notification channels for the user.", response = AccountRecoveryType.class, responseContainer = "List"), + @ApiResponse(code = 400, message = "Bad Request. The request cannot be processed by the server.", response = ErrorResponse.class), + @ApiResponse(code = 403, message = "Username recovery is not enabled.", response = ErrorResponse.class), + @ApiResponse(code = 404, message = "No user found for the given set of claims or no recovery channels are availabe for the user.", response = ErrorResponse.class), + @ApiResponse(code = 409, message = "Mutiple users found for the given claims.", response = ErrorResponse.class), + @ApiResponse(code = 500, message = "Server Error.", response = ErrorResponse.class) + }) + public Response initiateUsernameRecovery(@ApiParam(value = "Request to initate username recovery process. The request should contain the claims to identify the user. User claims are `REQUIRED`." ,required=true) @Valid InitRequest initRequest) { + + return delegate.initiateUsernameRecovery(initRequest ); + } + + @Valid + @POST + @Path("/password/recover") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Get Recovery Information ", notes = "- This API is used to send recovery information to the user who matches the recovery code via the channel specified by the channel Id. The API will return the recovery flow confirmation code. - NOTE: If the notification channel is EXTERNAL, the API will return a confirmationCode. - Use the returned confimation code with __password recovery confirm API__ to verify the password recovery process. - The API will return the next API call. ", response = PasswordRecoveryExternalNotifyResponse.class, tags={ "Password Recovery", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "- Password recovery initiated via `EXTERNAL` channel. API will return a `confirmationCode` to confirm password recovery. - Use the confirmation code with __password recovery confirm API__ to confirm the password recovery. ", response = PasswordRecoveryExternalNotifyResponse.class), + @ApiResponse(code = 202, message = "- Password recovery initiated via internal channels. API will send a `confirmationCode`/`otp` to the channel specified by the user. - Use the confirmation code/OTP with __password recovery confirm API__ to confirm the password recovery. ", response = PasswordRecoveryInternalNotifyResponse.class), + @ApiResponse(code = 400, message = "Bad Request. Request cannot be processed by the server.", response = ErrorResponse.class), + @ApiResponse(code = 403, message = "Password recovery is not enabled.", response = ErrorResponse.class), + @ApiResponse(code = 404, message = "Recovery code is not found.", response = ErrorResponse.class), + @ApiResponse(code = 406, message = "- Recovery code given in the request is not valid or expired. - Channel id is not valid ", response = ErrorResponse.class), + @ApiResponse(code = 500, message = "Server Error.", response = ErrorResponse.class) + }) + public Response recoverPassword(@ApiParam(value = "- Request to receive recovery notifications. - `recoveryCode` and `channelId` are `REQUIRED`. - __NOTE__ `channelId` should always be __larger than 0__. " ,required=true) @Valid RecoveryRequest recoveryRequest) { + + return delegate.recoverPassword(recoveryRequest ); + } + + @Valid + @POST + @Path("/username/recover") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Get Recovery Information", notes = "- This API is used to confirm username recovery and send username recovery information to the user who matches the recovery code via the channel specified by the channel Id. - __NOTE__: If the notification channel is __EXTERNAL__, the API will return the username of the user. ", response = UsernameRecoveryNotifyResponse.class, tags={ "Username Recovery", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Username is successfully recovered and the __notification channel__ is `EXTERNAL`.", response = UsernameRecoveryNotifyResponse.class), + @ApiResponse(code = 202, message = "Username is successfully recovered.", response = UsernameRecoveryNotifyResponse.class), + @ApiResponse(code = 400, message = "Bad Request. Request cannot be processed by the server.", response = ErrorResponse.class), + @ApiResponse(code = 404, message = "Recovery code is not found.", response = ErrorResponse.class), + @ApiResponse(code = 406, message = "- Recovery code given in the request is not valid or expired. - Channel id is not valid ", response = ErrorResponse.class), + @ApiResponse(code = 500, message = "Server Error.", response = ErrorResponse.class) + }) + public Response recoverUsername(@ApiParam(value = "- Request to confirm username recovery and receive recovery notifications. - `recoveryCode` and `channelId` are `REQUIRED`. - __NOTE__ `channelId` should always be __larger than 0__. " ,required=true) @Valid RecoveryRequest recoveryRequest) { + + return delegate.recoverUsername(recoveryRequest ); + } + + @Valid + @POST + @Path("/password/resend") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Resend password recovery confirmation details ", notes = "- This API is used to resend a confirmation code/OTP to the user via a user preferred channel defined at password recovery. - NOTE: The API cannot be used when the notification channel is external. - The API will return the next API calls. ", response = ResendConfirmationCodeExternalResponse.class, tags={ "Password Recovery", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "- API will return a new `confirmationCode`. - Use the confirmation code with __password recovery confirm API__ to confirm the password recovery. ", response = ResendConfirmationCodeExternalResponse.class), + @ApiResponse(code = 202, message = "- API will send a `confirmationCode`/`otp` to the channel specified by the user. - Use the confirmation code/OTP with __password recovery confirm API__ to confirm the password recovery. ", response = ResendConfirmationCodeInternalResponse.class), + @ApiResponse(code = 400, message = "Bad Request. Request cannot be processed by the server.", response = ErrorResponse.class), + @ApiResponse(code = 404, message = "Resend code is not found.", response = ErrorResponse.class), + @ApiResponse(code = 406, message = "Resend code given in the request is not valid or expired.", response = ErrorResponse.class), + @ApiResponse(code = 500, message = "Server Error.", response = ErrorResponse.class) + }) + public Response resendConfirmation(@ApiParam(value = "- Request to resend the `confirmationCode`/`otp` to the user via a user preferred channel. - Can send additional properties. " ,required=true) @Valid ResendConfirmationRequest resendConfirmationRequest) { + + return delegate.resendConfirmation(resendConfirmationRequest ); + } + + @Valid + @POST + @Path("/password/reset") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Reset password ", notes = "This API is used to reset the password of the user who matches the flowConfirmationCode given by the recover API and the resetCode given by the confirmation API. ", response = PasswordResetResponse.class, tags={ "Password Recovery" }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Successful password reset.", response = PasswordResetResponse.class), + @ApiResponse(code = 400, message = "Bad Request. Request cannot be processed by the server.", response = ErrorResponse.class), + @ApiResponse(code = 404, message = "Reset code is not found.", response = ErrorResponse.class), + @ApiResponse(code = 406, message = "Reset code given in the request is not valid or expired.", response = ErrorResponse.class), + @ApiResponse(code = 412, message = "Password policy violation.", response = RetryErrorResponse.class), + @ApiResponse(code = 500, message = "Server Error.", response = ErrorResponse.class) + }) + public Response resetPassword(@ApiParam(value = "- Request to reset the password. - `resetCode`, `flowConfirmationCode` and `password` are required. " ,required=true) @Valid ResetRequest resetRequest) { + + return delegate.resetPassword(resetRequest ); + } + +} diff --git a/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/RecoveryApiService.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/RecoveryApiService.java new file mode 100644 index 00000000..4d78dedf --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/RecoveryApiService.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.user.recovery.v2; + +import org.wso2.carbon.identity.rest.api.user.recovery.v2.*; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.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.rest.api.user.recovery.v2.model.AccountRecoveryType; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.ConfirmRequest; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.ErrorResponse; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.InitRequest; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.PasswordRecoveryExternalNotifyResponse; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.PasswordRecoveryInternalNotifyResponse; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.PasswordResetResponse; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.RecoveryRequest; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.ResendConfirmationCodeExternalResponse; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.ResendConfirmationCodeInternalResponse; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.ResendConfirmationRequest; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.ResetCodeResponse; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.ResetRequest; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.RetryErrorResponse; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.UsernameRecoveryNotifyResponse; +import javax.ws.rs.core.Response; + + +public interface RecoveryApiService { + + public Response confirmRecovery(ConfirmRequest confirmRequest); + + public Response initiatePasswordRecovery(InitRequest initRequest); + + public Response initiateUsernameRecovery(InitRequest initRequest); + + public Response recoverPassword(RecoveryRequest recoveryRequest); + + public Response recoverUsername(RecoveryRequest recoveryRequest); + + public Response resendConfirmation(ResendConfirmationRequest resendConfirmationRequest); + + public Response resetPassword(ResetRequest resetRequest); +} diff --git a/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/factories/RecoveryApiServiceFactory.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/factories/RecoveryApiServiceFactory.java new file mode 100644 index 00000000..8ce00fcf --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/factories/RecoveryApiServiceFactory.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.user.recovery.v2.factories; + +import org.wso2.carbon.identity.rest.api.user.recovery.v2.RecoveryApiService; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.impl.RecoveryApiServiceImpl; + +public class RecoveryApiServiceFactory { + + private final static RecoveryApiService service = new RecoveryApiServiceImpl(); + + public static RecoveryApiService getRecoveryApi() + { + return service; + } +} diff --git a/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/APICall.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/APICall.java new file mode 100644 index 00000000..f08079ba --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/APICall.java @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.user.recovery.v2.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.*; + +/** + * Object that holds next API call details + **/ + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; +@ApiModel(description = "Object that holds next API call details") +public class APICall { + + private String rel; + private String href; + private String type; + + /** + * Next API call + **/ + public APICall rel(String rel) { + + this.rel = rel; + return this; + } + + @ApiModelProperty(example = "next", value = "Next API call") + @JsonProperty("rel") + @Valid + public String getRel() { + return rel; + } + public void setRel(String rel) { + this.rel = rel; + } + + /** + * Next API url + **/ + public APICall href(String href) { + + this.href = href; + return this; + } + + @ApiModelProperty(example = "/api/users/recovery/v2/", value = "Next API url") + @JsonProperty("href") + @Valid + public String getHref() { + return href; + } + public void setHref(String href) { + this.href = href; + } + + /** + * HTTP method type + **/ + public APICall type(String type) { + + this.type = type; + return this; + } + + @ApiModelProperty(example = "POST", value = "HTTP method type") + @JsonProperty("type") + @Valid + public String getType() { + return type; + } + public void setType(String 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; + } + APICall apICall = (APICall) o; + return Objects.equals(this.rel, apICall.rel) && + Objects.equals(this.href, apICall.href) && + Objects.equals(this.type, apICall.type); + } + + @Override + public int hashCode() { + return Objects.hash(rel, href, type); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class APICall {\n"); + + sb.append(" rel: ").append(toIndentedString(rel)).append("\n"); + sb.append(" href: ").append(toIndentedString(href)).append("\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.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/AccountRecoveryType.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/AccountRecoveryType.java new file mode 100644 index 00000000..320407ee --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/AccountRecoveryType.java @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.user.recovery.v2.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.rest.api.user.recovery.v2.model.APICall; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.RecoveryChannelInformation; +import javax.validation.constraints.*; + +/** + * Object that encapsulates details of the account recovery channel + **/ + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; +@ApiModel(description = "Object that encapsulates details of the account recovery channel") +public class AccountRecoveryType { + + private String mode; + private String flowConfirmationCode; + private RecoveryChannelInformation channelInfo; + private List links = null; + + + /** + **/ + public AccountRecoveryType mode(String mode) { + + this.mode = mode; + return this; + } + + @ApiModelProperty(example = "recoverWithNotifications", value = "") + @JsonProperty("mode") + @Valid + public String getMode() { + return mode; + } + public void setMode(String mode) { + this.mode = mode; + } + + /** + **/ + public AccountRecoveryType flowConfirmationCode(String flowConfirmationCode) { + + this.flowConfirmationCode = flowConfirmationCode; + return this; + } + + @ApiModelProperty(example = "1234-1234-1234-1234", value = "") + @JsonProperty("flowConfirmationCode") + @Valid + public String getFlowConfirmationCode() { + return flowConfirmationCode; + } + public void setFlowConfirmationCode(String flowConfirmationCode) { + this.flowConfirmationCode = flowConfirmationCode; + } + + /** + **/ + public AccountRecoveryType channelInfo(RecoveryChannelInformation channelInfo) { + + this.channelInfo = channelInfo; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("channelInfo") + @Valid + public RecoveryChannelInformation getChannelInfo() { + return channelInfo; + } + public void setChannelInfo(RecoveryChannelInformation channelInfo) { + this.channelInfo = channelInfo; + } + + /** + * Contains available api calls + **/ + public AccountRecoveryType links(List links) { + + this.links = links; + return this; + } + + @ApiModelProperty(value = "Contains available api calls") + @JsonProperty("links") + @Valid + public List getLinks() { + return links; + } + public void setLinks(List links) { + this.links = links; + } + + public AccountRecoveryType addLinksItem(APICall linksItem) { + if (this.links == null) { + this.links = new ArrayList<>(); + } + this.links.add(linksItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AccountRecoveryType accountRecoveryType = (AccountRecoveryType) o; + return Objects.equals(this.mode, accountRecoveryType.mode) && + Objects.equals(this.flowConfirmationCode, accountRecoveryType.flowConfirmationCode) && + Objects.equals(this.channelInfo, accountRecoveryType.channelInfo) && + Objects.equals(this.links, accountRecoveryType.links); + } + + @Override + public int hashCode() { + return Objects.hash(mode, flowConfirmationCode, channelInfo, links); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class AccountRecoveryType {\n"); + + sb.append(" mode: ").append(toIndentedString(mode)).append("\n"); + sb.append(" flowConfirmationCode: ").append(toIndentedString(flowConfirmationCode)).append("\n"); + sb.append(" channelInfo: ").append(toIndentedString(channelInfo)).append("\n"); + sb.append(" links: ").append(toIndentedString(links)).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.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/ConfirmRequest.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/ConfirmRequest.java new file mode 100644 index 00000000..90927de1 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/ConfirmRequest.java @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.user.recovery.v2.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.rest.api.user.recovery.v2.model.Property; +import javax.validation.constraints.*; + +/** + * Request to confirm password recovery + **/ + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; +@ApiModel(description = "Request to confirm password recovery") +public class ConfirmRequest { + + private String confirmationCode; + private String otp; + private List properties = null; + + + /** + * Confirmation code of the recovery flow + **/ + public ConfirmRequest confirmationCode(String confirmationCode) { + + this.confirmationCode = confirmationCode; + return this; + } + + @ApiModelProperty(example = "1234-2ws34-12345", required = true, value = "Confirmation code of the recovery flow") + @JsonProperty("confirmationCode") + @Valid + @NotNull(message = "Property confirmationCode cannot be null.") + + public String getConfirmationCode() { + return confirmationCode; + } + public void setConfirmationCode(String confirmationCode) { + this.confirmationCode = confirmationCode; + } + + /** + * OTP sent to the user + **/ + public ConfirmRequest otp(String otp) { + + this.otp = otp; + return this; + } + + @ApiModelProperty(example = "wi8Ivm", value = "OTP sent to the user") + @JsonProperty("otp") + @Valid + public String getOtp() { + return otp; + } + public void setOtp(String otp) { + this.otp = otp; + } + + /** + * (OPTIONAL) Additional META properties + **/ + public ConfirmRequest properties(List properties) { + + this.properties = properties; + return this; + } + + @ApiModelProperty(value = "(OPTIONAL) Additional META properties") + @JsonProperty("properties") + @Valid + public List getProperties() { + return properties; + } + public void setProperties(List properties) { + this.properties = properties; + } + + public ConfirmRequest addPropertiesItem(Property propertiesItem) { + if (this.properties == null) { + this.properties = new ArrayList<>(); + } + this.properties.add(propertiesItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ConfirmRequest confirmRequest = (ConfirmRequest) o; + return Objects.equals(this.confirmationCode, confirmRequest.confirmationCode) && + Objects.equals(this.otp, confirmRequest.otp) && + Objects.equals(this.properties, confirmRequest.properties); + } + + @Override + public int hashCode() { + return Objects.hash(confirmationCode, otp, properties); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class ConfirmRequest {\n"); + + sb.append(" confirmationCode: ").append(toIndentedString(confirmationCode)).append("\n"); + sb.append(" otp: ").append(toIndentedString(otp)).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.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/ErrorResponse.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/ErrorResponse.java new file mode 100644 index 00000000..7267e580 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/ErrorResponse.java @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.user.recovery.v2.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class ErrorResponse { + + private String code; + private String message; + private String description; + private String traceId; + + /** + * Error code corresponding to the error + **/ + public ErrorResponse code(String code) { + + this.code = code; + return this; + } + + @ApiModelProperty(example = "UAR-10001", value = "Error code corresponding to the error") + @JsonProperty("code") + @Valid + public String getCode() { + return code; + } + public void setCode(String code) { + this.code = code; + } + + /** + * Error message + **/ + public ErrorResponse message(String message) { + + this.message = message; + return this; + } + + @ApiModelProperty(example = "invalid_request", value = "Error message") + @JsonProperty("message") + @Valid + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + + /** + * Description about the error + **/ + public ErrorResponse description(String description) { + + this.description = description; + return this; + } + + @ApiModelProperty(example = "Invalid claim uri", value = "Description about the error") + @JsonProperty("description") + @Valid + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + + /** + * Some Correlation for Error Instance + **/ + public ErrorResponse traceId(String traceId) { + + this.traceId = traceId; + return this; + } + + @ApiModelProperty(example = "2345dfgh678h789bhjk", value = "Some Correlation for Error Instance") + @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; + } + ErrorResponse errorResponse = (ErrorResponse) o; + return Objects.equals(this.code, errorResponse.code) && + Objects.equals(this.message, errorResponse.message) && + Objects.equals(this.description, errorResponse.description) && + Objects.equals(this.traceId, errorResponse.traceId); + } + + @Override + public int hashCode() { + return Objects.hash(code, message, description, traceId); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class ErrorResponse {\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.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/InitRequest.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/InitRequest.java new file mode 100644 index 00000000..dd13ee26 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/InitRequest.java @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.user.recovery.v2.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.rest.api.user.recovery.v2.model.Property; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.UserClaim; +import javax.validation.constraints.*; + +/** + * Request to initate an account recovery + **/ + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; +@ApiModel(description = "Request to initate an account recovery") +public class InitRequest { + + private List claims = new ArrayList<>(); + + private List properties = null; + + + /** + * User claims to identify the user as UserClaim objects + **/ + public InitRequest claims(List claims) { + + this.claims = claims; + return this; + } + + @ApiModelProperty(required = true, value = "User claims to identify the user as UserClaim objects") + @JsonProperty("claims") + @Valid + @NotNull(message = "Property claims cannot be null.") + + public List getClaims() { + return claims; + } + public void setClaims(List claims) { + this.claims = claims; + } + + public InitRequest addClaimsItem(UserClaim claimsItem) { + this.claims.add(claimsItem); + return this; + } + + /** + * (OPTIONAL) Additional META properties + **/ + public InitRequest properties(List properties) { + + this.properties = properties; + return this; + } + + @ApiModelProperty(value = "(OPTIONAL) Additional META properties") + @JsonProperty("properties") + @Valid + public List getProperties() { + return properties; + } + public void setProperties(List properties) { + this.properties = properties; + } + + public InitRequest addPropertiesItem(Property propertiesItem) { + if (this.properties == null) { + this.properties = new ArrayList<>(); + } + this.properties.add(propertiesItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InitRequest initRequest = (InitRequest) o; + return Objects.equals(this.claims, initRequest.claims) && + Objects.equals(this.properties, initRequest.properties); + } + + @Override + public int hashCode() { + return Objects.hash(claims, properties); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class InitRequest {\n"); + + sb.append(" claims: ").append(toIndentedString(claims)).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.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/PasswordRecoveryExternalNotifyResponse.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/PasswordRecoveryExternalNotifyResponse.java new file mode 100644 index 00000000..369c4e34 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/PasswordRecoveryExternalNotifyResponse.java @@ -0,0 +1,243 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.user.recovery.v2.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.rest.api.user.recovery.v2.model.APICall; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class PasswordRecoveryExternalNotifyResponse { + + private String code; + private String message; + private String flowConfirmationCode; + private String notificationChannel; + private String confirmationCode; + private String resendCode; + private List links = null; + + + /** + * Success status code + **/ + public PasswordRecoveryExternalNotifyResponse code(String code) { + + this.code = code; + return this; + } + + @ApiModelProperty(example = "PWR-02002", value = "Success status code") + @JsonProperty("code") + @Valid + public String getCode() { + return code; + } + public void setCode(String code) { + this.code = code; + } + + /** + * Success status message + **/ + public PasswordRecoveryExternalNotifyResponse message(String message) { + + this.message = message; + return this; + } + + @ApiModelProperty(example = "successful_request", value = "Success status message") + @JsonProperty("message") + @Valid + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + + /** + * Recovery flow confirmation code + **/ + public PasswordRecoveryExternalNotifyResponse flowConfirmationCode(String flowConfirmationCode) { + + this.flowConfirmationCode = flowConfirmationCode; + return this; + } + + @ApiModelProperty(example = "1234-1234-1234-1234", value = "Recovery flow confirmation code") + @JsonProperty("flowConfirmationCode") + @Valid + public String getFlowConfirmationCode() { + return flowConfirmationCode; + } + public void setFlowConfirmationCode(String flowConfirmationCode) { + this.flowConfirmationCode = flowConfirmationCode; + } + + /** + * Channel that is used to send recovery information + **/ + public PasswordRecoveryExternalNotifyResponse notificationChannel(String notificationChannel) { + + this.notificationChannel = notificationChannel; + return this; + } + + @ApiModelProperty(example = "EXTERNAL", value = "Channel that is used to send recovery information") + @JsonProperty("notificationChannel") + @Valid + public String getNotificationChannel() { + return notificationChannel; + } + public void setNotificationChannel(String notificationChannel) { + this.notificationChannel = notificationChannel; + } + + /** + * - Confirmation code for password recovery when the notifications are externally managed. - The confirmation code will be returned only if the notification channel is _EXTERNAL_. Use this code with password confirm API to get a password reset code. + **/ + public PasswordRecoveryExternalNotifyResponse confirmationCode(String confirmationCode) { + + this.confirmationCode = confirmationCode; + return this; + } + + @ApiModelProperty(example = "12345-45678-6789098-8765", value = "- Confirmation code for password recovery when the notifications are externally managed. - The confirmation code will be returned only if the notification channel is _EXTERNAL_. Use this code with password confirm API to get a password reset code. ") + @JsonProperty("confirmationCode") + @Valid + public String getConfirmationCode() { + return confirmationCode; + } + public void setConfirmationCode(String confirmationCode) { + this.confirmationCode = confirmationCode; + } + + /** + * Code to get a new confirmation code. + **/ + public PasswordRecoveryExternalNotifyResponse resendCode(String resendCode) { + + this.resendCode = resendCode; + return this; + } + + @ApiModelProperty(example = "1234-123456-12345-12345", value = "Code to get a new confirmation code.") + @JsonProperty("resendCode") + @Valid + public String getResendCode() { + return resendCode; + } + public void setResendCode(String resendCode) { + this.resendCode = resendCode; + } + + /** + * Contains available api calls + **/ + public PasswordRecoveryExternalNotifyResponse links(List links) { + + this.links = links; + return this; + } + + @ApiModelProperty(value = "Contains available api calls") + @JsonProperty("links") + @Valid + public List getLinks() { + return links; + } + public void setLinks(List links) { + this.links = links; + } + + public PasswordRecoveryExternalNotifyResponse addLinksItem(APICall linksItem) { + if (this.links == null) { + this.links = new ArrayList<>(); + } + this.links.add(linksItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PasswordRecoveryExternalNotifyResponse passwordRecoveryExternalNotifyResponse = (PasswordRecoveryExternalNotifyResponse) o; + return Objects.equals(this.code, passwordRecoveryExternalNotifyResponse.code) && + Objects.equals(this.message, passwordRecoveryExternalNotifyResponse.message) && + Objects.equals(this.flowConfirmationCode, passwordRecoveryExternalNotifyResponse.flowConfirmationCode) && + Objects.equals(this.notificationChannel, passwordRecoveryExternalNotifyResponse.notificationChannel) && + Objects.equals(this.confirmationCode, passwordRecoveryExternalNotifyResponse.confirmationCode) && + Objects.equals(this.resendCode, passwordRecoveryExternalNotifyResponse.resendCode) && + Objects.equals(this.links, passwordRecoveryExternalNotifyResponse.links); + } + + @Override + public int hashCode() { + return Objects.hash(code, message, flowConfirmationCode, notificationChannel, confirmationCode, resendCode, links); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class PasswordRecoveryExternalNotifyResponse {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" flowConfirmationCode: ").append(toIndentedString(flowConfirmationCode)).append("\n"); + sb.append(" notificationChannel: ").append(toIndentedString(notificationChannel)).append("\n"); + sb.append(" confirmationCode: ").append(toIndentedString(confirmationCode)).append("\n"); + sb.append(" resendCode: ").append(toIndentedString(resendCode)).append("\n"); + sb.append(" links: ").append(toIndentedString(links)).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.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/PasswordRecoveryInternalNotifyResponse.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/PasswordRecoveryInternalNotifyResponse.java new file mode 100644 index 00000000..d9bf97e8 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/PasswordRecoveryInternalNotifyResponse.java @@ -0,0 +1,221 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.user.recovery.v2.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.rest.api.user.recovery.v2.model.APICall; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class PasswordRecoveryInternalNotifyResponse { + + private String code; + private String message; + private String flowConfirmationCode; + private String notificationChannel; + private String resendCode; + private List links = null; + + + /** + * Success status code + **/ + public PasswordRecoveryInternalNotifyResponse code(String code) { + + this.code = code; + return this; + } + + @ApiModelProperty(example = "PWR-02002", value = "Success status code") + @JsonProperty("code") + @Valid + public String getCode() { + return code; + } + public void setCode(String code) { + this.code = code; + } + + /** + * Success status message + **/ + public PasswordRecoveryInternalNotifyResponse message(String message) { + + this.message = message; + return this; + } + + @ApiModelProperty(example = "successful_request", value = "Success status message") + @JsonProperty("message") + @Valid + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + + /** + * Recovery flow confirmation code + **/ + public PasswordRecoveryInternalNotifyResponse flowConfirmationCode(String flowConfirmationCode) { + + this.flowConfirmationCode = flowConfirmationCode; + return this; + } + + @ApiModelProperty(example = "1234-1234-1234-1234", value = "Recovery flow confirmation code") + @JsonProperty("flowConfirmationCode") + @Valid + public String getFlowConfirmationCode() { + return flowConfirmationCode; + } + public void setFlowConfirmationCode(String flowConfirmationCode) { + this.flowConfirmationCode = flowConfirmationCode; + } + + /** + * Channel that is used to send recovery information + **/ + public PasswordRecoveryInternalNotifyResponse notificationChannel(String notificationChannel) { + + this.notificationChannel = notificationChannel; + return this; + } + + @ApiModelProperty(example = "EMAIL", value = "Channel that is used to send recovery information") + @JsonProperty("notificationChannel") + @Valid + public String getNotificationChannel() { + return notificationChannel; + } + public void setNotificationChannel(String notificationChannel) { + this.notificationChannel = notificationChannel; + } + + /** + * Code to resend the confirmation code to the user via user user selected channel + **/ + public PasswordRecoveryInternalNotifyResponse resendCode(String resendCode) { + + this.resendCode = resendCode; + return this; + } + + @ApiModelProperty(example = "1234-123456-12345-12345", value = "Code to resend the confirmation code to the user via user user selected channel") + @JsonProperty("resendCode") + @Valid + public String getResendCode() { + return resendCode; + } + public void setResendCode(String resendCode) { + this.resendCode = resendCode; + } + + /** + * Contains available api calls + **/ + public PasswordRecoveryInternalNotifyResponse links(List links) { + + this.links = links; + return this; + } + + @ApiModelProperty(value = "Contains available api calls") + @JsonProperty("links") + @Valid + public List getLinks() { + return links; + } + public void setLinks(List links) { + this.links = links; + } + + public PasswordRecoveryInternalNotifyResponse addLinksItem(APICall linksItem) { + if (this.links == null) { + this.links = new ArrayList<>(); + } + this.links.add(linksItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PasswordRecoveryInternalNotifyResponse passwordRecoveryInternalNotifyResponse = (PasswordRecoveryInternalNotifyResponse) o; + return Objects.equals(this.code, passwordRecoveryInternalNotifyResponse.code) && + Objects.equals(this.message, passwordRecoveryInternalNotifyResponse.message) && + Objects.equals(this.flowConfirmationCode, passwordRecoveryInternalNotifyResponse.flowConfirmationCode) && + Objects.equals(this.notificationChannel, passwordRecoveryInternalNotifyResponse.notificationChannel) && + Objects.equals(this.resendCode, passwordRecoveryInternalNotifyResponse.resendCode) && + Objects.equals(this.links, passwordRecoveryInternalNotifyResponse.links); + } + + @Override + public int hashCode() { + return Objects.hash(code, message, flowConfirmationCode, notificationChannel, resendCode, links); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class PasswordRecoveryInternalNotifyResponse {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" flowConfirmationCode: ").append(toIndentedString(flowConfirmationCode)).append("\n"); + sb.append(" notificationChannel: ").append(toIndentedString(notificationChannel)).append("\n"); + sb.append(" resendCode: ").append(toIndentedString(resendCode)).append("\n"); + sb.append(" links: ").append(toIndentedString(links)).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.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/PasswordResetResponse.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/PasswordResetResponse.java new file mode 100644 index 00000000..9670b10f --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/PasswordResetResponse.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.user.recovery.v2.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.*; + +/** + * API response for a successful password reset + **/ + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; +@ApiModel(description = "API response for a successful password reset") +public class PasswordResetResponse { + + private String code; + private String message; + + /** + * Operation code + **/ + public PasswordResetResponse code(String code) { + + this.code = code; + return this; + } + + @ApiModelProperty(example = "PWR-02001", value = "Operation code") + @JsonProperty("code") + @Valid + public String getCode() { + return code; + } + public void setCode(String code) { + this.code = code; + } + + /** + * Message regarding the operation. + **/ + public PasswordResetResponse message(String message) { + + this.message = message; + return this; + } + + @ApiModelProperty(example = "successful_request", value = "Message regarding the operation.") + @JsonProperty("message") + @Valid + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PasswordResetResponse passwordResetResponse = (PasswordResetResponse) o; + return Objects.equals(this.code, passwordResetResponse.code) && + Objects.equals(this.message, passwordResetResponse.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, message); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class PasswordResetResponse {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).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.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/Property.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/Property.java new file mode 100644 index 00000000..30a904fb --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/Property.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.user.recovery.v2.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.*; + +/** + * object that holds a property as a key, value pair + **/ + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; +@ApiModel(description = "object that holds a property as a key, value pair") +public class Property { + + private String key; + private String value; + + /** + * Unique identifier as the key of the peroperty + **/ + public Property key(String key) { + + this.key = key; + return this; + } + + @ApiModelProperty(example = "key", value = "Unique identifier as the key of the peroperty") + @JsonProperty("key") + @Valid + public String getKey() { + return key; + } + public void setKey(String key) { + this.key = key; + } + + /** + * Value of the property + **/ + public Property value(String value) { + + this.value = value; + return this; + } + + @ApiModelProperty(example = "value", value = "Value of the property") + @JsonProperty("value") + @Valid + public String getValue() { + return value; + } + public void setValue(String value) { + this.value = value; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Property property = (Property) o; + return Objects.equals(this.key, property.key) && + Objects.equals(this.value, property.value); + } + + @Override + public int hashCode() { + return Objects.hash(key, value); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class Property {\n"); + + sb.append(" key: ").append(toIndentedString(key)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/RecoveryChannel.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/RecoveryChannel.java new file mode 100644 index 00000000..1bb26f28 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/RecoveryChannel.java @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.user.recovery.v2.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.*; + +/** + * Object with notification channel attributes + **/ + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; +@ApiModel(description = "Object with notification channel attributes") +public class RecoveryChannel { + + private String id; + private String type; + private String value; + private Boolean preferred; + + /** + * Id given to the channel + **/ + public RecoveryChannel id(String id) { + + this.id = id; + return this; + } + + @ApiModelProperty(example = "1", value = "Id given to the channel") + @JsonProperty("id") + @Valid + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + + /** + * Type of the chanel + **/ + public RecoveryChannel type(String type) { + + this.type = type; + return this; + } + + @ApiModelProperty(example = "EMAIL", value = "Type of the chanel") + @JsonProperty("type") + @Valid + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + + /** + * Masked channel value + **/ + public RecoveryChannel value(String value) { + + this.value = value; + return this; + } + + @ApiModelProperty(example = "wso2***********.com", value = "Masked channel value") + @JsonProperty("value") + @Valid + public String getValue() { + return value; + } + public void setValue(String value) { + this.value = value; + } + + /** + * Whether the channel is a user preferred channel + **/ + public RecoveryChannel preferred(Boolean preferred) { + + this.preferred = preferred; + return this; + } + + @ApiModelProperty(example = "true", value = "Whether the channel is a user preferred channel") + @JsonProperty("preferred") + @Valid + public Boolean getPreferred() { + return preferred; + } + public void setPreferred(Boolean preferred) { + this.preferred = preferred; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RecoveryChannel recoveryChannel = (RecoveryChannel) o; + return Objects.equals(this.id, recoveryChannel.id) && + Objects.equals(this.type, recoveryChannel.type) && + Objects.equals(this.value, recoveryChannel.value) && + Objects.equals(this.preferred, recoveryChannel.preferred); + } + + @Override + public int hashCode() { + return Objects.hash(id, type, value, preferred); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class RecoveryChannel {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append(" preferred: ").append(toIndentedString(preferred)).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.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/RecoveryChannelInformation.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/RecoveryChannelInformation.java new file mode 100644 index 00000000..a5c73c21 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/RecoveryChannelInformation.java @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.user.recovery.v2.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.rest.api.user.recovery.v2.model.RecoveryChannel; +import javax.validation.constraints.*; + +/** + * Response with the recovery ID and the available recovery channels + **/ + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; +@ApiModel(description = "Response with the recovery ID and the available recovery channels") +public class RecoveryChannelInformation { + + private String recoveryCode; + private List channels = null; + + + /** + * Code to recovery the user account + **/ + public RecoveryChannelInformation recoveryCode(String recoveryCode) { + + this.recoveryCode = recoveryCode; + return this; + } + + @ApiModelProperty(example = "1234-55678-5668-2345", value = "Code to recovery the user account") + @JsonProperty("recoveryCode") + @Valid + public String getRecoveryCode() { + return recoveryCode; + } + public void setRecoveryCode(String recoveryCode) { + this.recoveryCode = recoveryCode; + } + + /** + * Availabel recovery channels for the user + **/ + public RecoveryChannelInformation channels(List channels) { + + this.channels = channels; + return this; + } + + @ApiModelProperty(value = "Availabel recovery channels for the user") + @JsonProperty("channels") + @Valid + public List getChannels() { + return channels; + } + public void setChannels(List channels) { + this.channels = channels; + } + + public RecoveryChannelInformation addChannelsItem(RecoveryChannel channelsItem) { + if (this.channels == null) { + this.channels = new ArrayList<>(); + } + this.channels.add(channelsItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RecoveryChannelInformation recoveryChannelInformation = (RecoveryChannelInformation) o; + return Objects.equals(this.recoveryCode, recoveryChannelInformation.recoveryCode) && + Objects.equals(this.channels, recoveryChannelInformation.channels); + } + + @Override + public int hashCode() { + return Objects.hash(recoveryCode, channels); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class RecoveryChannelInformation {\n"); + + sb.append(" recoveryCode: ").append(toIndentedString(recoveryCode)).append("\n"); + sb.append(" channels: ").append(toIndentedString(channels)).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.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/RecoveryRequest.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/RecoveryRequest.java new file mode 100644 index 00000000..79c4b94d --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/RecoveryRequest.java @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.user.recovery.v2.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.rest.api.user.recovery.v2.model.Property; +import javax.validation.constraints.*; + +/** + * Request to start the recovery for the user who matches the recovery code via the given channelID + **/ + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; +@ApiModel(description = "Request to start the recovery for the user who matches the recovery code via the given channelID") +public class RecoveryRequest { + + private String recoveryCode; + private String channelId; + private List properties = null; + + + /** + * Recovery code for the user + **/ + public RecoveryRequest recoveryCode(String recoveryCode) { + + this.recoveryCode = recoveryCode; + return this; + } + + @ApiModelProperty(example = "1234-5678-2455-3433", required = true, value = "Recovery code for the user") + @JsonProperty("recoveryCode") + @Valid + @NotNull(message = "Property recoveryCode cannot be null.") + + public String getRecoveryCode() { + return recoveryCode; + } + public void setRecoveryCode(String recoveryCode) { + this.recoveryCode = recoveryCode; + } + + /** + * Id of the notification channel that user preferrs to get recovery notifications. + **/ + public RecoveryRequest channelId(String channelId) { + + this.channelId = channelId; + return this; + } + + @ApiModelProperty(example = "1", required = true, value = "Id of the notification channel that user preferrs to get recovery notifications.") + @JsonProperty("channelId") + @Valid + @NotNull(message = "Property channelId cannot be null.") + + public String getChannelId() { + return channelId; + } + public void setChannelId(String channelId) { + this.channelId = channelId; + } + + /** + * (OPTIONAL) Additional META properties + **/ + public RecoveryRequest properties(List properties) { + + this.properties = properties; + return this; + } + + @ApiModelProperty(value = "(OPTIONAL) Additional META properties") + @JsonProperty("properties") + @Valid + public List getProperties() { + return properties; + } + public void setProperties(List properties) { + this.properties = properties; + } + + public RecoveryRequest addPropertiesItem(Property propertiesItem) { + if (this.properties == null) { + this.properties = new ArrayList<>(); + } + this.properties.add(propertiesItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RecoveryRequest recoveryRequest = (RecoveryRequest) o; + return Objects.equals(this.recoveryCode, recoveryRequest.recoveryCode) && + Objects.equals(this.channelId, recoveryRequest.channelId) && + Objects.equals(this.properties, recoveryRequest.properties); + } + + @Override + public int hashCode() { + return Objects.hash(recoveryCode, channelId, properties); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class RecoveryRequest {\n"); + + sb.append(" recoveryCode: ").append(toIndentedString(recoveryCode)).append("\n"); + sb.append(" channelId: ").append(toIndentedString(channelId)).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.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/ResendConfirmationCodeExternalResponse.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/ResendConfirmationCodeExternalResponse.java new file mode 100644 index 00000000..d4164367 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/ResendConfirmationCodeExternalResponse.java @@ -0,0 +1,246 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.user.recovery.v2.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.rest.api.user.recovery.v2.model.APICall; +import javax.validation.constraints.*; + +/** + * Object encapsulate the details regarding resend confirmation code + **/ + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; +@ApiModel(description = "Object encapsulate the details regarding resend confirmation code") +public class ResendConfirmationCodeExternalResponse { + + private String code; + private String message; + private String flowConfirmationCode; + private String notificationChannel; + private String confirmationCode; + private String resendCode; + private List links = null; + + + /** + * Success status code + **/ + public ResendConfirmationCodeExternalResponse code(String code) { + + this.code = code; + return this; + } + + @ApiModelProperty(example = "PWR-02002", value = "Success status code") + @JsonProperty("code") + @Valid + public String getCode() { + return code; + } + public void setCode(String code) { + this.code = code; + } + + /** + * Success status message + **/ + public ResendConfirmationCodeExternalResponse message(String message) { + + this.message = message; + return this; + } + + @ApiModelProperty(example = "successful_request", value = "Success status message") + @JsonProperty("message") + @Valid + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + + /** + * Recovery flow confirmation code + **/ + public ResendConfirmationCodeExternalResponse flowConfirmationCode(String flowConfirmationCode) { + + this.flowConfirmationCode = flowConfirmationCode; + return this; + } + + @ApiModelProperty(example = "1234-1234-1234-1234", value = "Recovery flow confirmation code") + @JsonProperty("flowConfirmationCode") + @Valid + public String getFlowConfirmationCode() { + return flowConfirmationCode; + } + public void setFlowConfirmationCode(String flowConfirmationCode) { + this.flowConfirmationCode = flowConfirmationCode; + } + + /** + * Channel that is used to send recovery information + **/ + public ResendConfirmationCodeExternalResponse notificationChannel(String notificationChannel) { + + this.notificationChannel = notificationChannel; + return this; + } + + @ApiModelProperty(example = "EMAIL", value = "Channel that is used to send recovery information") + @JsonProperty("notificationChannel") + @Valid + public String getNotificationChannel() { + return notificationChannel; + } + public void setNotificationChannel(String notificationChannel) { + this.notificationChannel = notificationChannel; + } + + /** + * Confirmation code to confirm the password recovery + **/ + public ResendConfirmationCodeExternalResponse confirmationCode(String confirmationCode) { + + this.confirmationCode = confirmationCode; + return this; + } + + @ApiModelProperty(example = "1234-12345-234-123456", value = "Confirmation code to confirm the password recovery") + @JsonProperty("confirmationCode") + @Valid + public String getConfirmationCode() { + return confirmationCode; + } + public void setConfirmationCode(String confirmationCode) { + this.confirmationCode = confirmationCode; + } + + /** + * Resend code to resend the confirmation code + **/ + public ResendConfirmationCodeExternalResponse resendCode(String resendCode) { + + this.resendCode = resendCode; + return this; + } + + @ApiModelProperty(example = "1234-12345-234-123456", value = "Resend code to resend the confirmation code") + @JsonProperty("resendCode") + @Valid + public String getResendCode() { + return resendCode; + } + public void setResendCode(String resendCode) { + this.resendCode = resendCode; + } + + /** + * Contains available api calls + **/ + public ResendConfirmationCodeExternalResponse links(List links) { + + this.links = links; + return this; + } + + @ApiModelProperty(value = "Contains available api calls") + @JsonProperty("links") + @Valid + public List getLinks() { + return links; + } + public void setLinks(List links) { + this.links = links; + } + + public ResendConfirmationCodeExternalResponse addLinksItem(APICall linksItem) { + if (this.links == null) { + this.links = new ArrayList<>(); + } + this.links.add(linksItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ResendConfirmationCodeExternalResponse resendConfirmationCodeExternalResponse = (ResendConfirmationCodeExternalResponse) o; + return Objects.equals(this.code, resendConfirmationCodeExternalResponse.code) && + Objects.equals(this.message, resendConfirmationCodeExternalResponse.message) && + Objects.equals(this.flowConfirmationCode, resendConfirmationCodeExternalResponse.flowConfirmationCode) && + Objects.equals(this.notificationChannel, resendConfirmationCodeExternalResponse.notificationChannel) && + Objects.equals(this.confirmationCode, resendConfirmationCodeExternalResponse.confirmationCode) && + Objects.equals(this.resendCode, resendConfirmationCodeExternalResponse.resendCode) && + Objects.equals(this.links, resendConfirmationCodeExternalResponse.links); + } + + @Override + public int hashCode() { + return Objects.hash(code, message, flowConfirmationCode, notificationChannel, confirmationCode, resendCode, links); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class ResendConfirmationCodeExternalResponse {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" flowConfirmationCode: ").append(toIndentedString(flowConfirmationCode)).append("\n"); + sb.append(" notificationChannel: ").append(toIndentedString(notificationChannel)).append("\n"); + sb.append(" confirmationCode: ").append(toIndentedString(confirmationCode)).append("\n"); + sb.append(" resendCode: ").append(toIndentedString(resendCode)).append("\n"); + sb.append(" links: ").append(toIndentedString(links)).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.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/ResendConfirmationCodeInternalResponse.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/ResendConfirmationCodeInternalResponse.java new file mode 100644 index 00000000..9aa90690 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/ResendConfirmationCodeInternalResponse.java @@ -0,0 +1,224 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.user.recovery.v2.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.rest.api.user.recovery.v2.model.APICall; +import javax.validation.constraints.*; + +/** + * Object encapsulate the details regarding resend confirmation code + **/ + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; +@ApiModel(description = "Object encapsulate the details regarding resend confirmation code") +public class ResendConfirmationCodeInternalResponse { + + private String code; + private String message; + private String flowConfirmationCode; + private String notificationChannel; + private String resendCode; + private List links = null; + + + /** + * Success status code + **/ + public ResendConfirmationCodeInternalResponse code(String code) { + + this.code = code; + return this; + } + + @ApiModelProperty(example = "PWR-02002", value = "Success status code") + @JsonProperty("code") + @Valid + public String getCode() { + return code; + } + public void setCode(String code) { + this.code = code; + } + + /** + * Success status message + **/ + public ResendConfirmationCodeInternalResponse message(String message) { + + this.message = message; + return this; + } + + @ApiModelProperty(example = "successful_request", value = "Success status message") + @JsonProperty("message") + @Valid + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + + /** + * Recovery flow confirmation code + **/ + public ResendConfirmationCodeInternalResponse flowConfirmationCode(String flowConfirmationCode) { + + this.flowConfirmationCode = flowConfirmationCode; + return this; + } + + @ApiModelProperty(example = "1234-1234-1234-1234", value = "Recovery flow confirmation code") + @JsonProperty("flowConfirmationCode") + @Valid + public String getFlowConfirmationCode() { + return flowConfirmationCode; + } + public void setFlowConfirmationCode(String flowConfirmationCode) { + this.flowConfirmationCode = flowConfirmationCode; + } + + /** + * Channel that is used to send recovery information + **/ + public ResendConfirmationCodeInternalResponse notificationChannel(String notificationChannel) { + + this.notificationChannel = notificationChannel; + return this; + } + + @ApiModelProperty(example = "EMAIL", value = "Channel that is used to send recovery information") + @JsonProperty("notificationChannel") + @Valid + public String getNotificationChannel() { + return notificationChannel; + } + public void setNotificationChannel(String notificationChannel) { + this.notificationChannel = notificationChannel; + } + + /** + * Resend code to resend the confirmation code + **/ + public ResendConfirmationCodeInternalResponse resendCode(String resendCode) { + + this.resendCode = resendCode; + return this; + } + + @ApiModelProperty(example = "1234-12345-234-123456", value = "Resend code to resend the confirmation code") + @JsonProperty("resendCode") + @Valid + public String getResendCode() { + return resendCode; + } + public void setResendCode(String resendCode) { + this.resendCode = resendCode; + } + + /** + * Contains available api calls + **/ + public ResendConfirmationCodeInternalResponse links(List links) { + + this.links = links; + return this; + } + + @ApiModelProperty(value = "Contains available api calls") + @JsonProperty("links") + @Valid + public List getLinks() { + return links; + } + public void setLinks(List links) { + this.links = links; + } + + public ResendConfirmationCodeInternalResponse addLinksItem(APICall linksItem) { + if (this.links == null) { + this.links = new ArrayList<>(); + } + this.links.add(linksItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ResendConfirmationCodeInternalResponse resendConfirmationCodeInternalResponse = (ResendConfirmationCodeInternalResponse) o; + return Objects.equals(this.code, resendConfirmationCodeInternalResponse.code) && + Objects.equals(this.message, resendConfirmationCodeInternalResponse.message) && + Objects.equals(this.flowConfirmationCode, resendConfirmationCodeInternalResponse.flowConfirmationCode) && + Objects.equals(this.notificationChannel, resendConfirmationCodeInternalResponse.notificationChannel) && + Objects.equals(this.resendCode, resendConfirmationCodeInternalResponse.resendCode) && + Objects.equals(this.links, resendConfirmationCodeInternalResponse.links); + } + + @Override + public int hashCode() { + return Objects.hash(code, message, flowConfirmationCode, notificationChannel, resendCode, links); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class ResendConfirmationCodeInternalResponse {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" flowConfirmationCode: ").append(toIndentedString(flowConfirmationCode)).append("\n"); + sb.append(" notificationChannel: ").append(toIndentedString(notificationChannel)).append("\n"); + sb.append(" resendCode: ").append(toIndentedString(resendCode)).append("\n"); + sb.append(" links: ").append(toIndentedString(links)).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.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/ResendConfirmationRequest.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/ResendConfirmationRequest.java new file mode 100644 index 00000000..7c0f43de --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/ResendConfirmationRequest.java @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.user.recovery.v2.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.rest.api.user.recovery.v2.model.Property; +import javax.validation.constraints.*; + +/** + * Request to resend the confirmation code in password recovery + **/ + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; +@ApiModel(description = "Request to resend the confirmation code in password recovery") +public class ResendConfirmationRequest { + + private String resendCode; + private List properties = null; + + + /** + * Resend code returned by the password recovery API + **/ + public ResendConfirmationRequest resendCode(String resendCode) { + + this.resendCode = resendCode; + return this; + } + + @ApiModelProperty(example = "1234-2ws34-1234", value = "Resend code returned by the password recovery API") + @JsonProperty("resendCode") + @Valid + public String getResendCode() { + return resendCode; + } + public void setResendCode(String resendCode) { + this.resendCode = resendCode; + } + + /** + * (OPTIONAL) Additional META properties + **/ + public ResendConfirmationRequest properties(List properties) { + + this.properties = properties; + return this; + } + + @ApiModelProperty(value = "(OPTIONAL) Additional META properties") + @JsonProperty("properties") + @Valid + public List getProperties() { + return properties; + } + public void setProperties(List properties) { + this.properties = properties; + } + + public ResendConfirmationRequest addPropertiesItem(Property propertiesItem) { + if (this.properties == null) { + this.properties = new ArrayList<>(); + } + this.properties.add(propertiesItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ResendConfirmationRequest resendConfirmationRequest = (ResendConfirmationRequest) o; + return Objects.equals(this.resendCode, resendConfirmationRequest.resendCode) && + Objects.equals(this.properties, resendConfirmationRequest.properties); + } + + @Override + public int hashCode() { + return Objects.hash(resendCode, properties); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class ResendConfirmationRequest {\n"); + + sb.append(" resendCode: ").append(toIndentedString(resendCode)).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.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/ResetCodeResponse.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/ResetCodeResponse.java new file mode 100644 index 00000000..075f6eaa --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/ResetCodeResponse.java @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.user.recovery.v2.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.rest.api.user.recovery.v2.model.APICall; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class ResetCodeResponse { + + private String resetCode; + private List links = null; + + + /** + * Password reset code to reset the password + **/ + public ResetCodeResponse resetCode(String resetCode) { + + this.resetCode = resetCode; + return this; + } + + @ApiModelProperty(example = "1234-55678-5668-2345", value = "Password reset code to reset the password") + @JsonProperty("resetCode") + @Valid + public String getResetCode() { + return resetCode; + } + public void setResetCode(String resetCode) { + this.resetCode = resetCode; + } + + /** + * Contains available api calls + **/ + public ResetCodeResponse links(List links) { + + this.links = links; + return this; + } + + @ApiModelProperty(value = "Contains available api calls") + @JsonProperty("links") + @Valid + public List getLinks() { + return links; + } + public void setLinks(List links) { + this.links = links; + } + + public ResetCodeResponse addLinksItem(APICall linksItem) { + if (this.links == null) { + this.links = new ArrayList<>(); + } + this.links.add(linksItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ResetCodeResponse resetCodeResponse = (ResetCodeResponse) o; + return Objects.equals(this.resetCode, resetCodeResponse.resetCode) && + Objects.equals(this.links, resetCodeResponse.links); + } + + @Override + public int hashCode() { + return Objects.hash(resetCode, links); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class ResetCodeResponse {\n"); + + sb.append(" resetCode: ").append(toIndentedString(resetCode)).append("\n"); + sb.append(" links: ").append(toIndentedString(links)).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.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/ResetRequest.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/ResetRequest.java new file mode 100644 index 00000000..54d7e496 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/ResetRequest.java @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.user.recovery.v2.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.rest.api.user.recovery.v2.model.Property; +import javax.validation.constraints.*; + +/** + * Object to reset the password of a user + **/ + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; +@ApiModel(description = "Object to reset the password of a user") +public class ResetRequest { + + private String resetCode; + private String flowConfirmationCode; + private String password; + private List properties = null; + + + /** + * resetCode given by the confim API + **/ + public ResetRequest resetCode(String resetCode) { + + this.resetCode = resetCode; + return this; + } + + @ApiModelProperty(required = true, value = "resetCode given by the confim API") + @JsonProperty("resetCode") + @Valid + @NotNull(message = "Property resetCode cannot be null.") + + public String getResetCode() { + return resetCode; + } + public void setResetCode(String resetCode) { + this.resetCode = resetCode; + } + + /** + * Confirmation code of the recovery flow + **/ + public ResetRequest flowConfirmationCode(String flowConfirmationCode) { + + this.flowConfirmationCode = flowConfirmationCode; + return this; + } + + @ApiModelProperty(value = "Confirmation code of the recovery flow") + @JsonProperty("flowConfirmationCode") + @Valid + public String getFlowConfirmationCode() { + return flowConfirmationCode; + } + public void setFlowConfirmationCode(String flowConfirmationCode) { + this.flowConfirmationCode = flowConfirmationCode; + } + + /** + * New password given by the user + **/ + public ResetRequest password(String password) { + + this.password = password; + return this; + } + + @ApiModelProperty(required = true, value = "New password given by the user") + @JsonProperty("password") + @Valid + @NotNull(message = "Property password cannot be null.") + + public String getPassword() { + return password; + } + public void setPassword(String password) { + this.password = password; + } + + /** + * (OPTIONAL) Additional META properties + **/ + public ResetRequest properties(List properties) { + + this.properties = properties; + return this; + } + + @ApiModelProperty(value = "(OPTIONAL) Additional META properties") + @JsonProperty("properties") + @Valid + public List getProperties() { + return properties; + } + public void setProperties(List properties) { + this.properties = properties; + } + + public ResetRequest addPropertiesItem(Property propertiesItem) { + if (this.properties == null) { + this.properties = new ArrayList<>(); + } + this.properties.add(propertiesItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ResetRequest resetRequest = (ResetRequest) o; + return Objects.equals(this.resetCode, resetRequest.resetCode) && + Objects.equals(this.flowConfirmationCode, resetRequest.flowConfirmationCode) && + Objects.equals(this.password, resetRequest.password) && + Objects.equals(this.properties, resetRequest.properties); + } + + @Override + public int hashCode() { + return Objects.hash(resetCode, flowConfirmationCode, password, properties); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class ResetRequest {\n"); + + sb.append(" resetCode: ").append(toIndentedString(resetCode)).append("\n"); + sb.append(" flowConfirmationCode: ").append(toIndentedString(flowConfirmationCode)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).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.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/RetryErrorResponse.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/RetryErrorResponse.java new file mode 100644 index 00000000..32a1ebd2 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/RetryErrorResponse.java @@ -0,0 +1,221 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.user.recovery.v2.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.rest.api.user.recovery.v2.model.APICall; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class RetryErrorResponse { + + private String code; + private String message; + private String description; + private String traceId; + private String resetCode; + private List links = null; + + + /** + * Error code corresponding to the error + **/ + public RetryErrorResponse code(String code) { + + this.code = code; + return this; + } + + @ApiModelProperty(example = "PWR-10004", value = "Error code corresponding to the error") + @JsonProperty("code") + @Valid + public String getCode() { + return code; + } + public void setCode(String code) { + this.code = code; + } + + /** + * Error message + **/ + public RetryErrorResponse message(String message) { + + this.message = message; + return this; + } + + @ApiModelProperty(example = "Retry", value = "Error message") + @JsonProperty("message") + @Valid + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + + /** + * Error description + **/ + public RetryErrorResponse description(String description) { + + this.description = description; + return this; + } + + @ApiModelProperty(example = "Password policy violation", value = "Error description") + @JsonProperty("description") + @Valid + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + + /** + * Some Correlation for Error Instance + **/ + public RetryErrorResponse traceId(String traceId) { + + this.traceId = traceId; + return this; + } + + @ApiModelProperty(example = "2345dfgh678h789bhjk", value = "Some Correlation for Error Instance") + @JsonProperty("traceId") + @Valid + public String getTraceId() { + return traceId; + } + public void setTraceId(String traceId) { + this.traceId = traceId; + } + + /** + * Password reset code used in the request + **/ + public RetryErrorResponse resetCode(String resetCode) { + + this.resetCode = resetCode; + return this; + } + + @ApiModelProperty(example = "1234-34567-3456-2345678", value = "Password reset code used in the request") + @JsonProperty("resetCode") + @Valid + public String getResetCode() { + return resetCode; + } + public void setResetCode(String resetCode) { + this.resetCode = resetCode; + } + + /** + * Contains available api calls + **/ + public RetryErrorResponse links(List links) { + + this.links = links; + return this; + } + + @ApiModelProperty(value = "Contains available api calls") + @JsonProperty("links") + @Valid + public List getLinks() { + return links; + } + public void setLinks(List links) { + this.links = links; + } + + public RetryErrorResponse addLinksItem(APICall linksItem) { + if (this.links == null) { + this.links = new ArrayList<>(); + } + this.links.add(linksItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RetryErrorResponse retryErrorResponse = (RetryErrorResponse) o; + return Objects.equals(this.code, retryErrorResponse.code) && + Objects.equals(this.message, retryErrorResponse.message) && + Objects.equals(this.description, retryErrorResponse.description) && + Objects.equals(this.traceId, retryErrorResponse.traceId) && + Objects.equals(this.resetCode, retryErrorResponse.resetCode) && + Objects.equals(this.links, retryErrorResponse.links); + } + + @Override + public int hashCode() { + return Objects.hash(code, message, description, traceId, resetCode, links); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class RetryErrorResponse {\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(" resetCode: ").append(toIndentedString(resetCode)).append("\n"); + sb.append(" links: ").append(toIndentedString(links)).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.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/UserClaim.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/UserClaim.java new file mode 100644 index 00000000..7d39da7d --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/UserClaim.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.user.recovery.v2.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.*; + +/** + * Object that holds a user claim and the corresponding value + **/ + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; +@ApiModel(description = "Object that holds a user claim and the corresponding value") +public class UserClaim { + + private String uri; + private String value; + + /** + * Claim uri + **/ + public UserClaim uri(String uri) { + + this.uri = uri; + return this; + } + + @ApiModelProperty(example = "http://wso2.org/claims/givenname", value = "Claim uri") + @JsonProperty("uri") + @Valid + public String getUri() { + return uri; + } + public void setUri(String uri) { + this.uri = uri; + } + + /** + * Value for the claim + **/ + public UserClaim value(String value) { + + this.value = value; + return this; + } + + @ApiModelProperty(example = "user1", value = "Value for the claim") + @JsonProperty("value") + @Valid + public String getValue() { + return value; + } + public void setValue(String value) { + this.value = value; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UserClaim userClaim = (UserClaim) o; + return Objects.equals(this.uri, userClaim.uri) && + Objects.equals(this.value, userClaim.value); + } + + @Override + public int hashCode() { + return Objects.hash(uri, value); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class UserClaim {\n"); + + sb.append(" uri: ").append(toIndentedString(uri)).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.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/UsernameRecoveryNotifyResponse.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/UsernameRecoveryNotifyResponse.java new file mode 100644 index 00000000..1332d950 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/gen/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/model/UsernameRecoveryNotifyResponse.java @@ -0,0 +1,176 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.user.recovery.v2.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.*; + +/** + * API response for successful username recovery + **/ + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; +@ApiModel(description = "API response for successful username recovery") +public class UsernameRecoveryNotifyResponse { + + private String code; + private String message; + private String notificationChannel; + private String username; + + /** + * Success status code + **/ + public UsernameRecoveryNotifyResponse code(String code) { + + this.code = code; + return this; + } + + @ApiModelProperty(example = "UNR-02001", required = true, value = "Success status code") + @JsonProperty("code") + @Valid + @NotNull(message = "Property code cannot be null.") + + public String getCode() { + return code; + } + public void setCode(String code) { + this.code = code; + } + + /** + * Success status message + **/ + public UsernameRecoveryNotifyResponse message(String message) { + + this.message = message; + return this; + } + + @ApiModelProperty(example = "successful_request", required = true, value = "Success status message") + @JsonProperty("message") + @Valid + @NotNull(message = "Property message cannot be null.") + + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + + /** + * Channel which the recovery information is sent to the user + **/ + public UsernameRecoveryNotifyResponse notificationChannel(String notificationChannel) { + + this.notificationChannel = notificationChannel; + return this; + } + + @ApiModelProperty(example = "EXTERNAL", required = true, value = "Channel which the recovery information is sent to the user") + @JsonProperty("notificationChannel") + @Valid + @NotNull(message = "Property notificationChannel cannot be null.") + + public String getNotificationChannel() { + return notificationChannel; + } + public void setNotificationChannel(String notificationChannel) { + this.notificationChannel = notificationChannel; + } + + /** + * - Username of the user - Username will be returned _ONLY IF_ the notification channel is `EXTERNAL` + **/ + public UsernameRecoveryNotifyResponse username(String username) { + + this.username = username; + return this; + } + + @ApiModelProperty(example = "user1", required = true, value = "- Username of the user - Username will be returned _ONLY IF_ the notification channel is `EXTERNAL` ") + @JsonProperty("username") + @Valid + @NotNull(message = "Property username cannot be null.") + + public String getUsername() { + return username; + } + public void setUsername(String username) { + this.username = username; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UsernameRecoveryNotifyResponse usernameRecoveryNotifyResponse = (UsernameRecoveryNotifyResponse) o; + return Objects.equals(this.code, usernameRecoveryNotifyResponse.code) && + Objects.equals(this.message, usernameRecoveryNotifyResponse.message) && + Objects.equals(this.notificationChannel, usernameRecoveryNotifyResponse.notificationChannel) && + Objects.equals(this.username, usernameRecoveryNotifyResponse.username); + } + + @Override + public int hashCode() { + return Objects.hash(code, message, notificationChannel, username); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class UsernameRecoveryNotifyResponse {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" notificationChannel: ").append(toIndentedString(notificationChannel)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).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.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/impl/RecoveryApiServiceImpl.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/impl/RecoveryApiServiceImpl.java new file mode 100644 index 00000000..b49ed427 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/impl/RecoveryApiServiceImpl.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.user.recovery.v2.impl; + +import org.springframework.beans.factory.annotation.Autowired; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.RecoveryApiService; + +import org.wso2.carbon.identity.rest.api.user.recovery.v2.impl.core.PasswordRecoveryService; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.impl.core.UsernameRecoveryService; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.ConfirmRequest; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.InitRequest; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.RecoveryRequest; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.ResendConfirmationRequest; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.ResetRequest; + +import javax.ws.rs.core.Response; + +/** + * Implementation of RecoveryApi Service. + */ +public class RecoveryApiServiceImpl implements RecoveryApiService { + + @Autowired + private UsernameRecoveryService usernameRecoveryService; + + @Autowired + private PasswordRecoveryService passwordRecoveryService; + + @Override + public Response confirmRecovery(ConfirmRequest confirmRequest) { + + return passwordRecoveryService.confirmRecovery(confirmRequest); + } + + @Override + public Response initiatePasswordRecovery(InitRequest initRequest) { + + return passwordRecoveryService.initiatePasswordRecovery(initRequest); + } + + @Override + public Response initiateUsernameRecovery(InitRequest initRequest) { + + return usernameRecoveryService.initiateUsernameRecovery(initRequest); + } + + @Override + public Response recoverPassword(RecoveryRequest recoveryRequest) { + + return passwordRecoveryService.recoverPassword(recoveryRequest); + } + + @Override + public Response recoverUsername(RecoveryRequest recoveryRequest) { + + return usernameRecoveryService.recoverUsername(recoveryRequest); + } + + @Override + public Response resendConfirmation(ResendConfirmationRequest resendConfirmationRequest) { + + return passwordRecoveryService.resendConfirmation(resendConfirmationRequest); + } + + @Override + public Response resetPassword(ResetRequest resetRequest) { + + return passwordRecoveryService.resetPassword(resetRequest); + } +} diff --git a/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/impl/core/APICalls.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/impl/core/APICalls.java new file mode 100644 index 00000000..109005ca --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/impl/core/APICalls.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.user.recovery.v2.impl.core; + +/** + * Enum contains the recovery api names and the corresponding urls. + */ +public enum APICalls { + + INITIATE_USERNAME_RECOVERY_API("POST", "initiate_username_recovery", + "/recovery/username/init"), + INITIATE_PASSWORD_RECOVERY_API("POST", "initiate_password_recovery", + "/recovery/password/init"), + RECOVER_USERNAME_API("POST", "recover_username", + "/recovery/username/recover"), + RECOVER_PASSWORD_API("POST", "recover_password", + "/recovery/password/recover"), + CONFIRM_PASSWORD_RECOVERY_API("POST", "confirm_password_recovery", + "/recovery/password/confirm"), + RESET_PASSWORD_API("POST", "reset_password", + "/recovery/password/reset"), + RESEND_CONFIRMATION_API("POST", "resend_confirmation", + "/recovery/password/resend"), + RECOVER_WITH_SECURITY_QUESTIONS_API("GET", "security_questions_api", + "/security-question?username=%s"); + + /** + * Name of the API. + */ + private final String apiName; + + /** + * Url of the API. + */ + private final String apiUrl; + + /** + * Http method call. + */ + private String type; + + APICalls(String type, String apiName, String apiUrl) { + + this.type = type; + this.apiName = apiName; + this.apiUrl = apiUrl; + } + + /** + * Get http method type. + * + * @return Get http method type + */ + public String getType() { + return type; + } + + /** + * Get the url of the API. + * + * @return API url + */ + public String getApiUrl() { + + return apiUrl; + } +} diff --git a/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/impl/core/Constants.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/impl/core/Constants.java new file mode 100644 index 00000000..dde101bf --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/impl/core/Constants.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.user.recovery.v2.impl.core; + +import static org.wso2.carbon.identity.api.user.common.Constants.USER_API_PATH_COMPONENT; + +/** + * Constants for the recovery endpoint. + */ +public class Constants { + + public static final String SERVER_ERROR = "Error occurred in the server while performing the task."; + public static final String DEFAULT_RESPONSE_CONTENT_TYPE = "application/json"; + public static final String HEADER_CONTENT_TYPE = "Content-Type"; + + // Default error messages. + public static final String STATUS_FORBIDDEN_MESSAGE_DEFAULT = "Forbidden"; + public static final String STATUS_NOT_FOUND_MESSAGE_DEFAULT = "Not Found"; + public static final String STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT = "Internal server error"; + public static final String STATUS_METHOD_NOT_ACCEPTED_MESSAGE_DEFAULT = "Not Accepted"; + public static final String STATUS_CONFLICT_MESSAGE_DEFAULT = "Conflict"; + public static final String STATUS_PRECONDITION_FAILED_MESSAGE_DEFAULT = "Precondition Failed"; + public static final String STATUS_INTERNAL_SERVER_ERROR_DESCRIPTION_DEFAULT = + "The server encountered an internal error. Please contact administrator."; + + // Recovery type. + public static final String RECOVERY_WITH_NOTIFICATIONS = "recoverWithNotifications"; + public static final String RECOVER_WITH_CHALLENGE_QUESTIONS = "recoverWithChallengeQuestions"; + + public static final String ACCOUNT_RECOVERY_ENDPOINT_BASEPATH = USER_API_PATH_COMPONENT + "/v2"; + public static final String CHALLENGE_QUESTIONS_ENDPOINT_BASEPATH = "identity/recovery/v0.9"; + + /** + * Relation states for the APIs. + */ + public static class RelationStates { + + public static final String NEXT_REL = "next"; + public static final String RESEND_REL = "resend"; + } +} diff --git a/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/impl/core/PasswordRecoveryService.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/impl/core/PasswordRecoveryService.java new file mode 100644 index 00000000..31d01193 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/impl/core/PasswordRecoveryService.java @@ -0,0 +1,454 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.user.recovery.v2.impl.core; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.identity.api.user.common.Util; +import org.wso2.carbon.identity.api.user.recovery.commons.UserAccountRecoveryServiceDataHolder; +import org.wso2.carbon.identity.governance.service.notification.NotificationChannels; +import org.wso2.carbon.identity.recovery.IdentityRecoveryConstants; +import org.wso2.carbon.identity.recovery.IdentityRecoveryException; +import org.wso2.carbon.identity.recovery.dto.PasswordRecoverDTO; +import org.wso2.carbon.identity.recovery.dto.PasswordResetCodeDTO; +import org.wso2.carbon.identity.recovery.dto.RecoveryChannelInfoDTO; +import org.wso2.carbon.identity.recovery.dto.RecoveryInformationDTO; +import org.wso2.carbon.identity.recovery.dto.ResendConfirmationDTO; +import org.wso2.carbon.identity.recovery.dto.SuccessfulPasswordResetDTO; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.impl.core.utils.RecoveryUtil; + +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.APICall; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.AccountRecoveryType; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.ConfirmRequest; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.InitRequest; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.PasswordRecoveryExternalNotifyResponse; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.PasswordRecoveryInternalNotifyResponse; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.PasswordResetResponse; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.RecoveryChannel; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.RecoveryChannelInformation; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.RecoveryRequest; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.ResendConfirmationCodeExternalResponse; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.ResendConfirmationCodeInternalResponse; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.ResendConfirmationRequest; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.ResetCodeResponse; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.ResetRequest; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import javax.ws.rs.core.Response; + +/** + * Call internal OSGI services to perform password recovery. + */ +public class PasswordRecoveryService { + + private static final Log LOG = LogFactory.getLog(PasswordRecoveryService.class.getName()); + + /** + * Initiate Password Recovery from POST. + * + * @param initRequest {@link InitRequest} object which holds the information in the account recovery + * request + * @return Response + */ + public Response initiatePasswordRecovery(InitRequest initRequest) { + + if (initRequest == null) { + return Response.status(Response.Status.BAD_REQUEST).build(); + } + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + Map userClaims = RecoveryUtil.buildUserClaimsMap(initRequest.getClaims()); + try { + // Get password recovery notification information. + RecoveryInformationDTO recoveryInformationDTO = + UserAccountRecoveryServiceDataHolder.getPasswordRecoveryManager().initiate(userClaims, tenantDomain, + RecoveryUtil.buildPropertiesMap(initRequest.getProperties())); + return Response.ok().entity(buildPasswordRecoveryInitResponse(tenantDomain, recoveryInformationDTO)) + .build(); + } catch (IdentityRecoveryException e) { + throw RecoveryUtil.handleIdentityRecoveryException(e, tenantDomain, + IdentityRecoveryConstants.PASSWORD_RECOVERY_SCENARIO, Util.getCorrelation()); + } + } + + /** + * Send the recovery notifications to the user via user preferred channel given by the channelId param. + * + * @param recoveryRequest {@link RecoveryRequest} Object which holds the recovery information in the + * password recovery request + * @return Response + */ + public Response recoverPassword(RecoveryRequest recoveryRequest) { + + if (recoveryRequest == null) { + return Response.status(Response.Status.BAD_REQUEST).build(); + } + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + String recoveryId = recoveryRequest.getRecoveryCode(); + String channelId = recoveryRequest.getChannelId(); + try { + PasswordRecoverDTO passwordRecoverDTO = UserAccountRecoveryServiceDataHolder.getPasswordRecoveryManager() + .notify(recoveryId, channelId, tenantDomain, + RecoveryUtil.buildPropertiesMap(recoveryRequest.getProperties())); + if (passwordRecoverDTO == null) { + if (LOG.isDebugEnabled()) { + String message = String + .format("No password recovery data object for recovery code : %s", recoveryId); + LOG.debug(message); + } + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } + return buildPasswordRecoveryResponse(tenantDomain, passwordRecoverDTO.getNotificationChannel(), + passwordRecoverDTO); + } catch (IdentityRecoveryException e) { + throw RecoveryUtil.handleIdentityRecoveryException(e, tenantDomain, + IdentityRecoveryConstants.PASSWORD_RECOVERY_SCENARIO, Util.getCorrelation()); + } + } + + /** + * Validate the recovery code given for verify password reset. + * + * @param confirmRequest {@link ConfirmRequest}Confirmation code object received for password recovery + * @return Response + */ + public Response confirmRecovery(ConfirmRequest confirmRequest) { + + if (confirmRequest == null) { + return Response.status(Response.Status.BAD_REQUEST).build(); + } + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + try { + PasswordResetCodeDTO passwordResetCodeDTO = + UserAccountRecoveryServiceDataHolder.getPasswordRecoveryManager() + .confirm(confirmRequest.getOtp(), confirmRequest.getConfirmationCode(), tenantDomain, + RecoveryUtil.buildPropertiesMap(confirmRequest.getProperties())); + return Response.ok().entity(buildResetCodeResponse(tenantDomain, passwordResetCodeDTO)).build(); + } catch (IdentityRecoveryException e) { + throw RecoveryUtil.handleIdentityRecoveryException(e, tenantDomain, + IdentityRecoveryConstants.PASSWORD_RECOVERY_SCENARIO, Util.getCorrelation()); + } + } + + /** + * Update the password of the user with the new given password. + * + * @param resetRequest {@link ResetRequest} Object which holds the password reset code and password reset + * information + * @return Response + */ + public Response resetPassword(ResetRequest resetRequest) { + + if (resetRequest == null) { + return Response.status(Response.Status.BAD_REQUEST).build(); + } + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + char[] password = resetRequest.getPassword().toCharArray(); + try { + SuccessfulPasswordResetDTO successfulPasswordResetDTO = + UserAccountRecoveryServiceDataHolder.getPasswordRecoveryManager() + .reset(resetRequest.getResetCode(), resetRequest.getFlowConfirmationCode(), password, + RecoveryUtil.buildPropertiesMap(resetRequest.getProperties())); + return Response.ok().entity(buildPasswordResetResponse(successfulPasswordResetDTO)).build(); + } catch (IdentityRecoveryException e) { + // Send the reset code again for a retry attempt. + throw RecoveryUtil.handleIdentityRecoveryException(e, tenantDomain, + IdentityRecoveryConstants.PASSWORD_RECOVERY_SCENARIO, resetRequest.getResetCode(), + Util.getCorrelation()); + } + } + + /** + * Resend the recovery confirmation code to the user. + * + * @param resendConfirmationRequest ResendConfirmationRequest {@link ResendConfirmationRequest} object + * which wraps the resend request + * @return Response + */ + public Response resendConfirmation(ResendConfirmationRequest resendConfirmationRequest) { + + if (resendConfirmationRequest == null) { + return Response.status(Response.Status.BAD_REQUEST).build(); + } + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + String resendCode = resendConfirmationRequest.getResendCode(); + Map properties = RecoveryUtil.buildPropertiesMap(resendConfirmationRequest.getProperties()); + try { + ResendConfirmationDTO resendConfirmationDTO = + UserAccountRecoveryServiceDataHolder.getPasswordRecoveryManager() + .resend(tenantDomain, resendCode, properties); + if (resendConfirmationDTO == null) { + if (LOG.isDebugEnabled()) { + LOG.debug("No ResendConfirmationDTO data for resend code :" + resendCode); + } + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } + return buildResendConfirmationResponse(tenantDomain, resendConfirmationDTO); + } catch (IdentityRecoveryException e) { + throw RecoveryUtil.handleIdentityRecoveryException(e, tenantDomain, + IdentityRecoveryConstants.PASSWORD_RECOVERY_SCENARIO, Util.getCorrelation()); + } + } + + /** + * Build Resend confirmation code response according to the notification channel. + * + * @param tenantDomain Tenant domain in the request. + * @param resendConfirmationDTO ResendConfirmationDTO + * @return Response + */ + private Response buildResendConfirmationResponse(String tenantDomain, + ResendConfirmationDTO resendConfirmationDTO) { + + ArrayList apiCallsArrayList = new ArrayList<>(); + // Add confirm API call information. + apiCallsArrayList.add(RecoveryUtil.buildApiCall(APICalls.CONFIRM_PASSWORD_RECOVERY_API.getType(), + Constants.RelationStates.NEXT_REL, RecoveryUtil + .buildURIForBody(tenantDomain, APICalls.CONFIRM_PASSWORD_RECOVERY_API.getApiUrl(), + Constants.ACCOUNT_RECOVERY_ENDPOINT_BASEPATH), null)); + // Add resend confirmation code API call information. + apiCallsArrayList.add(RecoveryUtil.buildApiCall(APICalls.RESEND_CONFIRMATION_API.getType(), + Constants.RelationStates.RESEND_REL, RecoveryUtil + .buildURIForBody(tenantDomain, APICalls.RESEND_CONFIRMATION_API.getApiUrl(), + Constants.ACCOUNT_RECOVERY_ENDPOINT_BASEPATH), null)); + if (NotificationChannels.EXTERNAL_CHANNEL.getChannelType() + .equals(resendConfirmationDTO.getNotificationChannel())) { + ResendConfirmationCodeExternalResponse resendConfirmationCodeExternalResponse = + new ResendConfirmationCodeExternalResponse(); + resendConfirmationCodeExternalResponse.setCode(resendConfirmationDTO.getSuccessCode()); + resendConfirmationCodeExternalResponse.setMessage(resendConfirmationDTO.getSuccessMessage()); + resendConfirmationCodeExternalResponse.setFlowConfirmationCode(resendConfirmationDTO.getRecoveryFlowId()); + resendConfirmationCodeExternalResponse + .setNotificationChannel(resendConfirmationDTO.getNotificationChannel()); + resendConfirmationCodeExternalResponse.setResendCode(resendConfirmationDTO.getResendCode()); + resendConfirmationCodeExternalResponse + .setConfirmationCode(resendConfirmationDTO.getExternalConfirmationCode()); + resendConfirmationCodeExternalResponse.setLinks(apiCallsArrayList); + return Response.ok().entity(resendConfirmationCodeExternalResponse).build(); + } else { + ResendConfirmationCodeInternalResponse resendConfirmationCodeInternalResponse = + new ResendConfirmationCodeInternalResponse(); + resendConfirmationCodeInternalResponse.setCode(resendConfirmationDTO.getSuccessCode()); + resendConfirmationCodeInternalResponse.setMessage(resendConfirmationDTO.getSuccessMessage()); + resendConfirmationCodeInternalResponse.setFlowConfirmationCode(resendConfirmationDTO.getRecoveryFlowId()); + resendConfirmationCodeInternalResponse + .setNotificationChannel(resendConfirmationDTO.getNotificationChannel()); + resendConfirmationCodeInternalResponse.setResendCode(resendConfirmationDTO.getResendCode()); + resendConfirmationCodeInternalResponse.setLinks(apiCallsArrayList); + return Response.accepted().entity(resendConfirmationCodeInternalResponse).build(); + } + } + + /** + * Build successful response for successful password update. + * + * @param successfulPasswordResetDTO SuccessfulPasswordResetDTO object + * @return PasswordResetResponse + */ + private PasswordResetResponse buildPasswordResetResponse( + SuccessfulPasswordResetDTO successfulPasswordResetDTO) { + + PasswordResetResponse passwordResetResponseDTO = new PasswordResetResponse(); + passwordResetResponseDTO.setCode(successfulPasswordResetDTO.getSuccessCode()); + passwordResetResponseDTO.setMessage(successfulPasswordResetDTO.getMessage()); + return passwordResetResponseDTO; + } + + /** + * Build the ResetCodeResponse for successful confirmation code validation. + * + * @param tenantDomain Tenant Domain + * @param passwordResetCodeDTO {@link PasswordResetCodeDTO}PasswordResetCodeDTO + * @return ResetCodeResponseDTO {@link ResetCodeResponse}object with a password reset code + */ + private ResetCodeResponse buildResetCodeResponse(String tenantDomain, + PasswordResetCodeDTO passwordResetCodeDTO) { + + // Build next API calls list. + ArrayList apiCallsArrayList = new ArrayList<>(); + apiCallsArrayList.add(RecoveryUtil + .buildApiCall(APICalls.RESET_PASSWORD_API.getType(), Constants.RelationStates.NEXT_REL, + RecoveryUtil.buildURIForBody(tenantDomain, APICalls.RESET_PASSWORD_API.getApiUrl(), + Constants.ACCOUNT_RECOVERY_ENDPOINT_BASEPATH), null)); + ResetCodeResponse resetCodeResponseDTO = new ResetCodeResponse(); + resetCodeResponseDTO.setResetCode(passwordResetCodeDTO.getPasswordResetCode()); + resetCodeResponseDTO.setLinks(apiCallsArrayList); + return resetCodeResponseDTO; + } + + /** + * Build the successful response according to the notification channel. + * + * @param tenantDomain Tenant domain + * @param notificationChannel Notification channel + * @param passwordRecoverDTO {@link PasswordRecoverDTO} PasswordRecoverDTO + * @return Response + */ + private Response buildPasswordRecoveryResponse(String tenantDomain, String notificationChannel, + PasswordRecoverDTO passwordRecoverDTO) { + + // Build next API calls. + ArrayList apiCallsArrayList = new ArrayList<>(); + apiCallsArrayList.add(RecoveryUtil.buildApiCall(APICalls.CONFIRM_PASSWORD_RECOVERY_API.getType(), + Constants.RelationStates.NEXT_REL, RecoveryUtil + .buildURIForBody(tenantDomain, APICalls.CONFIRM_PASSWORD_RECOVERY_API.getApiUrl(), + Constants.ACCOUNT_RECOVERY_ENDPOINT_BASEPATH), null)); + // Add resend confirmation code API call information. + apiCallsArrayList.add(RecoveryUtil.buildApiCall(APICalls.RESEND_CONFIRMATION_API.getType(), + Constants.RelationStates.RESEND_REL, RecoveryUtil + .buildURIForBody(tenantDomain, APICalls.RESEND_CONFIRMATION_API.getApiUrl(), + Constants.ACCOUNT_RECOVERY_ENDPOINT_BASEPATH), null)); + if (NotificationChannels.EXTERNAL_CHANNEL.getChannelType().equals(notificationChannel)) { + return Response.ok() + .entity(buildPasswordRecoveryExternalResponse(passwordRecoverDTO, apiCallsArrayList)).build(); + } else { + return Response.accepted() + .entity(buildPasswordRecoveryInternalResponse(passwordRecoverDTO, apiCallsArrayList)).build(); + } + } + + /** + * Build PasswordRecoveryExternalNotifyResponse for successful password recovery. + * + * @param passwordRecoverDTO {@link PasswordRecoverDTO}PasswordRecoverDTO object + * @param apiCallsArrayList List of available API calls + * @return {@link PasswordRecoveryExternalNotifyResponse} Password recovery external notify response + */ + private PasswordRecoveryExternalNotifyResponse buildPasswordRecoveryExternalResponse( + PasswordRecoverDTO passwordRecoverDTO, ArrayList apiCallsArrayList) { + + PasswordRecoveryExternalNotifyResponse passwordRecoveryResponse = + new PasswordRecoveryExternalNotifyResponse(); + passwordRecoveryResponse.setCode(passwordRecoverDTO.getCode()); + passwordRecoveryResponse.setMessage(passwordRecoverDTO.getMessage()); + passwordRecoveryResponse.setFlowConfirmationCode(passwordRecoverDTO.getRecoveryFlowId()); + passwordRecoveryResponse.setNotificationChannel(passwordRecoverDTO.getNotificationChannel()); + passwordRecoveryResponse.setConfirmationCode(passwordRecoverDTO.getConfirmationCode()); + passwordRecoveryResponse.setResendCode(passwordRecoverDTO.getResendCode()); + passwordRecoveryResponse.setLinks(apiCallsArrayList); + return passwordRecoveryResponse; + } + + /** + * Build PasswordRecoveryInternalNotifyResponse for successful password recovery. + * + * @param passwordRecoverDTO {@link PasswordRecoverDTO}PasswordRecoverDTO object + * @param apiCallsArrayList List of available API calls + * @return {@link PasswordRecoveryInternalNotifyResponse} + */ + private PasswordRecoveryInternalNotifyResponse buildPasswordRecoveryInternalResponse( + PasswordRecoverDTO passwordRecoverDTO, ArrayList apiCallsArrayList) { + + PasswordRecoveryInternalNotifyResponse passwordRecoveryResponse = + new PasswordRecoveryInternalNotifyResponse(); + passwordRecoveryResponse.setCode(passwordRecoverDTO.getCode()); + passwordRecoveryResponse.setMessage(passwordRecoverDTO.getMessage()); + passwordRecoveryResponse.setFlowConfirmationCode(passwordRecoverDTO.getRecoveryFlowId()); + passwordRecoveryResponse.setNotificationChannel(passwordRecoverDTO.getNotificationChannel()); + passwordRecoveryResponse.setLinks(apiCallsArrayList); + passwordRecoveryResponse.setResendCode(passwordRecoverDTO.getResendCode()); + return passwordRecoveryResponse; + } + + /** + * Build recovery information for recover with notifications. + * + * @param recoveryType Recovery type + * @param recoveryFlowId Recovery flow id + * @param recoveryChannelInformation RecoveryChannelInformation which wraps recovery channel information + * @param apiCallsArrayList Available API calls + * @return AccountRecoveryType which wraps recovery options available for the user + */ + private AccountRecoveryType buildAccountRecoveryType(String recoveryType, String recoveryFlowId, + RecoveryChannelInformation recoveryChannelInformation, + ArrayList apiCallsArrayList) { + + AccountRecoveryType accountRecoveryType = new AccountRecoveryType(); + accountRecoveryType.setMode(recoveryType); + accountRecoveryType.setFlowConfirmationCode(recoveryFlowId); + accountRecoveryType.setChannelInfo(recoveryChannelInformation); + accountRecoveryType.setLinks(apiCallsArrayList); + return accountRecoveryType; + } + + /** + * Method to build recovery channel information. + * + * @param recoveryInformationDTO RecoveryInformation with recovery information + * @return RecoveryChannelInformation + */ + private RecoveryChannelInformation buildRecoveryChannelInformation( + RecoveryInformationDTO recoveryInformationDTO) { + + RecoveryChannelInfoDTO recoveryChannelInfoDTO = recoveryInformationDTO.getRecoveryChannelInfoDTO(); + List channels = RecoveryUtil + .buildRecoveryChannelInformation(recoveryChannelInfoDTO.getNotificationChannelDTOs()); + RecoveryChannelInformation recoveryChannelInformation = new RecoveryChannelInformation(); + recoveryChannelInformation.setRecoveryCode(recoveryChannelInfoDTO.getRecoveryCode()); + recoveryChannelInformation.setChannels(channels); + return recoveryChannelInformation; + } + + /** + * Build a list of account recovery options available for a successful password recovery. + * + * @param tenantDomain Tenant domain + * @param recoveryInformationDTO RecoveryInformationDTO which wraps the password recovery information + * @return List of {@link AccountRecoveryType} + */ + private List buildPasswordRecoveryInitResponse(String tenantDomain, + RecoveryInformationDTO recoveryInformationDTO) { + + ArrayList accountRecoveryTypes = new ArrayList<>(); + boolean isNotificationBasedRecoveryEnabled = recoveryInformationDTO.isNotificationBasedRecoveryEnabled(); + boolean isQuestionBasedRecoveryAllowedForUser = recoveryInformationDTO.isQuestionBasedRecoveryAllowedForUser(); + if (isNotificationBasedRecoveryEnabled) { + String recoveryFlowId = recoveryInformationDTO.getRecoveryFlowId(); + // Build next API calls list. + ArrayList apiCallsArrayList = new ArrayList<>(); + apiCallsArrayList.add(RecoveryUtil.buildApiCall(APICalls.RECOVER_PASSWORD_API.getType(), + Constants.RelationStates.NEXT_REL, RecoveryUtil + .buildURIForBody(tenantDomain, APICalls.RECOVER_PASSWORD_API.getApiUrl(), + Constants.ACCOUNT_RECOVERY_ENDPOINT_BASEPATH), null)); + RecoveryChannelInformation recoveryChannelInformation = buildRecoveryChannelInformation( + recoveryInformationDTO); + // Build recovery information for recover with notifications. + AccountRecoveryType accountRecoveryType = buildAccountRecoveryType(Constants.RECOVERY_WITH_NOTIFICATIONS, + recoveryFlowId, recoveryChannelInformation, apiCallsArrayList); + accountRecoveryTypes.add(accountRecoveryType); + } + if (isQuestionBasedRecoveryAllowedForUser) { + // Build next API calls list. + ArrayList apiCallsArrayList = new ArrayList<>(); + apiCallsArrayList.add(RecoveryUtil + .buildApiCall(APICalls.RECOVER_WITH_SECURITY_QUESTIONS_API.getType(), + Constants.RelationStates.NEXT_REL, RecoveryUtil.buildURIForBody(tenantDomain, + APICalls.RECOVER_WITH_SECURITY_QUESTIONS_API.getApiUrl(), + Constants.CHALLENGE_QUESTIONS_ENDPOINT_BASEPATH), + recoveryInformationDTO.getUsername())); + // Build recovery information for recover with security questions. + AccountRecoveryType accountRecoveryType = buildAccountRecoveryType( + Constants.RECOVER_WITH_CHALLENGE_QUESTIONS, null, null, apiCallsArrayList); + accountRecoveryTypes.add(accountRecoveryType); + } + return accountRecoveryTypes; + } +} diff --git a/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/impl/core/UsernameRecoveryService.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/impl/core/UsernameRecoveryService.java new file mode 100644 index 00000000..c0e8fc29 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/impl/core/UsernameRecoveryService.java @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.user.recovery.v2.impl.core; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.identity.api.user.common.Util; +import org.wso2.carbon.identity.api.user.recovery.commons.UserAccountRecoveryServiceDataHolder; +import org.wso2.carbon.identity.governance.service.notification.NotificationChannels; +import org.wso2.carbon.identity.recovery.IdentityRecoveryConstants; +import org.wso2.carbon.identity.recovery.IdentityRecoveryException; +import org.wso2.carbon.identity.recovery.dto.RecoveryChannelInfoDTO; +import org.wso2.carbon.identity.recovery.dto.RecoveryInformationDTO; +import org.wso2.carbon.identity.recovery.dto.UsernameRecoverDTO; + +import org.wso2.carbon.identity.rest.api.user.recovery.v2.impl.core.utils.RecoveryUtil; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.APICall; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.AccountRecoveryType; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.InitRequest; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.RecoveryChannel; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.RecoveryChannelInformation; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.RecoveryRequest; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.UsernameRecoveryNotifyResponse; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import javax.ws.rs.core.Response; + +/** + * Call internal OSGI services to perform username recovery. + */ +public class UsernameRecoveryService { + + private static final Log log = LogFactory.getLog(UsernameRecoveryService.class); + + /** + * Initiate userName recovery from POST. + * + * @param initRequest {@link InitRequest} object which holds the information in the account recovery request + * @return Response + */ + public Response initiateUsernameRecovery(InitRequest initRequest) { + + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + Map userClaims = RecoveryUtil.buildUserClaimsMap(initRequest.getClaims()); + try { + // Get username recovery notification information. + RecoveryInformationDTO recoveryInformationDTO = + UserAccountRecoveryServiceDataHolder.getUsernameRecoveryManager().initiate(userClaims, tenantDomain, + RecoveryUtil.buildPropertiesMap(initRequest.getProperties())); + if (recoveryInformationDTO == null) { + // If RecoveryChannelInfoDTO is null throw not found error. + String message = "No recovery information username recovery request"; + log.debug(message); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } + return Response.ok().entity(buildUsernameRecoveryInitResponse(recoveryInformationDTO, tenantDomain)) + .build(); + } catch (IdentityRecoveryException e) { + throw RecoveryUtil.handleIdentityRecoveryException(e, tenantDomain, + IdentityRecoveryConstants.USER_NAME_RECOVERY, Util.getCorrelation()); + } + } + + /** + * Send the recovery notifications to the user via user preferred channel given by the channelId param. + * + * @param recoveryRequest {@link RecoveryRequest} Object which holds the recovery information in the + * username recovery request + * @return Response + */ + public Response recoverUsername(RecoveryRequest recoveryRequest) { + + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + String recoveryId = recoveryRequest.getRecoveryCode(); + String channelId = recoveryRequest.getChannelId(); + try { + UsernameRecoverDTO usernameRecoverDTO = UserAccountRecoveryServiceDataHolder.getUsernameRecoveryManager(). + notify(recoveryId, channelId, tenantDomain, + RecoveryUtil.buildPropertiesMap(recoveryRequest.getProperties())); + if (usernameRecoverDTO == null) { + if (log.isDebugEnabled()) { + String message = String.format("No recovery data object for recovery code : %s", recoveryId); + log.debug(message); + } + return Response.status(Response.Status.OK).build(); + } + return buildUsernameRecoveryResponse(usernameRecoverDTO.getNotificationChannel(), usernameRecoverDTO); + } catch (IdentityRecoveryException e) { + throw RecoveryUtil.handleIdentityRecoveryException(e, tenantDomain, + IdentityRecoveryConstants.USER_NAME_RECOVERY, Util.getCorrelation()); + } + } + + /** + * Build the successful response according to the notification channel. + * + * @param notificationChannel Notification channel + * @param usernameRecoverDTO Object which holds the successful recovery information + * @return Response + */ + private Response buildUsernameRecoveryResponse(String notificationChannel, UsernameRecoverDTO usernameRecoverDTO) { + + UsernameRecoveryNotifyResponse usernameRecoveryNotifyResponse = + new UsernameRecoveryNotifyResponse(); + usernameRecoveryNotifyResponse.setCode(usernameRecoverDTO.getCode()); + usernameRecoveryNotifyResponse.setMessage(usernameRecoverDTO.getMessage()); + usernameRecoveryNotifyResponse.setNotificationChannel(usernameRecoverDTO.getNotificationChannel()); + if (NotificationChannels.EXTERNAL_CHANNEL.getChannelType().equals(notificationChannel)) { + usernameRecoveryNotifyResponse.setUsername(usernameRecoverDTO.getUsername()); + return Response.ok().entity(usernameRecoveryNotifyResponse).build(); + } else { + return Response.accepted().entity(usernameRecoveryNotifyResponse).build(); + } + } + + /** + * Build a list of account recovery options available for successful user identification and channel retrieval. + * + * @param recoveryInformationDTO User recovery information object {@link RecoveryInformationDTO} + * @param tenantDomain Tenant domain + * @return List of {@link AccountRecoveryType} + */ + private List buildUsernameRecoveryInitResponse( + RecoveryInformationDTO recoveryInformationDTO, String tenantDomain) { + + RecoveryChannelInfoDTO recoveryChannelInfoDTO = recoveryInformationDTO.getRecoveryChannelInfoDTO(); + List channels = RecoveryUtil + .buildRecoveryChannelInformation(recoveryChannelInfoDTO.getNotificationChannelDTOs()); + // Build Recovery Channel Information. + RecoveryChannelInformation recoveryChannelInformation = new RecoveryChannelInformation(); + recoveryChannelInformation.setRecoveryCode(recoveryChannelInfoDTO.getRecoveryCode()); + recoveryChannelInformation.setChannels(channels); + // Build next API calls. + ArrayList apiCallsArrayList = new ArrayList<>(); + apiCallsArrayList.add(RecoveryUtil + .buildApiCall(APICalls.RECOVER_USERNAME_API.getType(), Constants.RelationStates.NEXT_REL, + RecoveryUtil.buildURIForBody(tenantDomain, APICalls.RECOVER_USERNAME_API.getApiUrl(), + Constants.ACCOUNT_RECOVERY_ENDPOINT_BASEPATH), null)); + // Build recovery type information. + AccountRecoveryType accountRecoveryType = new AccountRecoveryType(); + accountRecoveryType.setMode(Constants.RECOVERY_WITH_NOTIFICATIONS); + accountRecoveryType.setChannelInfo(recoveryChannelInformation); + accountRecoveryType.setLinks(apiCallsArrayList); + + ArrayList recoveryTypeDTOS = new ArrayList<>(); + recoveryTypeDTOS.add(accountRecoveryType); + return recoveryTypeDTOS; + } +} diff --git a/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/impl/core/exceptions/PreconditionFailedException.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/impl/core/exceptions/PreconditionFailedException.java new file mode 100644 index 00000000..26e6b8e6 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/impl/core/exceptions/PreconditionFailedException.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.user.recovery.v2.impl.core.exceptions; + +import org.wso2.carbon.identity.rest.api.user.recovery.v2.impl.core.Constants; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.RetryErrorResponse; + +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.Response; + +/** + * PreconditionFailedException class. + */ +public class PreconditionFailedException extends WebApplicationException { + + /** + * Exception message. + */ + private String message; + + /** + * Constructs a new exception from the RetryErrorDTO{@link RetryErrorResponse} object. + * + * @param retryErrorResponse RetryErrorResponse{@link RetryErrorResponse} object holding the error code and the + * message + */ + public PreconditionFailedException(RetryErrorResponse retryErrorResponse) { + + super(Response.status(Response.Status.PRECONDITION_FAILED).entity(retryErrorResponse) + .header(Constants.HEADER_CONTENT_TYPE, Constants.DEFAULT_RESPONSE_CONTENT_TYPE).build()); + message = retryErrorResponse.getDescription(); + } + + /** + * Constructs a new exception instance. + */ + public PreconditionFailedException() { + + super(Response.Status.PRECONDITION_FAILED); + } + + /** + * Get exception message. + * + * @return Exception message + */ + @Override + public String getMessage() { + + return message; + } +} diff --git a/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/impl/core/utils/RecoveryUtil.java b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/impl/core/utils/RecoveryUtil.java new file mode 100644 index 00000000..d8c727df --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/java/org/wso2/carbon/identity/rest/api/user/recovery/v2/impl/core/utils/RecoveryUtil.java @@ -0,0 +1,432 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.user.recovery.v2.impl.core.utils; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.wso2.carbon.identity.api.user.common.error.APIError; +import org.wso2.carbon.identity.api.user.common.error.ErrorResponse; +import org.wso2.carbon.identity.core.ServiceURLBuilder; +import org.wso2.carbon.identity.core.URLBuilderException; +import org.wso2.carbon.identity.core.util.IdentityTenantUtil; +import org.wso2.carbon.identity.core.util.IdentityUtil; +import org.wso2.carbon.identity.recovery.IdentityRecoveryClientException; +import org.wso2.carbon.identity.recovery.IdentityRecoveryConstants; +import org.wso2.carbon.identity.recovery.IdentityRecoveryException; +import org.wso2.carbon.identity.recovery.dto.NotificationChannelDTO; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.impl.core.APICalls; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.impl.core.Constants; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.impl.core.exceptions.PreconditionFailedException; + +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.APICall; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.Property; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.RecoveryChannel; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.RetryErrorResponse; +import org.wso2.carbon.identity.rest.api.user.recovery.v2.model.UserClaim; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.Response; + +import static org.wso2.carbon.identity.api.user.common.Constants.TENANT_CONTEXT_PATH_COMPONENT; +import static org.wso2.carbon.identity.application.common.util.IdentityApplicationConstants.Error.UNEXPECTED_SERVER_ERROR; + +/** + * Contains the recovery endpoint utils. + */ +public class RecoveryUtil { + + private static final Log LOG = LogFactory.getLog(RecoveryUtil.class); + + /** + * Converts a list of UserClaim in to a UserClaim array. + * + * @param userClaimsList UserClaims List. + * @return Map of user claims. + */ + public static Map buildUserClaimsMap(List userClaimsList) { + + Map userClaims = new HashMap<>(); + for (UserClaim userClaimModel : userClaimsList) { + userClaims.put(userClaimModel.getUri(), userClaimModel.getValue()); + } + return userClaims; + } + + /** + * Convert the list of Properties in to an array. + * + * @param propertyList List of {@link Property} objects. + * @return Map of properties. + */ + public static Map buildPropertiesMap(List propertyList) { + + Map properties = new HashMap<>(); + if (propertyList == null) { + return properties; + } + for (Property propertyDTO : propertyList) { + properties.put(propertyDTO.getKey(), propertyDTO.getValue()); + } + return properties; + } + + /** + * Build the channel response object list. + * + * @param channels Available notification channels list as objects of {@link NotificationChannelDTO}. + * @return List of RecoveryChannels {@link RecoveryChannel}. + */ + public static List buildRecoveryChannelInformation(NotificationChannelDTO[] channels) { + + List recoveryChannelDTOs = new ArrayList<>(); + if (channels != null) { + // Create a response object and add the details to each object. + for (NotificationChannelDTO channel : channels) { + RecoveryChannel recoveryChannel = new RecoveryChannel(); + recoveryChannel.setId(Integer.toString(channel.getId())); + recoveryChannel.setType(channel.getType()); + recoveryChannel.setValue(channel.getValue()); + if (StringUtils.isNotEmpty(channel.getValue())) { + recoveryChannel.setPreferred(channel.isPreferred()); + } + recoveryChannelDTOs.add(recoveryChannel); + } + } + return recoveryChannelDTOs; + } + + /** + * Build API call information. + * + * @param type Type of the API call. + * @param rel API relation. + * @param apiUrl Url of the API. + * @param data Additional data. + * @return APICall {@link APICall} which encapsulates the API name and the url. + */ + public static APICall buildApiCall(String type, String rel, String apiUrl, String data) { + + if (StringUtils.isNotEmpty(data)) { + apiUrl = String.format(apiUrl, data); + } + APICall apiCall = new APICall(); + apiCall.setType(type); + apiCall.setRel(rel); + apiCall.setHref(apiUrl); + return apiCall; + } + + /** + * Builds URI prepending the user API context with the proxy context path to the endpoint. + * Ex: /t//api/users/ + * + * @param endpoint Relative endpoint path. + * @return Relative URI. + */ + public static String buildURIForBody(String tenantDomain, String endpoint, String baseUrl) { + + String url; + String context = getContext(tenantDomain, endpoint, baseUrl); + + try { + url = ServiceURLBuilder.create().addPath(context).build().getRelativePublicURL(); + } catch (URLBuilderException e) { + String errorDescription = "Server encountered an error while building URL for response body."; + ErrorResponse errorResponse = + new org.wso2.carbon.identity.api.user.common.error.ErrorResponse.Builder() + .withCode(UNEXPECTED_SERVER_ERROR.getCode()) + .withMessage("Error while building response.") + .withDescription(errorDescription) + .build(LOG, e, errorDescription); + + Response.Status status = Response.Status.INTERNAL_SERVER_ERROR; + throw new APIError(status, errorResponse); + } + return url; + } + + /** + * Handle errors with specific http codes. + * + * @param e Identity Recovery Exception. + * @param tenantDomain Tenant domain. + * @param scenario Recovery scenario. + * @param correlationId Correlation Id. + * @return WebApplicationException (NOTE: Returns null when the client error is for no user available or for + * multiple users available. + */ + public static WebApplicationException handleIdentityRecoveryException(IdentityRecoveryException e, + String tenantDomain, String scenario, + String correlationId) { + + return handleIdentityRecoveryException(e, tenantDomain, scenario, StringUtils.EMPTY, correlationId); + } + + /** + * Handle errors with specific http codes. + * + * @param e Identity Recovery Exception. + * @param scenario Recovery scenario. + * @param tenantDomain Tenant domain. + * @param code Recovery code. + * @param correlationId Correlation Id. + * @return WebApplicationException (NOTE: Returns null when the client error is for no user available or for + * multiple users available. + */ + public static WebApplicationException handleIdentityRecoveryException(IdentityRecoveryException e, + String tenantDomain, String scenario, + String code, String correlationId) { + + String errorCode = prependOperationScenarioToErrorCode(e.getErrorCode(), scenario); + String errorDescription = e.getMessage(); + String serverErrorDescription = Constants.STATUS_INTERNAL_SERVER_ERROR_DESCRIPTION_DEFAULT; + String errorMessage = Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT; + Response.Status status = Response.Status.INTERNAL_SERVER_ERROR; + + if (IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_PASSWORD_RECOVERY_WITH_NOTIFICATIONS_NOT_ENABLED. + getCode().equals(e.getErrorCode()) || IdentityRecoveryConstants.ErrorMessages. + ERROR_CODE_USERNAME_RECOVERY_NOT_ENABLED.getCode().equals(e.getErrorCode()) || + IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_DISABLED_ACCOUNT.getCode().equals(e.getErrorCode()) + || IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_LOCKED_ACCOUNT.getCode().equals(e.getErrorCode()) + || IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_PASSWORD_RECOVERY_NOT_ENABLED.getCode().equals( + e.getErrorCode())) { + errorMessage = Constants.STATUS_FORBIDDEN_MESSAGE_DEFAULT; + status = Response.Status.FORBIDDEN; + } else if (IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_USER_TENANT_DOMAIN_MISS_MATCH_WITH_CONTEXT. + getCode().equals(e.getErrorCode())) { + errorMessage = Constants.STATUS_CONFLICT_MESSAGE_DEFAULT; + status = Response.Status.CONFLICT; + } else if (IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_MULTIPLE_MATCHING_USERS.getCode().equals( + e.getErrorCode())) { + // If user notify is not enabled, throw an accepted response. + if (!Boolean.parseBoolean(IdentityUtil + .getProperty(IdentityRecoveryConstants.ConnectorConfig.NOTIFY_USER_EXISTENCE))) { + return new WebApplicationException(Response.accepted().build()); + } + errorMessage = Constants.STATUS_CONFLICT_MESSAGE_DEFAULT; + status = Response.Status.CONFLICT; + } else if (IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_NO_USER_FOUND.getCode().equals(e. + getErrorCode())) { + // If user notify is not enabled, throw an accepted response. + if (!Boolean.parseBoolean(IdentityUtil + .getProperty(IdentityRecoveryConstants.ConnectorConfig.NOTIFY_USER_EXISTENCE))) { + return new WebApplicationException(Response.accepted().build()); + } + errorMessage = Constants.STATUS_NOT_FOUND_MESSAGE_DEFAULT; + status = Response.Status.NOT_FOUND; + } else if (IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_NO_ACCOUNT_RECOVERY_DATA.getCode().equals( + e.getErrorCode()) || IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_NO_VERIFIED_CHANNELS_FOR_USER. + getCode().equals(e.getErrorCode())) { + errorMessage = Constants.STATUS_NOT_FOUND_MESSAGE_DEFAULT; + status = Response.Status.NOT_FOUND; + } else if (IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_INVALID_RECOVERY_CODE.getCode().equals( + e.getErrorCode()) || IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_INVALID_RESEND_CODE.getCode(). + equals(e.getErrorCode()) || IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_EXPIRED_RECOVERY_CODE. + getCode().equals(e.getErrorCode())) { + errorMessage = Constants.STATUS_METHOD_NOT_ACCEPTED_MESSAGE_DEFAULT; + status = Response.Status.NOT_ACCEPTABLE; + } else if (IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_PASSWORD_HISTORY_VIOLATION.getCode().equals( + e.getErrorCode()) || IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_PASSWORD_POLICY_VIOLATION. + getCode().equals(e.getErrorCode())) { + return RecoveryUtil.buildRetryPasswordResetObject(tenantDomain, errorDescription, errorCode, code, + correlationId); + } + + if (e instanceof IdentityRecoveryClientException) { + return buildClientError(errorCode, errorMessage, errorDescription, status); + } + return buildServerError(e, e.getErrorCode(), errorMessage, serverErrorDescription, status); + } + + /** + * Builds API error to be thrown. + * + * @param errorCode Error code. + * @param errorMessage Error message. + * @param errorDescription Error description. + * @param status HTTP status. + * @return APIError object which contains the error description. + */ + private static APIError buildClientError(String errorCode, String errorMessage, String errorDescription, + Response.Status status) { + + ErrorResponse errorResponse = buildErrorResponse(errorCode, errorMessage, errorDescription); + return new APIError(status, errorResponse); + } + + /** + * Builds API error to be thrown for server errors. + * + * @param e Identity Recovery Exception. + * @param errorCode Error code. + * @param errorMessage Error message. + * @param errorDescription Error description. + * @param status HTTP status. + * @return APIError object which contains the error description. + */ + private static APIError buildServerError(IdentityRecoveryException e, String errorCode, String errorMessage, + String errorDescription, Response.Status status) { + + ErrorResponse errorResponse = buildServerErrorResponse(e, errorCode, errorMessage, errorDescription); + return new APIError(status, errorResponse); + } + + /** + * Builds the API context on whether the tenant qualified url is enabled or not. In tenant qualified mode the + * ServiceURLBuilder appends the tenant domain to the URI as a path param automatically. But + * in non tenant qualified mode we need to append the tenant domain to the path manually. + * + * @param endpoint Relative endpoint path. + * @return Context of the API. + */ + private static String getContext(String tenantDomain, String endpoint, String baseUrl) { + + String context; + if (IdentityTenantUtil.isTenantQualifiedUrlsEnabled()) { + context = baseUrl + endpoint; + } else { + context = String.format(TENANT_CONTEXT_PATH_COMPONENT, tenantDomain) + baseUrl + endpoint; + } + return context; + } + + /** + * Builds error response. + * + * @param errorCode Error code. + * @param errorMessage Error message. + * @param errorDescription Error description. + * @return ErrorResponse. + */ + private static ErrorResponse buildErrorResponse(String errorCode, String errorMessage, String errorDescription) { + + return getErrorBuilder(errorCode, errorMessage, errorDescription).build(LOG, errorMessage); + } + + /** + * Builds server error response. + * + * @param e Identity Recovery Exception. + * @param errorCode Error code. + * @param errorMessage Error message. + * @param errorDescription Error description. + * @return ErrorResponse. + */ + private static ErrorResponse buildServerErrorResponse(IdentityRecoveryException e, String errorCode, + String errorMessage, String errorDescription) { + + return getErrorBuilder(errorCode, errorMessage, errorDescription).build(LOG, e, errorMessage); + } + + /** + * Get ErrorResponse Builder + * + * @param errorCode Error code. + * @param errorMessage Error message. + * @param errorDescription Error description. + * @return ErrorResponse.Builder. + */ + private static ErrorResponse.Builder getErrorBuilder(String errorCode, String errorMessage, + String errorDescription) { + + return new ErrorResponse.Builder().withCode(errorCode) + .withMessage(errorMessage) + .withDescription(errorDescription); + } + + /** + * Build the RetryErrorResponse for not valid password scenario. + * + * @param message Error message. + * @param description Error description. + * @param code Error code. + * @param resetCode Password reset code. + * @param correlationId Trace Id. + * @param apiCallsArrayList Available APIs. + * @return RetryErrorResponse. + */ + private static RetryErrorResponse buildRetryErrorResponse(String message, String description, String code, + String resetCode, String correlationId, + ArrayList apiCallsArrayList) { + + RetryErrorResponse retryErrorResponse = new RetryErrorResponse(); + retryErrorResponse.setCode(code); + retryErrorResponse.setMessage(message); + retryErrorResponse.setDescription(description); + retryErrorResponse.setResetCode(resetCode); + retryErrorResponse.setTraceId(correlationId); + retryErrorResponse.setLinks(apiCallsArrayList); + return retryErrorResponse; + } + + /** + * Returns a new PreconditionFailedException. + * + * @param tenantDomain Tenant domain. + * @param description Description of the exception. + * @param code Error code. + * @param resetCode Reset code given to the user by confirmation API. + * @param correlationId Correlation Id. + * @return A new PreconditionFailedException with the specified details as a response. + */ + private static PreconditionFailedException buildRetryPasswordResetObject(String tenantDomain, String description, + String code, String resetCode, + String correlationId) { + + // Build next API calls. + ArrayList apiCallsArrayList = new ArrayList<>(); + apiCallsArrayList.add(RecoveryUtil + .buildApiCall(APICalls.RESET_PASSWORD_API.getType(), Constants.RelationStates.NEXT_REL, + buildURIForBody(tenantDomain, APICalls.RESET_PASSWORD_API.getApiUrl(), + Constants.ACCOUNT_RECOVERY_ENDPOINT_BASEPATH), null)); + RetryErrorResponse retryErrorResponse = buildRetryErrorResponse( + Constants.STATUS_PRECONDITION_FAILED_MESSAGE_DEFAULT, code, description, resetCode, correlationId, + apiCallsArrayList); + LOG.debug(description); + return new PreconditionFailedException(retryErrorResponse); + } + + /** + * Prepend the operation scenario to the existing exception error code. + * (Eg: USR-20045) + * + * @param exceptionErrorCode Existing error code. + * @param scenario Operation scenario. + * @return New error code with the scenario prepended. + */ + private static String prependOperationScenarioToErrorCode(String exceptionErrorCode, String scenario) { + + if (StringUtils.isNotEmpty(exceptionErrorCode)) { + if (exceptionErrorCode.contains(IdentityRecoveryConstants.EXCEPTION_SCENARIO_SEPARATOR)) { + return exceptionErrorCode; + } + if (StringUtils.isNotEmpty(scenario)) { + exceptionErrorCode = + scenario + IdentityRecoveryConstants.EXCEPTION_SCENARIO_SEPARATOR + exceptionErrorCode; + } + } + return exceptionErrorCode; + } +} diff --git a/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/resources/META-INF/cxf/user-recovery-v2-cxf.xml b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/resources/META-INF/cxf/user-recovery-v2-cxf.xml new file mode 100644 index 00000000..aed37b9e --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/resources/META-INF/cxf/user-recovery-v2-cxf.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + diff --git a/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/resources/user.account.recovery.yaml b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/resources/user.account.recovery.yaml new file mode 100644 index 00000000..ae94b991 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.user.recovery/org.wso2.carbon.identity.rest.api.user.recovery.v2/src/main/resources/user.account.recovery.yaml @@ -0,0 +1,1261 @@ +openapi: 3.0.0 +info: + version: "v1-oas3" + title: WSO2 Identity Server User Account Recovery Rest API + description: > + This is the RESTful API for username and password recovery initated by the + user. + contact: + name: WSO2 Identity Server + url: 'https://wso2.com/identity-and-access-management' + email: architecture@wso2.org + license: + name: Apache 2.0 + url: 'http://www.apache.org/licenses/LICENSE-2.0.html' +paths: + /recovery/username/init: + post: + tags: + - Username Recovery + summary: Initiate Username Recovery + operationId: initiateUsernameRecovery + description: > + - This API is used to initiate username recovery by user. The API will + return available recovery information for username recovery with + notifications. + + - Use the returned __recoveryCode__ and the __channelId__ with + __username recover api__ to confirm the the username recovery and to + recieve recovery notifications via the channel specified by the user. + responses: + '200': + description: >- + User is successfully identified for the given claims and returning + available notification channels for the user. + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/AccountRecoveryType' + examples: + response: + value: + - mode: recoverWithNotifications + channelInfo: + recoveryCode: 1234-55678-5668-2345 + channels: + - id: 1 + type: EMAIL + value: wso2***********.com + preferred: true + - id: 2 + type: SMS + value: '**********123' + preferred: false + links: + - rel: next + href: /api/users/v2/recovery/username/recover + type: POST + '400': + description: Bad Request. The request cannot be processed by the server. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + examples: + response: + value: + code: UAR-10001 + message: bad_request + description: bad request + traceId: 23456fghj678vb78 + '403': + description: Username recovery is not enabled. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + examples: + response: + value: + code: UNR-10003 + message: Forbidden + description: Username recovery is not enabled + traceId: 23456fghj678vb78 + '404': + description: >- + No user found for the given set of claims or no recovery channels + are availabe for the user. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + examples: + response: + value: + code: UAR-10002 + message: Not found + description: No user found + traceId: 23456fghj678vb78 + '409': + description: Mutiple users found for the given claims. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + examples: + response: + value: + code: UAR-10008 + message: Conflict + description: Multiple users found for given claims + traceId: 23456fghj678vb78 + '500': + description: Server Error. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + examples: + response: + value: + code: UNR-15001 + message: Internal Error + description: Internal Error + traceId: 23456fghj678vb78 + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/InitRequest' + description: >- + Request to initate username recovery process. The request should + contain the claims to identify the user. User claims are `REQUIRED`. + required: true + /recovery/username/recover: + post: + tags: + - Username Recovery + summary: Get Recovery Information + operationId: recoverUsername + description: > + - This API is used to confirm username recovery and send username + recovery information to the user who matches the recovery code via the + channel specified by the channel Id. + - __NOTE__: If the notification channel is __EXTERNAL__, the API will return the username of the user. + responses: + '200': + description: >- + Username is successfully recovered and the __notification channel__ + is `EXTERNAL`. + content: + application/json: + schema: + $ref: '#/components/schemas/UsernameRecoveryNotifyResponse' + examples: + response: + value: + code: UNR-02002 + message: Username recovery information sent externally + notificationChannel: EXTERNAL + username: PRIMARY/sominda1@carbon.super + '202': + description: Username is successfully recovered. + content: + application/json: + schema: + $ref: '#/components/schemas/UsernameRecoveryNotifyResponse' + examples: + response: + value: + code: UNR-02001 + message: >- + Username recovery information sent via user preferred + notification channel + notificationChannel: EMAIL + '400': + description: Bad Request. Request cannot be processed by the server. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + examples: + response: + value: + code: UNR-10001 + message: bad_request + description: bad request + traceId: 23456fghj678vb78 + '404': + description: Recovery code is not found. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + examples: + response: + value: + code: UNR-10001 + message: not_found + description: recovery code not found + traceId: 23456fghj678vb78 + '406': + description: | + - Recovery code given in the request is not valid or expired. + - Channel id is not valid + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + examples: + response: + value: + code: UNR-10001 + message: not acceptable + description: 'invalid error code : 1234-2345-12345-123456' + traceId: 23456fghj678vb78 + '500': + description: Server Error. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + examples: + response: + value: + code: UNR-15001 + message: Internal Error + description: Internal Error + traceId: 23456fghj678vb78 + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/RecoveryRequest' + description: > + - Request to confirm username recovery and receive recovery + notifications. + + - `recoveryCode` and `channelId` are `REQUIRED`. + + - __NOTE__ `channelId` should always be __larger than 0__. + required: true + /recovery/password/init: + post: + tags: + - Password Recovery + summary: | + Initiate password recovery + operationId: initiatePasswordRecovery + description: > + - This API is used to initiate password recovery by user. The API will + return recovery information for password recovery with challenge + questions and password recovery with notifications. + + - `mode` __recoverWithNotifications__ contains recovery flow confirmation code, available communication channels and a recovery code for password recovery with notifications. + The next API call will be returned in the response. + + - If `password recovery with notifications` is not enabled, the response + will not contain __recoverWithNotifications__ mode. + + - __recoverWithChallengeQuestions__ contains the next API call to begin + the recovery process via challenge questions. + + - If `password recovery with challenge questions` is not enabled, the + response will not contain __recoverWithChallengeQuestions__ mode. + responses: + '200': + description: >- + User is successfully identified for the given claims and returning + available notification channels for the user. + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/AccountRecoveryType' + examples: + response: + value: + - mode: recoverWithNotifications + flowConfirmationCode: 1234-1234-1234-1234 + channelInfo: + recoveryCode: 1234-55678-5668-2345 + channels: + - id: 1 + type: EMAIL + value: wso2***********.com + preferred: false + - id: 2 + type: SMS + value: '**********123' + preferred: true + links: + - rel: next + href: /api/users/v2/recovery/password/recovery + type: POST + - mode: recoverWithChallengeQuestions + links: + - rel: next + href: >- + /t/carbon.super/api/identity/recovery/v0.9/security-question?username=sominda + type: GET + '400': + description: Bad Request. The request cannot be processed by the server. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + examples: + response: + value: + code: UAR-10001 + message: bad_request + description: bad request + traceId: 23456fghj678vb78 + '404': + description: >- + No user found for the given set of claims or no recovery channels + are availabe for the user. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + examples: + response: + value: + code: UAR-10002 + message: Not found + description: No user found + traceId: 23456fghj678vb78 + '409': + description: Mutiple users found for the given claims. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + examples: + response: + value: + code: UAR-10008 + message: Conflict + description: Multiple users found for given claims + traceId: 23456fghj678vb78 + '500': + description: Server Error. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + examples: + response: + value: + code: UAR-15001 + message: Internal Error + description: Internal Error + traceId: 23456fghj678vb78 + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/InitRequest' + description: >- + Request to initate password recovery process. The request should + contain the claims to identify the user. User claims are `REQUIRED`. + required: true + /recovery/password/recover: + post: + tags: + - Password Recovery + summary: | + Get Recovery Information + operationId: recoverPassword + description: > + - This API is used to send recovery information to the user who matches + the recovery code via the channel specified by the channel Id. The API will return the recovery flow confirmation code. + + - NOTE: If the notification channel is EXTERNAL, the API will return a + confirmationCode. + + - Use the returned confimation code with __password recovery confirm + API__ to verify the password recovery process. + + - The API will return the next API call. + responses: + '200': + description: > + - Password recovery initiated via `EXTERNAL` channel. API will + return a `confirmationCode` to confirm password recovery. + + - Use the confirmation code with __password recovery confirm API__ + to confirm the password recovery. + content: + application/json: + schema: + $ref: '#/components/schemas/PasswordRecoveryExternalNotifyResponse' + examples: + response: + value: + code: PWR-02002 + message: Password recovery information sent externally + flowConfirmationCode: 1234-1234-1234-1234 + notificationChannel: EXTERNAL + confirmationCode: 12345-45678-6789098-8765 + resendCode: 12345-45678-6789098-8765 + links: + - rel: next + href: api/users/v2/recovery/password/confirm + type: POST + - rel: resend + href: api/users/v2/recovery/password/resend + type: POST + '202': + description: > + - Password recovery initiated via internal channels. API will send a + `confirmationCode`/`otp` to the channel specified by the user. + + - Use the confirmation code/OTP with __password recovery confirm API__ + to confirm the password recovery. + content: + application/json: + schema: + $ref: '#/components/schemas/PasswordRecoveryInternalNotifyResponse' + examples: + response: + value: + code: PWR-02002 + message: Password recovery information sent externally + flowConfirmationCode: 1234-1234-1234-1234 + notificationChannel: EMAIL + resendCode: 12345-45678-6789098-8765 + links: + - rel: next + href: api/users/v2/recovery/password/confirm + type: POST + - rel: resend + href: api/users/v2/recovery/password/resend + type: POST + '400': + description: Bad Request. Request cannot be processed by the server. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + examples: + response: + value: + code: PWR-10001 + message: bad_request + description: bad request + traceId: 23456fghj678vb78 + '403': + description: Password recovery is not enabled. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + examples: + response: + value: + code: PWR-10004 + message: Forbidden + description: Password recovery is not enabled + traceId: 23456fghj678vb78 + '404': + description: Recovery code is not found. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + examples: + response: + value: + code: PWR-10001 + message: not_found + description: recovery code not found + traceId: 23456fghj678vb78 + '406': + description: | + - Recovery code given in the request is not valid or expired. + - Channel id is not valid + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + examples: + response: + value: + code: PWR-10003 + message: not acceptable + description: 'invalid error code : 1234-2345-12345-123456' + traceId: 23456fghj678vb78 + '500': + description: Server Error. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + examples: + response: + value: + code: PWR-15001 + message: Internal Error + description: Internal Error + traceId: 23456fghj678vb78 + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/RecoveryRequest' + description: | + - Request to receive recovery notifications. + - `recoveryCode` and `channelId` are `REQUIRED`. + - __NOTE__ `channelId` should always be __larger than 0__. + required: true + /recovery/password/resend: + post: + tags: + - Password Recovery + summary: | + Resend password recovery confirmation details + operationId: resendConfirmation + description: > + - This API is used to resend a confirmation code/OTP to the user via a user + preferred channel defined at password recovery. + + - NOTE: The API cannot be used when the notification channel is + external. + + - The API will return the next API calls. + responses: + '200': + description: > + - API will return a new `confirmationCode`. + + - Use the confirmation code with __password recovery confirm API__ + to confirm the password recovery. + content: + application/json: + schema: + $ref: '#/components/schemas/ResendConfirmationCodeExternalResponse' + examples: + response: + value: + code: PWR-02002 + message: successful_request + flowConfirmationCode: 1234-1234-1234-1234 + notificationChannel: EXTERNAL + confirmationCode: 1234-12345-234-123456 + resendCode: 1234-12345-234-123456 + links: + - rel: next + href: api/users/v2/recovery/password/recover + type: POST + - rel: resend + href: api/users/v2/recovery/password/resend + type: POST + '202': + description: > + - API will send a `confirmationCode`/`otp` to the channel specified by the + user. + + - Use the confirmation code/OTP with __password recovery confirm API__ + to confirm the password recovery. + content: + application/json: + schema: + $ref: '#/components/schemas/ResendConfirmationCodeInternalResponse' + examples: + response: + value: + code: PWR-02002 + message: successful_request + flowConfirmationCode: 1234-1234-1234-1234 + notificationChannel: EMAIL + resendCode: 1234-12345-234-123456 + links: + - rel: next + href: api/user/v2/recovery/password/recover + type: POST + - rel: resend + href: api/users/v2/recovery/password/resend + type: POST + '400': + description: Bad Request. Request cannot be processed by the server. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + examples: + response: + value: + code: UAR-10001 + message: bad_request + description: bad request + traceId: 23456fghj678vb78 + '404': + description: Resend code is not found. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + examples: + response: + value: + code: UAR-10001 + message: not_found + description: recovery code not found + traceId: 23456fghj678vb78 + '406': + description: Resend code given in the request is not valid or expired. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + examples: + response: + value: + code: UAR-10003 + message: not acceptable + description: 'invalid error code : 1234-2345-12345-123456' + traceId: 23456fghj678vb78 + '500': + description: Server Error. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + examples: + response: + value: + code: UAR-15001 + message: Internal Error + description: Internal Error + traceId: 23456fghj678vb78 + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ResendConfirmationRequest' + description: > + - Request to resend the `confirmationCode`/`otp` to the user via a user + preferred channel. + + - Can send additional properties. + required: true + /recovery/password/confirm: + post: + tags: + - Password Recovery + summary: | + Confirm password recovery + operationId: confirmRecovery + description: > + - This API is used to validate the __confirmationCode__/__otp__ given at + password recovery. + + - Use the returned __reset code__ with the __password reset API__ to + reset the password. + + - The API will return the next API call. + responses: + '200': + description: | + - Password reset confirmed. + - `resetCode` is returned. + content: + application/json: + schema: + $ref: '#/components/schemas/ResetCodeResponse' + examples: + response: + value: + resetCode: 2806aed9-fe7c-4b47-a91f-0aa897fac9a2 + links: + - rel: next + href: >- + /t/carbon.super/api/users/v2/recovery/password/reset + type: POST + '400': + description: Bad Request. Request cannot be processed by the server. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + examples: + response: + value: + code: PWR-10001 + message: bad_request + description: bad request + traceId: 23456fghj678vb78 + '404': + description: Confirmation code is not found. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + examples: + response: + value: + code: PWR-10001 + message: not_found + description: recovery code not found + traceId: 23456fghj678vb78 + '406': + description: | + Confirmation code given in the request is not valid or expired. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + examples: + response: + value: + code: PWR-10001 + message: not acceptable + description: 'invalid error code : 1234-2345-12345-123456' + traceId: 23456fghj678vb78 + '500': + description: Server Error. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + examples: + response: + value: + code: PWR-15001 + message: Internal Error + description: Internal Error + traceId: 23456fghj678vb78 + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ConfirmRequest' + description: | + - Request to confirm the password recovery. + - `confirmationCode` is `REQUIRED`. + - `otp` is required only for OTP based password recovery. The __flowConfirmationCode__ returned from the password recovery request should be set as the `confirmationCode` for OTP based recovery. + required: true + /recovery/password/reset: + post: + tags: + - Password Recovery + summary: | + Reset password + operationId: resetPassword + description: > + This API is used to reset the password of the user who matches the flowConfirmationCode given by the recover API and the resetCode given by the confirmation API. + responses: + '200': + description: Successful password reset. + content: + application/json: + schema: + $ref: '#/components/schemas/PasswordResetResponse' + examples: + response: + value: + code: PWR-02005 + message: Successful password reset + '400': + description: Bad Request. Request cannot be processed by the server. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + examples: + response: + value: + code: PWR-10001 + message: bad_request + description: bad request + traceId: 23456fghj678vb78 + '404': + description: Reset code is not found. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + examples: + response: + value: + code: PWR-10001 + message: not_found + description: recovery code not found + traceId: 23456fghj678vb78 + '406': + description: Reset code given in the request is not valid or expired. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + examples: + response: + value: + code: PWR-10001 + message: not acceptable + description: 'invalid error code : 1234-2345-12345-123456' + traceId: 23456fghj678vb78 + '412': + description: Password policy violation. + content: + application/json: + schema: + $ref: '#/components/schemas/RetryErrorResponse' + examples: + response: + value: + code: PWR-10001 + message: bad_request + description: password policy violation + traceId: 23456fghj678vb78 + resetCode: 1234-12345-sdf-34567567 + links: [ + { + "rel": "next", + "href": "/t/carbon.super/api/users/v2/recovery/password/reset", + "type": "POST" + } + ] + '500': + description: Server Error. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + examples: + response: + value: + code: PWR-15001 + message: Internal Error + description: Internal Error + traceId: 23456fghj678vb78 + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ResetRequest' + description: | + - Request to reset the password. + - `resetCode`, `flowConfirmationCode` and `password` are required. + required: true +servers: + - url: 'https://localhost/api/users/v2' +components: + schemas: + InitRequest: + type: object + description: Request to initate an account recovery + properties: + claims: + type: array + description: User claims to identify the user as UserClaim objects + items: + $ref: '#/components/schemas/UserClaim' + properties: + type: array + description: (OPTIONAL) Additional META properties + items: + $ref: '#/components/schemas/Property' + required: + - claims + RecoveryRequest: + type: object + description: >- + Request to start the recovery for the user who matches the recovery code + via the given channelID + properties: + recoveryCode: + type: string + description: Recovery code for the user + example: 1234-5678-2455-3433 + channelId: + type: string + description: >- + Id of the notification channel that user preferrs to get recovery + notifications. + example: '1' + properties: + type: array + description: (OPTIONAL) Additional META properties + items: + $ref: '#/components/schemas/Property' + required: + - recoveryCode + - channelId + ResendConfirmationRequest: + type: object + description: Request to resend the confirmation code in password recovery + properties: + resendCode: + type: string + description: Resend code returned by the password recovery API + example: 1234-2ws34-1234 + properties: + type: array + description: (OPTIONAL) Additional META properties + items: + $ref: '#/components/schemas/Property' + ConfirmRequest: + type: object + description: Request to confirm password recovery + required: + - confirmationCode + properties: + confirmationCode: + type: string + description: Confirmation code of the recovery flow + example: 1234-2ws34-12345 + otp: + type: string + description: OTP sent to the user + example: wi8Ivm + properties: + type: array + description: (OPTIONAL) Additional META properties + items: + $ref: '#/components/schemas/Property' + ResetRequest: + type: object + description: Object to reset the password of a user + required: + - resetCode + - password + properties: + resetCode: + type: string + description: resetCode given by the confim API + flowConfirmationCode: + type: string + description: Confirmation code of the recovery flow + password: + type: string + description: New password given by the user + properties: + type: array + description: (OPTIONAL) Additional META properties + items: + $ref: '#/components/schemas/Property' + PasswordRecoveryInternalNotifyResponse: + type: object + properties: + code: + type: string + description: Success status code + example: PWR-02002 + message: + type: string + description: Success status message + example: successful_request + flowConfirmationCode: + type: string + description: Recovery flow confirmation code + example: 1234-1234-1234-1234 + notificationChannel: + type: string + description: Channel that is used to send recovery information + example: EMAIL + resendCode: + type: string + description: >- + Code to resend the confirmation code to the user via user user + selected channel + example: 1234-123456-12345-12345 + links: + type: array + description: Contains available api calls + items: + $ref: '#/components/schemas/APICall' + PasswordRecoveryExternalNotifyResponse: + type: object + properties: + code: + type: string + description: Success status code + example: PWR-02002 + message: + type: string + description: Success status message + example: successful_request + flowConfirmationCode: + type: string + description: Recovery flow confirmation code + example: 1234-1234-1234-1234 + notificationChannel: + type: string + description: Channel that is used to send recovery information + example: EXTERNAL + confirmationCode: + type: string + description: > + - Confirmation code for password recovery when the notifications are + externally managed. + + - The confirmation code will be returned only if the notification + channel is _EXTERNAL_. Use this code with password confirm API to + get a password reset code. + example: 12345-45678-6789098-8765 + resendCode: + type: string + description: >- + Code to get a new confirmation code. + example: 1234-123456-12345-12345 + links: + type: array + description: Contains available api calls + items: + $ref: '#/components/schemas/APICall' + UsernameRecoveryNotifyResponse: + type: object + description: API response for successful username recovery + properties: + code: + type: string + description: Success status code + example: UNR-02001 + message: + type: string + description: Success status message + example: successful_request + notificationChannel: + type: string + description: Channel which the recovery information is sent to the user + example: EXTERNAL + username: + type: string + example: user1 + description: > + - Username of the user + + - Username will be returned _ONLY IF_ the notification channel is + `EXTERNAL` + required: + - code + - message + - notificationChannel + - username + ResetCodeResponse: + properties: + resetCode: + type: string + description: Password reset code to reset the password + example: 1234-55678-5668-2345 + links: + type: array + description: Contains available api calls + items: + $ref: '#/components/schemas/APICall' + PasswordResetResponse: + type: object + description: API response for a successful password reset + properties: + code: + type: string + description: Operation code + example: PWR-02001 + message: + type: string + description: Message regarding the operation. + example: successful_request + ResendConfirmationCodeExternalResponse: + type: object + description: Object encapsulate the details regarding resend confirmation code + properties: + code: + type: string + description: Success status code + example: PWR-02002 + message: + type: string + description: Success status message + example: successful_request + flowConfirmationCode: + type: string + description: Recovery flow confirmation code + example: 1234-1234-1234-1234 + notificationChannel: + type: string + description: Channel that is used to send recovery information + example: EMAIL + confirmationCode: + type: string + description: Confirmation code to confirm the password recovery + example: 1234-12345-234-123456 + resendCode: + type: string + description: Resend code to resend the confirmation code + example: 1234-12345-234-123456 + links: + type: array + description: Contains available api calls + items: + $ref: '#/components/schemas/APICall' + ResendConfirmationCodeInternalResponse: + type: object + description: Object encapsulate the details regarding resend confirmation code + properties: + code: + type: string + description: Success status code + example: PWR-02002 + message: + type: string + description: Success status message + example: successful_request + flowConfirmationCode: + type: string + description: Recovery flow confirmation code + example: 1234-1234-1234-1234 + notificationChannel: + type: string + description: Channel that is used to send recovery information + example: EMAIL + resendCode: + type: string + description: Resend code to resend the confirmation code + example: 1234-12345-234-123456 + links: + type: array + description: Contains available api calls + items: + $ref: '#/components/schemas/APICall' + RetryErrorResponse: + type: object + properties: + code: + type: string + description: Error code corresponding to the error + example: PWR-10004 + message: + type: string + description: Error message + example: Retry + description: + type: string + description: Error description + example: Password policy violation + traceId: + type: string + description: Some Correlation for Error Instance + example: 2345dfgh678h789bhjk + resetCode: + type: string + description: Password reset code used in the request + example: 1234-34567-3456-2345678 + links: + type: array + description: Contains available api calls + items: + $ref: '#/components/schemas/APICall' + ErrorResponse: + type: object + properties: + code: + type: string + description: Error code corresponding to the error + example: UAR-10001 + message: + type: string + description: Error message + example: invalid_request + description: + type: string + description: Description about the error + example: Invalid claim uri + traceId: + type: string + description: Some Correlation for Error Instance + example: 2345dfgh678h789bhjk + AccountRecoveryType: + type: object + description: Object that encapsulates details of the account recovery channel + properties: + mode: + type: string + example: recoverWithNotifications + flowConfirmationCode: + type: string + example: 1234-1234-1234-1234 + channelInfo: + $ref: '#/components/schemas/RecoveryChannelInformation' + links: + type: array + description: Contains available api calls + items: + $ref: '#/components/schemas/APICall' + RecoveryChannelInformation: + description: Response with the recovery ID and the available recovery channels + properties: + recoveryCode: + type: string + description: Code to recovery the user account + example: 1234-55678-5668-2345 + channels: + type: array + description: Availabel recovery channels for the user + items: + $ref: '#/components/schemas/RecoveryChannel' + RecoveryChannel: + type: object + description: Object with notification channel attributes + properties: + id: + type: string + description: Id given to the channel + example: '1' + type: + type: string + description: Type of the chanel + example: EMAIL + value: + type: string + description: Masked channel value + example: wso2***********.com + preferred: + type: boolean + description: Whether the channel is a user preferred channel + example: true + UserClaim: + type: object + description: Object that holds a user claim and the corresponding value + properties: + uri: + type: string + description: Claim uri + example: 'http://wso2.org/claims/givenname' + value: + type: string + description: Value for the claim + example: user1 + Property: + type: object + description: 'object that holds a property as a key, value pair' + properties: + key: + type: string + description: Unique identifier as the key of the peroperty + example: key + value: + type: string + description: Value of the property + example: value + APICall: + type: object + description: Object that holds next API call details + properties: + rel: + type: string + description: Next API call + example: next + href: + type: string + description: Next API url + example: /api/users/recovery/v2/ + type: + type: string + description: HTTP method type + example: POST diff --git a/components/org.wso2.carbon.identity.api.user.recovery/pom.xml b/components/org.wso2.carbon.identity.api.user.recovery/pom.xml index 691e04b7..efc2cb68 100644 --- a/components/org.wso2.carbon.identity.api.user.recovery/pom.xml +++ b/components/org.wso2.carbon.identity.api.user.recovery/pom.xml @@ -28,6 +28,7 @@ org.wso2.carbon.identity.api.user.recovery.commons org.wso2.carbon.identity.rest.api.user.recovery.v1 + org.wso2.carbon.identity.rest.api.user.recovery.v2 diff --git a/pom.xml b/pom.xml index fca748a1..a3c3a21b 100644 --- a/pom.xml +++ b/pom.xml @@ -421,7 +421,7 @@ 1.4 1.2.4 4.9.0 - 1.4.28 + 1.8.71 5.25.90 5.3.7 3.0.5