diff --git a/pom.xml b/pom.xml
index 1c54268..8940af0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
org.ccalm
jwt
- 0.0.1-SNAPSHOT
+ 1.0.1
jwt
jwt
@@ -79,16 +79,7 @@
json
20231013
-
-
+
io.jsonwebtoken
jjwt-api
@@ -180,6 +171,7 @@
+ org-ccalm-jwt
org.springframework.boot
diff --git a/src/main/java/org/ccalm/jwt/MainController.java b/src/main/java/org/ccalm/jwt/MainController.java
index bfd2405..a219b2e 100644
--- a/src/main/java/org/ccalm/jwt/MainController.java
+++ b/src/main/java/org/ccalm/jwt/MainController.java
@@ -204,6 +204,23 @@ public class MainController implements ServletContextAware {
return "";
}
//------------------------------------------------------------------------------------------------------------------
+ public static void validatePassword(String password) throws CustomException {
+ Translation trt = new Translation("en",null);
+
+ if(password.isEmpty())
+ throw new CustomException(200, 10000,trt.trt(false,"The_password_field_is_empty"),null,false);
+ if(!Pattern.compile("[0-9]").matcher(password).find())
+ throw new CustomException(200, 10000,trt.trt(false,"The_password_is_missing_a_number"),null,false);
+ if(!Pattern.compile("[a-z]").matcher(password).find())
+ throw new CustomException(200, 10000,trt.trt(false,"The_password_is_missing_a_small_Latin_letter"),null,false);
+ if (!Pattern.compile("[A-Z]").matcher(password).find())
+ throw new CustomException(200, 10000,trt.trt(false,"The_password_is_missing_a_big_Latin_letter"),null,false);
+ if (!Pattern.compile("[_!@#$%^&*]").matcher(password).find())
+ throw new CustomException(200, 10000,trt.trt(false,"The_password_is_missing_a_special_letter"),null,false);
+ if (password.length() < 6)
+ throw new CustomException(200, 10000,trt.trt(false,"The_password_is_less_than_six_characters"),null,false);
+ }
+ //------------------------------------------------------------------------------------------------------------------
private PrivateKey getPrivateKey() {
try {
byte[] keyBytes = Base64.getDecoder().decode(this.private_key);
@@ -343,20 +360,20 @@ public class MainController implements ServletContextAware {
json.put("error_message","");
json.put("error_marker",(String)null);
String buildDate="";
- //String buildVersion="";
+ String buildVersion="";
try {
InputStream inputStream = MainController.class.getClassLoader().getResourceAsStream("META-INF/build-info.properties");
if (inputStream != null) {
Properties properties = new Properties();
properties.load(inputStream);
buildDate = properties.getProperty("build.time");
- //buildVersion = properties.getProperty("build.version");
+ buildVersion = properties.getProperty("build.version");
}
} catch (Exception e) {
e.printStackTrace();
}
json.put("build_date",buildDate);
- //json.put("build_version",buildVersion);
+ json.put("version",buildVersion);
json.put("name",application_name);
//json.put("active_connections",dataSource.getHikariPoolMXBean().getActiveConnections());
//json.put("idle_connections",dataSource.getHikariPoolMXBean().getIdleConnections());
@@ -597,7 +614,7 @@ public class MainController implements ServletContextAware {
byte[] bytes = baos.toByteArray();
json.put("image",Base64.getEncoder().encodeToString(bytes));
} catch (IOException e) {
- throw new CustomException(401, 10000, trt.trt(false, "Input_output_error"),UUID.randomUUID().toString(),true);
+ throw new CustomException(500, 10000, trt.trt(false, "Input_output_error"),UUID.randomUUID().toString(),true);
}
//Формирую JSON токена и шифрую его
@@ -674,19 +691,19 @@ public class MainController implements ServletContextAware {
}
if(jToken==null) {
- throw new CustomException(401, 10000, trt.trt(false, "Please_send_a_valid_JSON_string_in_your_token"),null,false);
+ throw new CustomException(200, 10000, trt.trt(false, "Please_send_a_valid_JSON_string_in_your_token"),null,false);
}
if (!verificationModel.getCode().equals(jToken.getString("code"))) {
- throw new CustomException(401, 10000, trt.trt(false, "The_code_did_not_match_what_was_specified_in_the_captcha"),null,false);
+ throw new CustomException(200, 10000, trt.trt(false, "The_code_did_not_match_what_was_specified_in_the_captcha"),null,false);
}
if (jToken.getLong("exp") < (System.currentTimeMillis() / 1000L)) {
- throw new CustomException(401, 10000, List.of(trt.trt(false, "Captcha_is_outdated"),trt.trt(false, "Please_update_the_captcha")),null,false);
+ throw new CustomException(200, 10000, List.of(trt.trt(false, "Captcha_is_outdated"),trt.trt(false, "Please_update_the_captcha")),null,false);
}
if (!Tools.isValidEmail(jToken.getString("email"))) {
- throw new CustomException(401, 10000, trt.trt(false, "The_email_field_is_incorrect"),null,false);
+ throw new CustomException(200, 10000, trt.trt(false, "The_email_field_is_incorrect"),null,false);
}
if (!verificationModel.getEmail().equals(jToken.getString("email"))) {
- throw new CustomException(401, 10000, trt.trt(false, "The_email_did_not_match_what_was_specified_in_the_captcha"),null,false);
+ throw new CustomException(200, 10000, trt.trt(false, "The_email_did_not_match_what_was_specified_in_the_captcha"),null,false);
}
//If this is a repeat authorization, then we inform the client about it
@@ -780,7 +797,10 @@ public class MainController implements ServletContextAware {
@Operation(summary = "Create new user account", description = "After creating a user, adding a default user role")
@RequestMapping(value = "/create",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
@ResponseBody
- public ResponseEntity