+ private ExtendedHttpService waitForHttpService() {
+ final ServiceTracker<ExtendedHttpService, ExtendedHttpService> st = new ServiceTracker<ExtendedHttpService, ExtendedHttpService>(
+ bundleContext, ExtendedHttpService.class, null);
+ st.open();
+ ExtendedHttpService httpService;
+ try {
+ httpService = st.waitForService(1000);
+ } catch (InterruptedException e) {
+ httpService = null;
+ }
+
+ if (httpService == null)
+ throw new CmsException("Could not find "
+ + ExtendedHttpService.class + " service.");
+ return httpService;
+ }
+
+ private void createKeyStoreIfNeeded() {
+ char[] ksPwd = "changeit".toCharArray();
+ char[] keyPwd = Arrays.copyOf(ksPwd, ksPwd.length);
+ File keyStoreFile = KernelUtils.getOsgiConfigurationFile("node.p12");
+ if (!keyStoreFile.exists()) {
+ try {
+ KeyStore keyStore = PkiUtils.getKeyStore(keyStoreFile, ksPwd);
+ X509Certificate cert = PkiUtils.generateSelfSignedCertificate(
+ keyStore, new X500Principal(KernelHeader.ROLE_KERNEL),
+ keyPwd);
+ PkiUtils.saveKeyStore(keyStoreFile, ksPwd, keyStore);
+
+ } catch (Exception e) {
+ throw new CmsException("Cannot create key store "
+ + keyStoreFile, e);
+ }
+ }
+ }
+
+ final private static void directorsCut(long initDuration) {
+ // final long ms = 128l + (long) (Math.random() * 128d);
+ long ms = initDuration / 100;