use of org.wso2.carbon.identity.api.server.secret.management.v1.model.SecretAddRequest in project identity-api-server by wso2.
the class SecretManagementService method addSecret.
/**
* Create a secret.
*
* @param secretType Secret type name.
* @param secretAddRequest Secret post request.
* @return secret.
*/
public SecretResponse addSecret(String secretType, SecretAddRequest secretAddRequest) {
validateSecretAddRequest(secretAddRequest);
Secret requestDTO, responseDTO;
try {
requestDTO = buildSecretRequestDTOFromSecretAddRequest(secretAddRequest);
responseDTO = SecretManagementServiceHolder.getSecretConfigManager().addSecret(secretType, requestDTO);
} catch (SecretManagementException e) {
throw handleSecretMgtException(e, SecretManagementConstants.ErrorMessage.ERROR_CODE_ERROR_ADDING_SECRET, secretAddRequest.getName());
}
return buildSecretResponseFromResponseDTO(responseDTO);
}
use of org.wso2.carbon.identity.api.server.secret.management.v1.model.SecretAddRequest 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;
}
use of org.wso2.carbon.identity.api.server.secret.management.v1.model.SecretAddRequest in project identity-api-server by wso2.
the class SecretManagementService method buildSecretRequestDTOFromSecretAddRequest.
/**
* Build secret requestDTO by secret body request.
*
* @param secretAddRequest Secret post body.
* @return Secret requestDTO object.
*/
private Secret buildSecretRequestDTOFromSecretAddRequest(SecretAddRequest secretAddRequest) {
Secret requestDTO = new Secret();
requestDTO.setSecretName(secretAddRequest.getName());
requestDTO.setSecretValue(secretAddRequest.getValue());
requestDTO.setDescription(secretAddRequest.getDescription());
return requestDTO;
}
use of org.wso2.carbon.identity.api.server.secret.management.v1.model.SecretAddRequest 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);
}
use of org.wso2.carbon.identity.api.server.secret.management.v1.model.SecretAddRequest in project identity-api-server by wso2.
the class SecretsApiServiceImpl method createSecret.
@Override
public Response createSecret(String secretType, SecretAddRequest secretAddRequest) {
SecretResponse secretResponse = secretManagementService.addSecret(secretType, secretAddRequest);
URI location = ContextLoader.buildURIForHeader(V1_API_PATH_COMPONENT + SECRET_CONTEXT_PATH + "/" + secretResponse.getSecretName());
return Response.created(location).entity(secretResponse).build();
}
Aggregations