Search in sources :

Example 1 with SecretUpdateRequest

use of org.wso2.carbon.identity.api.server.secret.management.v1.model.SecretUpdateRequest in project identity-api-server by wso2.

the class SecretTypeManagementService method updateTypeSecret.

/**
 * Update secret details by name.
 *
 * @param name                Secret name.
 * @param secretUpdateRequest Secret's updated details.
 * @return Updated secret.
 */
public SecretTypeResponse updateTypeSecret(String name, SecretTypeUpdateRequest secretUpdateRequest) {
    SecretType requestDTO, responseDTO;
    SecretTypeAddRequest secretAdd = buildSecretTypeAddFromSecretTypeUpdateRequest(name, secretUpdateRequest);
    try {
        requestDTO = buildSecretTypeRequestDTOFromSecretTypeAddRequest(secretAdd);
        responseDTO = SecretManagementServiceHolder.getSecretConfigManager().replaceSecretType(requestDTO);
    } catch (SecretManagementException e) {
        throw handleSecretMgtException(e, SecretManagementConstants.ErrorMessage.ERROR_CODE_ERROR_UPDATING_SECRET, name);
    }
    return buildSecretTypeResponseFromResponseDTO(responseDTO);
}
Also used : SecretManagementException(org.wso2.carbon.identity.secret.mgt.core.exception.SecretManagementException) SecretType(org.wso2.carbon.identity.secret.mgt.core.model.SecretType) SecretTypeAddRequest(org.wso2.carbon.identity.api.server.secret.management.v1.model.SecretTypeAddRequest)

Example 2 with SecretUpdateRequest

use of org.wso2.carbon.identity.api.server.secret.management.v1.model.SecretUpdateRequest in project identity-api-server by wso2.

the class SecretManagementService method buildSecretAddFromSecretUpdateRequest.

/**
 * Build secretAdd object from secret update request.
 *
 * @param name                Secret name.
 * @param secretUpdateRequest Secret's update request body.
 * @return secretAdd object
 */
private SecretAddRequest buildSecretAddFromSecretUpdateRequest(String name, SecretUpdateRequest secretUpdateRequest) {
    SecretAddRequest secretAddRequest = new SecretAddRequest();
    secretAddRequest.setName(name);
    secretAddRequest.setValue(secretUpdateRequest.getValue());
    if (!StringUtils.isEmpty(secretUpdateRequest.getDescription())) {
        secretAddRequest.setDescription(secretUpdateRequest.getDescription());
    }
    return secretAddRequest;
}
Also used : SecretAddRequest(org.wso2.carbon.identity.api.server.secret.management.v1.model.SecretAddRequest)

Example 3 with SecretUpdateRequest

use of org.wso2.carbon.identity.api.server.secret.management.v1.model.SecretUpdateRequest in project identity-api-server by wso2.

the class SecretManagementService method updateSecret.

/**
 * Update secret details by name.
 *
 * @param secretType          Secret type name.
 * @param name                Secret name.
 * @param secretUpdateRequest Secret's updated details.
 * @return Updated secret.
 */
public SecretResponse updateSecret(String secretType, String name, SecretUpdateRequest secretUpdateRequest) {
    Secret requestDTO, responseDTO;
    SecretAddRequest secretAddRequest = buildSecretAddFromSecretUpdateRequest(name, secretUpdateRequest);
    try {
        requestDTO = buildSecretRequestDTOFromSecretAddRequest(secretAddRequest);
        responseDTO = SecretManagementServiceHolder.getSecretConfigManager().replaceSecret(secretType, requestDTO);
    } catch (SecretManagementException e) {
        throw handleSecretMgtException(e, SecretManagementConstants.ErrorMessage.ERROR_CODE_ERROR_UPDATING_SECRET, name);
    }
    return buildSecretResponseFromResponseDTO(responseDTO);
}
Also used : Secret(org.wso2.carbon.identity.secret.mgt.core.model.Secret) SecretAddRequest(org.wso2.carbon.identity.api.server.secret.management.v1.model.SecretAddRequest) SecretManagementException(org.wso2.carbon.identity.secret.mgt.core.exception.SecretManagementException)

Aggregations

SecretAddRequest (org.wso2.carbon.identity.api.server.secret.management.v1.model.SecretAddRequest)2 SecretManagementException (org.wso2.carbon.identity.secret.mgt.core.exception.SecretManagementException)2 SecretTypeAddRequest (org.wso2.carbon.identity.api.server.secret.management.v1.model.SecretTypeAddRequest)1 Secret (org.wso2.carbon.identity.secret.mgt.core.model.Secret)1 SecretType (org.wso2.carbon.identity.secret.mgt.core.model.SecretType)1