Ejemplo n.º 1
0
        }  // CompareAuthentication ...

        /// <summary>
        /// CompareCredentials compares two PSCredential credentials
        /// by doing a username and password comparison .
        /// </summary>
        /// <param name="credential1">Credential 1</param>
        /// <param name="credential2">Credential 2</param>
        /// <returns>True if they match else false.</returns>
        internal static bool CompareCredential(PSCredential credential1, PSCredential credential2)
        {
            if (credential1 == null && credential2 == null)
            {
                return(true);
            }

            // check credentials if present
            if (credential1 == null ^ credential2 == null)
            {
                return(false);
            }

            Debug.Assert(credential1 != null && credential2 != null &&
                         credential1.UserName != null && credential2.UserName != null, "Credentials should be != null");

            // check the username
            if (string.Compare(credential1.UserName, credential2.UserName, StringComparison.OrdinalIgnoreCase) != 0)
            {
                return(false);
            }

            // check the password
            if (!WorkflowUtils.ComparePassword(credential1.Password, credential2.Password))
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
 internal static bool CompareCredential(PSCredential credential1, PSCredential credential2)
 {
     if (credential1 != null || credential2 != null)
     {
         if (!(credential1 == null ^ credential2 == null))
         {
             if (string.Compare(credential1.UserName, credential2.UserName, StringComparison.OrdinalIgnoreCase) == 0)
             {
                 if (WorkflowUtils.ComparePassword(credential1.Password, credential2.Password))
                 {
                     return(true);
                 }
                 else
                 {
                     return(false);
                 }
             }
             else
             {
                 return(false);
             }
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(true);
     }
 }
Ejemplo n.º 3
0
        } // CompareCertificateThumbprint ...

        /// <summary>
        /// CompareProxySettings compares the proxy settings for two wsman connections
        /// by doing a comparison of elements.
        /// </summary>
        /// <param name="connectionInfo1">Connection info 1</param>
        /// <param name="connectionInfo2">Connection info 2</param>
        /// <returns>True if they match else false.</returns>
        internal static bool CompareProxySettings(WSManConnectionInfo connectionInfo1, WSManConnectionInfo connectionInfo2)
        {
            Debug.Assert(connectionInfo1 != null && connectionInfo2 != null, "Connections should be != null");

            if (connectionInfo1.ProxyAccessType != connectionInfo2.ProxyAccessType)
            {
                return(false);
            }

            if (connectionInfo1.ProxyAccessType == ProxyAccessType.None)
            {
                return(true); //stop here if no proxy access type
            }

            if (connectionInfo1.ProxyAuthentication != connectionInfo2.ProxyAuthentication)
            {
                return(false);
            }

            // check the proxy credentials password
            if (!WorkflowUtils.CompareCredential(connectionInfo1.ProxyCredential, connectionInfo2.ProxyCredential))
            {
                return(false);
            }

            return(true);
        }  // CompareProxySettings ...
Ejemplo n.º 4
0
 internal static bool CompareProxySettings(WSManConnectionInfo connectionInfo1, WSManConnectionInfo connectionInfo2)
 {
     if (connectionInfo1.ProxyAccessType == connectionInfo2.ProxyAccessType)
     {
         if (connectionInfo1.ProxyAccessType != ProxyAccessType.None)
         {
             if (connectionInfo1.ProxyAuthentication == connectionInfo2.ProxyAuthentication)
             {
                 if (WorkflowUtils.CompareCredential(connectionInfo1.ProxyCredential, connectionInfo2.ProxyCredential))
                 {
                     return(true);
                 }
                 else
                 {
                     return(false);
                 }
             }
             else
             {
                 return(false);
             }
         }
         else
         {
             return(true);
         }
     }
     else
     {
         return(false);
     }
 }