use of org.xipki.common.ConfPairs in project xipki by xipki.
the class SignerConf method eraseSensitiveData.
private static String eraseSensitiveData(String conf) {
if (conf == null || !conf.contains("password?")) {
return conf;
}
try {
ConfPairs pairs = new ConfPairs(conf);
String value = pairs.value("password");
if (value != null && !StringUtil.startsWithIgnoreCase(value, "PBE:")) {
pairs.putPair("password", "<sensitive>");
}
return pairs.getEncoded();
} catch (Exception ex) {
return conf;
}
}
use of org.xipki.common.ConfPairs in project xipki by xipki.
the class SignerConf method getKeystoreSignerConf.
public static SignerConf getKeystoreSignerConf(String keystoreFile, String password, HashAlgo hashAlgo, SignatureAlgoControl signatureAlgoControl) {
ParamUtil.requireNonBlank("keystoreFile", keystoreFile);
ParamUtil.requireNonBlank("password", password);
ParamUtil.requireNonNull("hashAlgo", hashAlgo);
ConfPairs conf = new ConfPairs("password", password);
conf.putPair("parallelism", "1");
conf.putPair("keystore", "file:" + keystoreFile);
return new SignerConf(conf.getEncoded(), hashAlgo, signatureAlgoControl);
}
use of org.xipki.common.ConfPairs in project xipki by xipki.
the class SignerConf method getPkcs11SignerConf.
public static SignerConf getPkcs11SignerConf(String pkcs11ModuleName, Integer slotIndex, Long slotId, String keyLabel, byte[] keyId, String signatureAlgorithm, int parallelism) {
ParamUtil.requireMin("parallelism", parallelism, 1);
ParamUtil.requireNonNull("algo", signatureAlgorithm);
if (slotIndex == null && slotId == null) {
throw new IllegalArgumentException("at least one of slotIndex and slotId must not be null");
}
if (keyId == null && keyLabel == null) {
throw new IllegalArgumentException("at least one of keyId and keyLabel must not be null");
}
ConfPairs conf = new ConfPairs("algo", signatureAlgorithm);
conf.putPair("parallelism", Integer.toString(parallelism));
if (pkcs11ModuleName != null && pkcs11ModuleName.length() > 0) {
conf.putPair("module", pkcs11ModuleName);
}
if (slotId != null) {
conf.putPair("slot-id", slotId.toString());
}
if (slotIndex != null) {
conf.putPair("slot", slotIndex.toString());
}
if (keyId != null) {
conf.putPair("key-id", Hex.encode(keyId));
}
if (keyLabel != null) {
conf.putPair("key-label", keyLabel);
}
return new SignerConf(conf.getEncoded());
}
Aggregations