GetObjectPropertyValue() public static method

Returns an OSAEObjectProperty whcih contains the value, type, ID, last updated, and name
public static GetObjectPropertyValue ( string ObjectName, string ObjectProperty ) : OSAE.OSAEObjectProperty
ObjectName string The name of the object to get the property of
ObjectProperty string
return OSAE.OSAEObjectProperty
Ejemplo n.º 1
0
        // 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);
        }
Ejemplo n.º 2
0
 public static Logging GetLogger()
 {
     lock (memoryLock)
     {
         if (privateInstance == null)
         {
             privateInstance = new Logging("Default");
         }
     }
     debug = OSAEObjectPropertyManager.GetObjectPropertyValue("SYSTEM", "Debug").Value;
     return(privateInstance);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Decrypts an OSAE Security encrypted Authentication string.
        /// Used to verify User to use in POST request.
        /// </summary>
        /// <param name="authkey">An OSAE Security encrypted String</param>
        /// <returns>Returns the Username, if criteria matches</returns>
        public static string DecryptUser(string authkey)
        {
            Log.Info("OSAE Security is Decoding an AuthKey");
            string uName            = null;
            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(uName);
                    }
                    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)
                    {
                        Log.Debug("Authintication: PASSED");
                        uName = ouser.Name;
                    }
                    else
                    {
                        Log.Debug("Authintication: FAILED");
                    }
                }
                else
                {
                    Log.Debug("Authintication: FAILED");
                }
            }
            catch
            {
                Log.Debug("Invalid Authintication key: FAILED");
            }
            return(uName);
        }
Ejemplo n.º 4
0
        public static void AddToLog(string audit, bool alwaysLog, string logFile)
        {
            try
            {
                if (debug != "FALSE" || alwaysLog)
                {
                    lock (logLocker)
                    {
                        string             filePath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\OSAE\Logs\" + logFile + ".log";
                        System.IO.FileInfo file     = new System.IO.FileInfo(filePath);
                        file.Directory.Create();
                        StreamWriter sw = File.AppendText(filePath);

                        sw.WriteLine(System.DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt") + " - " + audit);
                        sw.Close();

                        if (OSAEObjectPropertyManager.GetObjectPropertyValue("SYSTEM", "Prune Logs").Value == "TRUE")
                        {
                            if (file.Length > 1000000)
                            {
                                file.Delete();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                lock (logLocker)
                {
                    string             filePath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "/Logs/" + logFile + ".log";
                    System.IO.FileInfo file     = new System.IO.FileInfo(filePath);
                    file.Directory.Create();
                    StreamWriter sw = File.AppendText(filePath);
                    sw.WriteLine(System.DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt") + " - LOGGING ERROR: "
                                 + ex.Message + " - " + ex.InnerException);
                    sw.Close();
                    if (file.Length > 1000000)
                    {
                        file.Delete();
                    }
                }
            }
        }
Ejemplo n.º 5
0
 public static void InitialiseLogFolder()
 {
     try
     {
         FileInfo file = new FileInfo(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\OSAE\Logs\");
         file.Directory.Create();
         if (OSAEObjectPropertyManager.GetObjectPropertyValue("SYSTEM", "Prune Logs").Value == "TRUE")
         {
             string[] files = Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\OSAE\Logs\");
             foreach (string f in files)
             {
                 File.Delete(f);
             }
         }
     }
     catch (Exception ex)
     {
         Logging.GetLogger().AddToLog("Error getting registry settings and/or deleting logs: " + ex.Message, true);
     }
 }
Ejemplo n.º 6
0
 private static void GetConfiguration()
 {
     debug     = OSAEObjectPropertyManager.GetObjectPropertyValue("SYSTEM", "Debug").Value;
     pruneLogs = OSAEObjectPropertyManager.GetObjectPropertyValue("SYSTEM", "Prune Logs").Value;
 }