Browse Source

new front update 5 fix crypt

master
gsd 1 year ago
parent
commit
93582c2f07
  1. 18
      src/main/java/app/controllers/other/CryptoController.java

18
src/main/java/app/controllers/other/CryptoController.java

@ -3,12 +3,13 @@ package app.controllers.other;
import app.annotations.interfaces.CheckPermitionFlag;
import app.annotations.interfaces.CheckWebAccess;
import app.utils.CryptedCookie;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/api/crypto")
@ -20,10 +21,17 @@ public class CryptoController {
this.cryptedCookie = cryptedCookie;
}
@GetMapping
@CheckWebAccess
@CheckPermitionFlag
public HashMap<String, String> crypt(@RequestBody HashMap<String, String> need_crypt) {
@RequestMapping(method = RequestMethod.OPTIONS)
public ResponseEntity checkPermission(HttpServletRequest httpServletRequest) {
return ResponseEntity.ok().build();
}
@PostMapping("/crypt")
@CheckWebAccess
@CheckPermitionFlag
public HashMap<String, String> crypt(HttpServletRequest httpServletRequest, @RequestBody HashMap<String, String> need_crypt) {
return new HashMap<>() {{
need_crypt.entrySet().stream()
.map((item) -> Map.of("key", item.getKey(), "value", cryptedCookie.Hashed(item.getValue())))
@ -32,10 +40,10 @@ public class CryptoController {
}};
}
@PostMapping
@PostMapping("/decrypt")
@CheckWebAccess
@CheckPermitionFlag
public HashMap<String, String> decrypt(@RequestBody HashMap<String, String> need_decrypt) {
public HashMap<String, String> decrypt(HttpServletRequest httpServletRequest, @RequestBody HashMap<String, String> need_decrypt) {
return new HashMap<>() {{
need_decrypt.entrySet().stream()
.map((item) -> Map.of("key", item.getKey(), "value", cryptedCookie.ReadCh(item.getValue())))

Loading…
Cancel
Save