initial
This commit is contained in:
399
LiamBaseClasses/C4IT.LIAM.Base.cs
Normal file
399
LiamBaseClasses/C4IT.LIAM.Base.cs
Normal file
@@ -0,0 +1,399 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
|
||||
using C4IT.Logging;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
|
||||
namespace C4IT.LIAM
|
||||
{
|
||||
public enum eLiamAccessRoles
|
||||
{
|
||||
Owner = 1, Write = 2, Read = 3, Traverse = 4,
|
||||
ADOwner = 110, // "AD Owner Group"
|
||||
ADMember = 100, // "AD Member Group"
|
||||
ExchangeMLMember = 200, // "Mailing List Member"
|
||||
ExchangeMLOwner = 210, // "Mailing List Owner"
|
||||
ExchangeSMBFullAccess = 250, // "Shared Mailbox Full Access"
|
||||
ExchangeSMBSendAs = 260, // "Shared Mailbox Send as"
|
||||
ExchangeSMBOwner = 270 // "Shared Mailbox Owner"
|
||||
};
|
||||
public enum eLiamAccessRoleScopes { Unknown = 0, Universal = 1, Global = 2, DomainLocal = 3 };
|
||||
|
||||
public enum eLiamProviderTypes { Unknown = 0, Ntfs = 1, Sharepoint = 2, Matrix42 = 3, MsTeams = 4, ActiveDirectory = 5, Exchange = 6 };
|
||||
|
||||
public enum eLiamDataAreaTypes
|
||||
{
|
||||
Unknown = 0,
|
||||
NtfsShare = 101,
|
||||
NtfsFolder = 102,
|
||||
MsTeamsTeam = 401,
|
||||
MsTeamsChannel = 402,
|
||||
MsTeamsFolder = 403,
|
||||
ActiveDirectoryGroup = 501,
|
||||
ExchangeSharedMailbox = 601,
|
||||
ExchangeDistributionGroup = 602
|
||||
};
|
||||
|
||||
public enum eLiamGroupStrategies { None = 0, Ntfs_AGP = 0, Ntfs_AGDLP = 1 };
|
||||
|
||||
public class cLiamConfiguration
|
||||
{
|
||||
}
|
||||
|
||||
public class cLiamProviderData : ICloneable
|
||||
{
|
||||
|
||||
public eLiamProviderTypes ProviderType { get; set; } = eLiamProviderTypes.Unknown;
|
||||
|
||||
public string Domain { get; set; } = "";
|
||||
|
||||
public string RootPath { get; set; } = "";
|
||||
|
||||
public cLiamCredential Credential { get; set; } = null;
|
||||
|
||||
public int MaxDepth { get; set; } = 1;
|
||||
|
||||
public eLiamGroupStrategies GroupStrategy { get; set; } = eLiamGroupStrategies.None;
|
||||
|
||||
public string DataAreaFilter { get; set; } = "";
|
||||
|
||||
public string DataAreaRegEx { get; set; } = "";
|
||||
|
||||
public string GroupFilter { get; set; } = "";
|
||||
|
||||
public string GroupRegEx { get; set; } = "";
|
||||
|
||||
public string GroupPath { get; set; } = "";
|
||||
|
||||
public string OwnerGroupGlobal { get; set; } = "";
|
||||
public string OwnerGroupLocal { get; set; } = "";
|
||||
public string WriteGroupGlobal { get; set; } = "";
|
||||
public string WriteGroupLocal { get; set; } = "";
|
||||
public string ReadGroupGlobal { get; set; } = "";
|
||||
public string ReadGroupLocal { get; set; } = "";
|
||||
public string TraverseGroup { get; set; } = "";
|
||||
|
||||
public List<cLiamNamingConvention> NamingConventions { get; set; } = new List<cLiamNamingConvention>();
|
||||
public Dictionary<string, string> CustomTags { get; set; } = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
public Dictionary<string, string> AdditionalConfiguration { get; set; } = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
public static void Copy(cLiamProviderData From, cLiamProviderData To)
|
||||
{
|
||||
To.ProviderType = From.ProviderType;
|
||||
To.Domain = From.Domain;
|
||||
To.RootPath = From.RootPath;
|
||||
To.Credential = From.Credential;
|
||||
To.MaxDepth = From.MaxDepth;
|
||||
To.GroupStrategy = From.GroupStrategy;
|
||||
To.DataAreaFilter = From.DataAreaFilter;
|
||||
To.DataAreaRegEx = From.DataAreaRegEx;
|
||||
To.GroupFilter = From.GroupFilter;
|
||||
To.GroupRegEx = From.GroupRegEx;
|
||||
To.GroupPath = From.GroupPath;
|
||||
To.CustomTags = From.CustomTags;
|
||||
To.AdditionalConfiguration = From.AdditionalConfiguration;
|
||||
To.CustomTags = From.CustomTags;
|
||||
To.NamingConventions = From.NamingConventions;
|
||||
}
|
||||
|
||||
public cLiamProviderData()
|
||||
{
|
||||
}
|
||||
|
||||
public cLiamProviderData(cLiamProviderData PD)
|
||||
{
|
||||
Copy(PD, this);
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return new cLiamProviderData(this);
|
||||
}
|
||||
public void ReplaceCustomTags()
|
||||
{
|
||||
foreach (var customTag in this.CustomTags)
|
||||
{
|
||||
var Key = customTag.Key;
|
||||
|
||||
foreach (var namingConvention in NamingConventions)
|
||||
{
|
||||
if (customTag.Key == "Filesystem_GroupDomainLocalTag" && namingConvention.Scope == eLiamAccessRoleScopes.DomainLocal || customTag.Key == "Filesystem_GroupGlobalTag" && namingConvention.Scope == eLiamAccessRoleScopes.Global)
|
||||
Key = "SCOPETAG";
|
||||
else
|
||||
Key = customTag.Key;
|
||||
namingConvention.DescriptionTemplate = namingConvention.DescriptionTemplate.Replace($"{{{{{Key}}}}}", customTag.Value);
|
||||
namingConvention.NamingTemplate = namingConvention.NamingTemplate.Replace($"{{{{{Key}}}}}", customTag.Value);
|
||||
namingConvention.Wildcard = namingConvention.Wildcard.Replace($"{{{{{Key}}}}}", customTag.Value);
|
||||
}
|
||||
GroupFilter = GroupFilter.Replace($"{{{{{Key}}}}}", customTag.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class cLiamProviderBase : cLiamProviderData
|
||||
{
|
||||
public cLiamConfiguration LiamConfiguration { get; private set; }
|
||||
|
||||
public cLiamProviderBase(cLiamConfiguration Configuration, cLiamProviderData ProviderData) :
|
||||
base(ProviderData)
|
||||
{
|
||||
LiamConfiguration = Configuration;
|
||||
}
|
||||
|
||||
public abstract Task<List<cLiamDataAreaBase>> getDataAreasAsync(int MaxDepth = -1);
|
||||
|
||||
public abstract Task<bool> LogonAsync();
|
||||
public abstract string GetLastErrorMessage();
|
||||
|
||||
public abstract Task<cLiamDataAreaBase> LoadDataArea(string UID);
|
||||
|
||||
public static cLiamProviderBase CreateInstance(cLiamConfiguration LiamConfiguration, cLiamProviderData ProviderData)
|
||||
{
|
||||
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
var MyPath = Assembly.GetExecutingAssembly()?.Location;
|
||||
if (MyPath == null)
|
||||
return null;
|
||||
|
||||
MyPath = Path.GetDirectoryName(MyPath);
|
||||
var DllPath = Path.Combine(MyPath, $"Liam{ProviderData.ProviderType}.dll");
|
||||
if (!File.Exists(DllPath))
|
||||
{
|
||||
LogEntry($"Couldn not found Data Provider library '{DllPath}'", LogLevels.Error);
|
||||
return null;
|
||||
}
|
||||
|
||||
var assLocal = Assembly.LoadFrom(DllPath);
|
||||
if (assLocal == null)
|
||||
{
|
||||
LogEntry($"Could not load Data Provider library '{DllPath}'", LogLevels.Error);
|
||||
return null;
|
||||
}
|
||||
var TP = assLocal.GetTypes();
|
||||
var type = assLocal.GetType("C4IT.LIAM.LiamInitializer");
|
||||
if (type == null)
|
||||
{
|
||||
LogEntry($"Could not found class 'C4IT.LIAM.LiamInitializer' in library '{DllPath}'", LogLevels.Error);
|
||||
return null;
|
||||
}
|
||||
|
||||
var MI = type.GetMethod("CreateInstance");
|
||||
if (MI == null)
|
||||
{
|
||||
LogEntry($"Could not found method 'CreateInstance' in class 'C4IT.LIAM.LiamInitializer' in library '{DllPath}'", LogLevels.Error);
|
||||
return null;
|
||||
}
|
||||
var objDll = MI.Invoke(null, new object[] { LiamConfiguration, ProviderData });
|
||||
var RetVal = objDll as cLiamProviderBase;
|
||||
ProviderData.ReplaceCustomTags();
|
||||
return RetVal;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public abstract Task<List<cLiamDataAreaBase>> getSecurityGroupsAsync(string groupFilter);
|
||||
}
|
||||
|
||||
public class cLiamCredential
|
||||
{
|
||||
public string Domain { get; set; } = "";
|
||||
public string Identification { get; set; } = "";
|
||||
public string Secret { get; set; } = "";
|
||||
}
|
||||
|
||||
public class cLiamNamingConvention
|
||||
{
|
||||
public string Name { get; set; } = "";
|
||||
public string Description { get; set; } = "";
|
||||
public string NamingTemplate { get; set; } = "";
|
||||
public string DescriptionTemplate { get; set; } = "";
|
||||
public string Wildcard { get; set; } = "";
|
||||
public eLiamAccessRoles AccessRole { get; set; } = eLiamAccessRoles.Read;
|
||||
public eLiamAccessRoleScopes Scope { get; set; } = eLiamAccessRoleScopes.Unknown;
|
||||
public eLiamProviderTypes? ProviderType { get; set; } = null;
|
||||
}
|
||||
|
||||
public class cLiamDataAreaInfo
|
||||
{
|
||||
public string DisplayName { get; protected set; } = null;
|
||||
public string Description { get; protected set; } = null;
|
||||
public string OwnerRef { get; set; } = null;
|
||||
public string UID { get; protected set; } = null;
|
||||
public string CreatedDate { get; protected set; } = null;
|
||||
|
||||
public string TechnicalName { get; protected set; } = "";
|
||||
|
||||
public int Level { get; set; } = -1;
|
||||
|
||||
public string ParentUID { get; protected set; } = null;
|
||||
|
||||
public eLiamDataAreaTypes DataType { get; protected set; } = eLiamDataAreaTypes.Unknown;
|
||||
|
||||
public bool SupportsPermissions { get; protected set; } = false;
|
||||
|
||||
public bool SupportsOwners { get; protected set; } = false;
|
||||
}
|
||||
|
||||
public abstract class cLiamDataAreaBase : cLiamDataAreaInfo
|
||||
{
|
||||
|
||||
public readonly cLiamProviderBase Provider = null;
|
||||
|
||||
public cLiamDataAreaBase(cLiamProviderBase Provider)
|
||||
{
|
||||
this.Provider = Provider;
|
||||
}
|
||||
|
||||
public abstract Task<List<cLiamDataAreaBase>> getChildrenAsync(int Depth = -1);
|
||||
|
||||
public static async Task<List<cLiamDataAreaBase>> getChildrenFromListAsync(List<cLiamDataAreaBase> Items, int Depth = -1)
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
var RetVal = new List<cLiamDataAreaBase>();
|
||||
try
|
||||
{
|
||||
if (Items == null)
|
||||
return RetVal;
|
||||
|
||||
if (Depth <= 0)
|
||||
return RetVal;
|
||||
|
||||
foreach (var Entry in Items)
|
||||
{
|
||||
var Childs = await Entry.getChildrenAsync(Depth + 1);
|
||||
if (Childs != null)
|
||||
RetVal.AddRange(Childs);
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
return RetVal;
|
||||
}
|
||||
|
||||
public virtual async Task<List<cLiamUserInfo>> GetOwnersAsync()
|
||||
{
|
||||
await Task.Delay(0);
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual async Task<List<cLiamPermissionInfo>> GetPermissionsAsync(bool force)
|
||||
{
|
||||
await Task.Delay(0);
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual async Task<cLiamPermissionResult> GrantPermissionAsync(cLiamUserInfo User, eLiamAccessRoles Role)
|
||||
{
|
||||
await Task.Delay(0);
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual async Task<bool> RevokePermissionAsync(cLiamUserInfo User, eLiamAccessRoles Role)
|
||||
{
|
||||
await Task.Delay(0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public class cLiamUserInfo
|
||||
{
|
||||
public string DisplayName { get; set; } = null;
|
||||
public string GivenName { get; set; } = null;
|
||||
public string SurName { get; set; } = null;
|
||||
public string UserPrincipalName { get; set; } = null;
|
||||
public string EMail { get; set; } = null;
|
||||
public string SID { get; set; } = null;
|
||||
}
|
||||
|
||||
public class cLiamPermissionResult
|
||||
{
|
||||
public bool Valid { get; set; } = false;
|
||||
public string UserReference { get; set; } = null;
|
||||
}
|
||||
|
||||
public class cLiamPermissionInfo
|
||||
{
|
||||
public cLiamUserInfo User;
|
||||
public eLiamAccessRoles AccessRole = eLiamAccessRoles.Read;
|
||||
public bool OnlyEffective = false;
|
||||
}
|
||||
|
||||
|
||||
public class DataAreaEntryBase
|
||||
{
|
||||
public string DisplayName { get; set; }
|
||||
public string TechnicalName { get; set; }
|
||||
public string UID { get; set; }
|
||||
public string TargetType { get; set; }
|
||||
}
|
||||
|
||||
public class SecurityGroupEntry : DataAreaEntryBase
|
||||
{
|
||||
public string Scope { get; set; }
|
||||
}
|
||||
public class DataAreaEntry : DataAreaEntryBase
|
||||
{
|
||||
public string Parent { get; set; }
|
||||
public string ParentUID { get; set; }
|
||||
public string Owner { get; set; }
|
||||
public string Write { get; set; }
|
||||
public string Read { get; set; }
|
||||
public string Traverse { get; set; }
|
||||
public string CreatedDate { get; set; }
|
||||
public string Level { get; set; }
|
||||
public string ConfigurationId { get; set; }
|
||||
public string BaseFolder { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string UniqueId { get; set; }
|
||||
public string DataAreaType { get; set; }
|
||||
}
|
||||
public class LiamApiVersionInfo
|
||||
{
|
||||
public string ProductName { get; set; } = "- unknown -";
|
||||
public string ProductVersion { get; set; } = "";
|
||||
public string AssemblyName { get; set; } = "- unknown -";
|
||||
public string AssemblyVersion { get; set; } = "";
|
||||
}
|
||||
|
||||
public class ProviderCacheEntry
|
||||
{
|
||||
public Guid ID;
|
||||
public Guid ObjectID;
|
||||
public DateTime ValidUntil;
|
||||
public cLiamProviderBase Provider;
|
||||
}
|
||||
|
||||
public class LiamDataAreaEntry
|
||||
{
|
||||
public string DisplayName { get; set; } = "";
|
||||
|
||||
public string UID { get; set; } = "";
|
||||
|
||||
public bool SupportsPermissions { get; set; } = false;
|
||||
}
|
||||
}
|
||||
399
LiamBaseClasses/C4IT.LIAM.Base.cs.txt
Normal file
399
LiamBaseClasses/C4IT.LIAM.Base.cs.txt
Normal file
@@ -0,0 +1,399 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
|
||||
using C4IT.Logging;
|
||||
using static C4IT.Logging.cLogManager;
|
||||
|
||||
|
||||
namespace C4IT.LIAM
|
||||
{
|
||||
public enum eLiamAccessRoles
|
||||
{
|
||||
Owner = 1, Write = 2, Read = 3, Traverse = 4,
|
||||
ADOwner = 100, // "AD Owner Group"
|
||||
ADMember = 110, // "AD Member Group"
|
||||
ExchangeMLMember = 200, // "Mailing List Member"
|
||||
ExchangeMLOwner = 210, // "Mailing List Owner"
|
||||
ExchangeSMBFullAccess = 250, // "Shared Mailbox Full Access"
|
||||
ExchangeSMBSendAs = 260, // "Shared Mailbox Send as"
|
||||
ExchangeSMBOwner = 270 // "Shared Mailbox Owner"
|
||||
};
|
||||
public enum eLiamAccessRoleScopes { Unknown = 0, Universal = 1, Global = 2, DomainLocal = 3 };
|
||||
|
||||
public enum eLiamProviderTypes { Unknown = 0, Ntfs = 1, Sharepoint = 2, Matrix42 = 3, MsTeams = 4, ActiveDirectory = 5, Exchange = 6 };
|
||||
|
||||
public enum eLiamDataAreaTypes
|
||||
{
|
||||
Unknown = 0,
|
||||
NtfsShare = 101,
|
||||
NtfsFolder = 102,
|
||||
MsTeamsTeam = 401,
|
||||
MsTeamsChannel = 402,
|
||||
MsTeamsFolder = 403,
|
||||
ActiveDirectoryGroup = 501,
|
||||
ExchangeSharedMailbox = 601,
|
||||
ExchangeDistributionGroup = 602
|
||||
};
|
||||
|
||||
public enum eLiamGroupStrategies { None = 0, Ntfs_AGP = 0, Ntfs_AGDLP = 1 };
|
||||
|
||||
public class cLiamConfiguration
|
||||
{
|
||||
}
|
||||
|
||||
public class cLiamProviderData : ICloneable
|
||||
{
|
||||
|
||||
public eLiamProviderTypes ProviderType { get; set; } = eLiamProviderTypes.Unknown;
|
||||
|
||||
public string Domain { get; set; } = "";
|
||||
|
||||
public string RootPath { get; set; } = "";
|
||||
|
||||
public cLiamCredential Credential { get; set; } = null;
|
||||
|
||||
public int MaxDepth { get; set; } = 1;
|
||||
|
||||
public eLiamGroupStrategies GroupStrategy { get; set; } = eLiamGroupStrategies.None;
|
||||
|
||||
public string DataAreaFilter { get; set; } = "";
|
||||
|
||||
public string DataAreaRegEx { get; set; } = "";
|
||||
|
||||
public string GroupFilter { get; set; } = "";
|
||||
|
||||
public string GroupRegEx { get; set; } = "";
|
||||
|
||||
public string GroupPath { get; set; } = "";
|
||||
|
||||
public string OwnerGroupGlobal { get; set; } = "";
|
||||
public string OwnerGroupLocal { get; set; } = "";
|
||||
public string WriteGroupGlobal { get; set; } = "";
|
||||
public string WriteGroupLocal { get; set; } = "";
|
||||
public string ReadGroupGlobal { get; set; } = "";
|
||||
public string ReadGroupLocal { get; set; } = "";
|
||||
public string TraverseGroup { get; set; } = "";
|
||||
|
||||
public List<cLiamNamingConvention> NamingConventions { get; set; } = new List<cLiamNamingConvention>();
|
||||
public Dictionary<string, string> CustomTags { get; set; } = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
public Dictionary<string, string> AdditionalConfiguration { get; set; } = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
public static void Copy(cLiamProviderData From, cLiamProviderData To)
|
||||
{
|
||||
To.ProviderType = From.ProviderType;
|
||||
To.Domain = From.Domain;
|
||||
To.RootPath = From.RootPath;
|
||||
To.Credential = From.Credential;
|
||||
To.MaxDepth = From.MaxDepth;
|
||||
To.GroupStrategy = From.GroupStrategy;
|
||||
To.DataAreaFilter = From.DataAreaFilter;
|
||||
To.DataAreaRegEx = From.DataAreaRegEx;
|
||||
To.GroupFilter = From.GroupFilter;
|
||||
To.GroupRegEx = From.GroupRegEx;
|
||||
To.GroupPath = From.GroupPath;
|
||||
To.CustomTags = From.CustomTags;
|
||||
To.AdditionalConfiguration = From.AdditionalConfiguration;
|
||||
To.CustomTags = From.CustomTags;
|
||||
To.NamingConventions = From.NamingConventions;
|
||||
}
|
||||
|
||||
public cLiamProviderData()
|
||||
{
|
||||
}
|
||||
|
||||
public cLiamProviderData(cLiamProviderData PD)
|
||||
{
|
||||
Copy(PD, this);
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return new cLiamProviderData(this);
|
||||
}
|
||||
public void ReplaceCustomTags()
|
||||
{
|
||||
foreach (var customTag in this.CustomTags)
|
||||
{
|
||||
var Key = customTag.Key;
|
||||
|
||||
foreach (var namingConvention in NamingConventions)
|
||||
{
|
||||
if (customTag.Key == "Filesystem_GroupDomainLocalTag" && namingConvention.Scope == eLiamAccessRoleScopes.DomainLocal || customTag.Key == "Filesystem_GroupGlobalTag" && namingConvention.Scope == eLiamAccessRoleScopes.Global)
|
||||
Key = "SCOPETAG";
|
||||
else
|
||||
Key = customTag.Key;
|
||||
namingConvention.DescriptionTemplate = namingConvention.DescriptionTemplate.Replace($"{{{{{Key}}}}}", customTag.Value);
|
||||
namingConvention.NamingTemplate = namingConvention.NamingTemplate.Replace($"{{{{{Key}}}}}", customTag.Value);
|
||||
namingConvention.Wildcard = namingConvention.Wildcard.Replace($"{{{{{Key}}}}}", customTag.Value);
|
||||
}
|
||||
GroupFilter = GroupFilter.Replace($"{{{{{Key}}}}}", customTag.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class cLiamProviderBase : cLiamProviderData
|
||||
{
|
||||
public cLiamConfiguration LiamConfiguration { get; private set; }
|
||||
|
||||
public cLiamProviderBase(cLiamConfiguration Configuration, cLiamProviderData ProviderData) :
|
||||
base(ProviderData)
|
||||
{
|
||||
LiamConfiguration = Configuration;
|
||||
}
|
||||
|
||||
public abstract Task<List<cLiamDataAreaBase>> getDataAreasAsync(int MaxDepth = -1);
|
||||
|
||||
public abstract Task<bool> LogonAsync();
|
||||
public abstract string GetLastErrorMessage();
|
||||
|
||||
public abstract Task<cLiamDataAreaBase> LoadDataArea(string UID);
|
||||
|
||||
public static cLiamProviderBase CreateInstance(cLiamConfiguration LiamConfiguration, cLiamProviderData ProviderData)
|
||||
{
|
||||
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
try
|
||||
{
|
||||
var MyPath = Assembly.GetExecutingAssembly()?.Location;
|
||||
if (MyPath == null)
|
||||
return null;
|
||||
|
||||
MyPath = Path.GetDirectoryName(MyPath);
|
||||
var DllPath = Path.Combine(MyPath, $"Liam{ProviderData.ProviderType}.dll");
|
||||
if (!File.Exists(DllPath))
|
||||
{
|
||||
LogEntry($"Couldn not found Data Provider library '{DllPath}'", LogLevels.Error);
|
||||
return null;
|
||||
}
|
||||
|
||||
var assLocal = Assembly.LoadFrom(DllPath);
|
||||
if (assLocal == null)
|
||||
{
|
||||
LogEntry($"Could not load Data Provider library '{DllPath}'", LogLevels.Error);
|
||||
return null;
|
||||
}
|
||||
var TP = assLocal.GetTypes();
|
||||
var type = assLocal.GetType("C4IT.LIAM.LiamInitializer");
|
||||
if (type == null)
|
||||
{
|
||||
LogEntry($"Could not found class 'C4IT.LIAM.LiamInitializer' in library '{DllPath}'", LogLevels.Error);
|
||||
return null;
|
||||
}
|
||||
|
||||
var MI = type.GetMethod("CreateInstance");
|
||||
if (MI == null)
|
||||
{
|
||||
LogEntry($"Could not found method 'CreateInstance' in class 'C4IT.LIAM.LiamInitializer' in library '{DllPath}'", LogLevels.Error);
|
||||
return null;
|
||||
}
|
||||
var objDll = MI.Invoke(null, new object[] { LiamConfiguration, ProviderData });
|
||||
var RetVal = objDll as cLiamProviderBase;
|
||||
ProviderData.ReplaceCustomTags();
|
||||
return RetVal;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public abstract Task<List<cLiamDataAreaBase>> getSecurityGroupsAsync(string groupFilter);
|
||||
}
|
||||
|
||||
public class cLiamCredential
|
||||
{
|
||||
public string Domain { get; set; } = "";
|
||||
public string Identification { get; set; } = "";
|
||||
public string Secret { get; set; } = "";
|
||||
}
|
||||
|
||||
public class cLiamNamingConvention
|
||||
{
|
||||
public string Name { get; set; } = "";
|
||||
public string Description { get; set; } = "";
|
||||
public string NamingTemplate { get; set; } = "";
|
||||
public string DescriptionTemplate { get; set; } = "";
|
||||
public string Wildcard { get; set; } = "";
|
||||
public eLiamAccessRoles AccessRole { get; set; } = eLiamAccessRoles.Read;
|
||||
public eLiamAccessRoleScopes Scope { get; set; } = eLiamAccessRoleScopes.Unknown;
|
||||
public eLiamProviderTypes? ProviderType { get; set; } = null;
|
||||
}
|
||||
|
||||
public class cLiamDataAreaInfo
|
||||
{
|
||||
public string DisplayName { get; protected set; } = null;
|
||||
public string Description { get; protected set; } = null;
|
||||
public string OwnerRef { get; set; } = null;
|
||||
public string UID { get; protected set; } = null;
|
||||
public string CreatedDate { get; protected set; } = null;
|
||||
|
||||
public string TechnicalName { get; protected set; } = "";
|
||||
|
||||
public int Level { get; set; } = -1;
|
||||
|
||||
public string ParentUID { get; protected set; } = null;
|
||||
|
||||
public eLiamDataAreaTypes DataType { get; protected set; } = eLiamDataAreaTypes.Unknown;
|
||||
|
||||
public bool SupportsPermissions { get; protected set; } = false;
|
||||
|
||||
public bool SupportsOwners { get; protected set; } = false;
|
||||
}
|
||||
|
||||
public abstract class cLiamDataAreaBase : cLiamDataAreaInfo
|
||||
{
|
||||
|
||||
public readonly cLiamProviderBase Provider = null;
|
||||
|
||||
public cLiamDataAreaBase(cLiamProviderBase Provider)
|
||||
{
|
||||
this.Provider = Provider;
|
||||
}
|
||||
|
||||
public abstract Task<List<cLiamDataAreaBase>> getChildrenAsync(int Depth = -1);
|
||||
|
||||
public static async Task<List<cLiamDataAreaBase>> getChildrenFromListAsync(List<cLiamDataAreaBase> Items, int Depth = -1)
|
||||
{
|
||||
var CM = MethodBase.GetCurrentMethod();
|
||||
LogMethodBegin(CM);
|
||||
var RetVal = new List<cLiamDataAreaBase>();
|
||||
try
|
||||
{
|
||||
if (Items == null)
|
||||
return RetVal;
|
||||
|
||||
if (Depth <= 0)
|
||||
return RetVal;
|
||||
|
||||
foreach (var Entry in Items)
|
||||
{
|
||||
var Childs = await Entry.getChildrenAsync(Depth + 1);
|
||||
if (Childs != null)
|
||||
RetVal.AddRange(Childs);
|
||||
}
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
LogException(E);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LogMethodEnd(CM);
|
||||
}
|
||||
return RetVal;
|
||||
}
|
||||
|
||||
public virtual async Task<List<cLiamUserInfo>> GetOwnersAsync()
|
||||
{
|
||||
await Task.Delay(0);
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual async Task<List<cLiamPermissionInfo>> GetPermissionsAsync(bool force)
|
||||
{
|
||||
await Task.Delay(0);
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual async Task<cLiamPermissionResult> GrantPermissionAsync(cLiamUserInfo User, eLiamAccessRoles Role)
|
||||
{
|
||||
await Task.Delay(0);
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual async Task<bool> RevokePermissionAsync(cLiamUserInfo User, eLiamAccessRoles Role)
|
||||
{
|
||||
await Task.Delay(0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public class cLiamUserInfo
|
||||
{
|
||||
public string DisplayName { get; set; } = null;
|
||||
public string GivenName { get; set; } = null;
|
||||
public string SurName { get; set; } = null;
|
||||
public string UserPrincipalName { get; set; } = null;
|
||||
public string EMail { get; set; } = null;
|
||||
public string SID { get; set; } = null;
|
||||
}
|
||||
|
||||
public class cLiamPermissionResult
|
||||
{
|
||||
public bool Valid { get; set; } = false;
|
||||
public string UserReference { get; set; } = null;
|
||||
}
|
||||
|
||||
public class cLiamPermissionInfo
|
||||
{
|
||||
public cLiamUserInfo User;
|
||||
public eLiamAccessRoles AccessRole = eLiamAccessRoles.Read;
|
||||
public bool OnlyEffective = false;
|
||||
}
|
||||
|
||||
|
||||
public class DataAreaEntryBase
|
||||
{
|
||||
public string DisplayName { get; set; }
|
||||
public string TechnicalName { get; set; }
|
||||
public string UID { get; set; }
|
||||
public string TargetType { get; set; }
|
||||
}
|
||||
|
||||
public class SecurityGroupEntry : DataAreaEntryBase
|
||||
{
|
||||
public string Scope { get; set; }
|
||||
}
|
||||
public class DataAreaEntry : DataAreaEntryBase
|
||||
{
|
||||
public string Parent { get; set; }
|
||||
public string ParentUID { get; set; }
|
||||
public string Owner { get; set; }
|
||||
public string Write { get; set; }
|
||||
public string Read { get; set; }
|
||||
public string Traverse { get; set; }
|
||||
public string CreatedDate { get; set; }
|
||||
public string Level { get; set; }
|
||||
public string ConfigurationId { get; set; }
|
||||
public string BaseFolder { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string UniqueId { get; set; }
|
||||
public string DataAreaType { get; set; }
|
||||
}
|
||||
public class LiamApiVersionInfo
|
||||
{
|
||||
public string ProductName { get; set; } = "- unknown -";
|
||||
public string ProductVersion { get; set; } = "";
|
||||
public string AssemblyName { get; set; } = "- unknown -";
|
||||
public string AssemblyVersion { get; set; } = "";
|
||||
}
|
||||
|
||||
public class ProviderCacheEntry
|
||||
{
|
||||
public Guid ID;
|
||||
public Guid ObjectID;
|
||||
public DateTime ValidUntil;
|
||||
public cLiamProviderBase Provider;
|
||||
}
|
||||
|
||||
public class LiamDataAreaEntry
|
||||
{
|
||||
public string DisplayName { get; set; } = "";
|
||||
|
||||
public string UID { get; set; } = "";
|
||||
|
||||
public bool SupportsPermissions { get; set; } = false;
|
||||
}
|
||||
}
|
||||
61
LiamBaseClasses/LiamBaseClasses.csproj
Normal file
61
LiamBaseClasses/LiamBaseClasses.csproj
Normal file
@@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{3531C9E6-CF6E-458E-B604-4A5A8D1C7AB0}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>LiamBaseClasses</RootNamespace>
|
||||
<AssemblyName>LiamBaseClasses</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>false</Deterministic>
|
||||
<SccProjectName>SAK</SccProjectName>
|
||||
<SccLocalPath>SAK</SccLocalPath>
|
||||
<SccAuxPath>SAK</SccAuxPath>
|
||||
<SccProvider>SAK</SccProvider>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\SharedAssemblyInfo.cs">
|
||||
<Link>Properties\SharedAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="C4IT.LIAM.Base.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\LiamHelper\LiamHelper.csproj">
|
||||
<Project>{6b0e73a6-f918-42d5-9525-d59d4d16283d}</Project>
|
||||
<Name>LiamHelper</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
10
LiamBaseClasses/LiamBaseClasses.csproj.vspscc
Normal file
10
LiamBaseClasses/LiamBaseClasses.csproj.vspscc
Normal file
@@ -0,0 +1,10 @@
|
||||
""
|
||||
{
|
||||
"FILE_VERSION" = "9237"
|
||||
"ENLISTMENT_CHOICE" = "NEVER"
|
||||
"PROJECT_FILE_RELATIVE_PATH" = ""
|
||||
"NUMBER_OF_EXCLUDED_FILES" = "0"
|
||||
"ORIGINAL_PROJECT_FILE_PATH" = ""
|
||||
"NUMBER_OF_NESTED_PROJECTS" = "0"
|
||||
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
|
||||
}
|
||||
11
LiamBaseClasses/Properties/AssemblyInfo.cs
Normal file
11
LiamBaseClasses/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("LIAM support library for basic classes & interfaces")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
[assembly: Guid("3531c9e6-cf6e-458e-b604-4a5a8d1c7ab0")]
|
||||
BIN
LiamBaseClasses/bin/Debug/LiamBaseClasses.dll
Normal file
BIN
LiamBaseClasses/bin/Debug/LiamBaseClasses.dll
Normal file
Binary file not shown.
BIN
LiamBaseClasses/bin/Debug/LiamBaseClasses.pdb
Normal file
BIN
LiamBaseClasses/bin/Debug/LiamBaseClasses.pdb
Normal file
Binary file not shown.
BIN
LiamBaseClasses/bin/Debug/LiamHelper.dll
Normal file
BIN
LiamBaseClasses/bin/Debug/LiamHelper.dll
Normal file
Binary file not shown.
BIN
LiamBaseClasses/bin/Debug/LiamHelper.pdb
Normal file
BIN
LiamBaseClasses/bin/Debug/LiamHelper.pdb
Normal file
Binary file not shown.
BIN
LiamBaseClasses/bin/Debug/Newtonsoft.Json.dll
Normal file
BIN
LiamBaseClasses/bin/Debug/Newtonsoft.Json.dll
Normal file
Binary file not shown.
BIN
LiamBaseClasses/bin/Release/LiamBaseClasses.dll
Normal file
BIN
LiamBaseClasses/bin/Release/LiamBaseClasses.dll
Normal file
Binary file not shown.
BIN
LiamBaseClasses/bin/Release/LiamBaseClasses.pdb
Normal file
BIN
LiamBaseClasses/bin/Release/LiamBaseClasses.pdb
Normal file
Binary file not shown.
BIN
LiamBaseClasses/bin/Release/LiamHelper.dll
Normal file
BIN
LiamBaseClasses/bin/Release/LiamHelper.dll
Normal file
Binary file not shown.
BIN
LiamBaseClasses/bin/Release/LiamHelper.pdb
Normal file
BIN
LiamBaseClasses/bin/Release/LiamHelper.pdb
Normal file
Binary file not shown.
BIN
LiamBaseClasses/bin/Release/Newtonsoft.Json.dll
Normal file
BIN
LiamBaseClasses/bin/Release/Newtonsoft.Json.dll
Normal file
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
|
||||
Binary file not shown.
0
LiamBaseClasses/obj/Debug/LiamBase.24B0A51E.Up2Date
Normal file
0
LiamBaseClasses/obj/Debug/LiamBase.24B0A51E.Up2Date
Normal file
Binary file not shown.
@@ -0,0 +1 @@
|
||||
3908855f9633bf09d020c2efbd1fa153a9ad8a91b6e76b39255ee0403b9907f8
|
||||
@@ -0,0 +1,10 @@
|
||||
C:\Workspace\C4IT DEV LIAM WEB Service\LiamBaseClasses\bin\Debug\LiamBaseClasses.dll
|
||||
C:\Workspace\C4IT DEV LIAM WEB Service\LiamBaseClasses\bin\Debug\LiamBaseClasses.pdb
|
||||
C:\Workspace\C4IT DEV LIAM WEB Service\LiamBaseClasses\bin\Debug\LiamHelper.dll
|
||||
C:\Workspace\C4IT DEV LIAM WEB Service\LiamBaseClasses\bin\Debug\Newtonsoft.Json.dll
|
||||
C:\Workspace\C4IT DEV LIAM WEB Service\LiamBaseClasses\bin\Debug\LiamHelper.pdb
|
||||
C:\Workspace\C4IT DEV LIAM WEB Service\LiamBaseClasses\obj\Debug\LiamBaseClasses.csproj.AssemblyReference.cache
|
||||
C:\Workspace\C4IT DEV LIAM WEB Service\LiamBaseClasses\obj\Debug\LiamBaseClasses.csproj.CoreCompileInputs.cache
|
||||
C:\Workspace\C4IT DEV LIAM WEB Service\LiamBaseClasses\obj\Debug\LiamBase.24B0A51E.Up2Date
|
||||
C:\Workspace\C4IT DEV LIAM WEB Service\LiamBaseClasses\obj\Debug\LiamBaseClasses.dll
|
||||
C:\Workspace\C4IT DEV LIAM WEB Service\LiamBaseClasses\obj\Debug\LiamBaseClasses.pdb
|
||||
BIN
LiamBaseClasses/obj/Debug/LiamBaseClasses.dll
Normal file
BIN
LiamBaseClasses/obj/Debug/LiamBaseClasses.dll
Normal file
Binary file not shown.
BIN
LiamBaseClasses/obj/Debug/LiamBaseClasses.pdb
Normal file
BIN
LiamBaseClasses/obj/Debug/LiamBaseClasses.pdb
Normal file
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
77f86ea35cc63f1fe117fbff3ddf1a527617a8ddb75413eb5ef7f6b4cf6c8399
|
||||
@@ -0,0 +1,10 @@
|
||||
C:\Workspace\C4IT DEV LIAM WEB Service\LiamBaseClasses\bin\Release\LiamBaseClasses.dll
|
||||
C:\Workspace\C4IT DEV LIAM WEB Service\LiamBaseClasses\bin\Release\LiamBaseClasses.pdb
|
||||
C:\Workspace\C4IT DEV LIAM WEB Service\LiamBaseClasses\bin\Release\LiamHelper.dll
|
||||
C:\Workspace\C4IT DEV LIAM WEB Service\LiamBaseClasses\bin\Release\Newtonsoft.Json.dll
|
||||
C:\Workspace\C4IT DEV LIAM WEB Service\LiamBaseClasses\bin\Release\LiamHelper.pdb
|
||||
C:\Workspace\C4IT DEV LIAM WEB Service\LiamBaseClasses\obj\Release\LiamBaseClasses.csproj.AssemblyReference.cache
|
||||
C:\Workspace\C4IT DEV LIAM WEB Service\LiamBaseClasses\obj\Release\LiamBaseClasses.csproj.CoreCompileInputs.cache
|
||||
C:\Workspace\C4IT DEV LIAM WEB Service\LiamBaseClasses\obj\Release\LiamBase.24B0A51E.Up2Date
|
||||
C:\Workspace\C4IT DEV LIAM WEB Service\LiamBaseClasses\obj\Release\LiamBaseClasses.dll
|
||||
C:\Workspace\C4IT DEV LIAM WEB Service\LiamBaseClasses\obj\Release\LiamBaseClasses.pdb
|
||||
BIN
LiamBaseClasses/obj/Release/LiamBaseClasses.dll
Normal file
BIN
LiamBaseClasses/obj/Release/LiamBaseClasses.dll
Normal file
Binary file not shown.
BIN
LiamBaseClasses/obj/Release/LiamBaseClasses.pdb
Normal file
BIN
LiamBaseClasses/obj/Release/LiamBaseClasses.pdb
Normal file
Binary file not shown.
Reference in New Issue
Block a user