use of org.wso2.carbon.identity.rest.api.user.recovery.v1.model.RecoveryChannel in project identity-api-user by wso2.
the class RecoveryUtil method buildRecoveryChannelInformation.
/**
* 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<RecoveryChannel> buildRecoveryChannelInformation(NotificationChannelDTO[] channels) {
List<RecoveryChannel> 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;
}
use of org.wso2.carbon.identity.rest.api.user.recovery.v1.model.RecoveryChannel in project identity-api-user by wso2.
the class PasswordRecoveryService method buildRecoveryChannelInformation.
/**
* Method to build recovery channel information.
*
* @param recoveryInformationDTO RecoveryInformation with recovery information
* @return RecoveryChannelInformation
*/
private RecoveryChannelInformation buildRecoveryChannelInformation(RecoveryInformationDTO recoveryInformationDTO) {
RecoveryChannelInfoDTO recoveryChannelInfoDTO = recoveryInformationDTO.getRecoveryChannelInfoDTO();
List<RecoveryChannel> channels = RecoveryUtil.buildRecoveryChannelInformation(recoveryChannelInfoDTO.getNotificationChannelDTOs());
RecoveryChannelInformation recoveryChannelInformation = new RecoveryChannelInformation();
recoveryChannelInformation.setRecoveryCode(recoveryChannelInfoDTO.getRecoveryCode());
recoveryChannelInformation.setChannels(channels);
return recoveryChannelInformation;
}
use of org.wso2.carbon.identity.rest.api.user.recovery.v1.model.RecoveryChannel in project identity-api-user by wso2.
the class UsernameRecoveryService method buildUsernameRecoveryInitResponse.
/**
* 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<AccountRecoveryType> buildUsernameRecoveryInitResponse(RecoveryInformationDTO recoveryInformationDTO, String tenantDomain) {
RecoveryChannelInfoDTO recoveryChannelInfoDTO = recoveryInformationDTO.getRecoveryChannelInfoDTO();
List<RecoveryChannel> 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<APICall> apiCallsArrayList = new ArrayList<>();
apiCallsArrayList.add(RecoveryUtil.buildApiCall(Constants.APICall.RECOVER_USERNAME_API.getType(), Constants.RelationStates.NEXT_REL, RecoveryUtil.buildURIForBody(tenantDomain, Constants.APICall.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<AccountRecoveryType> recoveryTypeDTOS = new ArrayList<>();
recoveryTypeDTOS.add(accountRecoveryType);
return recoveryTypeDTOS;
}
Aggregations