@Override public boolean isHttps() { return bookmark.getProtocol().getScheme() == Scheme.https; }
@Override public String getOAuthRedirectUrl() { final String v = this.value("OAuth Redirect Url"); if(StringUtils.isBlank(v)) { return parent.getOAuthRedirectUrl(); } return v; }
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(); }
@Override public String getBaseURL() { return String.format("%s://%s%s", host.getProtocol().getScheme(), host.getHostname(), host.getProtocol().getContext()); }
@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; }
@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; }
@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())
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()); }
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(
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())); }
@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); }
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());
@Override public String disk() { if(null == disk) { return parent.disk(); } // Temporary file return disk.getAbsolute(); }
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();
session.getFeature(AnalyticsProvider.class).getSetup(session.getHost().getProtocol().getDefaultHostname(), session.getHost().getProtocol().getScheme(), file, credentials) ));
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());
@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; }
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)
@Override public Type getType() { return parent.getType(); }
/** * @param protocol Scheme */ public Host(final Protocol protocol) { this(protocol, protocol.getDefaultHostname()); }