Exemple #1
0
        public void CheckStoreAndLoadRA()
        {
            SimiasAccessLogger accessLog = new SimiasAccessLogger("Service", "Loading RA's");
            Store store = Store.GetStore();

            //Load the RSA for the domain - need to see how this can be migrated --FIXME
            if (store.DefaultDomain != null)
            {
                //Store the DEFAULT certificate(RSA information) for users using the "Server Default" option in client
                // need to find a better way of representing DEFAULT
                Simias.Security.RSAStore.CheckAndStoreRSA(store.DefaultRSARA.ToXmlString(true), "DEFAULT", true);
            }
            X509Certificate raCert = null;

            try
            {
                Simias.Configuration config = Store.Config;
                string raPath = config.Get("Server", "RAPath");

                if (raPath != null && raPath != String.Empty && raPath != "")
                {
                    string[] racertFiles = Directory.GetFiles(raPath, "*.?er");
                    Simias.Security.CertificateStore.CleanCertsFromStore();
                    foreach (string file in racertFiles)
                    {
                        try
                        {
                            raCert = X509Certificate.CreateFromCertFile(file);
                        }
                        catch (CryptographicException ce)
                        {
                            log.Debug("Exception {0}, File: {1}", ce.ToString(), file);
                            continue;
                        }
                        //Simias.Security.CertificateStore.StoreRACertificate (raCert.GetRawCertData(), raCert.GetName().ToLower(), true);
                        Simias.Security.CertificateStore.StoreRACertificate(raCert.GetRawCertData(), Path.GetFileNameWithoutExtension(file).ToLower(), true);
                        accessLog.LogAccess("CheckStoreAndLoadRA", "Loading RecoveryAgent", "-", raCert.GetName());
                    }
                }
            }
            catch (Exception e)
            {
                log.Error(e.ToString());
                accessLog.LogAccess("CheckStoreAndLoadRA", "Failed Loading RecoveryAgent", "-", "-");
            }

            Simias.Security.CertificateStore.LoadRACertsFromStore(); //this loads all Certs including RA - but client will not have RA
            if (store.DefaultDomain != null)                         //load the RSA data from store - only on server
            {
                Simias.Security.RSAStore.LoadRSAFromStore();
            }
        }
Exemple #2
0
        /// <summary>
        /// Open the File for Reading.
        /// </summary>
        public void OpenRead()
        {
            try
            {
                stream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read);

                // log
                log.LogAccess("OpenRead", node.GetRelativePath(), node.ID, "Success");
            }
            catch
            {
                // log
                log.LogAccess("OpenRead", node.GetRelativePath(), node.ID, "Failed");

                Close();

                throw;
            }
        }