mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 17:03:12 +07:00
WI-30337 Deployment server with invalid port is saved, but not correctly displayed
This commit is contained in:
@@ -25,6 +25,8 @@ public interface MutableRemoteCredentials extends RemoteCredentials {
|
||||
|
||||
void setPort(int port);
|
||||
|
||||
void setLiteralPort(String portText);
|
||||
|
||||
void setUserName(String userName);
|
||||
|
||||
void setPassword(@Nullable String password);
|
||||
|
||||
@@ -25,6 +25,8 @@ public interface RemoteCredentials {
|
||||
|
||||
int getPort();
|
||||
|
||||
String getLiteralPort();
|
||||
|
||||
@Transient
|
||||
String getUserName();
|
||||
|
||||
|
||||
@@ -39,7 +39,8 @@ public class RemoteCredentialsHolder implements MutableRemoteCredentials {
|
||||
public static final String SSH_PREFIX = "ssh://";
|
||||
|
||||
private String myHost;
|
||||
private int myPort;
|
||||
private int myPort;//will always be equal to myLiteralPort, if it's valid, or equal to 0 otherwise
|
||||
private String myLiteralPort;
|
||||
private boolean myAnonymous;
|
||||
private String myUserName;
|
||||
private String myPassword;
|
||||
@@ -51,7 +52,7 @@ public class RemoteCredentialsHolder implements MutableRemoteCredentials {
|
||||
private boolean myStorePassphrase;
|
||||
|
||||
public static String getCredentialsString(@NotNull RemoteCredentials cred) {
|
||||
return SSH_PREFIX + cred.getUserName() + "@" + cred.getHost() + ":" + cred.getPort();
|
||||
return SSH_PREFIX + cred.getUserName() + "@" + cred.getHost() + ":" + cred.getLiteralPort();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -68,8 +69,28 @@ public class RemoteCredentialsHolder implements MutableRemoteCredentials {
|
||||
return myPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets both int and String representations of port.
|
||||
*/
|
||||
@Override
|
||||
public void setPort(int port) {
|
||||
myPort = port;
|
||||
myLiteralPort = Integer.toString(port);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLiteralPort(){
|
||||
return myLiteralPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets string representation of port and its int value, which is equal to string one if it's a valid integer,
|
||||
* and is 0 otherwise.
|
||||
*/
|
||||
@Override
|
||||
public void setLiteralPort(String portText){
|
||||
myLiteralPort = portText;
|
||||
myPort = StringUtil.parseInt(portText, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -222,7 +243,7 @@ public class RemoteCredentialsHolder implements MutableRemoteCredentials {
|
||||
|
||||
public static void copyRemoteCredentials(@NotNull RemoteCredentials from, @NotNull MutableRemoteCredentials to) {
|
||||
to.setHost(from.getHost());
|
||||
to.setPort(from.getPort());
|
||||
to.setLiteralPort(from.getLiteralPort());//then port is copied
|
||||
to.setAnonymous(from.isAnonymous());
|
||||
to.setUserName(from.getUserName());
|
||||
to.setPassword(from.getPassword());
|
||||
@@ -235,7 +256,7 @@ public class RemoteCredentialsHolder implements MutableRemoteCredentials {
|
||||
|
||||
public void load(Element element) {
|
||||
setHost(element.getAttributeValue(HOST));
|
||||
setPort(StringUtil.parseInt(element.getAttributeValue(PORT), 22));
|
||||
setLiteralPort(element.getAttributeValue(PORT));
|
||||
setAnonymous(StringUtil.parseBoolean(element.getAttributeValue(ANONYMOUS), false));
|
||||
setSerializedUserName(element.getAttributeValue(USERNAME));
|
||||
setSerializedPassword(element.getAttributeValue(PASSWORD));
|
||||
@@ -247,7 +268,7 @@ public class RemoteCredentialsHolder implements MutableRemoteCredentials {
|
||||
|
||||
public void save(Element rootElement) {
|
||||
rootElement.setAttribute(HOST, StringUtil.notNullize(getHost()));
|
||||
rootElement.setAttribute(PORT, Integer.toString(getPort()));
|
||||
rootElement.setAttribute(PORT, getLiteralPort());
|
||||
rootElement.setAttribute(ANONYMOUS, Boolean.toString(isAnonymous()));
|
||||
rootElement.setAttribute(USERNAME, getSerializedUserName());
|
||||
rootElement.setAttribute(PASSWORD, getSerializedPassword());
|
||||
@@ -264,7 +285,7 @@ public class RemoteCredentialsHolder implements MutableRemoteCredentials {
|
||||
|
||||
RemoteCredentialsHolder holder = (RemoteCredentialsHolder)o;
|
||||
|
||||
if (myPort != holder.myPort) return false;
|
||||
if (myLiteralPort != null ? !myLiteralPort.equals(holder.myLiteralPort) : holder.myLiteralPort != null) return false;
|
||||
if (myAnonymous != holder.myAnonymous) return false;
|
||||
if (myUseKeyPair != holder.myUseKeyPair) return false;
|
||||
if (myStorePassword != holder.myStorePassword) return false;
|
||||
@@ -282,7 +303,7 @@ public class RemoteCredentialsHolder implements MutableRemoteCredentials {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = myHost != null ? myHost.hashCode() : 0;
|
||||
result = 31 * result + myPort;
|
||||
result = 31 * result + (myLiteralPort != null ? myLiteralPort.hashCode() : 0);
|
||||
result = 31 * result + (myAnonymous ? 1 : 0);
|
||||
result = 31 * result + (myUserName != null ? myUserName.hashCode() : 0);
|
||||
result = 31 * result + (myPassword != null ? myPassword.hashCode() : 0);
|
||||
|
||||
@@ -59,7 +59,7 @@ public class RemoteSdkCredentialsBuilder {
|
||||
|
||||
public static void copyCredentials(@NotNull RemoteCredentials data, @NotNull MutableRemoteCredentials copyTo) {
|
||||
copyTo.setHost(data.getHost());
|
||||
copyTo.setPort(data.getPort());
|
||||
copyTo.setLiteralPort(data.getLiteralPort());//then port is copied
|
||||
copyTo.setAnonymous(data.isAnonymous());
|
||||
copyTo.setUserName(data.getUserName());
|
||||
copyTo.setPassword(data.getPassword());
|
||||
|
||||
@@ -190,7 +190,7 @@ public class RemoteSdkCredentialsHolder extends RemoteCredentialsHolder implemen
|
||||
RemoteSdkCredentialsHolder holder = (RemoteSdkCredentialsHolder)o;
|
||||
|
||||
if (isAnonymous() != holder.isAnonymous()) return false;
|
||||
if (getPort() != holder.getPort()) return false;
|
||||
if (getLiteralPort() != null ? !getLiteralPort().equals(holder.getLiteralPort()) : holder.getLiteralPort() != null) return false;
|
||||
if (isStorePassphrase() != holder.isStorePassphrase()) return false;
|
||||
if (isStorePassword() != holder.isStorePassword()) return false;
|
||||
if (isUseKeyPair() != holder.isUseKeyPair()) return false;
|
||||
@@ -215,7 +215,7 @@ public class RemoteSdkCredentialsHolder extends RemoteCredentialsHolder implemen
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = getHost() != null ? getHost().hashCode() : 0;
|
||||
result = 31 * result + getPort();
|
||||
result = 31 * result + (getLiteralPort() != null ? getLiteralPort().hashCode() : 0);
|
||||
result = 31 * result + (isAnonymous() ? 1 : 0);
|
||||
result = 31 * result + (getUserName() != null ? getUserName().hashCode() : 0);
|
||||
result = 31 * result + (getPassword() != null ? getPassword().hashCode() : 0);
|
||||
@@ -235,8 +235,8 @@ public class RemoteSdkCredentialsHolder extends RemoteCredentialsHolder implemen
|
||||
"{getHost()='" +
|
||||
getHost() +
|
||||
'\'' +
|
||||
", getPort()=" +
|
||||
getPort() +
|
||||
", getLiteralPort()=" +
|
||||
getLiteralPort() +
|
||||
", isAnonymous()=" +
|
||||
isAnonymous() +
|
||||
", getUserName()='" +
|
||||
|
||||
Reference in New Issue
Block a user