/// <summary> /// Read the Blogical.Shared.Adapters.Sftp.Management.TransmitLocation.xsd and populate /// all properties /// </summary> /// <param name="endpointConfig"></param> public void ReadLocationConfiguration(XmlDocument endpointConfig) { _sshtrace = ExtractBool(endpointConfig, "/Config/trace"); TraceMessage("[SftpTransmitProperties] ReadLocationConfiguration called"); _ssoApplication = IfExistsExtract(endpointConfig, "/Config/ssoapplication", String.Empty); if (!String.IsNullOrEmpty(_ssoApplication)) { TraceMessage("[SftpTransmitProperties] SSO Authentication"); try { SSOConfigHelper.Credentials credentials = SSOConfigHelper.GetCredentials(_ssoApplication); _sshUser = credentials.Username; _sshPasswordProperty = credentials.Password; } catch (Exception e) { throw new Exception(@"Unable to read properties from SSO database. Make sure to use ""UserName"" and ""Password"" as fields", e); } } else { TraceMessage("[SftpTransmitProperties] Username/Password Authentication"); _sshUser = Extract(endpointConfig, "/Config/user", String.Empty); _sshPasswordProperty = IfExistsExtract(endpointConfig, "/Config/password", String.Empty); } //this._sshUser = Extract(endpointConfig, "/Config/user", String.Empty); //this._sshPasswordProperty = IfExistsExtract(endpointConfig, "/Config/password", String.Empty); _sshHost = Extract(endpointConfig, "/Config/host", String.Empty); _sshPort = ExtractInt(endpointConfig, "/Config/port"); _sshIdentityFile = IfExistsExtract(endpointConfig, "/Config/identityfile", String.Empty); _sshIdentityThumbprint = IfExistsExtract(endpointConfig, "/Config/identitythumbprint", String.Empty); _sshRemotePath = Extract(endpointConfig, "/Config/remotepath", String.Empty); _sshRemoteTempDir = IfNotEmptyExtract(endpointConfig, "/Config/remotetempdir", false, String.Empty); _sshRemoteFile = Extract(endpointConfig, "/Config/remotefile", String.Empty); _sshErrorThreshold = ExtractInt(endpointConfig, "/Config/errorThreshold"); _connectionLimit = ExtractInt(endpointConfig, "/Config/connectionlimit"); _applySecurityPermissions = IfExistsExtract(endpointConfig, "/Config/applySecurityPermissions", String.Empty); _verifyFileSize = IfExistsExtractBool(endpointConfig, "/Config/verifyFileSize", false); _sshRemoteTempFile = IfExistsExtract(endpointConfig, "/Config/remotetempfile", String.Empty); _sshPassphrase = IfExistsExtract(endpointConfig, "/Config/passphrase", String.Empty); // Proxy Settings _proxyHost = IfExistsExtract(endpointConfig, "/Config/proxyserver", String.Empty); _proxyPort = ExtractInt(endpointConfig, "/Config/proxyport"); _proxyUsername = IfExistsExtract(endpointConfig, "/Config/proxyusername", String.Empty); _proxyPassword = IfExistsExtract(endpointConfig, "/Config/proxypassword", String.Empty); }
/// <summary> /// Read the Blogical.Shared.Adapters.Sftp.Management.TransmitLocation.xsd from message context /// and populate properties /// </summary> /// <param name="context"></param> public void ReadLocationConfiguration(IBaseMessageContext context) { string propertyNS = "Blogical.Shared.Adapters.Sftp.TransmitLocation.v1"; _sshtrace = (bool)Extract(context, "trace", propertyNS, false, false); TraceMessage("[SftpTransmitProperties] ReadLocationConfiguration called"); _ssoApplication = (string)Extract(context, "ssoapplication", propertyNS, String.Empty, false); if (!String.IsNullOrEmpty(_ssoApplication)) { TraceMessage("[SftpTransmitProperties] SSO Authentication"); try { SSOConfigHelper.Credentials credentials = SSOConfigHelper.GetCredentials(_ssoApplication); _sshUser = credentials.Username; _sshPasswordProperty = credentials.Password; } catch (Exception e) { throw new Exception(@"Unable to read properties from SSO database. Make sure to use ""UserName"" and ""Password"" as fields", e); } } else { TraceMessage("[SftpTransmitProperties] Username/Password Authentication"); _sshUser = (string)Extract(context, "user", propertyNS, String.Empty, true); _sshPasswordProperty = (string)Extract(context, "password", propertyNS, String.Empty, false); } // this._sshUser = (string)Extract(context, "user", propertyNS, String.Empty, true); // this._sshPasswordProperty = (string)Extract(context, "password", propertyNS, String.Empty, false); _sshHost = (string)Extract(context, "host", propertyNS, String.Empty, true); _sshPort = (int)Extract(context, "portno", propertyNS, 22, true); _sshIdentityFile = (string)Extract(context, "identityfile", propertyNS, String.Empty, false); _sshIdentityThumbprint = (string)Extract(context, "identitythumbprint", propertyNS, String.Empty, false); _sshRemotePath = (string)Extract(context, "remotepath", propertyNS, String.Empty, false); _sshRemoteTempDir = (string)Extract(context, "remotetempdir", propertyNS, String.Empty, false); _sshRemoteFile = (string)Extract(context, "remotefile", propertyNS, String.Empty, true); _connectionLimit = (int)Extract(context, "connectionlimit", propertyNS, 10, false); _applySecurityPermissions = (string)Extract(context, "applySecurityPermissions", propertyNS, String.Empty, false); _verifyFileSize = (bool)Extract(context, "verifyFileSize", propertyNS, false, false); _sshRemoteTempFile = (string)Extract(context, "remotetempfile", propertyNS, String.Empty, false); _sshPassphrase = (string)Extract(context, "passphrase", propertyNS, string.Empty, false); // Proxy Settings _proxyHost = (string)Extract(context, "proxyserver", propertyNS, string.Empty, false); _proxyPort = (int)Extract(context, "proxyport", propertyNS, 80, false); _proxyUsername = (string)Extract(context, "proxyusername", propertyNS, string.Empty, false); _proxyPassword = (string)Extract(context, "proxypassword", propertyNS, string.Empty, false); }
/// <summary> /// Read the Blogical.Shared.Adapters.Sftp.Management.ReceiveLocation.xsd and populate /// all properties /// </summary> /// <param name="endpointConfig"></param> public void ReadLocationConfiguration(XmlDocument endpointConfig) { TraceMessage("[SftpReceiverEndpoint] ReadLocationConfiguration called"); this._ssoApplication = IfExistsExtract(endpointConfig, "/Config/ssoapplication", String.Empty); if (!String.IsNullOrEmpty(this._ssoApplication)) { TraceMessage("[SftpReceiverEndpoint] SSO Authentication"); try { SSOConfigHelper.Credentials credentials = SSOConfigHelper.GetCredentials(this._ssoApplication); this._sshUser = credentials.Username; this._sshPasswordProperty = credentials.Password; } catch (Exception e) { throw new Exception(@"Unable to read properties from SSO database. Make sure to use ""UserName"" and ""Password"" as fields", e); } } else { TraceMessage("[SftpReceiverEndpoint] Username/Password Authentication"); this._sshUser = Extract(endpointConfig, "/Config/user", String.Empty); this._sshPasswordProperty = IfExistsExtract(endpointConfig, "/Config/password", String.Empty); } this._sshHost = Extract(endpointConfig, "/Config/host", String.Empty); this._sshPort = ExtractInt(endpointConfig, "/Config/port"); this._sshIdentityFile = IfExistsExtract(endpointConfig, "/Config/identityfile", String.Empty); this._sshIdentityThumbprint = IfExistsExtract(endpointConfig, "/Config/identitythumbprint", String.Empty); this._sshFileMask = Extract(endpointConfig, "/Config/filemask", String.Empty); this._sshRemotePath = Extract(endpointConfig, "/Config/remotepath", String.Empty); this._sshtrace = ExtractBool(endpointConfig, "/Config/trace"); this._notifyOnEmptyBatch = ExtractBool(endpointConfig, "/Config/notifyOnEmptyBatch"); this._sshErrorThreshold = ExtractInt(endpointConfig, "/Config/errorThreshold"); this._maximumnumberoffiles = ExtractInt(endpointConfig, "/Config/maximumnumberoffiles"); this._maximumbatchsize = ExtractInt(endpointConfig, "/Config/maximumbatchsize"); this._useLoadBalancing = ExtractBool(endpointConfig, "/Config/useLoadBalancing"); // create the schedule XmlDocument scheduleXml = new XmlDocument(); scheduleXml.LoadXml(Schedule.Extract(endpointConfig, "/Config/schedule", true)); ScheduleType type = Schedule.ExtractScheduleType(scheduleXml); switch (type) { case ScheduleType.Daily: this._schedule = new DaySchedule(scheduleXml.OuterXml); break; case ScheduleType.Weekly: this._schedule = new WeekSchedule(scheduleXml.OuterXml); break; case ScheduleType.Monthly: this._schedule = new MonthSchedule(scheduleXml.OuterXml); break; default: this._schedule = new TimeSchedule(scheduleXml.OuterXml); break; } // Greg Killins 2010/06/07 - Pass default value of empty string instead of "Delete" when // extracting AfterGetActions value, since empty string is now a valid value which // represents "DoNothing". // If the extracted value is empty string, then explicitly assign "DoNothing" to // the AfterGetActions. string afterget = IfExistsExtract(endpointConfig, "/Config/aftergetaction", string.Empty); if (afterget.Trim() == String.Empty) { this._afterGet = AfterGetActions.DoNothing; } else { try { this._afterGet = (AfterGetActions)Enum.Parse(typeof(AfterGetActions), afterget, true); } catch (ArgumentException) { throw new Exception("You must specify an After Get Action: Delete, Rename or DoNothing. Empty field equals DoNothing."); } } this._afterGetFilename = IfExistsExtract(endpointConfig, "/Config/aftergetfilename", string.Empty); this._sshPassphrase = IfExistsExtract(endpointConfig, "/Config/passphrase", string.Empty); // Proxy Settings this._proxyHost = IfExistsExtract(endpointConfig, "/Config/proxyserver", String.Empty); this._proxyPort = ExtractInt(endpointConfig, "/Config/proxyport"); this._proxyUsername = IfExistsExtract(endpointConfig, "/Config/proxyusername", String.Empty); this._proxyPassword = IfExistsExtract(endpointConfig, "/Config/proxypassword", String.Empty); }