// Module defining this command


        // Optional custom code for this activity


        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of System.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (SecureString.Expression != null)
            {
                targetCommand.AddParameter("SecureString", SecureString.Get(context));
            }

            if (SecureKey.Expression != null)
            {
                targetCommand.AddParameter("SecureKey", SecureKey.Get(context));
            }

            if (Key.Expression != null)
            {
                targetCommand.AddParameter("Key", Key.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
Пример #2
0
 /// <summary>
 /// Releases unmanaged and - optionally - managed resources.
 /// </summary>
 /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         SecureKey?.Dispose();
     }
 }
Пример #3
0
        public IHttpActionResult LoginUser(LoginModel userLogin)
        {
            var user      = new UsersBl().GetUserByUsername(userLogin.Username);
            var secureKey = new SecureKey().GetSecureKey(user.Username.ToLower(), user.Password).ToString();

            if (userLogin.Password.Equals(secureKey))
            {
                return(Ok());
            }
            return(BadRequest());
        }
Пример #4
0
        public static CredManifest GetManifest(bool forceLoad = false)
        {
            if (_cred != null && !forceLoad)
            {
                return(_cred);
            }

            try
            {
                Retreiving = true;
                PasswordCredential credential = null; var vault = new PasswordVault();
                credential = vault.Retrieve("SteamAuthenticator", "Storage");
                if (credential != null)
                {
                    credential.RetrievePassword();
                }
                else
                {
                    return(_generateNewManifest(new SecureString()));
                }

                string manifestContents = credential.Password.ToString();
                manifestContents = Encryptor.DPAPIUnprotect(credential.Password.ToString());
                _cred            = JsonConvert.DeserializeObject <CredManifest>(manifestContents);
                _originalCred    = credential.Password.ToString();

                foreach (char c in UnsecureKey.ToCharArray())
                {
                    SecureKey.AppendChar(c);
                }

                UnsecureKey = null;
                GC.Collect(); // security at its finest
                GC.WaitForPendingFinalizers();

                Retreiving = false;

                return(_cred);
            }
            catch (Exception)
            {
                Retreiving = false;
                return(_generateNewManifest(new SecureString()));
            }
        }