本文整理了Java中ch.cyberduck.core.Protocol.getScheme()
方法的一些代码示例,展示了Protocol.getScheme()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Protocol.getScheme()
方法的具体详情如下:
包路径:ch.cyberduck.core.Protocol
类名称:Protocol
方法名:getScheme
暂无
代码示例来源:origin: iterate-ch/cyberduck
@Override
public boolean isHttps() {
return bookmark.getProtocol().getScheme() == Scheme.https;
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public Scheme getScheme() {
final String v = this.value("Scheme");
if(StringUtils.isBlank(v)) {
return parent.getScheme();
}
try {
return Scheme.valueOf(v);
}
catch(IllegalArgumentException e) {
log.warn(String.format("Unknown scheme %s", v));
return null;
}
}
代码示例来源:origin: iterate-ch/cyberduck
public HostKeyCallback create(final Controller c, final Protocol protocol) {
if(Scheme.sftp.equals(protocol.getScheme())) {
try {
if(null == constructor) {
constructor = ConstructorUtils.getMatchingAccessibleConstructor(clazz, c.getClass());
}
if(null == constructor) {
log.warn(String.format("No matching constructor for parameter %s", c.getClass()));
// Call default constructor for disabled implementations
return clazz.newInstance();
}
return constructor.newInstance(c);
}
catch(InstantiationException | InvocationTargetException | IllegalAccessException e) {
log.error(String.format("Failure loading callback class %s. %s", clazz, e.getMessage()));
return new DisabledHostKeyCallback();
}
}
return new DisabledHostKeyCallback();
}
代码示例来源:origin: iterate-ch/cyberduck
private String toURL(final Host host) {
StringBuilder url = new StringBuilder(host.getProtocol().getScheme().toString());
url.append("://");
url.append(new PunycodeConverter().convert(host.getHostname()));
url.append(":").append(host.getPort());
return url.toString();
}
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public Credentials getCredentials(final String username) {
// Resolve access key id
final String key = PreferencesFactory.get().getProperty(String.format("%s%s", prefix, username));
if(log.isDebugEnabled()) {
log.debug(String.format("Lookup access key for user %s with %s", username, key));
}
if(null == key) {
log.warn(String.format("No access key found for user %s", username));
return null;
}
return new Credentials(key, PasswordStoreFactory.get().getPassword(bookmark.getProtocol().getScheme(), bookmark.getPort(),
bookmark.getHostname(), key));
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public String findLoginToken(final Host bookmark) {
if(StringUtils.isEmpty(bookmark.getHostname())) {
log.warn("No hostname given");
return null;
}
if(log.isInfoEnabled()) {
log.info(String.format("Fetching login token from keychain for %s", bookmark));
}
// Find token named like "Shared Access Signature (SAS) Token"
final String token = this.getPassword(bookmark.getProtocol().getScheme(), bookmark.getPort(),
bookmark.getHostname(), bookmark.getProtocol().getTokenPlaceholder());
if(null == token) {
if(log.isInfoEnabled()) {
log.info(String.format("Token not found in keychain for %s", bookmark));
}
}
return token;
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public String getBaseURL() {
return String.format("%s://%s%s", host.getProtocol().getScheme(), host.getHostname(), host.getProtocol().getContext());
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public Host find(final Location.Name region, final boolean tls) {
final Protocol protocol;
if(tls) {
protocol = new UDTTLSProtocol();
}
else {
protocol = new UDTProtocol();
}
return new Host(protocol, String.format("%s.qloudsonic.io",
region.getIdentifier()), protocol.getScheme().getPort());
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public OAuthTokens findOAuthTokens(final Host bookmark) {
final long expiry = preferences.getLong(String.format("%s.oauth.expiry", bookmark.getProtocol().getIdentifier()));
final String prefix = this.getOAuthPrefix(bookmark);
return new OAuthTokens(this.getPassword(bookmark.getProtocol().getScheme(),
bookmark.getPort(), URI.create(bookmark.getProtocol().getOAuthTokenUrl()).getHost(),
String.format("%s OAuth2 Access Token", prefix)),
this.getPassword(bookmark.getProtocol().getScheme(),
bookmark.getPort(), URI.create(bookmark.getProtocol().getOAuthTokenUrl()).getHost(),
String.format("%s OAuth2 Refresh Token", prefix)),
expiry);
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public Credentials getCredentials(final String username) {
// Ignore user but use username from host credentials
final String user = host.getCredentials().getUsername();
final String password = store.getPassword(host.getProtocol().getScheme(), host.getPort(), host.getHostname(), user);
if(StringUtils.isEmpty(password)) {
return null;
}
return new Credentials(user, password);
}
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public boolean equals(Object o) {
if(this == o) {
return true;
}
if(!(o instanceof Protocol)) {
return false;
}
Protocol protocol = (Protocol) o;
if(this.getIdentifier() != null ? !this.getIdentifier().equals(protocol.getIdentifier()) : protocol.getIdentifier() != null) {
return false;
}
if(this.getScheme() != null ? !this.getScheme().equals(protocol.getScheme()) : protocol.getScheme() != null) {
return false;
}
if(this.getProvider() != null ? !this.getProvider().equals(protocol.getProvider()) : protocol.getProvider() != null) {
return false;
}
return true;
}
代码示例来源:origin: iterate-ch/cyberduck
public boolean alert(final ConnectionCallback callback) throws BackgroundException {
if(host.getProtocol().isSecure()) {
return false;
}
if(host.getCredentials().isAnonymousLogin()) {
return false;
}
final Preferences preferences = PreferencesFactory.get();
if(preferences.getBoolean(String.format("connection.unsecure.%s", host.getHostname()))) {
return false;
}
return preferences.getBoolean(
String.format("connection.unsecure.warning.%s", host.getProtocol().getScheme()));
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public HttpClientBuilder build(final Proxy proxy, final TranscriptListener listener, final LoginCallback prompt) {
final HttpClientBuilder builder = super.build(proxy, listener, prompt);
// Add filter to inject custom headers to authenticate with proxy
builder.setRequestExecutor(
new CustomHeaderHttpRequestExecutor(headers)
);
// Set proxy router planer
builder.setRoutePlanner(new DefaultProxyRoutePlanner(
new HttpHost(this.proxy.getHostname(), this.proxy.getPort(), this.proxy.getProtocol().getScheme().name()),
new DefaultSchemePortResolver()));
return builder;
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public DescriptiveUrlBag toUrl(final Path file) {
final String nodeid = file.isDirectory() ? file.attributes().getVersionId() : file.getParent().attributes().getVersionId();
if(StringUtils.isBlank(nodeid)) {
return DescriptiveUrlBag.empty();
}
return new DescriptiveUrlBag(Collections.singletonList(
new DescriptiveUrl(URI.create(String.format("%s/#/node/%s",
new HostUrlProvider().withUsername(false).get(session.getHost()), URIEncoder.encode(
nodeid
))),
DescriptiveUrl.Type.http,
MessageFormat.format(LocaleFactory.localizedString("{0} URL"), session.getHost().getProtocol().getScheme().toString().toUpperCase(Locale.ROOT)))
));
}
}
代码示例来源:origin: iterate-ch/cyberduck
/**
* @return URL
*/
public String get(final Host bookmark) {
final Scheme scheme = bookmark.getProtocol().getScheme();
final int port = bookmark.getPort();
final String username = bookmark.getCredentials().getUsername();
final String hostname = bookmark.getHostname();
final String path = bookmark.getDefaultPath();
return this.get(scheme, port, username, hostname, path);
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public String get(final Host bookmark) {
switch(bookmark.getProtocol().getScheme()) {
case sftp:
return super.get(Scheme.ftp, bookmark.getPort(), bookmark.getCredentials().getUsername(), bookmark.getHostname(), bookmark.getDefaultPath());
}
return super.get(bookmark);
}
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public DescriptiveUrlBag toUrl(final Path file) {
final DescriptiveUrlBag list = new DescriptiveUrlBag();
if(file.attributes().getLink() != null) {
list.add(file.attributes().getLink());
}
list.add(new DescriptiveUrl(URI.create(String.format("%s%s",
new HostUrlProvider().withUsername(false).get(host), URIEncoder.encode(file.getAbsolute()))),
DescriptiveUrl.Type.provider,
MessageFormat.format(LocaleFactory.localizedString("{0} URL"), host.getProtocol().getScheme().toString().toUpperCase(Locale.ROOT))));
list.addAll(new WebUrlProvider(host).toUrl(file));
return list;
}
}
代码示例来源:origin: iterate-ch/cyberduck
@Override
public void change(final Host bookmark) {
updateField(passwordField, credentials.getPassword());
passwordField.cell().setPlaceholderString(options.getPasswordPlaceholder());
passwordField.setEnabled(options.password && !credentials.isAnonymousLogin());
if(options.keychain) {
if(StringUtils.isBlank(bookmark.getHostname())) {
return;
}
if(StringUtils.isBlank(credentials.getUsername())) {
return;
}
final String password = keychain.getPassword(bookmark.getProtocol().getScheme(),
bookmark.getPort(),
bookmark.getHostname(),
credentials.getUsername());
if(StringUtils.isNotBlank(password)) {
credentials.setPassword(password);
updateField(passwordField, password);
}
}
}
});
代码示例来源:origin: iterate-ch/cyberduck
public OAuth2RequestInterceptor(final HttpClient client, final Host host) {
this(client,
Scheme.isURL(host.getProtocol().getOAuthTokenUrl()) ? host.getProtocol().getOAuthTokenUrl() : new HostUrlProvider().withUsername(false).withPath(true).get(
host.getProtocol().getScheme(), host.getPort(), null, host.getHostname(), host.getProtocol().getOAuthTokenUrl()),
Scheme.isURL(host.getProtocol().getOAuthAuthorizationUrl()) ? host.getProtocol().getOAuthAuthorizationUrl() : new HostUrlProvider().withUsername(false).withPath(true).get(
host.getProtocol().getScheme(), host.getPort(), null, host.getHostname(), host.getProtocol().getOAuthAuthorizationUrl()),
host.getProtocol().getOAuthClientId(),
host.getProtocol().getOAuthClientSecret(),
host.getProtocol().getOAuthScopes());
}
代码示例来源:origin: iterate-ch/cyberduck
public MantaSession(final Host host, final X509TrustManager trust, final X509KeyManager key) {
super(host, new ThreadLocalHostnameDelegatingTrustManager(new DisabledX509TrustManager(), host.getHostname()), key);
config = new AuthAwareConfigContext(new ChainedConfigContext(
new DefaultsConfigContext(),
new StandardConfigContext()
.setNoAuth(true)
.setMantaKeyPath(null)
.setHttpsProtocols(PreferencesFactory.get().getProperty("connection.ssl.protocols"))
.setDisableNativeSignatures(true)
.setMantaUser(host.getCredentials().getUsername())
.setMantaURL(String.format("%s://%s", host.getProtocol().getScheme().name(), host.getHostname()))
));
}
内容来源于网络,如有侵权,请联系作者删除!