Search in sources :

Example 36 with ConfPairs

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;
    }
}
Also used : ConfPairs(org.xipki.common.ConfPairs) IOException(java.io.IOException)

Example 37 with ConfPairs

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);
}
Also used : ConfPairs(org.xipki.common.ConfPairs)

Example 38 with ConfPairs

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());
}
Also used : ConfPairs(org.xipki.common.ConfPairs)

Aggregations

ConfPairs (org.xipki.common.ConfPairs)38 HashMap (java.util.HashMap)8 Test (org.junit.Test)7 X509CaEntry (org.xipki.ca.server.mgmt.api.x509.X509CaEntry)5 IOException (java.io.IOException)4 CertificateException (java.security.cert.CertificateException)4 X509Certificate (java.security.cert.X509Certificate)4 SQLException (java.sql.SQLException)4 NameId (org.xipki.ca.api.NameId)4 CertValidity (org.xipki.ca.api.profile.CertValidity)4 CaMgmtException (org.xipki.ca.server.mgmt.api.CaMgmtException)4 ValidityMode (org.xipki.ca.server.mgmt.api.ValidityMode)4 DataAccessException (org.xipki.datasource.DataAccessException)4 SignerConf (org.xipki.security.SignerConf)4 XiSecurityException (org.xipki.security.exception.XiSecurityException)4 PreparedStatement (java.sql.PreparedStatement)3 OperationException (org.xipki.ca.api.OperationException)3 CaStatus (org.xipki.ca.server.mgmt.api.CaStatus)3 X509CaUris (org.xipki.ca.server.mgmt.api.x509.X509CaUris)3 X509ChangeCaEntry (org.xipki.ca.server.mgmt.api.x509.X509ChangeCaEntry)3