use of org.wso2.carbon.identity.api.server.secret.management.v1.model.SecretTypeResponse in project carbon-identity-framework by wso2.
the class SecretDAOImpl method getSecretTypeByName.
@Override
public SecretType getSecretTypeByName(String secretTypeName) throws SecretManagementException {
NamedJdbcTemplate jdbcTemplate = getNewTemplate();
SecretType secretTypeResponse;
try {
secretTypeResponse = jdbcTemplate.fetchSingleRecord(GET_SECRET_TYPE_BY_NAME, (resultSet, rowNumber) -> {
SecretType secretType = new SecretType();
secretType.setId(resultSet.getString(DB_SCHEMA_COLUMN_NAME_ID));
secretType.setName(resultSet.getString(DB_SCHEMA_COLUMN_NAME_NAME));
secretType.setDescription(resultSet.getString(DB_SCHEMA_COLUMN_NAME_DESCRIPTION));
return secretType;
}, preparedStatement -> preparedStatement.setString(DB_SCHEMA_COLUMN_NAME_NAME, secretTypeName));
return secretTypeResponse;
} catch (DataAccessException e) {
throw handleServerException(ERROR_CODE_RETRIEVE_SECRET_TYPE, secretTypeName, e);
}
}
use of org.wso2.carbon.identity.api.server.secret.management.v1.model.SecretTypeResponse 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);
}
use of org.wso2.carbon.identity.api.server.secret.management.v1.model.SecretTypeResponse in project identity-api-server by wso2.
the class SecretTypeManagementService method getSecretType.
/**
* Retrieve the secret details by name.
*
* @param secretTypeName Secret name.
* @return secret.
*/
public SecretTypeResponse getSecretType(String secretTypeName) {
try {
SecretType responseDTO = SecretManagementServiceHolder.getSecretConfigManager().getSecretType(secretTypeName);
SecretTypeResponse secretTypeResponse = new SecretTypeResponse();
secretTypeResponse.setId(responseDTO.getId());
secretTypeResponse.setName(responseDTO.getName());
secretTypeResponse.description(responseDTO.getDescription());
return secretTypeResponse;
} catch (SecretManagementException e) {
throw handleSecretMgtException(e, SecretManagementConstants.ErrorMessage.ERROR_CODE_ERROR_GETTING_SECRET, secretTypeName);
}
}
use of org.wso2.carbon.identity.api.server.secret.management.v1.model.SecretTypeResponse in project identity-api-server by wso2.
the class SecretTypeManagementService method addSecretType.
/**
* Create a secret Type.
*
* @param secretTypeAddRequest Secret post request.
* @return secret.
*/
public SecretTypeResponse addSecretType(SecretTypeAddRequest secretTypeAddRequest) {
validateSecretTypeAddRequest(secretTypeAddRequest);
SecretType requestDTO, responseDTO;
try {
requestDTO = buildSecretTypeRequestDTOFromSecretTypeAddRequest(secretTypeAddRequest);
responseDTO = SecretManagementServiceHolder.getSecretConfigManager().addSecretType(requestDTO);
} catch (SecretManagementException e) {
throw handleSecretMgtException(e, SecretManagementConstants.ErrorMessage.ERROR_CODE_ERROR_ADDING_SECRET, secretTypeAddRequest.getName());
}
return buildSecretTypeResponseFromResponseDTO(responseDTO);
}
use of org.wso2.carbon.identity.api.server.secret.management.v1.model.SecretTypeResponse in project identity-api-server by wso2.
the class SecretTypeManagementService method buildSecretTypeResponseFromResponseDTO.
/**
* To create Secret Response object for the post request
*
* @param secretTypeReq Secret object.
* @return {@link SecretTypeResponse} .
*/
private SecretTypeResponse buildSecretTypeResponseFromResponseDTO(SecretType secretTypeReq) {
SecretTypeResponse secretTypeResponse = new SecretTypeResponse();
secretTypeResponse.setId(secretTypeReq.getId());
secretTypeResponse.setName(secretTypeReq.getName());
secretTypeResponse.setDescription(secretTypeReq.getDescription());
return secretTypeResponse;
}
Aggregations