ObjectPropertySet() public static method

Set the value of a object's property
public static ObjectPropertySet ( string objectName, string propertyName, string propertyValue, string source ) : void
objectName string The name of the object
propertyName string The name of the property
propertyValue string The value of the property
source string
return void
Example #1
0
        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);
            }
        }
Example #2
0
        /// <summary>
        /// Determines if the System object has a SecurityKey property.
        /// If property exist, will verify it contains a valid Key.
        /// If no key is found, a new key is created.
        /// If Property does not exist, will create and populate a new property.
        /// </summary>
        public static void GenerateSecurityKey()
        {
            string securityKey = "";

            try
            {
                Log.Info("Checking if System Security Key exist");
                string cSSK = OSAE.OSAEObjectPropertyManager.GetObjectPropertyValue("System", "SecurityKey").Value;
                if (cSSK == " ")
                {
                    Log.Info("System Security Key found, but is empty.");
                    Log.Info("Generating a new Security Key...");
                    securityKey = GenerateRandomCryptographicKey(12);
                    OSAEObjectPropertyManager.ObjectPropertySet("System", "SecurityKey", securityKey, "Rest");
                }
                else
                {
                    Log.Info("System Security Key found.");
                }
            }
            catch
            {
                Log.Info("System Security Key does not exist..");
                Log.Info("Creating System object property: SecurityKey.");
                OSAEObjectTypeManager.ObjectTypePropertyAdd("System", "SecurityKey", "String", "", "", false, true, "This key is used in HTTP and Rest authorization. Must be 16 characters.");
                Log.Info("Generating a new Security Key...");
                securityKey = GenerateRandomCryptographicKey(12);
                OSAEObjectPropertyManager.ObjectPropertySet("System", "SecurityKey", securityKey, "Rest");
            }
        }
Example #3
0
        /// <summary>
        /// Determines if the Rest Plugin has an APIKEY property.
        /// If property exist, will verify it contains a valid Key.
        /// If no key is found, a new key is created.
        /// If Property does not exist, will create and populate a new property.
        /// </summary>
        public static void GenerateAPIKey()
        {
            string apiKey = "";

            try
            {
                Log.Info("Checking if REST API Key exist");
                string cRAK = OSAE.OSAEObjectPropertyManager.GetObjectPropertyValue("Rest", "APIKEY").Value;
                if (cRAK == " ")
                {
                    Log.Info("REST API Key found, but is empty.");
                    Log.Info("Generating a new Rest API Key...");
                    apiKey = GenerateRandomCryptographicKey(24);
                    OSAEObjectPropertyManager.ObjectPropertySet("Rest", "APIKEY", apiKey, "Rest");
                }
                else
                {
                    Log.Info("REST API Key found.");
                }
            }
            catch
            {
                Log.Info("REST API Key does not exist..");
                Log.Info("Creating Rest Plugin property: APIKEY.");
                OSAEObjectTypeManager.ObjectTypePropertyAdd("Rest", "APIKEY", "String", "", "", false, true, "This is the Rest Plugin API Key. This property isused by remote clients and devices to encrypt and decrypt user information for authentication.");
                Log.Info("Generating a new Rest API Key...");
                apiKey = GenerateRandomCryptographicKey(24);
                OSAEObjectPropertyManager.ObjectPropertySet("Rest", "APIKEY", apiKey, "Rest");;
            }
        }
 public void SetProperty(string prop, string value, string source)
 {
     OSAEObjectPropertyManager.ObjectPropertySet(Name, prop, value, source);
     foreach (OSAEObjectProperty p in Properties)
     {
         if (p.Name == prop)
         {
             p.Value = value;
         }
     }
 }
Example #5
0
        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);
            }
        }