use of com.helger.commons.lang.NonBlockingProperties in project ph-web by phax.
the class AbstractScpTestBase method initializeClass.
@BeforeClass
public static void initializeClass() {
try (final InputStream inputStream = ClassLoader.getSystemResourceAsStream("configuration.properties")) {
Assume.assumeNotNull(inputStream);
s_aProperties = new NonBlockingProperties();
s_aProperties.load(inputStream);
} catch (final IOException e) {
LOGGER.warn("cant find properties file (tests will be skipped): " + e.getMessage());
s_aProperties = null;
return;
}
final String knownHosts = s_aProperties.getProperty("ssh.knownHosts");
final String privateKey = s_aProperties.getProperty("ssh.privateKey");
s_sScpPath = s_aProperties.getProperty("scp.out.test.scpPath");
s_sFileSystemPath = s_aProperties.getProperty("scp.out.test.filesystemPath");
final String username = s_aProperties.getProperty("scp.out.test.username");
final String hostname = "localhost";
final int port = Integer.parseInt(s_aProperties.getProperty("scp.out.test.port"));
final DefaultSessionFactory defaultSessionFactory = new DefaultSessionFactory(username, hostname, port);
try {
defaultSessionFactory.setKnownHosts(knownHosts);
defaultSessionFactory.setIdentityFromPrivateKey(privateKey);
} catch (final JSchException e) {
Assume.assumeNoException(e);
}
s_aSessionFactory = defaultSessionFactory;
}
use of com.helger.commons.lang.NonBlockingProperties in project ph-web by phax.
the class TunnelConnectionTest method initializeClass.
@BeforeClass
public static void initializeClass() {
try (final InputStream inputStream = ClassLoader.getSystemResourceAsStream("configuration.properties")) {
Assume.assumeNotNull(inputStream);
properties = new NonBlockingProperties();
properties.load(inputStream);
} catch (final IOException e) {
LOGGER.warn("cant find properties file (tests will be skipped)", e);
properties = null;
return;
}
final String knownHosts = properties.getProperty("ssh.knownHosts");
final String privateKey = properties.getProperty("ssh.privateKey");
final String username = properties.getProperty("scp.out.test.username");
final String hostname = "localhost";
final int port = Integer.parseInt(properties.getProperty("scp.out.test.port"));
final DefaultSessionFactory defaultSessionFactory = new DefaultSessionFactory(username, hostname, port);
try {
defaultSessionFactory.setKnownHosts(knownHosts);
defaultSessionFactory.setIdentityFromPrivateKey(privateKey);
} catch (final JSchException e) {
LOGGER.error("Failed to configure default session, skipping tests", e);
Assume.assumeNoException(e);
}
sessionFactory = defaultSessionFactory;
}
use of com.helger.commons.lang.NonBlockingProperties in project phase4 by phax.
the class AS4CryptoProperties method _setProperty.
private void _setProperty(@Nonnull final String sName, @Nullable final String sValue) {
ValueEnforcer.notNull(sName, "Name");
NonBlockingProperties aProps = m_aProps;
if (sValue == null) {
// Remove property
if (aProps != null)
aProps.remove(sName);
} else {
// Set property
if (aProps == null)
aProps = m_aProps = new NonBlockingProperties();
aProps.put(sName, sValue);
}
}
use of com.helger.commons.lang.NonBlockingProperties in project ph-commons by phax.
the class SettingsPersistenceProperties method writeSettings.
@Nonnull
public ESuccess writeSettings(@Nonnull final ISettings aSettings, @Nonnull @WillClose final OutputStream aOS) {
ValueEnforcer.notNull(aOS, "OutputStream");
try {
final NonBlockingProperties aProps = new NonBlockingProperties();
// Must not be sorted, as Properties sorts them as it wishes...
for (final Map.Entry<String, Object> aEntry : aSettings.entrySet()) {
final String sName = aEntry.getKey();
final Object aValue = aEntry.getValue();
if (aValue instanceof ISettings)
throw new IllegalArgumentException("When saving settings to a Properties object, it may not contained nested settings! Now the key '" + sName + "' is mapped to a nested ISettings object!");
final String sValue = TypeConverter.convert(aValue, String.class);
aProps.put(sName, sValue);
}
// Does not close the output stream!
aProps.store(aOS, aSettings.getName());
return ESuccess.SUCCESS;
} catch (final IOException ex) {
LOGGER.error("Failed to write settings to properties file", ex);
return ESuccess.FAILURE;
} finally {
StreamHelper.close(aOS);
}
}
use of com.helger.commons.lang.NonBlockingProperties in project ph-web by phax.
the class ConnectionTest method initializeClass.
@BeforeClass
public static void initializeClass() {
NonBlockingProperties properties = null;
try (final InputStream inputStream = ClassLoader.getSystemResourceAsStream("configuration.properties")) {
Assume.assumeNotNull(inputStream);
properties = new NonBlockingProperties();
properties.load(inputStream);
} catch (final IOException e) {
LOGGER.warn("cant find properties file (tests will be skipped)", e);
Assume.assumeNoException(e);
}
username = properties.getProperty("scp.out.test.username");
hostname = properties.getProperty("scp.out.test.host");
correctPassword = properties.getProperty("scp.out.test.password");
port = Integer.parseInt(properties.getProperty("scp.out.test.port"));
incorrectPassword = correctPassword + ".";
}
Aggregations