public IXAuthentication(ClientInfo clientInfo, IXProperties sessOpts, EAuthenticationType authType) { this.loginResult = new LoginResult(); this.loginResult.clientInfo = clientInfo; this.loginResult.user = new UserInfo(); this.sessOpts = sessOpts; this.encrPasswords = new IXProperties(); this.authType = authType; }
public virtual IXConnection CreateFromTicket(ClientInfo ci) { EAuthenticationType authType = EAuthenticationType.FROM_TICKET; IXAuthentication auth = new IXAuthentication_FromTicket(ci, sessOpts, authType); BSyncResult <IXConnection> asyncResult = new BSyncResult <IXConnection>(); internalCreateConnection(auth, BAsyncResultHelper.ToDelegate(asyncResult)); return(asyncResult.GetResult()); }
internal IXAuthentication_RunAsFromTicket( ClientInfo clientInfo, IXProperties sessOpts, EAuthenticationType authType, String runAs) : base(clientInfo, sessOpts, authType) { ciAdmin = new ClientInfo(); ciAdmin.ticket = clientInfo.ticket; ciAdmin.language = clientInfo.language; ciAdmin.country = clientInfo.country; ciAdmin.timeZone = clientInfo.timeZone; this.runAs = runAs; }
public virtual IXConnection Create(ClientInfo ciAdmin, String runAs) { EAuthenticationType authType = EAuthenticationType.RUN_AS; IXAuthentication auth = new IXAuthentication_RunAsFromTicket(ciAdmin, sessOpts, authType, runAs); BSyncResult <IXConnection> asyncResult = new BSyncResult <IXConnection>(); internalCreateConnection(auth, BAsyncResultHelper.ToDelegate(asyncResult)); return(asyncResult.GetResult()); }
internal IXAuthentication_NameOrRunAsReportAs( ClientInfo clientInfo, IXProperties sessOpts, EAuthenticationType authType, String userName, String userPwd, String computerName, String runAs, bool reportAs) : base(clientInfo, sessOpts, authType) { this.userName = userName; this.userPwd = userPwd; this.computerName = computerName; this.runAs = runAs; this.reportAs = reportAs; }
public static string GetAuthenticationMethodName(EAuthenticationType type) { switch (type) { case EAuthenticationType.Plain: return("PLAIN"); case EAuthenticationType.Login: return("LOGIN"); } return("NONE"); }
public virtual IXConnection CreateSso(ClientInfo ci, String computerName) { if (ci == null) { ci = MakeDefaultClientInfo(); } EAuthenticationType authType = EAuthenticationType.SSO; IXAuthentication auth = new IXAuthentication_SSO(ci, sessOpts, authType, computerName); BSyncResult <IXConnection> asyncResult = new BSyncResult <IXConnection>(); internalCreateConnection(auth, BAsyncResultHelper.ToDelegate(asyncResult)); return(asyncResult.GetResult()); }
public virtual IXConnection CreateAdmin(ClientInfo ci, String userName, String userPwd, String computerName, String reportAs) { if (ci == null) { ci = MakeDefaultClientInfo(); } EAuthenticationType authType = EAuthenticationType.REPORT_AS; IXAuthentication auth = new IXAuthentication_NameOrRunAsReportAs(ci, sessOpts, authType, userName, userPwd, computerName, reportAs, true); BSyncResult <IXConnection> asyncResult = new BSyncResult <IXConnection>(); internalCreateConnection(auth, BAsyncResultHelper.ToDelegate(asyncResult)); return(asyncResult.GetResult()); }
/// <summary> /// Create aconnection for the given user. /// <param name="ci"> ClientInfo object with language, country and timezone</param> /// <param name="userName"> User name.</param> /// <param name="userPwd"> Plain text user password.</param> /// <param name="computerName"> Computer name.</param> /// <param name="runAs"> User name or ID if this should be a run-as connection.</param> /// <returns>IXConnection object.</returns> /// @throws java.rmi.RemoteException /// </summary> public virtual IXConnection Create(ClientInfo ci, String userName, String userPwd, String computerName, String runAs) { if (ci == null) { ci = MakeDefaultClientInfo(); } EAuthenticationType authType = runAs != null && runAs.Length != 0 ? EAuthenticationType.RUN_AS : EAuthenticationType.NAME_PASSWORD; IXAuthentication auth = new IXAuthentication_NameOrRunAsReportAs(ci, sessOpts, authType, userName, userPwd, computerName, runAs, false); BSyncResult <IXConnection> asyncResult = new BSyncResult <IXConnection>(); internalCreateConnection(auth, BAsyncResultHelper.ToDelegate(asyncResult)); return(asyncResult.GetResult()); }
public SmtpClient(string host, ushort port, string smtpUser, string smtpPassword, EInteractionType interactionType, EAuthenticationType authenticationType) { this.Init(host, port, smtpUser, smtpPassword, interactionType, authenticationType); }
public SmtpClient(string host, ushort port, EInteractionType interactionType, EAuthenticationType authenticationType) { this.Init(host, port, "", "", interactionType, authenticationType); }
protected void Init(string host, ushort port, string smtpUser, string smtpPassword, EInteractionType interactionType, EAuthenticationType authenticationType) { if (host == null) { throw new ArgumentNullException("host"); } if (smtpUser == null) { throw new ArgumentNullException("smtpUser"); } if (smtpPassword == null) { throw new ArgumentNullException("smtpPassword"); } this._configurationProvider = new CodeConfigurationProvider(host, port, interactionType, authenticationType); this._connectionFactory = new ConnectionFactory(); this.Username = smtpUser; this.Password = smtpPassword; this.ProxyUser = ""; this.State = ESmtpClientState.Awaiting; }
protected static ISmtpAction GetAuthenticationCommand(string user, string password, EAuthenticationType authenticationType, IEnumerable <SmtpResponseLine> serverExtensions) { switch (authenticationType) { case EAuthenticationType.Auto: foreach (SmtpResponseLine line in serverExtensions) { if (line.Comment.Contains("AUTH")) { if (line.Comment.Contains("PLAIN")) { return(new AUTHPlainCommand(user, password)); } if (line.Comment.Contains("LOGIN")) { return(new AUTHLoginCommand(user, password)); } } } return(null); case EAuthenticationType.Plain: if (!IsAuthMethosSupported(serverExtensions, "PLAIN")) { throw new AuthenticationMethodNotSupportedException(); } return(new AUTHPlainCommand(user, password)); case EAuthenticationType.Login: if (!IsAuthMethosSupported(serverExtensions, "LOGIN")) { throw new AuthenticationMethodNotSupportedException(); } return(new AUTHLoginCommand(user, password)); default: return(null); } }
public Pop3Client(string accountName, string host, ushort port, string login, string password, EInteractionType interactionType, EAuthenticationType authenticationType) { this.Init(accountName, host, port, login, password, interactionType, authenticationType); }
protected void Init(string host, ushort port, EInteractionType interactionType, EAuthenticationType authenticationType, int sendTimeOut, int receiveTimeOut) { if (host == null) { throw new ArgumentNullException("host"); } if (sendTimeOut < 0) { throw new ArgumentOutOfRangeException("sendTimeOut"); } if (receiveTimeOut < 0) { throw new ArgumentOutOfRangeException("receiveTimeOut"); } this.Host = host; this.Port = port; this.SSLInteractionType = interactionType; this.AuthenticationType = authenticationType; this.SendTimeOut = sendTimeOut; this.ReceiveTimeOut = receiveTimeOut; this.ProxyHost = ""; this.ProxyPort = 0; this.ProxyType = EProxyType.No; this.AttachmentDirectory = ApplicationData.Current.LocalFolder.Path; }
public CodeConfigurationProvider(string host, ushort port, EInteractionType interactionType, EAuthenticationType authenticationType) { this._proxyUser = ""; this._proxyPassword = ""; this.Init(host, port, interactionType, authenticationType, 0x2710, 0x2710); }
public static BaseAUTHENTICATECommand CreateAuthenticateCommand(EAuthenticationType type, string username, string password) { return(CreateAuthenticateCommand(GetAuthenticationMethodName(type), username, password)); }
internal IXAuthentication_SSO(ClientInfo clientInfo, IXProperties sessOpts, EAuthenticationType authType, String computerName) : base(clientInfo, sessOpts, authType) { this.computerName = computerName; }
internal IXAuthentication_FromTicket( ClientInfo clientInfo, IXProperties sessOpts, EAuthenticationType authType) : base(clientInfo, sessOpts, authType) { }
private string SendWebDAVRequest(string url, string webdavRequest, string username, string password) { HttpWebRequest webRequest = null; HttpWebResponse webResponse = null; Stream responseStream = null; string responseStreamXml = ""; try { // Create the web request webRequest = (HttpWebRequest)WebRequest.Create(url); // Configure HTTP headers webRequest.ContentType = "text/xml; charset=\"UTF-8\""; webRequest.ProtocolVersion = HttpVersion.Version11; webRequest.KeepAlive = false; webRequest.Method = "PROPFIND"; webRequest.Timeout = 10000; webRequest.Headers.Add("Translate", "f"); webRequest.Headers.Add("Depth", "0"); webRequest.CookieContainer = new CookieContainer(1); // Credentials NetworkCredential myCred = new NetworkCredential(username, password); CredentialCache myCache = new CredentialCache(); if (username.Length > 0) { if (EAuthenticationType.BASIC == m_AuthType) { myCache.Add(new Uri(url), "Basic", myCred); } else if (EAuthenticationType.NTLM == m_AuthType) { return("<ntlm />"); } else if (EAuthenticationType.NEGOTIATE == m_AuthType) { myCache.Add(new Uri(url), "Negotiate", (NetworkCredential)CredentialCache.DefaultCredentials); } else { myCache.Add(new Uri(url), "Digest", myCred); } webRequest.Credentials = myCache; webRequest.PreAuthenticate = true; } // The body of the HTTP request contains the WebDAV request byte[] queryData = Encoding.UTF8.GetBytes(webdavRequest); // Set the Content Length webRequest.ContentLength = queryData.Length; // Send the request Stream requestStream = webRequest.GetRequestStream(); requestStream.Write(queryData, 0, queryData.Length); requestStream.Close(); // Get the HTTP Web Response webResponse = (HttpWebResponse)webRequest.GetResponse(); // Get the repsonse stream responseStream = webResponse.GetResponseStream(); // Pipes response stream to a UTF-8 stream reader StreamReader readerResponseStream = new StreamReader(responseStream, Encoding.UTF8); responseStreamXml = readerResponseStream.ReadToEnd(); // Release the resources of the response readerResponseStream.Close(); } catch (WebException e) { responseStreamXml = "<error>" + e.Message + "</error>"; if (e.Message.Contains("401")) { string authenticationHeader = e.Response.Headers["WWW-Authenticate"]; authenticationHeader = (null != authenticationHeader) ? (authenticationHeader.ToLower()) : (""); if (("" == authenticationHeader) || authenticationHeader.StartsWith("basic")) { m_AuthType = EAuthenticationType.BASIC; } else if (authenticationHeader.StartsWith("ntlm")) { m_AuthType = EAuthenticationType.NTLM; } else if ("negotiate" == authenticationHeader) { m_AuthType = EAuthenticationType.NEGOTIATE; } } } catch (Exception e) { responseStreamXml = "<error>WebDAV error from Alfresco: " + e.Message + "</error>"; } finally { if (webResponse != null) { webResponse.Close(); } if (responseStream != null) { responseStream.Close(); } if (webRequest != null) { webRequest.Abort(); } } return(responseStreamXml); }
public Pop3Client(IConfigurationProvider configurationProvider, string login, string password, EAuthenticationType authenticationType) { if (configurationProvider == null) { throw new ArgumentNullException("configurationProvider"); } if (login == null) { throw new ArgumentNullException("login"); } if (password == null) { throw new ArgumentNullException("password"); } this._configurationProvider = configurationProvider; this._connectionFactory = new ConnectionFactory(); this.Username = login; this.Password = password; this.ConnectionState = EPop3ConnectionState.Disconnected; this.State = EPop3ClientState.Awaiting; this.AuthenticationType = authenticationType; }
public CodeConfigurationProvider(string host, ushort port, EInteractionType interactionType, EAuthenticationType authenticationType, int sendTimeOut, int recieveTimeOut) { this._proxyUser = ""; this._proxyPassword = ""; this.Init(host, port, interactionType, authenticationType, sendTimeOut, recieveTimeOut); }
protected virtual void Init(string accountName, string host, ushort port, string login, string password, EInteractionType interactionType, EAuthenticationType authenticationType) { if (string.IsNullOrEmpty(accountName)) { throw new ArgumentNullException("accountName"); } if (host == null) { throw new ArgumentNullException("host"); } if (login == null) { throw new ArgumentNullException("login"); } if (password == null) { throw new ArgumentNullException("password"); } this._connectionFactory = new ConnectionFactory(); this._configurationProvider = new CodeConfigurationProvider(host, port, interactionType, authenticationType); this.AuthenticationType = authenticationType; this.AccountName = accountName; this.Username = login; this.Password = password; this.ConnectionState = EPop3ConnectionState.Disconnected; this.State = EPop3ClientState.Awaiting; }
private string SendWebDAVRequest(string url, string webdavRequest, string username, string password) { HttpWebRequest webRequest = null; HttpWebResponse webResponse = null; Stream responseStream = null; string responseStreamXml = ""; try { // Create the web request webRequest = (HttpWebRequest)WebRequest.Create(url); // Configure HTTP headers webRequest.ContentType = "text/xml; charset=\"UTF-8\""; webRequest.ProtocolVersion = HttpVersion.Version11; webRequest.KeepAlive = false; webRequest.Method = "PROPFIND"; webRequest.Timeout = 10000; webRequest.Headers.Add("Translate", "f"); webRequest.Headers.Add("Depth", "0"); webRequest.CookieContainer = new CookieContainer(1); // Credentials NetworkCredential myCred = new NetworkCredential(username, password); CredentialCache myCache = new CredentialCache(); if (username.Length > 0) { if (EAuthenticationType.BASIC == m_AuthType) { myCache.Add(new Uri(url), "Basic", myCred); } else if (EAuthenticationType.NTLM == m_AuthType) { return "<ntlm />"; } else if (EAuthenticationType.NEGOTIATE == m_AuthType) { myCache.Add(new Uri(url), "Negotiate", (NetworkCredential)CredentialCache.DefaultCredentials); } else { myCache.Add(new Uri(url), "Digest", myCred); } webRequest.Credentials = myCache; webRequest.PreAuthenticate = true; } // The body of the HTTP request contains the WebDAV request byte[] queryData = Encoding.UTF8.GetBytes(webdavRequest); // Set the Content Length webRequest.ContentLength = queryData.Length; // Send the request Stream requestStream = webRequest.GetRequestStream(); requestStream.Write(queryData, 0, queryData.Length); requestStream.Close(); // Get the HTTP Web Response webResponse = (HttpWebResponse)webRequest.GetResponse(); // Get the repsonse stream responseStream = webResponse.GetResponseStream(); // Pipes response stream to a UTF-8 stream reader StreamReader readerResponseStream = new StreamReader(responseStream, Encoding.UTF8); responseStreamXml = readerResponseStream.ReadToEnd(); // Release the resources of the response readerResponseStream.Close(); } catch (WebException e) { responseStreamXml = "<error>" + e.Message + "</error>"; if (e.Message.Contains("401")) { string authenticationHeader = e.Response.Headers["WWW-Authenticate"]; authenticationHeader = (null != authenticationHeader) ? (authenticationHeader.ToLower()) : (""); if (("" == authenticationHeader) || authenticationHeader.StartsWith("basic")) { m_AuthType = EAuthenticationType.BASIC; } else if (authenticationHeader.StartsWith("ntlm")) { m_AuthType = EAuthenticationType.NTLM; } else if ("negotiate" == authenticationHeader) { m_AuthType = EAuthenticationType.NEGOTIATE; } } } catch (Exception e) { responseStreamXml = "<error>WebDAV error from Alfresco: " + e.Message + "</error>"; } finally { if (webResponse != null) { webResponse.Close(); } if (responseStream != null) { responseStream.Close(); } if (webRequest != null) { webRequest.Abort(); } } return responseStreamXml; }
public Pop3Client(string accountName, string host, ushort port, EInteractionType interactionType, EAuthenticationType authenticationType) { this.Init(accountName, host, port, "", "", interactionType, authenticationType); }