public static void CreateComputerObject(string sourceName) { Logging.GetLogger().AddToLog("Creating Computer object", true); string computerIp = Common.GetComputerIP(); if (OSAEObjectManager.GetObjectByName(Common.ComputerName) == null) { OSAEObject obj = OSAEObjectManager.GetObjectByAddress(computerIp); if (obj == null) { OSAEObjectManager.ObjectAdd(Common.ComputerName, Common.ComputerName, Common.ComputerName, "COMPUTER", computerIp, string.Empty, true); OSAEObjectPropertyManager.ObjectPropertySet(Common.ComputerName, "Host Name", Common.ComputerName, sourceName); } else if (obj.Type == "COMPUTER") { OSAEObjectManager.ObjectUpdate(obj.Name, Common.ComputerName, obj.Alias, obj.Description, "COMPUTER", computerIp, obj.Container, obj.Enabled); OSAEObjectPropertyManager.ObjectPropertySet(Common.ComputerName, "Host Name", Common.ComputerName, sourceName); } else { OSAEObjectManager.ObjectAdd(Common.ComputerName + "." + computerIp, Common.ComputerName, Common.ComputerName, "COMPUTER", computerIp, string.Empty, true); OSAEObjectPropertyManager.ObjectPropertySet(Common.ComputerName + "." + computerIp, "Host Name", Common.ComputerName, sourceName); } } else { OSAEObject obj = OSAEObjectManager.GetObjectByName(Common.ComputerName); OSAEObjectManager.ObjectUpdate(obj.Name, obj.Name, obj.Alias, obj.Description, "COMPUTER", computerIp, obj.Container, obj.Enabled); OSAEObjectPropertyManager.ObjectPropertySet(obj.Name, "Host Name", Common.ComputerName, sourceName); } }
// Authorize /// <summary> /// Decrypts an OSAE Security encrypted Authentication string, and compares trust level with the object being accessed. /// Used to verify User Trust in GET request /// </summary> /// <param name="authkey">An OSAE Security encrypted String</param> /// <param name="objName">The name of the OSAE Object being accessed</param> /// <returns>True or False, depending on criteria matches.</returns> public static Boolean Authorize(string authkey, string objName) { OSAEObject OSAEobj = OSAEObjectManager.GetObjectByName(objName); Log.Debug("OSAE Security is Decoding an AuthKey"); Boolean auth = false; int uTrustLevel = 0; string decryptedAuthKey = DecryptString(authkey); string[] user = decryptedAuthKey.Split(':'); try { OSAEObject ouser = OSAE.OSAEObjectManager.GetObjectByName(user[0]); Log.Debug("Found User: "******"Password").Value) { DateTime authDate = new DateTime(); try { authDate = Convert.ToDateTime(user[1].Substring(0, 4) + "-" + user[1].Substring(4, 2) + "-" + user[1].Substring(6, 2) + " " + user[1].Substring(8, 2) + ":" + user[1].Substring(10, 2) + ":" + user[1].Substring(12, 2)); } catch { Log.Debug("Could not resolve TimeStamp: FAILED"); return(auth); } Log.Debug("Auth Date and Time: " + authDate.ToString()); //DateTime nowAuth = DateTime.Now; DateTime sDate = DateTime.Now.AddSeconds(timeSplit - (timeSplit * 2)); DateTime eDate = DateTime.Now.AddSeconds(timeSplit); if (authDate > sDate && authDate < eDate) { uTrustLevel = Convert.ToInt32(OSAEObjectPropertyManager.GetObjectPropertyValue(ouser.Name, "Trust Level").Value); if (uTrustLevel > OSAEobj.MinTrustLevel) { Log.Debug("Authintication: PASSED"); auth = true; } else { Log.Debug("Trust Level too low. Access denied!"); } } else { Log.Debug("Authintication: FAILED"); } } else { Log.Debug("Authintication: FAILED"); } } catch { Log.Debug("Authintication: FAILED"); } return(auth); }
public static OSAEAdmin GetAdminSettings() { OSAEAdmin adSets = new OSAEAdmin(); OSAEObject oObject = OSAEObjectManager.GetObjectByName("WEB SERVER"); adSets.ScreenTrust = Convert.ToInt32(oObject.Property("Screen Trust").Value); adSets.defaultScreen = Convert.ToString(oObject.Property("Screen Trust").Value); adSets.ObjectsTrust = Convert.ToInt32(oObject.Property("Objects Trust").Value); adSets.ObjectsAddTrust = Convert.ToInt32(oObject.Property("Objects Add Trust").Value); adSets.ObjectsUpdateTrust = Convert.ToInt32(oObject.Property("Objects Update Trust").Value); adSets.ObjectsDeleteTrust = Convert.ToInt32(oObject.Property("Objects Delete Trust").Value); adSets.AnalyticsTrust = Convert.ToInt32(oObject.Property("Analytics Trust").Value); adSets.LogsTrust = Convert.ToInt32(oObject.Property("Logs Trust").Value); adSets.LogsClearTrust = Convert.ToInt32(oObject.Property("Logs Clear Trust").Value); adSets.EventLogTrust = Convert.ToInt32(oObject.Property("Event Log Trust").Value); adSets.MethodLogTrust = Convert.ToInt32(oObject.Property("Method Log Trust").Value); adSets.ServerLogTrust = Convert.ToInt32(oObject.Property("Server Log Trust").Value); adSets.DebugLogTrust = Convert.ToInt32(oObject.Property("Debug Log Trust").Value); adSets.ValuesTrust = Convert.ToInt32(oObject.Property("Values Trust").Value); adSets.ManagementTrust = Convert.ToInt32(oObject.Property("Management Trust").Value); adSets.ObjectTypeTrust = Convert.ToInt32(oObject.Property("ObjectType Trust").Value); adSets.ObjectTypeAddTrust = Convert.ToInt32(oObject.Property("ObjectType Add Trust").Value); adSets.ObjectTypeUpdateTrust = Convert.ToInt32(oObject.Property("ObjectType Update Trust").Value); adSets.ObjectTypeDeleteTrust = Convert.ToInt32(oObject.Property("ObjectType Delete Trust").Value); adSets.ScriptTrust = Convert.ToInt32(oObject.Property("Script Trust").Value); adSets.ScriptAddTrust = Convert.ToInt32(oObject.Property("Script Add Trust").Value); adSets.ScriptUpdateTrust = Convert.ToInt32(oObject.Property("Script Update Trust").Value); adSets.ScriptDeleteTrust = Convert.ToInt32(oObject.Property("Script Delete Trust").Value); adSets.ScriptObjectAddTrust = Convert.ToInt32(oObject.Property("Script Object Add Trust").Value); adSets.ScriptObjectTypeAddTrust = Convert.ToInt32(oObject.Property("Script ObjectType Add Trust").Value); adSets.PatternTrust = Convert.ToInt32(oObject.Property("Pattern Trust").Value); adSets.PatternAddTrust = Convert.ToInt32(oObject.Property("Pattern Add Trust").Value); adSets.PatternUpdateTrust = Convert.ToInt32(oObject.Property("Pattern Update Trust").Value); adSets.PatternDeleteTrust = Convert.ToInt32(oObject.Property("Pattern Delete Trust").Value); adSets.ReaderTrust = Convert.ToInt32(oObject.Property("Reader Trust").Value); adSets.ReaderAddTrust = Convert.ToInt32(oObject.Property("Reader Add Trust").Value); adSets.ReaderUpdateTrust = Convert.ToInt32(oObject.Property("Reader Update Trust").Value); adSets.ReaderDeleteTrust = Convert.ToInt32(oObject.Property("Reader Delete Trust").Value); adSets.ScheduleTrust = Convert.ToInt32(oObject.Property("Schedule Trust").Value); adSets.ScheduleAddTrust = Convert.ToInt32(oObject.Property("Schedule Add Trust").Value); adSets.ScheduleUpdateTrust = Convert.ToInt32(oObject.Property("Schedule Update Trust").Value); adSets.ScheduleDeleteTrust = Convert.ToInt32(oObject.Property("Schedule Delete Trust").Value); adSets.ImagesTrust = Convert.ToInt32(oObject.Property("Images Trust").Value); adSets.ImagesAddTrust = Convert.ToInt32(oObject.Property("Images Add Trust").Value); adSets.ImagesDeleteTrust = Convert.ToInt32(oObject.Property("Images Delete Trust").Value); adSets.ConfigTrust = Convert.ToInt32(oObject.Property("Config Trust").Value); return(adSets); }
public static void CheckComputerObject(string sourceName) { Logging.GetLogger().AddToLog("Checking for Computer object", true); string computerIp = Common.GetComputerIP(); if (OSAEObjectManager.GetObjectByName(Common.ComputerName) == null) { OSAEObject obj = OSAEObjectManager.GetObjectByAddress(computerIp); if (obj == null) { Logging.GetLogger().AddToLog("Computer Object not found, creating it...", true); OSAEObjectManager.ObjectAdd(Common.ComputerName, "", Common.ComputerName, "COMPUTER", computerIp, "", 30, true); OSAEObjectPropertyManager.ObjectPropertySet(Common.ComputerName, "Host Name", Common.ComputerName, sourceName); Logging.GetLogger().AddToLog("Computer Object created called: " + Common.ComputerName, true); } else if (obj.Type == "COMPUTER") { Logging.GetLogger().AddToLog("Computer Object found under a different name, updating it...", true); OSAEObjectManager.ObjectUpdate(obj.Name, Common.ComputerName, obj.Alias, obj.Description, "COMPUTER", computerIp, obj.Container, obj.MinTrustLevel, obj.Enabled); OSAEObjectPropertyManager.ObjectPropertySet(Common.ComputerName, "Host Name", Common.ComputerName, sourceName); } else { Logging.GetLogger().AddToLog("Computer Object found under a different Name and Object Type, updating it...", true); OSAEObjectManager.ObjectAdd(Common.ComputerName, "", Common.ComputerName, "COMPUTER", computerIp, string.Empty, obj.MinTrustLevel, true); OSAEObjectPropertyManager.ObjectPropertySet(Common.ComputerName + "." + computerIp, "Host Name", Common.ComputerName, sourceName); } } else { Logging.GetLogger().AddToLog("Computer Object found, updating it...", true); OSAEObject obj = OSAEObjectManager.GetObjectByName(Common.ComputerName); OSAEObjectManager.ObjectUpdate(obj.Name, obj.Name, obj.Alias, obj.Description, "COMPUTER", computerIp, obj.Container, obj.MinTrustLevel, obj.Enabled); OSAEObjectPropertyManager.ObjectPropertySet(obj.Name, "Host Name", Common.ComputerName, sourceName); } }