ch.cyberduck.core.Protocol类的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(10.6k)|赞(0)|评价(0)|浏览(154)

本文整理了Java中ch.cyberduck.core.Protocol类的一些代码示例,展示了Protocol类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Protocol类的具体详情如下:
包路径:ch.cyberduck.core.Protocol
类名称:Protocol

Protocol介绍

暂无

代码示例

代码示例来源:origin: iterate-ch/cyberduck

@Override
public boolean isHttps() {
  return bookmark.getProtocol().getScheme() == Scheme.https;
}

代码示例来源:origin: iterate-ch/cyberduck

@Override
public String getOAuthRedirectUrl() {
  final String v = this.value("OAuth Redirect Url");
  if(StringUtils.isBlank(v)) {
    return parent.getOAuthRedirectUrl();
  }
  return v;
}

代码示例来源:origin: iterate-ch/cyberduck

public void configure(final Protocol protocol) {
  publickey = protocol.isPrivateKeyConfigurable();
  certificate = protocol.isCertificateConfigurable();
  anonymous = protocol.isAnonymousConfigurable();
  user = protocol.isUsernameConfigurable();
  password = protocol.isPasswordConfigurable();
  token = protocol.isTokenConfigurable();
  oauth = protocol.isOAuthConfigurable();
  icon = protocol.disk();
  usernamePlaceholder = protocol.getUsernamePlaceholder();
  passwordPlaceholder = protocol.getPasswordPlaceholder();
}

代码示例来源: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 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

@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.getContext() != null ? !this.getContext().equals(protocol.getContext()) : protocol.getContext() != null) {
    return false;
  }
  if(this.getAuthorization() != null ? !this.getAuthorization().equals(protocol.getAuthorization()) : protocol.getAuthorization() != null) {
    return false;
  }
  if(this.getProvider() != null ? !this.getProvider().equals(protocol.getProvider()) : protocol.getProvider() != null) {
    return false;
  }
  if(this.getDefaultHostname() != null ? !this.getDefaultHostname().equals(protocol.getDefaultHostname()) : protocol.getDefaultHostname() != null) {
    return false;
  }
  return true;
}

代码示例来源:origin: iterate-ch/cyberduck

@Override
protected SDSApiClient connect(final Proxy proxy, final HostKeyCallback key, final LoginCallback prompt) {
  final HttpClientBuilder configuration = builder.build(proxy, this, prompt);
  switch(SDSProtocol.Authorization.valueOf(host.getProtocol().getAuthorization())) {
    case oauth:
      authorizationService = new OAuth2RequestInterceptor(builder.build(proxy, this, prompt).addInterceptorLast(new HttpRequestInterceptor() {
        host).withRedirectUri(Scheme.isURL(host.getProtocol().getOAuthRedirectUrl()) ? host.getProtocol().getOAuthRedirectUrl() : new HostUrlProvider().withUsername(false).withPath(true).get(
        host.getProtocol().getScheme(), host.getPort(), null, host.getHostname(), host.getProtocol().getOAuthRedirectUrl())
      );
      configuration.setServiceUnavailableRetryStrategy(new OAuth2ErrorResponseInterceptor(authorizationService));
  client.setBasePath(new HostUrlProvider().withUsername(false).withPath(true).get(host.getProtocol().getScheme(), host.getPort(),
    null, host.getHostname(), host.getProtocol().getContext()));
  client.setHttpClient(ClientBuilder.newClient(new ClientConfig()
    .register(new InputStreamProvider())

代码示例来源: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 Set<? extends AuthenticationRequest> getRequest(final Host bookmark, final LoginCallback prompt)
    throws LoginCanceledException {
  final StringBuilder url = new StringBuilder();
  url.append(bookmark.getProtocol().getScheme().toString()).append("://");
  url.append(bookmark.getHostname());
  if(!(bookmark.getProtocol().getScheme().getPort() == bookmark.getPort())) {
    url.append(":").append(bookmark.getPort());
  final String context = PathNormalizer.normalize(bookmark.getProtocol().getContext());
  if(bookmark.getProtocol().getDefaultHostname().endsWith("identity.api.rackspacecloud.com")
    || bookmark.getHostname().endsWith("identity.api.rackspacecloud.com")) {
    return Collections.singleton(new Authentication20RAXUsernameKeyRequest(

代码示例来源: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 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

return;
this.addPassword(bookmark.getProtocol().getScheme(), bookmark.getPort(),
  bookmark.getHostname(), credentials.getUsername(), credentials.getPassword());
this.addPassword(bookmark.getProtocol().getScheme(), bookmark.getPort(),
  bookmark.getHostname(), bookmark.getProtocol().getTokenPlaceholder(), credentials.getToken());
  this.addPassword(bookmark.getProtocol().getScheme(),
    bookmark.getPort(), URI.create(bookmark.getProtocol().getOAuthTokenUrl()).getHost(),
    String.format("%s OAuth2 Access Token", prefix), credentials.getOauth().getAccessToken());
  this.addPassword(bookmark.getProtocol().getScheme(),
    bookmark.getPort(), URI.create(bookmark.getProtocol().getOAuthTokenUrl()).getHost(),
    String.format("%s OAuth2 Refresh Token", prefix), credentials.getOauth().getRefreshToken());
  preferences.setProperty(String.format("%s.oauth.expiry", bookmark.getProtocol().getIdentifier()), credentials.getOauth().getExpiryInMilliseconds());

代码示例来源:origin: iterate-ch/cyberduck

@Override
public String disk() {
  if(null == disk) {
    return parent.disk();
  }
  // Temporary file
  return disk.getAbsolute();
}

代码示例来源:origin: iterate-ch/cyberduck

if(protocol.isAnonymousConfigurable()) {
  username = preferences.getProperty("connection.login.anon.name");
int port = protocol.getDefaultPort();
switch(protocol.getType()) {
  case azure:
  case onedrive:
    if(StringUtils.isNotBlank(protocol.getDefaultHostname())) {
      if(StringUtils.isNotBlank(hostname)) {
          path = PathNormalizer.normalize(hostname) + path;
        hostname = protocol.getDefaultHostname();
if(!protocol.isHostnameConfigurable()) {
  if(StringUtils.isNotBlank(protocol.getDefaultHostname())) {
    hostname = protocol.getDefaultHostname();

代码示例来源:origin: iterate-ch/cyberduck

session.getFeature(AnalyticsProvider.class).getSetup(session.getHost().getProtocol().getDefaultHostname(),
    session.getHost().getProtocol().getScheme(), file, credentials)
));

代码示例来源:origin: iterate-ch/cyberduck

log.debug(String.format("Protocol selection changed to %s", selected));
bookmark.setPort(selected.getDefaultPort());
if(!bookmark.getProtocol().isHostnameConfigurable()) {
  bookmark.setHostname(selected.getDefaultHostname());
if(!selected.isHostnameConfigurable()) {
  bookmark.setHostname(selected.getDefaultHostname());
if(StringUtils.isNotBlank(selected.getDefaultHostname())) {
  bookmark.setHostname(selected.getDefaultHostname());
if(Objects.equals(bookmark.getDefaultPath(), bookmark.getProtocol().getDefaultPath()) ||
  !selected.isPathConfigurable()) {
  bookmark.setDefaultPath(selected.getDefaultPath());

代码示例来源: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

final String password = host.getCredentials().getPassword();
switch(SDSProtocol.Authorization.valueOf(host.getProtocol().getAuthorization())) {
  case oauth:
    authorizationService.setTokens(authorizationService.authorize(host, controller, cancel));
      LocaleFactory.localizedString("Multi-Factor Authentication", "S3"),
      new LoginOptions()
        .icon(host.getProtocol().disk())
        .user(false)
        .keychain(false)
      .authType(LoginRequest.AuthTypeEnum.fromValue(host.getProtocol().getAuthorization()))
      .login(login)
      .password(additional.getPassword())
      .authType(LoginRequest.AuthTypeEnum.fromValue(host.getProtocol().getAuthorization()))
      .login(login)
      .password(password)

代码示例来源:origin: iterate-ch/cyberduck

@Override
public Type getType() {
  return parent.getType();
}

代码示例来源:origin: iterate-ch/cyberduck

/**
 * @param protocol Scheme
 */
public Host(final Protocol protocol) {
  this(protocol, protocol.getDefaultHostname());
}

相关文章