/** * Copyright (c) 2008-2016, XebiaLabs B.V., All rights reserved. * * * Overthere is licensed under the terms of the GPLv2 * <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most XebiaLabs Libraries. * There are special exceptions to the terms and conditions of the GPLv2 as it is applied to * this software, see the FLOSS License Exception * <http://github.com/xebialabs/overthere/blob/master/LICENSE>. * * This program is free software; you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Foundation; version 2 * of the License. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along with this * program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth * Floor, Boston, MA 02110-1301 USA */ package com.xebialabs.overthere.cifs; import com.xebialabs.overthere.ConnectionOptions; import com.xebialabs.overthere.OverthereConnection; import com.xebialabs.overthere.cifs.telnet.CifsTelnetConnection; import com.xebialabs.overthere.cifs.winrm.CifsWinRmConnection; import com.xebialabs.overthere.cifs.winrs.CifsWinrsConnection; import com.xebialabs.overthere.spi.AddressPortMapper; import com.xebialabs.overthere.spi.OverthereConnectionBuilder; import com.xebialabs.overthere.spi.Protocol; import static com.xebialabs.overthere.cifs.CifsConnectionBuilder.CIFS_PROTOCOL; /** * Builds CIFS connections. */ @Protocol(name = CIFS_PROTOCOL) public class CifsConnectionBuilder extends BaseCifsConnectionBuilder implements OverthereConnectionBuilder { /** * Name of the protocol handled by this connection builder, i.e. "cifs". */ public static final String CIFS_PROTOCOL = "cifs"; /** * See <a href="https://github.com/xebialabs/overthere/blob/master/README.md#cifs_cifsPort">the online documentation</a> */ public static final String CIFS_PORT = "cifsPort"; /** * See <a href="https://github.com/xebialabs/overthere/blob/master/README.md#cifs_cifsPort">the online documentation</a> */ public static final int CIFS_PORT_DEFAULT = 445; private CifsConnection connection; public CifsConnectionBuilder(String type, ConnectionOptions options, AddressPortMapper mapper) { CifsConnectionType cifsConnectionType = options.getEnum(CONNECTION_TYPE, CifsConnectionType.class); switch (cifsConnectionType) { case TELNET: connection = new CifsTelnetConnection(type, options, mapper); break; case WINRM_INTERNAL: connection = new CifsWinRmConnection(type, options, mapper); break; case WINRM_NATIVE: connection = new CifsWinrsConnection(type, options, mapper); break; default: throw new IllegalArgumentException("Unknown CIFS connection type " + cifsConnectionType); } } @Override public OverthereConnection connect() { connection.connect(); return connection; } @Override public String toString() { return connection.toString(); } }