use of ch.cyberduck.core.preferences.Preferences in project cyberduck by iterate-ch.
the class BundleLocale method setDefault.
@Override
public void setDefault(final String language) {
final Preferences preferences = PreferencesFactory.get();
if (null == language) {
// Revert to system default language
preferences.deleteProperty("AppleLanguages");
} else {
preferences.setProperty("AppleLanguages", Collections.singletonList(language));
}
cache.clear();
}
use of ch.cyberduck.core.preferences.Preferences in project cyberduck by iterate-ch.
the class CertificateStoreX509KeyManager method getKeystore.
private synchronized KeyStore getKeystore() throws IOException {
String type = null;
try {
if (null == keystore) {
// Get the key manager factory for the default algorithm.
final Preferences preferences = PreferencesFactory.get();
type = preferences.getProperty("connection.ssl.keystore.type");
if (log.isInfoEnabled()) {
log.info(String.format("Load default store of type %s", type));
}
if (null == type) {
type = KeyStore.getDefaultType();
}
final String provider = preferences.getProperty("connection.ssl.keystore.provider");
if (StringUtils.isBlank(provider)) {
keystore = KeyStore.getInstance(type);
} else {
keystore = KeyStore.getInstance(type, provider);
}
// Load default key store
keystore.load(null, null);
}
} catch (Exception e) {
try {
log.error(String.format("Could not load default store of type %s", type), e);
if (log.isInfoEnabled()) {
log.info("Load default store of default type");
}
keystore = KeyStore.getInstance(KeyStore.getDefaultType());
keystore.load(null, null);
} catch (NoSuchAlgorithmException | KeyStoreException | CertificateException ex) {
log.error(String.format("Initialization of key store failed. %s", e.getMessage()));
throw new IOException(e);
}
}
return keystore;
}
use of ch.cyberduck.core.preferences.Preferences in project cyberduck by iterate-ch.
the class TerminalHelpPrinter method print.
public static void print(final Options options, final HelpFormatter formatter) {
formatter.setSyntaxPrefix("Usage:");
final Preferences preferences = PreferencesFactory.get();
final StringBuilder builder = new StringBuilder().append("Default protocols").append(StringUtils.LF);
final ProtocolFactory protocols = ProtocolFactory.get();
for (Protocol p : protocols.find(new DefaultProtocolPredicate(EnumSet.of(Protocol.Type.ftp, Protocol.Type.sftp, Protocol.Type.dav)))) {
append(p, builder);
}
builder.append(StringUtils.LF);
for (Protocol p : protocols.find(new DefaultProtocolPredicate(EnumSet.of(Protocol.Type.s3, Protocol.Type.swift, Protocol.Type.azure, Protocol.Type.b2, Protocol.Type.googlestorage)))) {
append(p, builder);
}
builder.append(StringUtils.LF);
for (Protocol p : protocols.find(new DefaultProtocolPredicate(EnumSet.of(Protocol.Type.dropbox, Protocol.Type.onedrive, Protocol.Type.googledrive, Protocol.Type.nextcloud, Protocol.Type.owncloud, Protocol.Type.dracoon, Protocol.Type.brick)))) {
append(p, builder);
}
builder.append("Local Disk");
builder.append(StringUtils.LF);
for (Protocol p : protocols.find(new DefaultProtocolPredicate(EnumSet.of(Protocol.Type.file)))) {
append(p, builder);
}
builder.append(StringUtils.LF);
builder.append(String.format("Third party connection profiles. Install additional connection profiles in %s", LocalFactory.get(SupportDirectoryFinderFactory.get().find(), PreferencesFactory.get().getProperty("profiles.folder.name")).getAbbreviatedPath()));
builder.append(StringUtils.LF);
for (Protocol p : protocols.find(new ProfileProtocolPredicate())) {
append(p, builder);
}
final StringBuilder header = new StringBuilder(StringUtils.LF).append("\t").append("URLs must be fully qualified. Paths can either denote " + "a remote file (ftps://user@example.net/resource) or folder (ftps://user@example.net/directory/) " + "with a trailing slash. You can reference files relative to your home directory with /~ (ftps://user@example.net/~/).").append(StringUtils.LF).append(builder).append(StringUtils.LF).append(StringUtils.LF);
final StringBuilder footer = new StringBuilder(StringUtils.LF);
footer.append(String.format("Cyberduck is libre software licenced under the GPL. For general help about using Cyberduck, please refer to %s and the wiki at %s. For bug reports or feature requests open a ticket at %s.", preferences.getProperty("website.cli"), preferences.getProperty("website.help"), MessageFormat.format(preferences.getProperty("website.bug"), preferences.getProperty("application.version"))));
final License l = LicenseFactory.find();
footer.append(StringUtils.LF);
if (l.verify(new DisabledLicenseVerifierCallback())) {
footer.append(l.toString());
} else {
footer.append("Not registered. Purchase a donation key to support the development of this software.");
}
formatter.printHelp("duck [options...]", header.toString(), options, footer.toString());
}
use of ch.cyberduck.core.preferences.Preferences in project cyberduck by iterate-ch.
the class ProtocolFactoryTest method testRegisterUnregisterIsEnabled.
@Test
public void testRegisterUnregisterIsEnabled() throws Exception {
Preferences preferences = new MemoryPreferences();
PreferencesFactory.set(preferences);
final ProtocolFactory factory = new ProtocolFactory(Stream.of(new TestProtocol() {
@Override
public Type getType() {
return Type.s3;
}
@Override
public boolean isEnabled() {
return false;
}
}).collect(Collectors.toSet()));
final ProfilePlistReader reader = new ProfilePlistReader(factory);
final Local file = new Local("src/test/resources/Test S3 (HTTP).cyberduckprofile");
Profile profile = reader.read(file);
factory.register(file);
assertTrue(profile.isEnabled());
factory.unregister(profile);
assertFalse(profile.isEnabled());
assertTrue(file.exists());
}
use of ch.cyberduck.core.preferences.Preferences in project cyberduck by iterate-ch.
the class MainApplication method main.
public static void main(String... arguments) {
final ActionOperationBatcher autorelease = new AutoreleaseActionOperationBatcher(1);
try {
// This method also makes a connection to the window server and completes other initialization.
// Your program should invoke this method as one of the first statements in main();
// The NSApplication class sets up autorelease pools (instances of the NSAutoreleasePool class)
// during initialization and inside the event loop—specifically, within its initialization
// (or sharedApplication) and run methods.
final NSApplication app = NSApplication.sharedApplication();
// Register factory implementations.
final Preferences preferences = new ApplicationUserDefaultsPreferences();
PreferencesFactory.set(preferences);
final ProtocolFactory protocols = ProtocolFactory.get();
protocols.register(new FTPProtocol(), new FTPTLSProtocol(), new SFTPProtocol(), new DAVProtocol(), new DAVSSLProtocol(), new SwiftProtocol(), new S3Protocol(), new GoogleStorageProtocol(), new AzureProtocol(), new IRODSProtocol(), new SpectraProtocol(), new B2Protocol(), new DropboxProtocol(), new DriveProtocol(), new HubicProtocol(), new OneDriveProtocol(), new SharepointProtocol(), new SharepointSiteProtocol(), new LocalProtocol(), new MantaProtocol(), new SDSProtocol(), new StoregateProtocol(), new BrickProtocol(), new NextcloudProtocol(), new OwncloudProtocol(), new CteraProtocol(), new BoxProtocol());
protocols.load();
final MainController c = new MainController();
// Must implement NSApplicationDelegate protocol
app.setDelegate(c.id());
// When the Finder launches an app, using a value of NO for flag allows the app to become active if the user waits for it to launch
app.activateIgnoringOtherApps(false);
// Starts the main event loop. The loop continues until a stop: or terminate: message is
// received. Upon each iteration through the loop, the next available event
// from the window server is stored and then dispatched by sending it to NSApp using sendEvent:.
// The global application object uses autorelease pools in its run method.
app.run();
} finally {
autorelease.operate();
}
}
Aggregations