Search in sources :

Example 6 with ConfPairs

use of org.xipki.common.ConfPairs in project xipki by xipki.

the class HttpsHostnameVerifier method setCommonnameHostMap.

public void setCommonnameHostMap(String commonnameHostMap) {
    hostnameMap.clear();
    if (StringUtil.isBlank(commonnameHostMap)) {
        return;
    }
    ConfPairs pairs = new ConfPairs(commonnameHostMap);
    Set<String> commonNames = pairs.names();
    for (String commonName : commonNames) {
        String str = pairs.value(commonName);
        Set<String> hosts = StringUtil.splitAsSet(str, ",; \t");
        hostnameMap.put(commonName, hosts);
    }
}
Also used : ConfPairs(org.xipki.common.ConfPairs)

Example 7 with ConfPairs

use of org.xipki.common.ConfPairs in project xipki by xipki.

the class P12CertUpdateCmd method assertMatch.

private void assertMatch(X509Certificate cert, String password) throws ObjectCreationException {
    ConfPairs pairs = new ConfPairs("keystore", "file:" + p12File);
    if (password != null) {
        pairs.putPair("password", new String(password));
    }
    SignerConf conf = new SignerConf(pairs.getEncoded(), HashAlgo.SHA256, null);
    securityFactory.createSigner("PKCS12", conf, cert);
}
Also used : ConfPairs(org.xipki.common.ConfPairs) SignerConf(org.xipki.security.SignerConf)

Example 8 with ConfPairs

use of org.xipki.common.ConfPairs in project xipki by xipki.

the class DemoX509Certprofile method getExtraExtensions.

@Override
public ExtensionValues getExtraExtensions(Map<ASN1ObjectIdentifier, ExtensionControl> extensionOccurences, X500Name requestedSubject, X500Name grantedSubject, Extensions requestedExtensions, Date notBefore, Date notAfter, PublicCaInfo caInfo) throws CertprofileException, BadCertTemplateException {
    ExtensionValues extnValues = new ExtensionValues();
    if (addCaExtraControl) {
        ASN1ObjectIdentifier type = id_demo_ca_extra_control;
        ExtensionControl extnControl = extensionOccurences.get(type);
        if (extnControl != null) {
            ConfPairs caExtraControl = caInfo.getExtraControl();
            String name = "name-a";
            String value = null;
            if (caExtraControl != null) {
                value = caExtraControl.value(name);
            }
            if (value == null) {
                value = "UNDEF";
            }
            ExtensionValue extnValue = new ExtensionValue(extnControl.isCritical(), new DERUTF8String(name + ": " + value));
            extnValues.addExtension(type, extnValue);
        }
    }
    if (addSequence) {
        ASN1ObjectIdentifier type = id_demo_other_namespace;
        ExtensionControl extnControl = extensionOccurences.get(type);
        if (extnControl != null) {
            if (sequence == null) {
                throw new IllegalStateException("CertProfile is not initialized");
            }
            ExtensionValue extnValue = new ExtensionValue(extnControl.isCritical(), sequence);
            extnValues.addExtension(type, extnValue);
        }
    }
    return extnValues.size() == 0 ? null : extnValues;
}
Also used : DERUTF8String(org.bouncycastle.asn1.DERUTF8String) ExtensionValue(org.xipki.ca.api.profile.ExtensionValue) ExtensionControl(org.xipki.ca.api.profile.ExtensionControl) ConfPairs(org.xipki.common.ConfPairs) DERUTF8String(org.bouncycastle.asn1.DERUTF8String) ExtensionValues(org.xipki.ca.api.profile.ExtensionValues) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier)

Example 9 with ConfPairs

use of org.xipki.common.ConfPairs in project xipki by xipki.

the class ConfPairsTest method test7.

@Test
public void test7() {
    ConfPairs pairs = new ConfPairs("key-a=value-a\\=\\?");
    String expEncoded = "key-a=value-a\\=?";
    Map<String, String> expNameValues = new HashMap<>();
    expNameValues.put("key-a", "value-a=?");
    check(pairs, expEncoded, expNameValues);
}
Also used : HashMap(java.util.HashMap) ConfPairs(org.xipki.common.ConfPairs) Test(org.junit.Test)

Example 10 with ConfPairs

use of org.xipki.common.ConfPairs in project xipki by xipki.

the class ConfPairsTest method test2.

@Test
public void test2() {
    ConfPairs pairs = new ConfPairs("key-a=value-a");
    String expEncoded = "key-a=value-a";
    Map<String, String> expNameValues = new HashMap<>();
    expNameValues.put("key-a", "value-a");
    check(pairs, expEncoded, expNameValues);
}
Also used : HashMap(java.util.HashMap) ConfPairs(org.xipki.common.ConfPairs) Test(org.junit.Test)

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