|
|
|
@ -146,9 +146,12 @@ public class GPKI extends AbstractComponent {
|
|
|
|
|
|
|
|
|
|
private static void load(gpkiapi_jni gpki, String serverID) throws Exception {
|
|
|
|
|
X509Certificate cert = null;
|
|
|
|
|
String certFile = conf.certDir + File.separator + serverID + ".cer";
|
|
|
|
|
|
|
|
|
|
String certFile = conf.certDir + File.separator + conf.targetCert(serverID);
|
|
|
|
|
try {
|
|
|
|
|
cert = Disk.readCert(certFile);
|
|
|
|
|
if (cert != null)
|
|
|
|
|
log(GPKI.class).debug(certFile + " loaded");
|
|
|
|
|
} catch (GpkiApiException e) {
|
|
|
|
|
cert = null;
|
|
|
|
|
}
|
|
|
|
@ -165,6 +168,7 @@ public class GPKI extends AbstractComponent {
|
|
|
|
|
|
|
|
|
|
cert = new X509Certificate(gpki.baReturnArray);
|
|
|
|
|
Disk.writeCert(certFile, cert);
|
|
|
|
|
log(GPKI.class).debug(certFile + " downloaded");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cert != null)
|
|
|
|
@ -262,6 +266,19 @@ public class GPKI extends AbstractComponent {
|
|
|
|
|
gpki = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean test(String serverID) {
|
|
|
|
|
String plain = "나랏말씀이 중국과 달라";
|
|
|
|
|
log().debug("plain text: {}", plain);
|
|
|
|
|
|
|
|
|
|
String encrypted = encrypt(serverID, plain);
|
|
|
|
|
log().debug("encrypted: {}", encrypted);
|
|
|
|
|
|
|
|
|
|
String decrypted = decrypt(encrypted);
|
|
|
|
|
log().debug("decrypted: {}", decrypted);
|
|
|
|
|
|
|
|
|
|
return plain.equals(decrypted);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**GPKI 설정파일(intf-conf/gpki.conf)을 로드한다.
|
|
|
|
|
* 설정 항목은 JSON 포맷으로 된 다음 내용을 적재한다.
|
|
|
|
|
* <pre><code> {
|
|
|
|
@ -305,7 +322,9 @@ public class GPKI extends AbstractComponent {
|
|
|
|
|
charset,
|
|
|
|
|
license,
|
|
|
|
|
ldapUrl,
|
|
|
|
|
certDir;
|
|
|
|
|
certDir,
|
|
|
|
|
targetCert;
|
|
|
|
|
|
|
|
|
|
private Map<String, String>
|
|
|
|
|
server,
|
|
|
|
|
env,
|
|
|
|
@ -381,6 +400,24 @@ public class GPKI extends AbstractComponent {
|
|
|
|
|
this.certDir = certDir;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**targetCert을(를) 반환한다.
|
|
|
|
|
* @return targetCert
|
|
|
|
|
*/
|
|
|
|
|
public String getTargetCert() {
|
|
|
|
|
return ifEmpty(targetCert, () -> "{serverID}.cer");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String targetCert(String serverID) {
|
|
|
|
|
return getTargetCert().replace("{serverID}", serverID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**targetCert을(를) 설정한다.
|
|
|
|
|
* @param targetCert targetCert
|
|
|
|
|
*/
|
|
|
|
|
public void setTargetCert(String targetCert) {
|
|
|
|
|
this.targetCert = targetCert;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**server을(를) 반환한다.
|
|
|
|
|
* @return server
|
|
|
|
|
*/
|
|
|
|
|