package go.kr.project.vmis.gpki; import go.kr.project.vmis.config.properties.VmisProperties; import go.kr.project.vmis.util.GpkiCryptoUtil; /** * Real GPKI service backed by native GPKI JNI via legacy NewGpkiUtil wrapper. * Uses YAML-configured paths and options in {@link VmisProperties.GpkiProps}. */ public class RealGpkiService implements GpkiService { private final VmisProperties props; private final GpkiCryptoUtil crypto; public RealGpkiService(VmisProperties props) { this.props = props; try { this.crypto = GpkiCryptoUtil.from(props.getGpki()); } catch (Exception e) { throw new IllegalStateException("Failed to initialize GPKI (JNI) util. Check YAML paths/passwords and license.", e); } } @Override public String encrypt(String plain) throws Exception { String charset = props.getGpki().getCharset(); String targetId = props.getGpki().getTargetServerId(); return crypto.encryptToBase64(plain, targetId, charset); } @Override public String decrypt(String cipher) throws Exception { String charset = props.getGpki().getCharset(); return crypto.decryptFromBase64(cipher, charset); } @Override public boolean isEnabled() { return true; } }