Commit d1f18992 authored by maqing's avatar maqing

RSA密码加密

parent d7fa84c9
...@@ -8,6 +8,7 @@ import org.springframework.security.oauth2.common.OAuth2AccessToken; ...@@ -8,6 +8,7 @@ import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.provider.endpoint.TokenEndpoint; import org.springframework.security.oauth2.provider.endpoint.TokenEndpoint;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.security.NoSuchAlgorithmException;
import java.security.Principal; import java.security.Principal;
import java.util.Map; import java.util.Map;
...@@ -26,7 +27,7 @@ public class AuthController { ...@@ -26,7 +27,7 @@ public class AuthController {
@SneakyThrows @SneakyThrows
public Result<OAuth2AccessToken> postAccessToken(Principal principal, @RequestParam Map<String, String> parameters) { public Result<OAuth2AccessToken> postAccessToken(Principal principal, @RequestParam Map<String, String> parameters) {
String password = parameters.get("password"); String password = parameters.get("password");
String decrypt = CsoftSecurityUtil.decrypt(password); String decrypt = CsoftSecurityUtil.decryptRSADefault(password);
parameters.put("password", decrypt); parameters.put("password", decrypt);
OAuth2AccessToken oAuth2AccessToken = tokenEndpoint.postAccessToken(principal, parameters).getBody(); OAuth2AccessToken oAuth2AccessToken = tokenEndpoint.postAccessToken(principal, parameters).getBody();
return Result.success(oAuth2AccessToken); return Result.success(oAuth2AccessToken);
...@@ -38,7 +39,7 @@ public class AuthController { ...@@ -38,7 +39,7 @@ public class AuthController {
*/ */
@GetMapping("/genKeyPair") @GetMapping("/genKeyPair")
public Result<String> genKeyPair() { public Result<String> genKeyPair() {
Map keyMap = CsoftSecurityUtil.genKeyPair(); Map keyMap = CsoftSecurityUtil.createKeyPairs();
return Result.success(keyMap.get(0).toString()); return Result.success(keyMap.get(0).toString());
} }
......
...@@ -33,14 +33,4 @@ public class PublicKeyController { ...@@ -33,14 +33,4 @@ public class PublicKeyController {
return new JWKSet(key).toJSONObject(); return new JWKSet(key).toJSONObject();
} }
/**
* 获取公钥
* @return
*/
@GetMapping("/genKeyPair")
public Result<String> genKeyPair() {
Map keyMap = CsoftSecurityUtil.genKeyPair();
return Result.success(keyMap.get(0).toString());
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment