Skip to content

Commit

Permalink
Added suport for new SU connection type (fixed #102).
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Partington committed Mar 10, 2014
1 parent 2e2310b commit e53779b
Show file tree
Hide file tree
Showing 33 changed files with 1,086 additions and 708 deletions.
200 changes: 161 additions & 39 deletions README.md

Large diffs are not rendered by default.

86 changes: 34 additions & 52 deletions src/main/java/com/xebialabs/overthere/ConnectionOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,147 +35,129 @@
public class ConnectionOptions {

/**
* Connection option for all protocols that specifies the operating system to connect to. This is used to determine
* how to encode paths and commands and to determine the default temporary directory path.
* See <a href="https://github.com/xebialabs/overthere/blob/master/README.md#os">the online documentation</a>
*/
public static final String OPERATING_SYSTEM = "os";

/**
* Connection option for most protocols that specifies the directory in which the connection-scope temporary
* directory is created. Any {@link OverthereConnection#getTempFile(String)} temporary file created, will be created
* in this directory.
* See <a href="https://github.com/xebialabs/overthere/blob/master/README.md#tmp">the online documentation</a>
*/
public static final String TEMPORARY_DIRECTORY_PATH = "tmp";

/**
* Connection option (Boolean) for most protocols that specifies whether to delete the connection-scope temporary
* directory when the connection is closed.
* See <a href="https://github.com/xebialabs/overthere/blob/master/README.md#tmpDeleteOnDisconnect">the online documentation</a>
*/
public static final String TEMPORARY_DIRECTORY_DELETE_ON_DISCONNECT = "tmpDeleteOnDisconnect";

/**
* Default value (<code>true</code>) for the connection option that specifies whether to delete the connection-scope
* temporary directory when the connection is closed.
* See <a href="https://github.com/xebialabs/overthere/blob/master/README.md#tmpDeleteOnDisconnect">the online documentation</a>
*/
public static final boolean DEFAULT_TEMPORARY_DIRECTORY_DELETE_ON_DISCONNECT = true;
public static final boolean TEMPORARY_DIRECTORY_DELETE_ON_DISCONNECT_DEFAULT = true;

/**
* Connection option (Integer) for most protocol that specifies how many times to retry creating a unique temporary file
* name before giving up.
* See <a href="https://github.com/xebialabs/overthere/blob/master/README.md#tmpFileCreationRetries">the online documentation</a>
*/
public static final String TEMPORARY_FILE_CREATION_RETRIES = "tmpFileCreationRetries";

/**
* Default value (<code>100</code>) for the connection option that specifies how many times to retry creating a
* unique temporary file name before giving up.
* See <a href="https://github.com/xebialabs/overthere/blob/master/README.md#tmpFileCreationRetries">the online documentation</a>
*/
public static final int DEFAULT_TEMPORARY_FILE_CREATION_RETRIES = 100;
public static final int TEMPORARY_FILE_CREATION_RETRIES_DEFAULT = 100;

/**
* Connection option (Integer) for all protocol that specifies the connection timeout in milliseconds to use.
* See <a href="https://github.com/xebialabs/overthere/blob/master/README.md#connectionTimeoutMillis">the online documentation</a>
*/
public static final String CONNECTION_TIMEOUT_MILLIS = "connectionTimeoutMillis";

/**
* Default value (<code>120000</code>) for the connection option that specifies the connection timeout in
* milliseconds to use.
* See <a href="https://github.com/xebialabs/overthere/blob/master/README.md#connectionTimeoutMillis">the online documentation</a>
*/
public static final int DEFAULT_CONNECTION_TIMEOUT_MILLIS = 120000;
public static final int CONNECTION_TIMEOUT_MILLIS_DEFAULT = 120000;

/**
* Common connection option that specifies the address to connect to.
* See <a href="https://github.com/xebialabs/overthere/blob/master/README.md#address">the online documentation</a>
*/
public static final String ADDRESS = "address";

/**
* Common connection option that specifies the port to connect to.
* See <a href="https://github.com/xebialabs/overthere/blob/master/README.md#port">the online documentation</a>
*/
public static final String PORT = "port";

/**
* Common connection option that specifies the username with which to connect.
* See <a href="https://github.com/xebialabs/overthere/blob/master/README.md#username">the online documentation</a>
*/
public static final String USERNAME = "username";

/**
* Common connection option that specifies the password with which to connect.
* See <a href="https://github.com/xebialabs/overthere/blob/master/README.md#password">the online documentation</a>
*/
public static final String PASSWORD = "password";

/**
* Common connection option (<code>ConnectionOptions</code>) that specifies the {@link ConnectionOptions connection
* options} to be used to create a tunnel.
* See <a href="https://github.com/xebialabs/overthere/blob/master/README.md#jumpstation">the online documentation</a>
*/
public static final String JUMPSTATION = "jumpstation";

/**
* Common connection option (<code>ConnectionOptions</code>) that specifies the command used to copy a file on a remote Unix host.
* See <a href="https://github.com/xebialabs/overthere/blob/master/README.md#fileCopyCommandForUnix">the online documentation</a>
*/
public static final String FILE_COPY_COMMAND_FOR_UNIX = "fileCopyCommandForUnix";

/**
* Default value (<code>cp -p {0} {1}</code>) for the common connection option (<code>ConnectionOptions</code>) that specifies the
* command used to copy a file on a remote Unix host.
* See <a href="https://github.com/xebialabs/overthere/blob/master/README.md#fileCopyCommandForUnix">the online documentation</a>
*/
public static final String FILE_COPY_COMMAND_FOR_UNIX_DEFAULT_VALUE = "cp -p {0} {1}";
public static final String FILE_COPY_COMMAND_FOR_UNIX_DEFAULT = "cp -p {0} {1}";

/**
* Common connection option (<code>ConnectionOptions</code>) that specifies the command used to copy a directory on a remote Unix host.
* See <a href="https://github.com/xebialabs/overthere/blob/master/README.md#directoryCopyCommandForUnix">the online documentation</a>
*/
public static final String DIRECTORY_COPY_COMMAND_FOR_UNIX = "directoryCopyCommandForUnix";

/**
* Default value (<code>tar cC {0} . | tar xmC {1} .</code>) for the common connection option (<code>ConnectionOptions</code>) that specifies the
* command used to copy a directory on a remote Unix host.
*
* Alternative values:
* <ul><code>find {0} -depth 1 -exec cp -pr {} {1} ;</code></ul>
* See <a href="https://github.com/xebialabs/overthere/blob/master/README.md#directoryCopyCommandForUnix">the online documentation</a>
*/
public static final String DIRECTORY_COPY_COMMAND_FOR_UNIX_DEFAULT_VALUE = "tar c -C {0} . | tar xm -C {1}";
public static final String DIRECTORY_COPY_COMMAND_FOR_UNIX_DEFAULT = "tar c -C {0} . | tar xm -C {1}";

/**
* Common connection option (<code>ConnectionOptions</code>) that specifies the command used to copy a file on a remote Windows host.
* See <a href="https://github.com/xebialabs/overthere/blob/master/README.md#fileCopyCommandForWindows">the online documentation</a>
*/
public static final String FILE_COPY_COMMAND_FOR_WINDOWS = "fileCopyCommandForWindows";

/**
* Default value (<code>copy {0} {1} /y</code>) for the common connection option (<code>ConnectionOptions</code>) that specifies the
* command used to copy a file on a remote Windows host.
* See <a href="https://github.com/xebialabs/overthere/blob/master/README.md#fileCopyCommandForWindows">the online documentation</a>
*/
public static final String FILE_COPY_COMMAND_FOR_WINDOWS_DEFAULT_VALUE = "copy {0} {1} /y";
public static final String FILE_COPY_COMMAND_FOR_WINDOWS_DEFAULT = "copy {0} {1} /y";

/**
* Common connection option (<code>ConnectionOptions</code>) that specifies the command used to copy a directory on a remote Windows host.
* See <a href="https://github.com/xebialabs/overthere/blob/master/README.md#directoryCopyCommandForWindows">the online documentation</a>
*/
public static final String DIRECTORY_COPY_COMMAND_FOR_WINDOWS = "directoryCopyCommandForWindows";

/**
* Default value (<code>xcopy {0} {1} /i /y /s /e /h /q</code>) for the common connection option (<code>ConnectionOptions</code>) that specifies the
* command used to copy a directory on a remote Windows host.
* See <a href="https://github.com/xebialabs/overthere/blob/master/README.md#directoryCopyCommandForWindows">the online documentation</a>
*/
public static final String DIRECTORY_COPY_COMMAND_FOR_WINDOWS_DEFAULT_VALUE = "xcopy {0} {1} /i /y /s /e /h /q";
public static final String DIRECTORY_COPY_COMMAND_FOR_WINDOWS_DEFAULT = "xcopy {0} {1} /i /y /s /e /h /q";

/**
* Common connection option (<code>ConnectionOptions</code>) that specifies the command used to copy a file on a remote z/OS host.
* See <a href="https://github.com/xebialabs/overthere/blob/master/README.md#fileCopyCommandForZos">the online documentation</a>
*/
public static final String FILE_COPY_COMMAND_FOR_ZOS = "fileCopyCommandForZos";

/**
* Default value (<code>cp -p {0} {1}</code>) for the common connection option (<code>ConnectionOptions</code>) that specifies the
* command used to copy a file on a remote z/OS host.
* See <a href="https://github.com/xebialabs/overthere/blob/master/README.md#fileCopyCommandForZos">the online documentation</a>
*/
public static final String FILE_COPY_COMMAND_FOR_ZOS_DEFAULT_VALUE = "cp -p {0} {1}";
public static final String FILE_COPY_COMMAND_FOR_ZOS_DEFAULT = "cp -p {0} {1}";

/**
* Common connection option (<code>ConnectionOptions</code>) that specifies the command used to copy a directory on a remote z/OS host.
* See <a href="https://github.com/xebialabs/overthere/blob/master/README.md#directoryCopyCommandForZos">the online documentation</a>
*/
public static final String DIRECTORY_COPY_COMMAND_FOR_ZOS = "directoryCopyCommandForZos";

/**
* Default value (<code>tar cC {0} . | tar xmC {1} .</code>) for the common connection option (<code>ConnectionOptions</code>) that specifies the
* command used to copy a directory on a remote z/OS host.
* See <a href="https://github.com/xebialabs/overthere/blob/master/README.md#directoryCopyCommandForZos">the online documentation</a>
*/
public static final String DIRECTORY_COPY_COMMAND_FOR_ZOS_DEFAULT_VALUE = "tar cC {0} . | tar xmC {1}";
public static final String DIRECTORY_COPY_COMMAND_FOR_ZOS_DEFAULT = "tar cC {0} . | tar xmC {1}";

private final Map<String, Object> options;

Expand Down
20 changes: 10 additions & 10 deletions src/main/java/com/xebialabs/overthere/cifs/CifsConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
import static com.xebialabs.overthere.ConnectionOptions.USERNAME;
import static com.xebialabs.overthere.cifs.CifsConnectionBuilder.CIFS_PORT;
import static com.xebialabs.overthere.cifs.CifsConnectionBuilder.CONNECTION_TYPE;
import static com.xebialabs.overthere.cifs.CifsConnectionBuilder.DEFAULT_CIFS_PORT;
import static com.xebialabs.overthere.cifs.CifsConnectionBuilder.DEFAULT_TELNET_PORT;
import static com.xebialabs.overthere.cifs.CifsConnectionBuilder.DEFAULT_WINRM_ENABLE_HTTPS;
import static com.xebialabs.overthere.cifs.CifsConnectionBuilder.DEFAULT_WINRM_HTTPS_PORT;
import static com.xebialabs.overthere.cifs.CifsConnectionBuilder.DEFAULT_WINRM_HTTP_PORT;
import static com.xebialabs.overthere.cifs.CifsConnectionBuilder.CIFS_PORT_DEFAULT;
import static com.xebialabs.overthere.cifs.CifsConnectionBuilder.PORT_DEFAULT_TELNET;
import static com.xebialabs.overthere.cifs.CifsConnectionBuilder.WINRM_ENABLE_HTTPS_DEFAULT;
import static com.xebialabs.overthere.cifs.CifsConnectionBuilder.PORT_DEFAULT_WINRM_HTTPS;
import static com.xebialabs.overthere.cifs.CifsConnectionBuilder.PORT_DEFAULT_WINRM_HTTP;
import static com.xebialabs.overthere.cifs.CifsConnectionBuilder.PATH_SHARE_MAPPINGS;
import static com.xebialabs.overthere.cifs.CifsConnectionBuilder.PATH_SHARE_MAPPINGS_DEFAULT;
import static com.xebialabs.overthere.cifs.CifsConnectionBuilder.WINRM_ENABLE_HTTPS;
Expand Down Expand Up @@ -99,7 +99,7 @@ public CifsConnection(String protocol, ConnectionOptions options, AddressPortMap
this.port = addressPort.getPort();
this.username = options.get(USERNAME);
this.password = options.get(PASSWORD);
int unmappedCifsPort = options.getInteger(CIFS_PORT, DEFAULT_CIFS_PORT);
int unmappedCifsPort = options.getInteger(CIFS_PORT, CIFS_PORT_DEFAULT);
InetSocketAddress addressCifsPort = mapper.map(createUnresolved(unmappedAddress, unmappedCifsPort));
this.cifsPort = addressCifsPort.getPort();
this.encoder = new PathEncoder(null, null, this.address, cifsPort, options.get(PATH_SHARE_MAPPINGS, PATH_SHARE_MAPPINGS_DEFAULT));
Expand All @@ -109,13 +109,13 @@ public CifsConnection(String protocol, ConnectionOptions options, AddressPortMap
private int getDefaultPort(ConnectionOptions options) {
switch (cifsConnectionType) {
case TELNET:
return DEFAULT_TELNET_PORT;
return PORT_DEFAULT_TELNET;
case WINRM_INTERNAL:
case WINRM_NATIVE:
if (!options.getBoolean(WINRM_ENABLE_HTTPS, DEFAULT_WINRM_ENABLE_HTTPS)) {
return DEFAULT_WINRM_HTTP_PORT;
if (!options.getBoolean(WINRM_ENABLE_HTTPS, WINRM_ENABLE_HTTPS_DEFAULT)) {
return PORT_DEFAULT_WINRM_HTTP;
} else {
return DEFAULT_WINRM_HTTPS_PORT;
return PORT_DEFAULT_WINRM_HTTPS;
}
default:
throw new IllegalArgumentException("Unknown CIFS connection type " + cifsConnectionType);
Expand Down
Loading

0 comments on commit e53779b

Please sign in to comment.