@Before
    public void setUp() throws Exception {
        ehCacheManager = CacheManager.newInstance();
        File targetDir = new File("target");
        partition = initLdapTestSetup(
            PARTITION_NAME,
            targetDir,
            ehCacheManager,
            getLdapServer().getDirectoryService()
        );
        injectLdifFiles(
            getLdapServer().getDirectoryService(),
            "io/apiman/gateway/engine/policies/users.ldif"
        );

        Path keyStorePath = Paths.get(targetDir.getAbsolutePath(), LDAP_KEYSTORE).toAbsolutePath();
        // Init (delete if exist) key store for ldaps server
        Files.deleteIfExists(keyStorePath);

        // Get LDAP Root entry
        Entry entry = service.getAdminSession().lookup(partition.getSuffixDn());

        // Add private KeyPair and a self-signed certificate corresponding to the entry.
        // Importantly, we generate a large key to ensure that we aren't hit by security policy limitations that
        // have banned RSA keys with a short length (the default of the underlying library, currently, if you
        // call TlsKeyGenerator.addKeyPair#entry(Entry) without additional arguments)
        String hostName = InetAddress.getLocalHost().getHostName();
        TlsKeyGenerator.addKeyPair(entry, "CN=" + hostName + ", OU=Directory, O=Apiman, C=World",
             "CN=" + hostName + ", OU=Directory, O=ASF, C=World",
             "RSA", 4096);
        KeyPair keyPair = TlsKeyGenerator.getKeyPair(entry);
        X509Certificate cert = TlsKeyGenerator.getCertificate(entry);

        // Add generated certificate to the keystore
        KeyStore keyStore = KeyStore.getInstance("JKS");
        keyStore.load(null, null);
        keyStore.setCertificateEntry("apacheds", cert);
        keyStore.setKeyEntry("apacheds", keyPair.getPrivate(),
             LDAP_KEYSTORE_PASSWD.toCharArray(),
             new Certificate[]{cert});
        keyStore.store(new FileOutputStream(keyStorePath.toFile()), LDAP_KEYSTORE_PASSWD.toCharArray());

        if (Files.notExists(keyStorePath)) {
            throw new IOException(String.format("Keystore [%s] doesn't exist.", keyStorePath));
        }

        this.ldapComponent = new DefaultLdapComponent();
        overrideDefaultTrustStore(keyStorePath, ldapComponent);
    }
Fires up an ldaps server to do a better job testing the basic auth
policy when configured for ldaps.

@author jhauray
gateway/engine/policies/src/test/java/io/apiman/gateway/engine/policies/BasicAuthLDAPSTest.java