Example #1
0
		public ApplicationTrust (ApplicationIdentity applicationIdentity)
			: this ()
		{
			if (applicationIdentity == null)
				throw new ArgumentNullException ("applicationIdentity");
			_appid = applicationIdentity;
		}
 public static void SignOut()
 {
     m_Instance = new ApplicationIdentity();
     WebServiceAccount blankWebServiceAccount = new WebServiceAccount();
     blankWebServiceAccount.IsKnown = false;
     m_Instance.WebServiceAccount = blankWebServiceAccount;
 }
	public void TestApplicationIdentityFullName01()
	{
		ApplicationIdentity identity = new ApplicationIdentity("A");
		// this is the expected result but fails in pnet for now
		// AssertEquals("Fullname01 :","A, Culture=neutral",identity.FullName);
		AssertEquals("Fullname01 :", "A", identity.FullName);
	}
Example #4
0
		public ActivationArguments (ApplicationIdentity applicationIdentity)
		{
			if (applicationIdentity == null)
				throw new ArgumentNullException ("applicationIdentity");

			_identity = applicationIdentity;
		}
Example #5
0
		public ActivationArguments (ApplicationIdentity applicationIdentity, string[] activationData)
		{
			if (applicationIdentity == null)
				throw new ArgumentNullException ("applicationIdentity");

			_identity = applicationIdentity;
			_data = activationData;
		}
Example #6
0
		public ActivationArguments (ActivationContext activationData)
		{
			if (activationData == null)
				throw new ArgumentNullException ("activationData");

			_context = activationData;
			_identity = activationData.Identity;
		}
        public ActivationArguments (ApplicationIdentity applicationIdentity, string[] activationData) {
            if (applicationIdentity == null)
                throw new ArgumentNullException("applicationIdentity");
            Contract.EndContractBlock();

            m_appFullName = applicationIdentity.FullName;
            m_activationData = activationData;
        }
        public static IApplicationPrincipal Convert(this PrincipalSession session)
        {
            Contract.Assert(session != null);

            var identity  = new ApplicationIdentity(session.UserId, session.Login, session.Name, session.Email);
            var principal = new ApplicationPrincipal(identity, session.Role, session.Permissions);

            return(principal);
        }
 /// <summary>Initializes a new instance of the <see cref="T:System.Runtime.Hosting.ActivationArguments" /> class with the specified application identity and activation data.</summary>
 /// <param name="applicationIdentity">An object that identifies the manifest-based activation application.</param>
 /// <param name="activationData">An array of strings containing host-provided activation data.</param>
 /// <exception cref="T:System.ArgumentNullException">
 ///         <paramref name="applicationIdentity" /> is <see langword="null" />.</exception>
 // Token: 0x060065B3 RID: 26035 RVA: 0x0015553A File Offset: 0x0015373A
 public ActivationArguments(ApplicationIdentity applicationIdentity, string[] activationData)
 {
     if (applicationIdentity == null)
     {
         throw new ArgumentNullException("applicationIdentity");
     }
     this.m_appFullName    = applicationIdentity.FullName;
     this.m_activationData = activationData;
 }
Example #10
0
    public void TestApplicationIdentityFullName02()
    {
        ApplicationIdentity identity = new ApplicationIdentity("Testruntime");

        // this is the expected result but fails in pnet for now
        // AssertEquals("Fullname01 :", "Testruntime, Culture=neutral",
        //								identity.FullName);
        AssertEquals("Fullname01 :", "Testruntime", identity.FullName);
    }
        /// <summary>Removes all application trust objects that match the specified criteria from the collection.</summary>
        /// <param name="applicationIdentity">The <see cref="T:System.ApplicationIdentity" /> of the <see cref="T:System.Security.Policy.ApplicationTrust" /> object to be removed.</param>
        /// <param name="versionMatch">One of the <see cref="T:System.Security.Policy.ApplicationVersionMatch" /> values.</param>
        /// <PermissionSet>
        ///   <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Read="*AllFiles*" PathDiscovery="*AllFiles*" />
        ///   <IPermission class="System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="MemberAccess" />
        ///   <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence, ControlPolicy" />
        /// </PermissionSet>
        public void Remove(ApplicationIdentity applicationIdentity, ApplicationVersionMatch versionMatch)
        {
            ApplicationTrustCollection applicationTrustCollection = this.Find(applicationIdentity, versionMatch);

            foreach (ApplicationTrust trust in applicationTrustCollection)
            {
                this.RemoveAllInstances(trust);
            }
        }
Example #12
0
        public static void SetApplicationIdentity(ApplicationIdentity id)
        {
            if (_thisApplication != null)
            {
                throw new Exception("Application identity cannot be set twice");
            }

            _thisApplication = id;
        }
Example #13
0
        public void Remove(ApplicationIdentity applicationIdentity, ApplicationVersionMatch versionMatch)
        {
            ApplicationTrustCollection coll = Find(applicationIdentity, versionMatch);

            foreach (ApplicationTrust t in coll)
            {
                RemoveAllInstances(t);
            }
        }
	public static ActivationContext CreatePartialActivationContext(
						ApplicationIdentity identity, String[] manifestPaths)
	{
		if(identity == null)
		{
			throw new ArgumentNullException("identity");
		}
		return new ActivationContext();
	}
Example #15
0
 /// <summary>Initializes a new instance of the <see cref="T:System.Runtime.Hosting.ActivationArguments" /> class with the specified application identity and activation data.</summary>
 /// <param name="applicationIdentity">An <see cref="T:System.ApplicationIdentity" /> object identifying the manifest-based activation application.</param>
 /// <param name="activationData">An array of strings containing host-provided activation data.</param>
 /// <exception cref="T:System.ArgumentNullException">
 ///   <paramref name="applicationIdentity" /> is null.</exception>
 public ActivationArguments(ApplicationIdentity applicationIdentity, string[] activationData)
 {
     if (applicationIdentity == null)
     {
         throw new ArgumentNullException("applicationIdentity");
     }
     this._identity = applicationIdentity;
     this._data     = activationData;
 }
Example #16
0
 public ApplicationTrust(ApplicationIdentity applicationIdentity)
     : this()
 {
     if (applicationIdentity == null)
     {
         throw new ArgumentNullException("applicationIdentity");
     }
     _appid = applicationIdentity;
 }
Example #17
0
 /// <summary>Initializes a new instance of the <see cref="T:System.Runtime.Hosting.ActivationArguments" /> class with the specified activation context. </summary>
 /// <param name="activationData">An <see cref="T:System.ActivationContext" /> object identifying the manifest-based activation application.</param>
 /// <exception cref="T:System.ArgumentNullException">
 ///   <paramref name="activationData" /> is null.</exception>
 public ActivationArguments(ActivationContext activationData)
 {
     if (activationData == null)
     {
         throw new ArgumentNullException("activationData");
     }
     this._context  = activationData;
     this._identity = activationData.Identity;
 }
Example #18
0
		public ActivationArguments (ActivationContext activationContext, string[] activationData)
		{
			if (activationContext == null)
				throw new ArgumentNullException ("activationContext");

			_context = activationContext;
			_identity = activationContext.Identity;
			_data = activationData;
		}
Example #19
0
        public ActivationArguments(ApplicationIdentity applicationIdentity)
        {
            if (applicationIdentity == null)
            {
                throw new ArgumentNullException("applicationIdentity");
            }

            _identity = applicationIdentity;
        }
Example #20
0
 public static ActivationContext CreatePartialActivationContext(
     ApplicationIdentity identity, String[] manifestPaths)
 {
     if (identity == null)
     {
         throw new ArgumentNullException("identity");
     }
     return(new ActivationContext());
 }
Example #21
0
        public static void Main(string[] args)
        {
            ActivationContext   ac = AppDomain.CurrentDomain.ActivationContext;
            ApplicationIdentity ai = ac.Identity;

            Console.WriteLine("Full name = " + ai.FullName);
            Console.WriteLine("Code base = " + ai.CodeBase);

            Console.Read();
        }
Example #22
0
 /// <summary>Initializes a new instance of the <see cref="T:System.Runtime.Hosting.ActivationArguments" /> class with the specified activation context and activation data.</summary>
 /// <param name="activationContext">An <see cref="T:System.ActivationContext" /> object identifying the manifest-based activation application.</param>
 /// <param name="activationData">An array of strings containing host-provided activation data.</param>
 /// <exception cref="T:System.ArgumentNullException">
 ///   <paramref name="activationContext" /> is null.</exception>
 public ActivationArguments(ActivationContext activationContext, string[] activationData)
 {
     if (activationContext == null)
     {
         throw new ArgumentNullException("activationContext");
     }
     this._context  = activationContext;
     this._identity = activationContext.Identity;
     this._data     = activationData;
 }
 public ApplicationTrust this[string appFullName] {
     get {
         ApplicationIdentity        identity  = new ApplicationIdentity(appFullName);
         ApplicationTrustCollection appTrusts = Find(identity, ApplicationVersionMatch.MatchExactVersion);
         if (appTrusts.Count > 0)
         {
             return(appTrusts[0]);
         }
         return(null);
     }
 }
Example #24
0
 public void TestApplicationIdentityConstructor01()
 {
     try
     {
         ApplicationIdentity identity = new ApplicationIdentity(null);
         Fail("Test should have thrown a NullReferenceException");
     }
     catch (NullReferenceException)
     {
     }
 }
 public ApplicationManifest(GetManifestCompletedEventArgs args)
 {
     _identity             = args.ApplicationIdentity;
     _manifest             = XDocument.Load(args.ApplicationManifest);
     _deploymentManifest   = XDocument.Load(args.DeploymentManifest);
     _isCached             = args.IsCached;
     _logFilePath          = args.LogFilePath;
     _productName          = args.ProductName;
     _subscriptionIdentity = args.SubscriptionIdentity;
     _version = args.Version;
 }
Example #26
0
        public ActivationArguments(ApplicationIdentity applicationIdentity, string[] activationData)
        {
            if (applicationIdentity == null)
            {
                throw new ArgumentNullException("applicationIdentity");
            }
            Contract.EndContractBlock();

            m_appFullName    = applicationIdentity.FullName;
            m_activationData = activationData;
        }
	public void TestApplicationIdentityConstructor01()
	{
		try
		{
			ApplicationIdentity identity = new ApplicationIdentity(null);
			Fail("Test should have thrown a NullReferenceException");			
		}
		catch (NullReferenceException)
		{
		}
	}
Example #28
0
 public ApplicationTrust this[string appFullName] {
     [System.Security.SecurityCritical]  // auto-generated
     get {
         ApplicationIdentity        identity  = new ApplicationIdentity(appFullName);
         ApplicationTrustCollection appTrusts = Find(identity, ApplicationVersionMatch.MatchExactVersion);
         if (appTrusts.Count > 0)
         {
             return(appTrusts[0]);
         }
         return(null);
     }
 }
		public ApplicationTrustCollection Find(ApplicationIdentity applicationIdentity, ApplicationVersionMatch versionMatch)
		{
			ApplicationTrustCollection applicationTrustCollection = new ApplicationTrustCollection(false);
			foreach (ApplicationTrust applicationTrust in this)
			{
				if (CmsUtils.CompareIdentities(applicationTrust.ApplicationIdentity, applicationIdentity, versionMatch))
				{
					applicationTrustCollection.Add(applicationTrust);
				}
			}
			return applicationTrustCollection;
		}
 // Token: 0x06004FFA RID: 20474 RVA: 0x001196E0 File Offset: 0x001178E0
 internal static void CreateActivationContext(string fullName, string[] manifestPaths, bool useFusionActivationContext, out ApplicationIdentity applicationIdentity, out ActivationContext activationContext)
 {
     applicationIdentity = new ApplicationIdentity(fullName);
     activationContext   = null;
     if (useFusionActivationContext)
     {
         if (manifestPaths != null)
         {
             activationContext = new ActivationContext(applicationIdentity, manifestPaths);
             return;
         }
         activationContext = new ActivationContext(applicationIdentity);
     }
 }
        void updateChecker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                Configuration config = Configuration.GetNewInstance();
                if (config.Settings.CheckForUpdates == true)
                {
                    ApplicationIdentity appId       = new ApplicationIdentity(typeof(Configuration).Assembly);
                    Version             thisVersion = appId.VersionObject;

                    System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                    doc.Load("http://ftp.cdc.gov/pub/software/epi_info/versions.xml");
                    List <System.Xml.XmlElement> elements = new List <System.Xml.XmlElement>();
                    foreach (System.Xml.XmlElement element in doc.DocumentElement.ChildNodes)
                    {
                        if (element.Name.Equals("version"))
                        {
                            string   versionNumber = element.Attributes["number"].Value;
                            string[] splits        = versionNumber.Split('.');
                            int      majorVersion  = int.Parse(splits[0]);
                            int      minorVersion  = int.Parse(splits[1]);
                            int      build         = int.Parse(splits[2]);
                            int      revision      = int.Parse(splits[3]);

                            if (thisVersion.Major < majorVersion)
                            {
                                elements.Add(element);
                            }
                            else if (thisVersion.Minor < minorVersion)
                            {
                                elements.Add(element);
                            }
                            else if (thisVersion.Build < build)
                            {
                                elements.Add(element);
                            }
                            else if (thisVersion.Revision < revision)
                            {
                                elements.Add(element);
                            }
                        }
                    }
                    e.Result = elements;
                }
            }
            catch (Exception ex)
            {
                //
            }
        }
Example #32
0
 public HostContextInternal(TrustManagerContext trustManagerContext)
 {
     if (trustManagerContext == null)
     {
         this.persist = true;
     }
     else
     {
         this.ignorePersistedDecision = trustManagerContext.IgnorePersistedDecision;
         this.noPrompt      = trustManagerContext.NoPrompt;
         this.persist       = trustManagerContext.Persist;
         this.previousAppId = trustManagerContext.PreviousApplicationIdentity;
     }
 }
		/// <summary>Gets the <see cref="T:System.Security.Policy.ApplicationTrust" /> object for the specified application.</summary>
		/// <param name="appFullName">The full name of the application.</param>
		/// <returns>The <see cref="T:System.Security.Policy.ApplicationTrust" /> object for the specified application, or <see langword="null" /> if the object cannot be found.</returns>
		// Token: 0x17000562 RID: 1378
		public ApplicationTrust this[string appFullName]
		{
			[SecurityCritical]
			get
			{
				ApplicationIdentity applicationIdentity = new ApplicationIdentity(appFullName);
				ApplicationTrustCollection applicationTrustCollection = this.Find(applicationIdentity, ApplicationVersionMatch.MatchExactVersion);
				if (applicationTrustCollection.Count > 0)
				{
					return applicationTrustCollection[0];
				}
				return null;
			}
		}
Example #34
0
        public ApplicationTrustCollection Find(ApplicationIdentity applicationIdentity, ApplicationVersionMatch versionMatch)
        {
            ApplicationTrustCollection trusts     = new ApplicationTrustCollection(false);
            ApplicationTrustEnumerator enumerator = this.GetEnumerator();

            while (enumerator.MoveNext())
            {
                ApplicationTrust current = enumerator.Current;
                if (CmsUtils.CompareIdentities(current.ApplicationIdentity, applicationIdentity, versionMatch))
                {
                    trusts.Add(current);
                }
            }
            return(trusts);
        }
Example #35
0
        public static bool CreateDomain(string name, string dir)
        {
            var applicationIdentity = new ApplicationIdentity("AppFullName");
            var activationContext   = ActivationContext.CreatePartialActivationContext(applicationIdentity, null);
            var setup = new AppDomainSetup(activationContext);

            //
            setup.ApplicationName = "AppName";
            setup.ApplicationBase = dir;
            setup.DynamicBase     = dir;
            setup.PrivateBinPath  = dir;
            setup.DisallowApplicationBaseProbing = true;
            var domain = AppDomain.CreateDomain(name, null, setup, null);

            return(false);
        }
Example #36
0
        static void Main(string[] args)
        {
            //Console.Title = "KnowYourPC";
            //Console.BackgroundColor = ConsoleColor.Blue;
            //Console.ForegroundColor = ConsoleColor.Red;

            CultureInfo ci = new CultureInfo(CultureInfo.CurrentUICulture.ToString());

            Console.WriteLine("Idioma: {0}, Idioma Atual: {1}, Idioma Padrão: {2}", ci.Name, ci.NativeName, ci.TwoLetterISOLanguageName);

            Console.WriteLine(Console.CapsLock);

            Console.WriteLine(Environment.MachineName);
            Console.WriteLine(Environment.OSVersion);
            Console.WriteLine(Environment.Is64BitOperatingSystem);
            Console.WriteLine(Environment.UserName);
            Console.WriteLine(Environment.TickCount);
            Console.WriteLine(Environment.ProcessorCount);
            Console.WriteLine("Isso é: " + Environment.OSVersion.Platform.ToString());
            Console.WriteLine("Tentando: " + Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE"));
            Console.WriteLine("64bit: " + Environment.Is64BitOperatingSystem);


            if (Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86)))
            {
                Console.WriteLine("é de 64");
            }
            else
            {
                Console.WriteLine("32");
            }


            ApplicationIdentity ap = new ApplicationIdentity("KnowYourPC");

            Console.WriteLine(ap);

            string[] drive = Environment.GetLogicalDrives();

            foreach (string drives in drive)
            {
                Console.WriteLine(drives);
            }

            Console.ReadLine();
        }
Example #37
0
        /// <summary>
        /// Handles the load event of the form
        /// </summary>
        /// <param name="sender">.NET supplied object</param>
        /// <param name="e">.NET supplied event parameters</param>
        private void MainForm_Load(object sender, System.EventArgs e)
        {
            if (!this.DesignMode)
            {
                ApplicationIdentity appId = new ApplicationIdentity(typeof(Configuration).Assembly);
                // this.tsslLocale.Text = Thread.CurrentThread.CurrentUICulture.NativeName;
                this.tsslLocale.Text  = Thread.CurrentThread.CurrentUICulture.Name;
                this.tsslVersion.Text = appId.Version;
                this.tsslCaps.Enabled = base.IsKeyToggled((int)Keys.CapsLock);
                this.tsslNUM.Enabled  = base.IsKeyToggled((int)Keys.NumLock);
                this.tsslINS.Enabled  = base.IsKeyToggled((int)Keys.Insert);

                this.KeyUp += new KeyEventHandler(OnKeyUp);
                ShowHideStatusStrip();
                UpdateWindowTitle();
            }
        }
Example #38
0
        private static void FixTrust(ApplicationDeployment currentDeployment)
        {
            //Create the appropriate Trust settings so the Application can do
            //Click-Once Related updating
            var deploymentFullName = currentDeployment.UpdatedApplicationFullName;
            var appId      = new ApplicationIdentity(deploymentFullName);
            var everything = new PermissionSet(PermissionState.Unrestricted);

            var trust = new ApplicationTrust(appId)
            {
                DefaultGrantSet           = new PolicyStatement(everything),
                IsApplicationTrustedToRun = true,
                Persist = true
            };

            ApplicationSecurityManager.UserApplicationTrusts.Add(trust);
        }
        public ContextBaseTests()
        {
            var documentTypeResolver = new DocumentTypeResolver().WithMessagingDocuments();

            ArtificialIntelligenceExtension = Substitute.For <IArtificialIntelligenceExtension>();
            ContactExtension      = Substitute.For <IContactExtension>();
            HelpDeskExtension     = Substitute.For <IHelpDeskExtension>();
            TunnelExtension       = Substitute.For <ITunnelExtension>();
            Logger                = Substitute.For <ILogger>();
            Configuration         = Substitute.For <IConfiguration>();
            OwnerCallerContactMap = new OwnerCallerContactMap();
            Sender                = Substitute.For <ISender>();
            Flow = new Flow()
            {
                Id            = "0",
                Configuration = new Dictionary <string, string>()
            };
            User        = "******";
            Application = new Application()
            {
                Identifier = "application",
                Domain     = "msging.net",
                Instance   = "default"
            };
            Input = new LazyInput(
                new Message()
            {
                From    = User.ToNode(),
                To      = ApplicationIdentity.ToNode(),
                Content = new PlainText()
                {
                    Text = "Hello world!"
                }
            },
                User,
                Flow.BuilderConfiguration,
                new DocumentSerializer(documentTypeResolver),
                new EnvelopeSerializer(documentTypeResolver),
                ArtificialIntelligenceExtension,
                CancellationToken);
            Configuration.ContactCacheExpiration.Returns(TimeSpan.FromMinutes(5));
        }
        public static void SignIn(YellowstonePathology.YpiConnect.Contract.Identity.WebServiceAccount webServiceAccount)
        {
            if (webServiceAccount.UserName == m_Instance.WebServiceAccount.UserName)
            {
                webServiceAccount.LocalFileDownloadDirectory = m_Instance.WebServiceAccount.LocalFileDownloadDirectory;
                webServiceAccount.LocalFileUploadDirectory = m_Instance.WebServiceAccount.LocalFileUploadDirectory;
            }

            m_Instance = new ApplicationIdentity();
            m_Instance.WebServiceAccount = webServiceAccount;

            if (m_Instance.WebServiceAccount.EnableSaveSettings == false)
            {
                SavedSettings.Delete();
            }
            else
            {
                m_Instance.Save();
            }
        }
Example #41
0
        ClaimsPrincipal Transform(ClaimsPrincipal incomingPrincipal)
        {
            var nameClaim = incomingPrincipal.Identities.First().FindFirst(ClaimTypes.Name);

            var userService = DependencyResolver.Current.GetService<IUserService>();

            var user = userService.GetByUsername(nameClaim.Value);

            if (user == null)
            {
                throw new InvalidOperationException("Cannot initialize user");
            }

            var id = new ApplicationIdentity(user);

            var principal = new ClaimsPrincipal(id);

            SetCustomPrincipalClaims(userService, ref principal);

            return principal;
        }
Example #42
0
        public ObjectHandle ApplicationInstance(AppDomain domain, string applicationFullname)
        {
            var identityBuilder = new IdentityBuilder(applicationFullname);
            var id             = identityBuilder.GetId();
            var newAppIdentity = new ApplicationIdentity("DxBall.Screen.ConsoleDisplay");
            var domainManager  = new AppDomainManager();

            domain.SetData("DomainManager", domainManager);
            return(domainManager
                   .ApplicationActivator
                   .CreateInstance(
                       ActivationContext
                       .CreatePartialActivationContext(
                           newAppIdentity)));
            //return domain
            //    .DomainManager
            //    .ApplicationActivator
            //    .CreateInstance(
            //        ActivationContext.CreatePartialActivationContext(
            //            newAppIdentity));
        }
Example #43
0
        /// <summary>
        /// AboutEpiInfo load event
        /// </summary>
        /// <param name="sender">Object that fired the event.</param>
        /// <param name="e">.NET supplied event args.</param>
        private void AboutEpiInfo_Load(object sender, System.EventArgs e)
        {
            try
            {
                ApplicationIdentity appId = new ApplicationIdentity(typeof(Configuration).Assembly);

                // App Name
                WordBuilder appNameBuilder = new WordBuilder();
                appNameBuilder.Add(appId.SuiteName);
                appNameBuilder.Add(appId.Version);
                lblAppName.Text = appNameBuilder.ToString();

                // Release date
                lblReleaseDate.Text = appId.VersionReleaseDate;

                // Description
                txtDescription.Text = Util.GetProductDescription();
            }
            catch (FileNotFoundException ex)
            {
                MsgBox.ShowException(ex);
            }
        }
Example #44
0
 public ApplicationTrust (ApplicationIdentity applicationIdentity) : this () {
     ApplicationIdentity = applicationIdentity; 
 }
Example #45
0
 [System.Security.SecurityCritical]  // auto-generated 
 public void Remove (ApplicationIdentity applicationIdentity, ApplicationVersionMatch versionMatch) {
     ApplicationTrustCollection collection = Find(applicationIdentity, versionMatch); 
     RemoveRange(collection); 
 }
Example #46
0
 [System.Security.SecurityCritical]  // auto-generated
 public ApplicationTrustCollection Find (ApplicationIdentity applicationIdentity, ApplicationVersionMatch versionMatch) { 
     ApplicationTrustCollection collection = new ApplicationTrustCollection(false);
     foreach (ApplicationTrust trust in this) { 
         if (CmsUtils.CompareIdentities(trust.ApplicationIdentity, applicationIdentity, versionMatch)) 
             collection.Add(trust);
     } 
     return collection;
 }
Example #47
0
        private void CommitApplicationTrust(ApplicationIdentity applicationIdentity, string trustXml) { 
            StoreOperationMetadataProperty[] properties = new StoreOperationMetadataProperty[] {
                    new StoreOperationMetadataProperty(ClrPropertySet, ApplicationTrustProperty, trustXml) 
                }; 

            IEnumDefinitionIdentity idenum = applicationIdentity.Identity.EnumAppPath(); 
            IDefinitionIdentity[] asbId = new IDefinitionIdentity[1];
            IDefinitionIdentity deplId = null;
            if (idenum.Next(1, asbId) == 1)
                deplId = asbId[0]; 

            IDefinitionAppId defAppId = IsolationInterop.AppIdAuthority.CreateDefinition(); 
            defAppId.SetAppPath(1, new IDefinitionIdentity[] {deplId}); 
            defAppId.put_Codebase(applicationIdentity.CodeBase);
 
            using (StoreTransaction storeTxn = new StoreTransaction()) {
                storeTxn.Add(new StoreOperationSetDeploymentMetadata(defAppId, InstallReference, properties));
                RefreshStorePointer();
                m_pStore.Transact(storeTxn.Operations); 
            }
 
            m_appTrusts = null; // reset the app trusts in the collection. 
        }
Example #48
0
 public ApplicationTrust this[string appFullName] {
     [System.Security.SecurityCritical]  // auto-generated 
     get {
         ApplicationIdentity identity = new ApplicationIdentity(appFullName);
         ApplicationTrustCollection appTrusts = Find(identity, ApplicationVersionMatch.MatchExactVersion);
         if (appTrusts.Count > 0) 
             return appTrusts[0];
         return null; 
     } 
 }
	// Methods
	public static ActivationContext CreatePartialActivationContext(ApplicationIdentity identity) {}
	public void TestApplicationIdentityCodeBase02()
	{
		ApplicationIdentity identity = new ApplicationIdentity("Testruntime");
		AssertNull("CodeBase01 :", identity.CodeBase);
	}
Example #51
0
		public void FromXml (SecurityElement element) 
		{
			if (element == null)
				throw new ArgumentNullException ("element");

			if (element.Tag != "ApplicationTrust")
				throw new ArgumentException ("element");

			string s = element.Attribute ("FullName");
			if (s != null)
				_appid = new ApplicationIdentity (s);
			else
				_appid = null;

			_defaultPolicy = null;
			SecurityElement defaultGrant = element.SearchForChildByTag ("DefaultGrant");
			if (defaultGrant != null) {
				for (int i=0; i < defaultGrant.Children.Count; i++) {
					SecurityElement se = (defaultGrant.Children [i] as SecurityElement);
					if (se.Tag == "PolicyStatement") {
						DefaultGrantSet.FromXml (se, null);
						break;
					}
				}
			}

			if (!Boolean.TryParse (element.Attribute ("TrustedToRun"), out _trustrun))
				_trustrun = false;

			if (!Boolean.TryParse (element.Attribute ("Persist"), out _persist))
				_persist = false;

			_xtranfo = null;
			SecurityElement xtra = element.SearchForChildByTag ("ExtraInfo");
			if (xtra != null) {
				s = xtra.Attribute ("Data");
				if (s != null) {
					byte[] data = CryptoConvert.FromHex (s);
					using (MemoryStream ms = new MemoryStream (data)) {
						BinaryFormatter bf = new BinaryFormatter ();
						_xtranfo = bf.Deserialize (ms);
					}
				}
			}
		}
		public ApplicationTrustCollection Find (ApplicationIdentity applicationIdentity, ApplicationVersionMatch versionMatch)
		{
			if (applicationIdentity == null)
				throw new ArgumentNullException ("applicationIdentity");

			string fullname = applicationIdentity.FullName;

			switch (versionMatch) {
			case ApplicationVersionMatch.MatchAllVersions:
				int pos = fullname.IndexOf (", Version=");
				if (pos >= 0)
					fullname = fullname.Substring (0, pos);
				break;
			case ApplicationVersionMatch.MatchExactVersion:
				break;
			default:
				throw new ArgumentException ("versionMatch");
			}

			ApplicationTrustCollection coll = new ApplicationTrustCollection ();
			foreach (ApplicationTrust t in _list) {
				if (t.ApplicationIdentity.FullName.StartsWith (fullname)) {
					coll.Add (t);
				}
			}

			return coll;
		}
Example #53
0
        /// <summary>
        /// Creates attributes for the root element
        /// </summary>
        /// <param name="xmlDataPackage">The Xml Data Package document</param>
        /// <param name="root">The root element of the document</param>
        protected virtual void CreateRootAttributes(XmlDocument xmlDataPackage, XmlElement root)
        {
            #region Input Validation
            if (xmlDataPackage == null) { throw new ArgumentNullException("xmlDataPackage"); }
            if (root == null) { throw new ArgumentNullException("root"); }
            #endregion // Input Validation

            ApplicationIdentity appId = new ApplicationIdentity(typeof(Configuration).Assembly);

            // Append timestamp in UTC so that people sending packages across time zones don't need to worry about what zone it was packaged in.
            DateTime dt = DateTime.UtcNow;
            string dateDisplayValue = String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:s}", dt);

            XmlAttribute version = xmlDataPackage.CreateAttribute("Version"); // The version of Epi Info 7 that was used to create it
            XmlAttribute created = xmlDataPackage.CreateAttribute("Created"); // The date/time the package creation started
            XmlAttribute pakName = xmlDataPackage.CreateAttribute("Name"); // The name of the package (should mirror the file name but without a filename-based timestamp)
            XmlAttribute guidStr = xmlDataPackage.CreateAttribute("Id"); // Unique ID value for the package; may be useful to avoid importing the same package twice depending on how system designers have set up their import mechanisms

            version.Value = appId.Version;
            created.Value = dateDisplayValue;
            pakName.Value = PackageName;
            guidStr.Value = System.Guid.NewGuid().ToString();

            root.Attributes.Append(version);
            root.Attributes.Append(created);
            root.Attributes.Append(pakName);
            root.Attributes.Append(guidStr);
        }
		public void Remove (ApplicationIdentity applicationIdentity, ApplicationVersionMatch versionMatch)
		{
			ApplicationTrustCollection coll = Find (applicationIdentity, versionMatch);
			foreach (ApplicationTrust t in coll) {
				RemoveAllInstances (t);
			}
		}
Example #55
0
        /// <summary>
        /// Inserts the project parameters into the metadata database
        /// </summary>		
        private void InsertProject()
        {
            try
            {
                ApplicationIdentity appId = new ApplicationIdentity(typeof(Configuration).Assembly);

                Query query = db.CreateQuery("insert into metaDBInfo([ProjectId], [ProjectName], [ProjectLocation], [EpiVersion], [Purpose]) values (@ProjectId, @ProjectName, @ProjectLocation, @EpiVersion, @Purpose)");
                query.Parameters.Add(new QueryParameter("@ProjectId", DbType.Guid, this.Project.Id));
                query.Parameters.Add(new QueryParameter("@ProjectName", DbType.String, Project.Name));
                query.Parameters.Add(new QueryParameter("@ProjectLocation", DbType.String, Project.Location));
                query.Parameters.Add(new QueryParameter("@EpiVersion", DbType.String, appId.Version));

                if (Project.MetadataSource == MetadataSource.SameDb)
                    query.Parameters.Add(new QueryParameter("@Purpose", DbType.Int32, (int)DatabasePurpose.MetadataAndCollectedData));
                else
                    query.Parameters.Add(new QueryParameter("@Purpose", DbType.Int32, (int)DatabasePurpose.Metadata));

                db.ExecuteNonQuery(query);
            }
            catch (Exception ex)
            {
                throw new GeneralException("Could not create new project: " + ex.ToString(), ex);
            }
            finally
            {
            }
        }
	public void TestApplicationIdentityConstructor02()
	{
		ApplicationIdentity identity = new ApplicationIdentity("A");
	}
 public static void ReadSavedSettings()
 {
     YellowstonePathology.YpiConnect.Contract.Identity.SavedSettings savedSettings = SavedSettings.Read();
     m_Instance = new ApplicationIdentity();
     m_Instance.WebServiceAccount = new WebServiceAccount(savedSettings);
 }
	public static ActivationContext CreatePartialActivationContext(ApplicationIdentity identity, string[] manifestPaths) {}
 public ActivationArguments (ApplicationIdentity applicationIdentity) : this (applicationIdentity, null) {}
Example #60
0
        public void FromXml (SecurityElement element) {
            if (element == null)
                throw new ArgumentNullException("element"); 
            if (String.Compare(element.Tag, "ApplicationTrust", StringComparison.Ordinal) != 0)
                throw new ArgumentException(Environment.GetResourceString("Argument_InvalidXML")); 
 
#if FEATURE_CLICKONCE
            m_appTrustedToRun = false; 
            string isAppTrustedToRun = element.Attribute("TrustedToRun");
            if (isAppTrustedToRun != null && String.Compare(isAppTrustedToRun, "true", StringComparison.Ordinal) == 0) {
                m_appTrustedToRun = true;
            } 

            m_persist = false; 
            string persist = element.Attribute("Persist"); 
            if (persist != null && String.Compare(persist, "true", StringComparison.Ordinal) == 0) {
                m_persist = true; 
            }

            m_appId = null;
            string fullName = element.Attribute("FullName"); 
            if (fullName != null && fullName.Length > 0) {
                m_appId = new ApplicationIdentity(fullName); 
            } 
#endif // FEATURE_CLICKONCE
 
            m_psDefaultGrant = null;
            m_grantSetSpecialFlags = 0;
            SecurityElement elDefaultGrant = element.SearchForChildByTag("DefaultGrant");
            if (elDefaultGrant != null) { 
                SecurityElement elDefaultGrantPS = elDefaultGrant.SearchForChildByTag("PolicyStatement");
                if (elDefaultGrantPS != null) { 
                    PolicyStatement ps = new PolicyStatement(null); 
                    ps.FromXml(elDefaultGrantPS);
                    m_psDefaultGrant = ps; 
                    m_grantSetSpecialFlags = SecurityManager.GetSpecialFlags(ps.PermissionSet, null);
                }
            }
 
            List<StrongName> fullTrustAssemblies = new List<StrongName>();
            SecurityElement elFullTrustAssemblies = element.SearchForChildByTag("FullTrustAssemblies"); 
            if (elFullTrustAssemblies != null && elFullTrustAssemblies.InternalChildren != null) { 
                IEnumerator enumerator = elFullTrustAssemblies.Children.GetEnumerator();
                while (enumerator.MoveNext()) { 
                    StrongName fullTrustAssembly = new StrongName();
                    fullTrustAssembly.FromXml(enumerator.Current as SecurityElement);
                    fullTrustAssemblies.Add(fullTrustAssembly);
                } 
            }
 
            m_fullTrustAssemblies = fullTrustAssemblies.AsReadOnly(); 

#if FEATURE_CLICKONCE 
            m_elExtraInfo = element.SearchForChildByTag("ExtraInfo");
#endif // FEATURE_CLICKONCE
        }