first commit

This commit is contained in:
yy
2026-09-11 17:34:14 +08:00
commit dfb943919d
622 changed files with 26659 additions and 0 deletions
@@ -0,0 +1,37 @@
package com.metalloop.modules.auth.controller;
import com.metalloop.common.auth.encrypt.KeyProperties;
import com.metalloop.common.auth.encrypt.KeyStoreKeyFactory;
import org.springframework.web.bind.annotation.ResponseBody;
import java.security.KeyPair;
import java.security.PublicKey;
import java.security.interfaces.RSAPublicKey;
import java.util.Base64;
/**
* 获取公钥端点
*
* @author zhaowenhao
* @since 2023-03-19
*/
public class RsaPublicKeyController {
private final KeyProperties keyProperties;
public RsaPublicKeyController(KeyProperties keyProperties) {
this.keyProperties = keyProperties;
}
@ResponseBody
public String getPublicKey() {
if (keyProperties != null) {
KeyPair keyPair = new KeyStoreKeyFactory(keyProperties.getKeyStore().getLocation(), keyProperties.getKeyStore().getSecret().toCharArray()).getKeyPair(keyProperties.getKeyStore().getAlias());
PublicKey publicKey = keyPair.getPublic();
RSAPublicKey rsaPublicKey = (RSAPublicKey) publicKey;
byte[] publicKeyBytes = rsaPublicKey.getEncoded();
return Base64.getEncoder().encodeToString(publicKeyBytes);
}
return "获取失败";
}
}