1 package ch
.cyberduck
.core
;
4 * Copyright (c) 2007 David Kocher. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * Bug fixes, suggestions and comments should be sent to:
18 * dkocher@cyberduck.ch
21 import ch
.cyberduck
.core
.features
.Location
;
22 import ch
.cyberduck
.core
.preferences
.PreferencesFactory
;
24 import org
.apache
.commons
.lang3
.StringUtils
;
26 import java
.util
.Collections
;
27 import java
.util
.Locale
;
33 public abstract class AbstractProtocol
implements Protocol
{
36 public String
getProvider() {
37 return this.getIdentifier();
41 public String
getName() {
42 return this.getScheme().name().toUpperCase(Locale
.ROOT
);
46 public String
favicon() {
51 public boolean isEnabled() {
52 return PreferencesFactory
.get().getBoolean(String
.format("connection.protocol.%s.enable", this.getIdentifier()));
56 public String
[] getSchemes() {
57 return new String
[]{this.getScheme().name()};
61 public String
toString() {
62 return this.getProvider();
66 * @return A mounted disk icon to display
69 public String
disk() {
70 return String
.format("%s.tiff", this.getIdentifier());
74 * @return A small icon to display
77 public String
icon() {
82 public boolean isSecure() {
83 return this.getScheme().isSecure();
87 public boolean isHostnameConfigurable() {
88 return StringUtils
.isBlank(this.getDefaultHostname());
92 * @return False if the port to connect is static.
95 public boolean isPortConfigurable() {
100 public boolean isEncodingConfigurable() {
105 public boolean isAnonymousConfigurable() {
110 public boolean isUsernameConfigurable() {
115 public boolean isPasswordConfigurable() {
120 public boolean isUTCTimezone() {
125 public String
getUsernamePlaceholder() {
126 return LocaleFactory
.localizedString("Username", "Credentials");
130 public String
getPasswordPlaceholder() {
131 return LocaleFactory
.localizedString("Password", "Credentials");
135 public String
getDefaultHostname() {
137 return PreferencesFactory
.get().getProperty("connection.hostname.default");
141 * @return Available regions for containers
144 public Set
<Location
.Name
> getRegions() {
145 return Collections
.emptySet();
149 * @return The default port this protocol connects to
152 public int getDefaultPort() {
153 return this.getScheme().getPort();
157 * @return Authentication path
160 public String
getContext() {
165 public String
getRegion() {
170 public Type
getType() {
171 return Type
.valueOf(this.getIdentifier());
175 public boolean validate(Credentials credentials
, LoginOptions options
) {
176 return this.getType().validate(credentials
, options
);
180 public boolean equals(Object o
) {
184 if(!(o
instanceof Protocol
)) {
187 Protocol protocol
= (Protocol
) o
;
188 if(this.getIdentifier() != null ?
!this.getIdentifier().equals(protocol
.getIdentifier()) : protocol
.getIdentifier() != null) {
191 if(this.getScheme() != null ?
!this.getScheme().equals(protocol
.getScheme()) : protocol
.getScheme() != null) {
194 if(this.getProvider() != null ?
!this.getProvider().equals(protocol
.getProvider()) : protocol
.getProvider() != null) {
201 public int compareTo(final Protocol o
) {
202 return this.getIdentifier().compareTo(o
.getIdentifier());
206 public int hashCode() {
207 int result
= this.getIdentifier() != null ?
this.getIdentifier().hashCode() : 0;
208 result
= 31 * result
+ (this.getScheme() != null ?
this.getScheme().hashCode() : 0);
209 result
= 31 * result
+ (this.getProvider() != null ?
this.getProvider().hashCode() : 0);