Added usersname and password option for the updater #1460

This commit is contained in:
Jamie.Rees 2017-10-18 10:47:31 +01:00
commit 22a0e92b63
7 changed files with 52 additions and 37 deletions

View file

@ -1,5 +1,7 @@
using System.Globalization;
using System;
using System.Globalization;
using System.Linq;
using System.Security;
using System.Security.Cryptography;
using System.Text;
@ -44,5 +46,24 @@ namespace Ombi.Helpers
return string.Join("", (sha1.ComputeHash(Encoding.UTF8.GetBytes(input))).Select(x => x.ToString("x2")).ToArray());
}
public static bool IsNullOrEmpty(this string s) => string.IsNullOrEmpty(s);
public static bool HasValue(this string s) => !IsNullOrEmpty(s);
public static SecureString ToSecureString(this string password)
{
if (password == null)
throw new ArgumentNullException(nameof(password));
var securePassword = new SecureString();
foreach (var c in password)
{
securePassword.AppendChar(c);
}
securePassword.MakeReadOnly();
return securePassword;
}
}
}

View file

@ -1,34 +0,0 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2017 Jamie Rees
// File: StringHelpers.cs
// Created By: Jamie Rees
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ************************************************************************/
#endregion
namespace Ombi.Helpers
{
public static class StringHelpers
{
public static bool IsNullOrEmpty(this string s) => string.IsNullOrEmpty(s);
public static bool HasValue(this string s) => !IsNullOrEmpty(s);
}
}