use of com.vartech.common.app.beans.ResponseResult in project varsql by varsqlinfo.
the class GlobalExceptionHandler method databaseBlockingExceptionHandler.
/**
* @method : databaseBlockingExceptionHandler
* @desc : database 차된
* @author : ytkim
* @date : 2021. 8. 19.
* @param ex
* @param request
* @param response
*/
@ExceptionHandler(value = DatabaseBlockingException.class)
public void databaseBlockingExceptionHandler(DatabaseBlockingException ex, HttpServletRequest request, HttpServletResponse response) {
ResponseResult result = new ResponseResult();
exceptionRequestHandle(ex, request, response, result, "blockingDatabase");
}
use of com.vartech.common.app.beans.ResponseResult in project varsql by varsqlinfo.
the class VarsqlBasicAuthenticationEntryPoint method commence.
@Override
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authEx) throws IOException {
logger.warn("VarsqlBasicAuthenticationEntryPoint url : {}, parameter : {} ", request.getRequestURL(), HttpUtils.getServletRequestParam(request));
logger.warn("cookie values : {} ", HttpUtils.getAllCookieString(request));
logger.warn("request header : {} ", HttpUtils.getAllReqHeaderString(request));
logger.warn("response header : {} ", HttpUtils.getAllResHeaderString(response));
logger.warn("varsqlBasicAuthenticationEntryPoint commence : {}", authEx.getMessage(), authEx);
response.addHeader("WWW-Authenticate", "Basic realm=" + getRealmName());
if (VarsqlUtils.isAjaxRequest(request)) {
ResponseResult result = new ResponseResult();
response.setContentType(VarsqlConstants.JSON_CONTENT_TYPE);
response.setStatus(HttpStatus.OK.value());
result.setResultCode(RequestResultCode.PRECONDITION_FAILED);
try (Writer writer = response.getWriter()) {
writer.write(VartechUtils.objectToJsonString(result));
} catch (IOException e) {
logger.error("exceptionRequestHandle Cause :" + e.getMessage(), e);
}
} else {
try {
RequestDispatcher dispatcher = request.getRequestDispatcher("/error/invalidToken");
dispatcher.forward(request, response);
} catch (ServletException | IOException e1) {
logger.error("commence Cause :" + e1.getMessage(), e1);
}
}
// response.sendError(HttpStatus.UNAUTHORIZED.value(), HttpStatus.UNAUTHORIZED.getReasonPhrase());
}
use of com.vartech.common.app.beans.ResponseResult in project varsql by varsqlinfo.
the class AdminDbMgmtServiceImpl method viewVtConntionPwInfo.
/**
* @method : viewVtConntionPwInfo
* @desc : view db password
* @author : ytkim
* @date : 2020. 7. 4.
* @param vconnid
* @return ResponseResult
*/
public ResponseResult viewVtConntionPwInfo(String vconnid, String userPw) {
ResponseResult resultObject = new ResponseResult();
if (!userService.passwordCheck(SecurityUtil.loginName(), userPw)) {
resultObject.setResultCode(RequestResultCode.ERROR);
resultObject.setMessage("password not valid");
return resultObject;
}
DBConnectionEntity dbInfo = dbConnectionModelRepository.findOne(DBConnectionSpec.detailInfo(vconnid)).orElseThrow(NullPointerException::new);
try {
resultObject.setItemOne(DBPasswordCryptionFactory.getInstance().decrypt(dbInfo.getVpw()));
} catch (EncryptDecryptException e) {
resultObject.setItemOne("password decrypt error");
}
return resultObject;
}
use of com.vartech.common.app.beans.ResponseResult in project varsql by varsqlinfo.
the class AdminDbMgmtServiceImpl method connectionCheck.
/**
* @Method Name : connectionCheck
* @Method 설명 : 커넥션 체크.
* @작성자 : ytkim
* @작성일 : 2018. 1. 22.
* @변경이력 :
* @param vtConnection
* @return
* @throws EncryptDecryptException
*/
public ResponseResult connectionCheck(DBConnectionRequestDTO vtConnection) throws EncryptDecryptException {
ResponseResult resultObject = new ResponseResult();
this.dbConnectionModelRepository.findByConnInfo(vtConnection.getVconnid());
logger.debug("connection check object param : {}", VartechUtils.reflectionToString(vtConnection));
String username = vtConnection.getVid();
DBConnectionEntity dbInfo = this.dbConnectionModelRepository.findOne(DBConnectionSpec.detailInfo(vtConnection.getVconnid())).orElseThrow(NullPointerException::new);
DBTypeDriverProviderEntity driverProviderEntity = dbInfo.getDbTypeDriverProvider();
String url = vtConnection.getVurl();
String defaultDriverValidationQuery = ValidationProperty.getInstance().validationQuery(driverProviderEntity.getDbType());
if (!"Y".equals(driverProviderEntity.getDirectYn())) {
DBTypeDriverEntity dbDriverModel = this.dbTypeDriverModelRepository.findByDriverId(driverProviderEntity.getDriverId());
if (!"Y".equals(vtConnection.getUrlDirectYn())) {
url = VarsqlJdbcUtil.getJdbcUrl(dbDriverModel.getUrlFormat(), JdbcURLFormatParam.builder().serverIp(vtConnection.getVserverip()).port(vtConnection.getVport()).databaseName(vtConnection.getVdatabasename()).build());
}
defaultDriverValidationQuery = StringUtils.isBlank(dbDriverModel.getValidationQuery()) ? defaultDriverValidationQuery : dbDriverModel.getValidationQuery();
}
logger.debug("connection check url : {}", url);
String validation_query = driverProviderEntity.getValidationQuery();
validation_query = StringUtils.isBlank(validation_query) ? defaultDriverValidationQuery : validation_query;
String failMessage = "";
PreparedStatement pstmt = null;
Connection connChk = null;
VarsqlAppCode resultCode = VarsqlAppCode.SUCCESS;
try {
String pwd = vtConnection.getVpw();
if (pwd == null || "".equals(pwd))
pwd = dbInfo.getVpw();
pwd = (pwd == null) ? "" : pwd;
pwd = DBPasswordCryptionFactory.getInstance().decrypt(pwd);
Properties p = new Properties();
p.setProperty("user", username);
p.setProperty("password", pwd);
List<FileInfo> driverJarFiles;
if (PathType.PATH.equals(PathType.getPathType(driverProviderEntity.getPathType()))) {
driverJarFiles = FileServiceUtils.getFileInfos(driverProviderEntity.getDriverPath().split(";"));
} else {
driverJarFiles = FileServiceUtils.getFileInfos(dbTypeDriverFileEntityRepository.findByFileContId(driverProviderEntity.getDriverProviderId()));
}
JDBCDriverInfo jdbcDriverInfo = new JDBCDriverInfo(dbInfo.getDbTypeDriverProvider().getDriverProviderId(), dbInfo.getDbTypeDriverProvider().getDriverClass());
jdbcDriverInfo.setDriverFiles(driverJarFiles);
Driver dbDriver = JdbcDriverLoader.checkDriver(jdbcDriverInfo);
connChk = dbDriver.connect(url, p);
pstmt = connChk.prepareStatement(validation_query);
pstmt.executeQuery();
connChk.close();
} catch (EncryptDecryptException e) {
resultCode = VarsqlAppCode.ERROR;
failMessage = "password decrypt error : " + e.getMessage();
logger.error(getClass().getName(), (Throwable) e);
} catch (ClassNotFoundException e) {
resultCode = VarsqlAppCode.ERROR;
failMessage = e.getMessage();
logger.error("url :{}", url);
logger.error(getClass().getName(), e);
} catch (Exception e) {
resultCode = VarsqlAppCode.ERROR;
failMessage = e.getMessage();
logger.error(getClass().getName(), e);
} finally {
JdbcUtils.close(connChk, pstmt, null);
}
resultObject.setResultCode(resultCode);
resultObject.setMessage(failMessage);
return resultObject;
}
use of com.vartech.common.app.beans.ResponseResult in project varsql by varsqlinfo.
the class AdminDbMgmtServiceImpl method jdbcProviderList.
public ResponseResult jdbcProviderList(SearchParameter searchParameter) {
Sort sort = Sort.by(Sort.Direction.ASC, DBTypeDriverProviderEntity.DB_TYPE).and(Sort.by(Sort.Direction.ASC, DBTypeDriverProviderEntity.PROVIDER_NAME));
List<DBTypeDriverProviderEntity> result = dbTypeDriverProviderRepository.findAll(DBTypeDriverProviderSpec.searchField(searchParameter), sort);
List<DBTypeDriverProviderResponseDTO> list = result.stream().map(item -> {
DBTypeDriverProviderResponseDTO dto = new DBTypeDriverProviderResponseDTO();
dto.setDbType(item.getDbType());
dto.setProviderName(item.getProviderName());
dto.setDriverProviderId(item.getDriverProviderId());
dto.setDriverId(item.getDriverId());
dto.setDirectYn(item.getDirectYn());
return dto;
}).collect(Collectors.toList());
return VarsqlUtils.getResponseResultItemList(list);
}
Aggregations