/// <summary> /// 获取网络物理文件 /// \\SERVERSVN\Shared\test.txt /// </summary> public FileResult GetNetworkFile(string filepath, string filename = "") { //if (string.IsNullOrWhiteSpace(filepath)) // throw new ArgumentNullException(nameof(filepath)); //WebRequest request = WebRequest.Create(filepath); //request.Method = "GET"; //request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8"; ////request.Credentials = this.getNetworkCredential(); //var response = request.GetResponse(); //return File(response.GetResponseStream(), response.ContentType); string server = this._settingManager.GetSettingValue("WinToolServer"); string username = this._settingManager.GetSettingValue("WinToolServerUid"); string password = this._settingManager.GetSettingValue("WinToolServerPwd"); FileStream fs = null; var contentType = MimeMapping.GetMimeMapping(filepath); using (IdentityScope scope = new IdentityScope(username, server, password)) { fs = System.IO.File.OpenRead(filepath); } return(File(fs, contentType)); }
//把文件从一个服务器拷到另一个服务器 public void getShareFile() { string sharefileSource = ConfigurationManager.AppSettings["sharefileSource"]; string sharefileTarget = ConfigurationManager.AppSettings["sharefileTarget"]; string ftpTarget = ConfigurationManager.AppSettings["FTPTarget"]; string strAdmin = ConfigurationManager.AppSettings["shareAdmin"]; string strPwd = ConfigurationManager.AppSettings["sharePwd"]; string strIP = ConfigurationManager.AppSettings["shareIP"]; string[] sAry = sharefileSource.Split('|'); string[] tAry = sharefileTarget.Split('|'); string[] fAry = ftpTarget.Split('|'); int thour = 1; string tday = ""; if (DateTime.Now.Hour == 1) { tday = DateTime.Now.AddDays(-1).ToString("yyyMMdd"); thour = 12; } if (DateTime.Now.Hour == 13) { tday = DateTime.Now.ToString("yyyMMdd"); thour = 0; } tday = DateTime.Now.ToString("yyyMMdd"); thour = 0; using (IdentityScope iss = new IdentityScope(strAdmin, strPwd, strIP)) { for (int i = 0; i < sAry.Length; i++) { DirectoryInfo TheFolder = new DirectoryInfo(sAry[i]); foreach (FileInfo FileItem in TheFolder.GetFiles()) { if (FileItem.Name.IndexOf(tday) > -1) { int hour = Int32.Parse(FileItem.Name.Split('_')[4].Substring(8, 2)); if (true)//hour == thour { int num = Int32.Parse(FileItem.Name.Split('-')[4].Split('.')[0]); if (num % 600 == 0) { if (File.Exists(tAry[i] + FileItem.Name)) { continue; } File.Copy(sAry[i] + FileItem.Name, tAry[i] + FileItem.Name, false); UploadFile(fAry[i], tAry[i] + FileItem.Name); //File.Delete(tempfilepath + FileItem.Name); writelog("成功同步文件:" + sAry[i] + FileItem.Name); } } } } } } }
/// <summary> /// Gets a value indicating whether the specified identity is a member of the specified permission scope. /// </summary> /// <param name="type">Identity scope.</param> /// <param name="identity">Identity.</param> /// <param name="scope">Permissions scope.</param> /// <returns>True is the specified identity is within the specified scope, otherwise false.</returns> public bool IsIdentityInPermissionScope(IdentityScope type, string identity, PermissionScope scope) { var si = SecurityIdentity.Create(type, identity); // TODO: Consider making a virtual hash set and calling contains (it'll be faster). return(this.GetScopeIdentities(scope, type).Any(i => i.Equals(si))); }
/// <summary> /// 获取气象预报报文 /// </summary> public void getQxPacket1() { string SourcePath = ConfigurationManager.AppSettings["PacketSource"]; string targetPath = ConfigurationManager.AppSettings["PacketTarget"]; string strAdmin = ConfigurationManager.AppSettings["shareAdmin"]; string strPwd = ConfigurationManager.AppSettings["sharePwd"]; string strIP = ConfigurationManager.AppSettings["shareIP"]; using (IdentityScope iss = new IdentityScope(strAdmin, strPwd, strIP)) { DirectoryInfo TheFolder = new DirectoryInfo(SourcePath); writelog("遍历文件夹:" + SourcePath); foreach (FileInfo FileItem in TheFolder.GetFiles()) { string str1 = DateTime.Now.ToString("yyyMMdd") + "224519"; string str2 = DateTime.Now.ToString("yyyMMdd") + "083019"; if (FileItem.Name.IndexOf(str1) > -1)//上午 { File.Copy(SourcePath + FileItem.Name, targetPath + FileItem.Name, true); ReadTXT(targetPath + FileItem.Name, 0); writelog("成功同步文件:" + FileItem.Name); } if (FileItem.Name.IndexOf(str2) > -1)//下午 { File.Copy(SourcePath + FileItem.Name, targetPath + FileItem.Name, true); ReadTXT(targetPath + FileItem.Name, 1); writelog("成功同步文件:" + FileItem.Name); } } } }
public static Core.Models.Scope ToModel(this IdentityScope s) { if (s == null) { return(null); } return(Config.CreateMapper().Map <IdentityScope, IdentityServer3.Core.Models.Scope>(s)); }
public async Task RevokePermissionsAsync(PermissionScope scope, IdentityScope identityType, string identity) { var resp = await _client.SendObjectAsync(HttpMethod.Delete, String.Format("table/{0}/permissions/{1}", _tableName, scope.ToString().ToLowerInvariant()), value : SecurityIdentity.Create(identityType, identity)); await resp.EnsureArribaSuccess(); return; }
public static IdentityServer3.Core.Models.Scope ToModel(this IdentityScope s) { if (s == null) { return(null); } return(Mapper.Map <IdentityScope, IdentityServer3.Core.Models.Scope>(s)); }
public SecurityIdentity(IdentityScope type, string name) { if (name == null) { throw new ArgumentNullException("name"); } else if (name.Length == 0) { throw new ArgumentException("Name must not be empty", "name"); } this.Scope = type; this.Name = name.ToLowerInvariant(); }
public void AutomapperConfigurationIsValid() { IdentityServer3.Core.Models.Scope s = new IdentityServer3.Core.Models.Scope() { }; var e = s.ToEntity(); IdentityServer3.Core.Models.Client c = new IdentityServer3.Core.Models.Client() { }; var e2 = c.ToEntity(); IdentityScope s2 = new IdentityScope() { ScopeClaims = new HashSet <IdentityServer3.EntityFramework.Entities.ScopeClaim>(), ScopeSecrets = new HashSet <IdentityServer3.EntityFramework.Entities.ScopeSecret>(), }; var m = s2.ToModel(); EntitiesMap.Config.AssertConfigurationIsValid(); }
public void AutomapperConfigurationIsValid() { IdentityServer3.Core.Models.Scope s = new IdentityServer3.Core.Models.Scope() { }; var e = s.ToEntity(); IdentityServer3.Core.Models.Client c = new IdentityServer3.Core.Models.Client() { }; var e2 = c.ToEntity(); IdentityScope s2 = new IdentityScope() { ScopeClaims = new HashSet<IdentityServer3.EntityFramework.Entities.ScopeClaim>(), ScopeSecrets = new HashSet<IdentityServer3.EntityFramework.Entities.ScopeSecret>(), }; var m = s2.ToModel(); EntitiesMap.Config.AssertConfigurationIsValid(); }
private static void SetTableCreators(string creators) { Console.WriteLine("Setting table creators..."); SecurityPermissions createPermissions = new SecurityPermissions(); foreach (string creator in creators.Split(';')) { string[] parts = creator.Split(':'); IdentityScope scope = parts[0].Equals("u", StringComparison.OrdinalIgnoreCase) ? IdentityScope.User : IdentityScope.Group; createPermissions.Grant(new SecurityIdentity(scope, parts[1]), PermissionScope.Owner); Console.WriteLine($" - {scope} {parts[1]}"); } // Create table, if required SecureDatabase db = new SecureDatabase(); db.SetSecurity("", createPermissions); db.SaveSecurity(""); }
protected static void SetSystemScope(IdentityScope scope) { SystemScope = scope; }
/// <summary> /// Revoke the specified identity for the specified permission scope. /// </summary> /// <param name="type">Type of Identity (Group, User)</param> /// <param name="identity">Identity to revoke permissions from (DOMAIN\user).</param> /// <param name="scope">Scope of permissions to revoke (Owner, Writer, Reader)</param> public void Revoke(IdentityScope type, string identity, PermissionScope scope) { Revoke(SecurityIdentity.Create(type, identity), scope); }
/// <summary> /// Grant the specified identity for the specified permission scope. /// </summary> /// <param name="type">Type of Identity (Group, User)</param> /// <param name="identity">Identity to grant permissions to (DOMAIN\user).</param> /// <param name="scope">Scope of permissions to grant (Owner, Writer, Reader)</param> public void Grant(IdentityScope type, string identity, PermissionScope scope) { Grant(SecurityIdentity.Create(type, identity), scope); }
protected static void SetSystemScope(IdentityScope scope) { SystemScope = scope; }
public static SecurityIdentity Create(IdentityScope type, string identity) { return(new SecurityIdentity(type, identity)); }