Merge branch 'main' of https://git.dirt.kz/igor/org.ccalm.jwt
# Conflicts: # src/main/java/org/ccalm/jwt/MainController.java
This commit is contained in:
@ -24,6 +24,9 @@ import net.logicsquad.nanocaptcha.image.renderer.DefaultWordRenderer;
|
|||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.slf4j.MarkerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.dao.DataAccessException;
|
import org.springframework.dao.DataAccessException;
|
||||||
@ -40,8 +43,6 @@ import org.springframework.web.context.ServletContextAware;
|
|||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.apache.commons.text.RandomStringGenerator;
|
import org.apache.commons.text.RandomStringGenerator;
|
||||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
|
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
@ -78,7 +79,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
@Controller
|
@Controller
|
||||||
public class MainController implements ServletContextAware {
|
public class MainController implements ServletContextAware {
|
||||||
|
|
||||||
private static final Logger logger = LogManager.getLogger(MainController.class);
|
private static final Logger logger = LoggerFactory.getLogger(MainController.class);
|
||||||
|
|
||||||
@Value("${spring.application.name}")
|
@Value("${spring.application.name}")
|
||||||
String application_name = "";
|
String application_name = "";
|
||||||
@ -228,7 +229,7 @@ public class MainController implements ServletContextAware {
|
|||||||
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
||||||
return keyFactory.generatePrivate(spec);
|
return keyFactory.generatePrivate(spec);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e);
|
logger.error(e.getMessage());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -241,7 +242,7 @@ public class MainController implements ServletContextAware {
|
|||||||
PublicKey key = keyFactory.generatePublic(spec);
|
PublicKey key = keyFactory.generatePublic(spec);
|
||||||
return key;
|
return key;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e);
|
logger.error(e.getMessage());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -325,7 +326,7 @@ public class MainController implements ServletContextAware {
|
|||||||
cache.set(token, userAgentHash, access_time);
|
cache.set(token, userAgentHash, access_time);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
logger.error(uuid, e);
|
logger.error(MarkerFactory.getMarker(uuid), e.getMessage());
|
||||||
throw new CustomException(500, 10000, trt.trt(false, "Internal_Server_Error"), null, true);
|
throw new CustomException(500, 10000, trt.trt(false, "Internal_Server_Error"), null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,12 +338,12 @@ public class MainController implements ServletContextAware {
|
|||||||
} catch (CustomException e) {
|
} catch (CustomException e) {
|
||||||
if(e.isSaveToLog()) {
|
if(e.isSaveToLog()) {
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
logger.error(uuid, e);
|
logger.error(MarkerFactory.getMarker(uuid), e.getMessage());
|
||||||
}
|
}
|
||||||
return new ResponseEntity<>(e.getErrorResponseModel(), getHttpStatus(e.getHttpCode()));
|
return new ResponseEntity<>(e.getErrorResponseModel(), getHttpStatus(e.getHttpCode()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
logger.error(uuid, e);
|
logger.error(MarkerFactory.getMarker(uuid), e.getMessage());
|
||||||
return new ResponseEntity<>(new ErrorResponseModel(500, 10000, trt.trt(false, "Internal_Server_Error"), null, uuid), HttpStatus.INTERNAL_SERVER_ERROR);
|
return new ResponseEntity<>(new ErrorResponseModel(500, 10000, trt.trt(false, "Internal_Server_Error"), null, uuid), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -392,7 +393,7 @@ public class MainController implements ServletContextAware {
|
|||||||
return new ResponseEntity<>(json.toString(), HttpStatus.OK);
|
return new ResponseEntity<>(json.toString(), HttpStatus.OK);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
logger.error(uuid, e);
|
logger.error(MarkerFactory.getMarker(uuid), e.getMessage());
|
||||||
return new ResponseEntity<>(new ErrorResponseModel(500, 10000, trt.trt(false, "Internal_Server_Error"), null, uuid), HttpStatus.INTERNAL_SERVER_ERROR);
|
return new ResponseEntity<>(new ErrorResponseModel(500, 10000, trt.trt(false, "Internal_Server_Error"), null, uuid), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -432,12 +433,12 @@ public class MainController implements ServletContextAware {
|
|||||||
return new ResponseEntity<>(data, HttpStatus.OK);
|
return new ResponseEntity<>(data, HttpStatus.OK);
|
||||||
} catch (CustomException e) {
|
} catch (CustomException e) {
|
||||||
if(e.isSaveToLog()) {
|
if(e.isSaveToLog()) {
|
||||||
logger.error(e.getErrorMarker(), e);
|
logger.error(MarkerFactory.getMarker(e.getErrorMarker()), e.getMessage());
|
||||||
}
|
}
|
||||||
return new ResponseEntity<>(e.getErrorResponseModel(), getHttpStatus(e.getHttpCode()));
|
return new ResponseEntity<>(e.getErrorResponseModel(), getHttpStatus(e.getHttpCode()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
logger.error(uuid, e);
|
logger.error(MarkerFactory.getMarker(uuid), e.getMessage());
|
||||||
return new ResponseEntity<>(new ErrorResponseModel(500, 10000, trt.trt(false, "Internal_Server_Error"), null, uuid), HttpStatus.INTERNAL_SERVER_ERROR);
|
return new ResponseEntity<>(new ErrorResponseModel(500, 10000, trt.trt(false, "Internal_Server_Error"), null, uuid), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -495,12 +496,12 @@ public class MainController implements ServletContextAware {
|
|||||||
return new ResponseEntity<>(new ErrorResponseModel(200, 0), HttpStatus.OK);
|
return new ResponseEntity<>(new ErrorResponseModel(200, 0), HttpStatus.OK);
|
||||||
} catch (CustomException e) {
|
} catch (CustomException e) {
|
||||||
if(e.isSaveToLog()) {
|
if(e.isSaveToLog()) {
|
||||||
logger.error(e.getErrorMarker(), e);
|
logger.error(MarkerFactory.getMarker(e.getErrorMarker()), e.getMessage());
|
||||||
}
|
}
|
||||||
return new ResponseEntity<>(e.getErrorResponseModel(), getHttpStatus(e.getHttpCode()));
|
return new ResponseEntity<>(e.getErrorResponseModel(), getHttpStatus(e.getHttpCode()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
logger.error(uuid, e);
|
logger.error(MarkerFactory.getMarker(uuid), e.getMessage());
|
||||||
return new ResponseEntity<>(new ErrorResponseModel(500, 10000, trt.trt(false, "Internal_Server_Error"), null, uuid), HttpStatus.INTERNAL_SERVER_ERROR);
|
return new ResponseEntity<>(new ErrorResponseModel(500, 10000, trt.trt(false, "Internal_Server_Error"), null, uuid), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -569,12 +570,12 @@ public class MainController implements ServletContextAware {
|
|||||||
return new ResponseEntity<>(ApiResponseData.success(data), HttpStatus.OK);
|
return new ResponseEntity<>(ApiResponseData.success(data), HttpStatus.OK);
|
||||||
} catch (CustomException e) {
|
} catch (CustomException e) {
|
||||||
if(e.isSaveToLog()) {
|
if(e.isSaveToLog()) {
|
||||||
logger.error(e.getErrorMarker(), e);
|
logger.error(MarkerFactory.getMarker(e.getErrorMarker()), e.getMessage());
|
||||||
}
|
}
|
||||||
return new ResponseEntity<>(e.getErrorResponseModel(), getHttpStatus(e.getHttpCode()));
|
return new ResponseEntity<>(e.getErrorResponseModel(), getHttpStatus(e.getHttpCode()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
logger.error(uuid, e);
|
logger.error(MarkerFactory.getMarker(uuid), e.getMessage());
|
||||||
return new ResponseEntity<>(new ErrorResponseModel(500, 10000, trt.trt(false, "Internal_Server_Error"), null, uuid), HttpStatus.INTERNAL_SERVER_ERROR);
|
return new ResponseEntity<>(new ErrorResponseModel(500, 10000, trt.trt(false, "Internal_Server_Error"), null, uuid), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -630,12 +631,12 @@ public class MainController implements ServletContextAware {
|
|||||||
return new ResponseEntity<>(json.toString(), HttpStatus.OK);
|
return new ResponseEntity<>(json.toString(), HttpStatus.OK);
|
||||||
} catch (CustomException e) {
|
} catch (CustomException e) {
|
||||||
if(e.isSaveToLog()) {
|
if(e.isSaveToLog()) {
|
||||||
logger.error(e.getErrorMarker(), e);
|
logger.error(MarkerFactory.getMarker(e.getErrorMarker()), e.getMessage());
|
||||||
}
|
}
|
||||||
return new ResponseEntity<>(e.getErrorResponseModel(), getHttpStatus(e.getHttpCode()));
|
return new ResponseEntity<>(e.getErrorResponseModel(), getHttpStatus(e.getHttpCode()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
logger.error(uuid, e);
|
logger.error(MarkerFactory.getMarker(uuid), e.getMessage());
|
||||||
return new ResponseEntity<>(new ErrorResponseModel(500, 10000, trt.trt(false, "Internal_Server_Error"), null, uuid), HttpStatus.INTERNAL_SERVER_ERROR);
|
return new ResponseEntity<>(new ErrorResponseModel(500, 10000, trt.trt(false, "Internal_Server_Error"), null, uuid), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -687,7 +688,7 @@ public class MainController implements ServletContextAware {
|
|||||||
try {
|
try {
|
||||||
jToken = new JSONObject(sToken);
|
jToken = new JSONObject(sToken);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
logger.error(e);
|
logger.error(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(jToken==null) {
|
if(jToken==null) {
|
||||||
@ -783,12 +784,12 @@ public class MainController implements ServletContextAware {
|
|||||||
return new ResponseEntity<>(new ErrorResponseModel(200, 0,trt.trt(false, "The_verification_code_has_been_sent_to_your_email_address"),null), HttpStatus.OK);
|
return new ResponseEntity<>(new ErrorResponseModel(200, 0,trt.trt(false, "The_verification_code_has_been_sent_to_your_email_address"),null), HttpStatus.OK);
|
||||||
} catch (CustomException e) {
|
} catch (CustomException e) {
|
||||||
if(e.isSaveToLog()) {
|
if(e.isSaveToLog()) {
|
||||||
logger.error(e.getErrorMarker(), e);
|
logger.error(MarkerFactory.getMarker(e.getErrorMarker()), e.getMessage());
|
||||||
}
|
}
|
||||||
return new ResponseEntity<>(e.getErrorResponseModel(), getHttpStatus(e.getHttpCode()));
|
return new ResponseEntity<>(e.getErrorResponseModel(), getHttpStatus(e.getHttpCode()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
logger.error(uuid, e);
|
logger.error(MarkerFactory.getMarker(uuid), e.getMessage());
|
||||||
return new ResponseEntity<>(new ErrorResponseModel(500, 10000, trt.trt(false, "Internal_Server_Error"), null, uuid), HttpStatus.INTERNAL_SERVER_ERROR);
|
return new ResponseEntity<>(new ErrorResponseModel(500, 10000, trt.trt(false, "Internal_Server_Error"), null, uuid), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -920,12 +921,12 @@ public class MainController implements ServletContextAware {
|
|||||||
return new ResponseEntity<>(json.toString(), HttpStatus.OK);
|
return new ResponseEntity<>(json.toString(), HttpStatus.OK);
|
||||||
} catch (CustomException e) {
|
} catch (CustomException e) {
|
||||||
if(e.isSaveToLog()) {
|
if(e.isSaveToLog()) {
|
||||||
logger.error(e.getErrorMarker(), e);
|
logger.error(MarkerFactory.getMarker(e.getErrorMarker()), e.getMessage());
|
||||||
}
|
}
|
||||||
return new ResponseEntity<>(e.getErrorResponseModel(), getHttpStatus(e.getHttpCode()));
|
return new ResponseEntity<>(e.getErrorResponseModel(), getHttpStatus(e.getHttpCode()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
logger.error(uuid, e);
|
logger.error(MarkerFactory.getMarker(uuid), e.getMessage());
|
||||||
return new ResponseEntity<>(new ErrorResponseModel(500, 10000, trt.trt(false, "Internal_Server_Error"), null, uuid), HttpStatus.INTERNAL_SERVER_ERROR);
|
return new ResponseEntity<>(new ErrorResponseModel(500, 10000, trt.trt(false, "Internal_Server_Error"), null, uuid), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -981,12 +982,12 @@ public class MainController implements ServletContextAware {
|
|||||||
return new ResponseEntity<>(json.toString(), HttpStatus.OK);
|
return new ResponseEntity<>(json.toString(), HttpStatus.OK);
|
||||||
} catch (CustomException e) {
|
} catch (CustomException e) {
|
||||||
if(e.isSaveToLog()) {
|
if(e.isSaveToLog()) {
|
||||||
logger.error(e.getErrorMarker(), e);
|
logger.error(MarkerFactory.getMarker(e.getErrorMarker()), e.getMessage());
|
||||||
}
|
}
|
||||||
return new ResponseEntity<>(e.getErrorResponseModel(), getHttpStatus(e.getHttpCode()));
|
return new ResponseEntity<>(e.getErrorResponseModel(), getHttpStatus(e.getHttpCode()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
logger.error(uuid, e);
|
logger.error(MarkerFactory.getMarker(uuid), e.getMessage());
|
||||||
return new ResponseEntity<>(new ErrorResponseModel(500, 10000, trt.trt(false, "Internal_Server_Error"), null, uuid), HttpStatus.INTERNAL_SERVER_ERROR);
|
return new ResponseEntity<>(new ErrorResponseModel(500, 10000, trt.trt(false, "Internal_Server_Error"), null, uuid), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1050,7 +1051,7 @@ public class MainController implements ServletContextAware {
|
|||||||
}
|
}
|
||||||
}catch (DataAccessException ex){
|
}catch (DataAccessException ex){
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
logger.error(uuid,ex);
|
logger.error(MarkerFactory.getMarker(uuid),ex.getMessage());
|
||||||
throw new CustomException(500, 10000, trt.trt(false, "Internal_Server_Error"),uuid,true);
|
throw new CustomException(500, 10000, trt.trt(false, "Internal_Server_Error"),uuid,true);
|
||||||
}
|
}
|
||||||
if(json==null) {
|
if(json==null) {
|
||||||
@ -1062,6 +1063,7 @@ public class MainController implements ServletContextAware {
|
|||||||
msglist.add(trt.trt(false, "Authorization_attempts_s_out_of_s"));
|
msglist.add(trt.trt(false, "Authorization_attempts_s_out_of_s"));
|
||||||
parlist.add(attempt_count+";"+attempt_limit+";");
|
parlist.add(attempt_count+";"+attempt_limit+";");
|
||||||
}
|
}
|
||||||
|
//logger.warn("Failed password for {} from {} port {}", loginModel.getLogin(), ipAddress, 443); //Сохраняю в лог ошибку авторизации для последующего анализа Wazuh
|
||||||
throw new CustomException(200, 10000, msglist, parlist, null,false);
|
throw new CustomException(200, 10000, msglist, parlist, null,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1094,7 +1096,7 @@ public class MainController implements ServletContextAware {
|
|||||||
String str = String.valueOf(attempt_count);
|
String str = String.valueOf(attempt_count);
|
||||||
errorSettings.add(str + ";" + String.valueOf(attempt_limit) + ";");
|
errorSettings.add(str + ";" + String.valueOf(attempt_limit) + ";");
|
||||||
}
|
}
|
||||||
|
//logger.warn("Failed TOTP for {} from {} port {}", loginModel.getLogin(), ipAddress, 443); //Сохраняю в лог ошибку авторизации для последующего анализа Wazuh
|
||||||
throw new CustomException(200, 10012, errorMessages, errorSettings, (String)null,false);
|
throw new CustomException(200, 10012, errorMessages, errorSettings, (String)null,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1108,7 +1110,7 @@ public class MainController implements ServletContextAware {
|
|||||||
String str = String.valueOf(attempt_count);
|
String str = String.valueOf(attempt_count);
|
||||||
errorSettings.add(str + ";" + String.valueOf(attempt_limit) + ";");
|
errorSettings.add(str + ";" + String.valueOf(attempt_limit) + ";");
|
||||||
}
|
}
|
||||||
|
//logger.warn("Failed TOTP for {} from {} port {}", loginModel.getLogin(), ipAddress, 443); //Сохраняю в лог ошибку авторизации для последующего анализа Wazuh
|
||||||
throw new CustomException(200, 10000, errorMessages, errorSettings, (String)null,false);
|
throw new CustomException(200, 10000, errorMessages, errorSettings, (String)null,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1136,7 +1138,7 @@ public class MainController implements ServletContextAware {
|
|||||||
}
|
}
|
||||||
}catch (Exception ex){
|
}catch (Exception ex){
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
logger.error(uuid,ex);
|
logger.error(MarkerFactory.getMarker(uuid),ex.getMessage());
|
||||||
throw new CustomException(500, 10000, trt.trt(false, "Error_executing_SQL_query"),uuid,false);
|
throw new CustomException(500, 10000, trt.trt(false, "Error_executing_SQL_query"),uuid,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1233,12 +1235,12 @@ public class MainController implements ServletContextAware {
|
|||||||
return new ResponseEntity<>(json.toString(), HttpStatus.OK);
|
return new ResponseEntity<>(json.toString(), HttpStatus.OK);
|
||||||
} catch (CustomException e) {
|
} catch (CustomException e) {
|
||||||
if(e.isSaveToLog()) {
|
if(e.isSaveToLog()) {
|
||||||
logger.error(e.getErrorMarker(), e);
|
logger.error(MarkerFactory.getMarker(e.getErrorMarker()), e.getMessage());
|
||||||
}
|
}
|
||||||
return new ResponseEntity<>(e.getErrorResponseModel(), getHttpStatus(e.getHttpCode()));
|
return new ResponseEntity<>(e.getErrorResponseModel(), getHttpStatus(e.getHttpCode()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
logger.error(uuid, e);
|
logger.error(MarkerFactory.getMarker(uuid), e.getMessage());
|
||||||
return new ResponseEntity<>(new ErrorResponseModel(500, 10000, trt.trt(false, "Internal_Server_Error"), null, uuid), HttpStatus.INTERNAL_SERVER_ERROR);
|
return new ResponseEntity<>(new ErrorResponseModel(500, 10000, trt.trt(false, "Internal_Server_Error"), null, uuid), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1273,11 +1275,11 @@ public class MainController implements ServletContextAware {
|
|||||||
throw e;
|
throw e;
|
||||||
}catch (DataAccessException ex){
|
}catch (DataAccessException ex){
|
||||||
java.lang.String uuid = UUID.randomUUID().toString();
|
java.lang.String uuid = UUID.randomUUID().toString();
|
||||||
logger.error(uuid, ex);
|
logger.error(MarkerFactory.getMarker(uuid), ex.getMessage());
|
||||||
throw new CustomException(500, 10000, trt.trt(false, "Internal_Server_Error"),uuid,false);
|
throw new CustomException(500, 10000, trt.trt(false, "Internal_Server_Error"),uuid,false);
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
logger.error(uuid,e);
|
logger.error(MarkerFactory.getMarker(uuid),e.getMessage());
|
||||||
throw new CustomException(500, 10000, trt.trt(false, "Internal_Server_Error"),uuid,false);
|
throw new CustomException(500, 10000, trt.trt(false, "Internal_Server_Error"),uuid,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1339,7 +1341,7 @@ public class MainController implements ServletContextAware {
|
|||||||
}
|
}
|
||||||
}catch (DataAccessException ex){
|
}catch (DataAccessException ex){
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
logger.error(uuid,ex);
|
logger.error(MarkerFactory.getMarker(uuid),ex.getMessage());
|
||||||
throw new CustomException(500, 10000, trt.trt(false, "Error_executing_SQL_query"),uuid,false);
|
throw new CustomException(500, 10000, trt.trt(false, "Error_executing_SQL_query"),uuid,false);
|
||||||
}
|
}
|
||||||
if(json==null) {
|
if(json==null) {
|
||||||
@ -1351,6 +1353,7 @@ public class MainController implements ServletContextAware {
|
|||||||
msglist.add(trt.trt(false, "Authorization_attempts_s_out_of_s"));
|
msglist.add(trt.trt(false, "Authorization_attempts_s_out_of_s"));
|
||||||
parlist.add(attempt_count+";"+attempt_limit+";");
|
parlist.add(attempt_count+";"+attempt_limit+";");
|
||||||
}
|
}
|
||||||
|
//logger.warn("Failed password for {} from {} port {}", loginModel.getLogin(), ipAddress, 443); //Сохраняю в лог ошибку авторизации для последующего анализа Wazuh
|
||||||
throw new CustomException(200, 10000, msglist, parlist, null,false);
|
throw new CustomException(200, 10000, msglist, parlist, null,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1391,7 +1394,7 @@ public class MainController implements ServletContextAware {
|
|||||||
int cnt = jdbcTemplate.update(sql, parameters);
|
int cnt = jdbcTemplate.update(sql, parameters);
|
||||||
}catch (DataAccessException ex){
|
}catch (DataAccessException ex){
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
logger.error(uuid,ex);
|
logger.error(MarkerFactory.getMarker(uuid),ex.getMessage());
|
||||||
throw new CustomException(500, 10000, trt.trt(false, "Error_executing_SQL_query"),uuid,false);
|
throw new CustomException(500, 10000, trt.trt(false, "Error_executing_SQL_query"),uuid,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1410,12 +1413,12 @@ public class MainController implements ServletContextAware {
|
|||||||
return new ResponseEntity<>(json.toString(), HttpStatus.OK);
|
return new ResponseEntity<>(json.toString(), HttpStatus.OK);
|
||||||
} catch (CustomException e) {
|
} catch (CustomException e) {
|
||||||
if(e.isSaveToLog()) {
|
if(e.isSaveToLog()) {
|
||||||
logger.error(e.getErrorMarker(), e);
|
logger.error(MarkerFactory.getMarker(e.getErrorMarker()), e.getMessage());
|
||||||
}
|
}
|
||||||
return new ResponseEntity<>(e.getErrorResponseModel(), getHttpStatus(e.getHttpCode()));
|
return new ResponseEntity<>(e.getErrorResponseModel(), getHttpStatus(e.getHttpCode()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
logger.error(uuid, e);
|
logger.error(MarkerFactory.getMarker(uuid), e.getMessage());
|
||||||
return new ResponseEntity<>(new ErrorResponseModel(500, 10000, trt.trt(false, "Internal_Server_Error"), null, uuid), HttpStatus.INTERNAL_SERVER_ERROR);
|
return new ResponseEntity<>(new ErrorResponseModel(500, 10000, trt.trt(false, "Internal_Server_Error"), null, uuid), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1518,12 +1521,12 @@ public class MainController implements ServletContextAware {
|
|||||||
return new ResponseEntity<>(json.toString(), HttpStatus.OK);
|
return new ResponseEntity<>(json.toString(), HttpStatus.OK);
|
||||||
} catch (CustomException e) {
|
} catch (CustomException e) {
|
||||||
if(e.isSaveToLog()) {
|
if(e.isSaveToLog()) {
|
||||||
logger.error(e.getErrorMarker(), e);
|
logger.error(MarkerFactory.getMarker(e.getErrorMarker()), e.getMessage());
|
||||||
}
|
}
|
||||||
return new ResponseEntity<>(e.getErrorResponseModel(), getHttpStatus(e.getHttpCode()));
|
return new ResponseEntity<>(e.getErrorResponseModel(), getHttpStatus(e.getHttpCode()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
logger.error(uuid, e);
|
logger.error(MarkerFactory.getMarker(uuid), e.getMessage());
|
||||||
return new ResponseEntity<>(new ErrorResponseModel(500, 10000, trt.trt(false, "Internal_Server_Error"), null, uuid), HttpStatus.INTERNAL_SERVER_ERROR);
|
return new ResponseEntity<>(new ErrorResponseModel(500, 10000, trt.trt(false, "Internal_Server_Error"), null, uuid), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1578,7 +1581,7 @@ public class MainController implements ServletContextAware {
|
|||||||
int cnt = jdbcTemplate.update(sql, parameters);
|
int cnt = jdbcTemplate.update(sql, parameters);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
logger.error(uuid,e);
|
logger.error(MarkerFactory.getMarker(uuid),e.getMessage());
|
||||||
return createHTMLError(10000,trt.trt(false, "Internal_Server_Error"));
|
return createHTMLError(10000,trt.trt(false, "Internal_Server_Error"));
|
||||||
}
|
}
|
||||||
return createHTMLError(0,trt.trt(false, "The_password_has_been_changed_and_you_have_been_redirected_to_the_main_page"));
|
return createHTMLError(0,trt.trt(false, "The_password_has_been_changed_and_you_have_been_redirected_to_the_main_page"));
|
||||||
@ -1674,12 +1677,12 @@ public class MainController implements ServletContextAware {
|
|||||||
return new ResponseEntity<>(createStrJSONError(0, trt.trt(false,"A_recovery_link_has_been_sent_to_your_email"),(String)null,(String)null), HttpStatus.OK);
|
return new ResponseEntity<>(createStrJSONError(0, trt.trt(false,"A_recovery_link_has_been_sent_to_your_email"),(String)null,(String)null), HttpStatus.OK);
|
||||||
} catch (CustomException e) {
|
} catch (CustomException e) {
|
||||||
if(e.isSaveToLog()) {
|
if(e.isSaveToLog()) {
|
||||||
logger.error(e.getErrorMarker(), e);
|
logger.error(MarkerFactory.getMarker(e.getErrorMarker()), e.getMessage());
|
||||||
}
|
}
|
||||||
return new ResponseEntity<>(e.getErrorResponseModel(), getHttpStatus(e.getHttpCode()));
|
return new ResponseEntity<>(e.getErrorResponseModel(), getHttpStatus(e.getHttpCode()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
logger.error(uuid, e);
|
logger.error(MarkerFactory.getMarker(uuid), e.getMessage());
|
||||||
return new ResponseEntity<>(new ErrorResponseModel(500, 10000, trt.trt(false, "Internal_Server_Error"), null, uuid), HttpStatus.INTERNAL_SERVER_ERROR);
|
return new ResponseEntity<>(new ErrorResponseModel(500, 10000, trt.trt(false, "Internal_Server_Error"), null, uuid), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1749,12 +1752,12 @@ public class MainController implements ServletContextAware {
|
|||||||
return new ResponseEntity<>(json.toString(), HttpStatus.OK);
|
return new ResponseEntity<>(json.toString(), HttpStatus.OK);
|
||||||
} catch (CustomException e) {
|
} catch (CustomException e) {
|
||||||
if(e.isSaveToLog()) {
|
if(e.isSaveToLog()) {
|
||||||
logger.error(e.getErrorMarker(), e);
|
logger.error(MarkerFactory.getMarker(e.getErrorMarker()), e.getMessage());
|
||||||
}
|
}
|
||||||
return new ResponseEntity<>(e.getErrorResponseModel(), getHttpStatus(e.getHttpCode()));
|
return new ResponseEntity<>(e.getErrorResponseModel(), getHttpStatus(e.getHttpCode()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
logger.error(uuid, e);
|
logger.error(MarkerFactory.getMarker(uuid), e.getMessage());
|
||||||
return new ResponseEntity<>(new ErrorResponseModel(500, 10000, trt.trt(false, "Internal_Server_Error"), null, uuid), HttpStatus.INTERNAL_SERVER_ERROR);
|
return new ResponseEntity<>(new ErrorResponseModel(500, 10000, trt.trt(false, "Internal_Server_Error"), null, uuid), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1813,12 +1816,12 @@ public class MainController implements ServletContextAware {
|
|||||||
return new ResponseEntity<>(new ErrorResponseModel(200, 0,"",""), HttpStatus.OK);
|
return new ResponseEntity<>(new ErrorResponseModel(200, 0,"",""), HttpStatus.OK);
|
||||||
} catch (CustomException e) {
|
} catch (CustomException e) {
|
||||||
if(e.isSaveToLog()) {
|
if(e.isSaveToLog()) {
|
||||||
logger.error(e.getErrorMarker(), e);
|
logger.error(MarkerFactory.getMarker(e.getErrorMarker()), e.getMessage());
|
||||||
}
|
}
|
||||||
return new ResponseEntity<>(e.getErrorResponseModel(), getHttpStatus(e.getHttpCode()));
|
return new ResponseEntity<>(e.getErrorResponseModel(), getHttpStatus(e.getHttpCode()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
logger.error(uuid, e);
|
logger.error(MarkerFactory.getMarker(uuid), e.getMessage());
|
||||||
return new ResponseEntity<>(new ErrorResponseModel(500, 10000, trt.trt(false,"Internal_Server_Error"), null, uuid), HttpStatus.INTERNAL_SERVER_ERROR);
|
return new ResponseEntity<>(new ErrorResponseModel(500, 10000, trt.trt(false,"Internal_Server_Error"), null, uuid), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,17 +1,15 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Please check if the user has access to the directory from which the application is being executed -->
|
|
||||||
<property name="LOGS" value="logs" />
|
<property name="LOGS" value="logs" />
|
||||||
<springProperty scope="context" name="appName" source="spring.application.name"/>
|
<springProperty scope="context" name="appName" source="spring.application.name"/>
|
||||||
|
|
||||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
<file>${LOGS}/${appName}.log</file>
|
<file>${LOGS}/${appName}.log</file>
|
||||||
<encoder>
|
<encoder>
|
||||||
<pattern>{"timestamp":"%d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z'}","thread":"[%thread]","level":"%level","logger":"%logger{36}","marker":"%X{marker}","message":"%msg"}%n</pattern>
|
<pattern>
|
||||||
|
{"timestamp":"%d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z'}","thread":"[%thread]","level":"%level","logger":"%logger{36}","marker":"%marker","message":"%msg","exception":"%ex"}%n
|
||||||
|
</pattern>
|
||||||
</encoder>
|
</encoder>
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
<fileNamePattern>${LOGS}/${appName}.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
<fileNamePattern>${LOGS}/${appName}.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||||
@ -24,15 +22,16 @@
|
|||||||
|
|
||||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
<encoder>
|
<encoder>
|
||||||
<pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z'} | %level | %logger{36} | %X{marker} | %msg%n</pattern>
|
<pattern>
|
||||||
|
%d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z'} | %level | %logger{36} | %marker | %msg%n
|
||||||
|
</pattern>
|
||||||
</encoder>
|
</encoder>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
<root level="info">
|
|
||||||
<!--root level="warn"-->
|
<!--root level="warn"-->
|
||||||
|
<root level="info">
|
||||||
<appender-ref ref="FILE" />
|
<appender-ref ref="FILE" />
|
||||||
<appender-ref ref="CONSOLE" />
|
<appender-ref ref="CONSOLE" />
|
||||||
</root>
|
</root>
|
||||||
|
|
||||||
|
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
Reference in New Issue
Block a user