Пример #1
0
        /// <summary>
        /// Get a connection to the home server of the specified member
        /// </summary>
        /// <param name="domainID">The domain ID</param>
        /// <param name="userID">The user to authenticate as.</param>
        /// <param name="authType">The authentication type.</param>
        /// <param name="member">The member</param>
        /// <returns>a connection.</returns>
        internal static HostConnection GetConnection(string domainID, string userID, SimiasConnection.AuthType authType, Member member)
        {
            HostConnection conn;
            string         key = member.HomeServer.UserID;

            if (key != null)
            {
                lock (connectionTable)
                {
                    conn = (HostConnection)connectionTable[key];
                    if (conn == null)
                    {
                        conn                 = new HostConnection(domainID, userID, authType, member);
                        conn.key             = key;
                        connectionTable[key] = conn;
                    }
                }
            }
            else
            {
                conn = new HostConnection(domainID, userID, authType, member);
            }
            conn.InitializeConnection();
            return(conn);
        }
Пример #2
0
        /// <summary>
        /// Get a connection to the home server of the specified member
        /// </summary>
        /// <param name="domainID">The domain ID</param>
        /// <param name="userID">The user to authenticate as.</param>
        /// <param name="authType">The authentication type.</param>
        /// <param name="host">Host information against which authentication has to be done.</param>
        /// <returns>a connection.</returns>
        internal static HostConnection GetConnection(string domainID, string userID, SimiasConnection.AuthType authType, HostNode host)
        {
            HostConnection conn;
            string         key = host.UserID;

            log.Debug("2-dID {0}, hUID {1}, UID {2}", domainID, host.UserID, userID);
            if (key != null)
            {
                lock (connectionTable)
                {
                    conn = (HostConnection)connectionTable[key];
                    if (conn == null)
                    {
                        conn                 = new HostConnection(domainID, userID, authType, host);
                        conn.key             = key;
                        connectionTable[key] = conn;
                    }
                }
            }
            else
            {
                conn = new HostConnection(domainID, userID, authType, host);
            }
            conn.InitializeConnection();
            return(conn);
        }
Пример #3
0
        /// <summary>
        /// Get a connection that can be used to access the host of specified collection.
        /// </summary>
        /// <param name="domainID">The domain ID</param>
        /// <param name="userID">The user to authenticate as.</param>
        /// <param name="authType">The type of authentication.</param>
        /// <param name="collection">The collection to be accessed</param>
        /// <returns>Connection</returns>
        internal static HostConnection GetConnection(string domainID, string userID, SimiasConnection.AuthType authType, Collection collection)
        {
            HostConnection conn;
            string         key = collection.HostID;

            if (key != null)
            {
                lock (connectionTable)
                {
                    conn = (HostConnection)connectionTable[key];
                    if (conn == null)
                    {
                        conn                 = new HostConnection(domainID, userID, authType, collection);
                        conn.key             = key;
                        connectionTable[key] = conn;
                    }
                }
            }
            else
            {
                conn = new HostConnection(domainID, userID, authType, collection);
            }
            conn.ssl = collection.SSL;
            conn.InitializeConnection();
            return(conn);
        }
Пример #4
0
 /// <summary>
 /// Constructor to create new host connection
 /// </summary>
 /// <param name="domainID">ID of the domain</param>
 /// <param name="userID">User Id</param>
 /// <param name="authType">Authentication type</param>
 /// <param name="member">Member name</param>
 private HostConnection(string domainID, string userID, SimiasConnection.AuthType authType, Member member)
 {
     this.domainID     = domainID;
     this.userID       = userID;
     this.collectionID = domainID;
     this.hostID       = member.HomeServer.UserID;
     this.authType     = authType;
     baseUri           = DomainProvider.ResolvePOBoxLocation(domainID, member.UserID).ToString();
 }
Пример #5
0
 /// <summary>
 /// Constructor to create new host connection
 /// </summary>
 /// <param name="domainID">ID of the domain</param>
 /// <param name="userID">User Id</param>
 /// <param name="authType">Authentication type</param>
 /// <param name="host">Host name</param>
 private HostConnection(string domainID, string userID, SimiasConnection.AuthType authType, HostNode host)
 {
     this.domainID     = domainID;
     this.userID       = userID;
     this.collectionID = domainID;
     this.hostID       = host.UserID;
     this.authType     = authType;
     baseUri           = DomainProvider.ResolveHostAddress(domainID, host.UserID).ToString();
     log.Debug("dID {0}, hUID {1}, UID {2}", domainID, host.UserID, userID);
 }
Пример #6
0
        /// <summary>
        /// Get a WebState object for the specified domain.
        /// </summary>
        /// <param name="DomainID">The domain ID.</param>
        /// <param name="CollectionID">The collection ID.</param>
        /// <param name="UserID">User ID of a member in the domain.</param>
        /// <param name="authType">The type of authentication to use.</param>
        public WebState(string DomainID, string CollectionID, string UserID, SimiasConnection.AuthType authType) :
            this( DomainID )
        {
            BasicCredentials creds;

            // Get the credentials for this collection.
            Member member = null;
            try
            {
                if (UserID == null)
                {
                    member = Store.GetStore().GetDomain(DomainID).GetCurrentMember();
                }
                else
                {
                    member = Store.GetStore().GetDomain(DomainID).GetMemberByID(UserID);
                }

                UTF8Encoding utf8Name = new UTF8Encoding();
                byte[]       encodedCredsByteArray = utf8Name.GetBytes(member.Name);
                string       iFolderUserBase64     = Convert.ToBase64String(encodedCredsByteArray);

                creds = new BasicCredentials(DomainID, CollectionID, iFolderUserBase64);
                if (creds.Cached == true)
                {
                    credentials = creds.GetNetworkCredential();
                }
                else
                {
                    // Get the credentials for this collection.
                    creds = new BasicCredentials(DomainID, DomainID, iFolderUserBase64);
                    if (creds.Cached == true)
                    {
                        credentials = creds.GetNetworkCredential();
                    }
                }
            }
            catch {}

            if (credentials == null && authType == SimiasConnection.AuthType.BASIC)
            {
                log.Debug("failed to get NetworkCredential for {0}", member != null ? member.Name : "");
                new EventPublisher().RaiseEvent(new NeedCredentialsEventArgs(DomainID, CollectionID));
                throw new NeedCredentialsException();
            }
        }
Пример #7
0
        /// <summary>
        /// Construction to create new Host connection
        /// </summary>
        /// <param name="domainID">Id of the Domain</param>
        /// <param name="userID">Id of the User</param>
        /// <param name="authType">Authentication type</param>
        /// <param name="collection">Collection Name</param>
        private HostConnection(string domainID, string userID, SimiasConnection.AuthType authType, Collection collection)
        {
            this.domainID     = domainID;
            this.userID       = userID;
            this.collectionID = collection.ID;
            this.hostID       = collection.HostID;
            //need to add the collection.SSL property here to Host, so that collection based SSL sync can be done
            this.ssl      = collection.SSL;        //there is collection.UseSSL -> need to see who uses it
            this.authType = authType;
//			baseUri = DomainProvider.ResolveLocation( collection ).ToString();
            System.UriBuilder uri = new UriBuilder(DomainProvider.ResolveLocation(collection).ToString());

            if (collection.SSL)
            {
                uri.Scheme = Uri.UriSchemeHttps;
            }

            baseUri = uri.ToString().TrimEnd('/') + '/';

            //baseUri = baseUri.TrimEnd('/') + '/';
        }