14 private const string ApplicationTrustProperty =
"ApplicationTrust";
16 private const string InstallerIdentifier =
"{60051b8f-4f12-400a-8e50-dd05ebd438d1}";
18 private static Guid ClrPropertySet =
new Guid(
"c989bb7a-8385-4715-98cf-a741a8edb823");
20 private static object s_installReference =
null;
22 private object m_appTrusts;
24 private bool m_storeBounded;
26 private Store m_pStore;
28 private static StoreApplicationReference InstallReference
32 if (s_installReference ==
null)
34 Interlocked.
CompareExchange(ref s_installReference,
new StoreApplicationReference(IsolationInterop.GUID_SXS_INSTALL_REFERENCE_SCHEME_OPAQUESTRING,
"{60051b8f-4f12-400a-8e50-dd05ebd438d1}",
null),
null);
36 return (StoreApplicationReference)s_installReference;
45 if (m_appTrusts ==
null)
50 RefreshStorePointer();
51 StoreDeploymentMetadataEnumeration storeDeploymentMetadataEnumeration = m_pStore.EnumInstallerDeployments(IsolationInterop.GUID_SXS_INSTALL_REFERENCE_SCHEME_OPAQUESTRING,
"{60051b8f-4f12-400a-8e50-dd05ebd438d1}",
"ApplicationTrust",
null);
52 foreach (IDefinitionAppId item
in storeDeploymentMetadataEnumeration)
54 StoreDeploymentMetadataPropertyEnumeration storeDeploymentMetadataPropertyEnumeration = m_pStore.EnumInstallerDeploymentProperties(IsolationInterop.GUID_SXS_INSTALL_REFERENCE_SCHEME_OPAQUESTRING,
"{60051b8f-4f12-400a-8e50-dd05ebd438d1}",
"ApplicationTrust", item);
55 foreach (StoreOperationMetadataProperty item2
in storeDeploymentMetadataPropertyEnumeration)
57 string value = item2.Value;
58 if (value !=
null && value.Length > 0)
62 applicationTrust.
FromXml(element);
63 arrayList.
Add(applicationTrust);
78 [SecuritySafeCritical]
81 return AppTrusts.
Count;
111 if (applicationTrustCollection.
Count > 0)
113 return applicationTrustCollection[0];
124 [SecuritySafeCritical]
135 [SecuritySafeCritical]
144 : this(storeBounded: false)
148 internal ApplicationTrustCollection(
bool storeBounded)
150 m_storeBounded = storeBounded;
154 private void RefreshStorePointer()
156 if (m_pStore !=
null)
160 m_pStore = IsolationInterop.GetUserStore();
164 private void CommitApplicationTrust(ApplicationIdentity applicationIdentity,
string trustXml)
166 StoreOperationMetadataProperty[] setProperties =
new StoreOperationMetadataProperty[1]
168 new StoreOperationMetadataProperty(ClrPropertySet,
"ApplicationTrust", trustXml)
170 IEnumDefinitionIdentity enumDefinitionIdentity = applicationIdentity.Identity.EnumAppPath();
171 IDefinitionIdentity[] array =
new IDefinitionIdentity[1];
172 IDefinitionIdentity definitionIdentity =
null;
173 if (enumDefinitionIdentity.Next(1u, array) == 1)
175 definitionIdentity = array[0];
177 IDefinitionAppId definitionAppId = IsolationInterop.AppIdAuthority.CreateDefinition();
178 definitionAppId.SetAppPath(1u,
new IDefinitionIdentity[1]
182 definitionAppId.put_Codebase(applicationIdentity.CodeBase);
183 using (StoreTransaction storeTransaction =
new StoreTransaction())
185 storeTransaction.Add(
new StoreOperationSetDeploymentMetadata(definitionAppId, InstallReference, setProperties));
186 RefreshStorePointer();
187 m_pStore.Transact(storeTransaction.Operations);
214 return AppTrusts.
Add(trust);
232 for (; i < trusts.Length; i++)
239 for (
int j = 0; j < i; j++)
272 for (
int i = 0; i < num; i++)
292 if (CmsUtils.CompareIdentities(current.
ApplicationIdentity, applicationIdentity, versionMatch))
294 applicationTrustCollection.
Add(current);
297 return applicationTrustCollection;
350 for (; i < trusts.Length; i++)
357 for (
int j = 0; j < i; j++)
389 for (
int i = 0; i < num; i++)
407 if (item.ApplicationIdentity ==
null)
411 CommitApplicationTrust(item.ApplicationIdentity,
null);
426 [SecuritySafeCritical]
441 [SecuritySafeCritical]
452 if (index < 0 || index >= array.Length)
454 throw new ArgumentOutOfRangeException(
"index", Environment.GetResourceString(
"ArgumentOutOfRange_Index"));
456 if (array.Length - index <
Count)
458 throw new ArgumentException(Environment.GetResourceString(
"Argument_InvalidOffLen"));
460 for (
int i = 0; i <
Count; i++)
462 array.SetValue(
this[i], index++);
Represents the enumerator for T:System.Security.Policy.ApplicationTrust objects in the T:System....
void Clear()
Removes all the application trusts from the collection.
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
void FromXml(SecurityElement element)
Reconstructs an T:System.Security.Policy.ApplicationTrust object with a given state from an XML encod...
Encapsulates security decisions about an application. This class cannot be inherited.
bool IsSynchronized
Gets a value indicating whether access to the collection is synchronized (thread safe).
static int ReleaseComObject(object o)
Decrements the reference count of the Runtime Callable Wrapper (RCW) associated with the specified CO...
int Add(ApplicationTrust trust)
Adds an element to the collection.
virtual int Count
Gets the number of elements actually contained in the T:System.Collections.ArrayList.
bool MoveNext()
Moves to the next element in the T:System.Security.Policy.ApplicationTrustCollection collection.
ApplicationTrust Current
Gets the current T:System.Security.Policy.ApplicationTrust object in the T:System....
void CopyTo(ApplicationTrust[] array, int index)
Copies the entire collection to a compatible one-dimensional array, starting at the specified index o...
virtual void Clear()
Removes all elements from the T:System.Collections.ArrayList.
void Remove(ApplicationTrust trust)
Removes the specified application trust from the collection.
void RemoveRange(ApplicationTrust[] trusts)
Removes the application trust objects in the specified array from the collection.
int Count
Gets the number of items contained in the collection.
Exposes an enumerator, which supports a simple iteration over a non-generic collection....
Provides information about, and means to manipulate, the current environment and platform....
ApplicationTrustEnumerator GetEnumerator()
Returns an object that can be used to iterate over the collection.
Represents a globally unique identifier (GUID).To browse the .NET Framework source code for this type...
ApplicationTrustCollection Find(ApplicationIdentity applicationIdentity, ApplicationVersionMatch versionMatch)
Gets the application trusts in the collection that match the specified application identity.
Represents the XML object model for encoding security objects. This class cannot be inherited.
static int CompareExchange(ref int location1, int value, int comparand)
Compares two 32-bit signed integers for equality and, if they are equal, replaces the first value.
void RemoveRange(ApplicationTrustCollection trusts)
Removes the application trust objects in the specified collection from the collection.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Provides a collection of methods for allocating unmanaged memory, copying unmanaged memory blocks,...
ApplicationVersionMatch
Specifies how to match versions when locating application trusts in a collection.
IEnumerator GetEnumerator()
Returns an enumerator that iterates through a collection.
ApplicationIdentity ApplicationIdentity
Gets or sets the application identity for the application trust object.
SecurityElement ToXml()
Creates an XML encoding of the T:System.Security.Policy.ApplicationTrust object and its current state...
virtual int Add(object value)
Adds an object to the end of the T:System.Collections.ArrayList.
object SyncRoot
Gets an object that can be used to synchronize access to the collection.
The exception that is thrown when one of the arguments provided to a method is not valid.
static SecurityElement FromString(string xml)
Creates a security element from an XML-encoded string.
Represents a collection of T:System.Security.Policy.ApplicationTrust objects. This class cannot be in...
virtual void Remove(object obj)
Removes the first occurrence of a specific object from the T:System.Collections.ArrayList.
Provides the ability to uniquely identify a manifest-activated application. This class cannot be inhe...
void Remove(ApplicationIdentity applicationIdentity, ApplicationVersionMatch versionMatch)
Removes all application trust objects that match the specified criteria from the collection.
Defines size, enumerators, and synchronization methods for all nongeneric collections.
void CopyTo(Array array, int index)
Copies the elements of the T:System.Collections.ICollection to an T:System.Array, starting at a parti...
Provides atomic operations for variables that are shared by multiple threads.
void AddRange(ApplicationTrustCollection trusts)
Copies the elements of the specified T:System.Security.Policy.ApplicationTrustCollection to the end o...
Supports a simple iteration over a non-generic collection.
override string ToString()
Produces a string representation of an XML element and its constituent attributes,...
void AddRange(ApplicationTrust[] trusts)
Copies the elements of the specified T:System.Security.Policy.ApplicationTrust array to the end of th...
Implements the T:System.Collections.IList interface using an array whose size is dynamically increase...