4 changed files with 71 additions and 14 deletions
@ -0,0 +1,46 @@ |
|||
package app.controllers.other; |
|||
|
|||
import app.annotations.interfaces.CheckPermitionFlag; |
|||
import app.annotations.interfaces.CheckWebAccess; |
|||
import app.utils.CryptedCookie; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
import java.util.stream.Collectors; |
|||
|
|||
@RestController |
|||
@RequestMapping("/api/crypto") |
|||
public class CryptoController { |
|||
private CryptedCookie cryptedCookie; |
|||
|
|||
@Autowired |
|||
public CryptoController(CryptedCookie cryptedCookie) { |
|||
this.cryptedCookie = cryptedCookie; |
|||
} |
|||
|
|||
@GetMapping |
|||
@CheckWebAccess |
|||
@CheckPermitionFlag |
|||
public HashMap<String, String> crypt(@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()))) |
|||
.toList() |
|||
.forEach((m) -> put(m.get("key"), m.get("value"))); |
|||
}}; |
|||
} |
|||
|
|||
@PostMapping |
|||
@CheckWebAccess |
|||
@CheckPermitionFlag |
|||
public HashMap<String, String> decrypt(@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()))) |
|||
.toList() |
|||
.forEach((m) -> put(m.get("key"), m.get("value"))); |
|||
}}; |
|||
} |
|||
} |
Loading…
Reference in new issue