Updates referencesource to .NET 4.7
[mono.git] / mcs / class / referencesource / mscorlib / system / security / policy / iapplicationtrustmanager.cs
1 // ==++==
2 //
3 //   Copyright (c) Microsoft Corporation.  All rights reserved.
4 //
5 // ==--==
6 // <OWNER>Microsoft</OWNER>
7 // 
8
9 //
10 // IApplicationTrustManager.cs
11 //
12
13 namespace System.Security.Policy {
14
15     //
16     // Interface that defines an IApplicationTrustManager. An IApplicationTrustManager handles application security decisions
17     // when there is no stored policy for that app, be this by prompting the user, checking a web service, or other means.
18     //
19
20     [System.Runtime.InteropServices.ComVisible(true)]
21     public interface IApplicationTrustManager : ISecurityEncodable {
22         ApplicationTrust DetermineApplicationTrust (ActivationContext activationContext, TrustManagerContext context);
23     }
24
25     //
26     // This enumeration provides a hint to the trust manager as to the UI it should provide for the trust decision.
27     //
28
29     [System.Runtime.InteropServices.ComVisible(true)]
30     public enum TrustManagerUIContext {
31         Install,
32         Upgrade,
33         Run
34     }
35
36     //
37     // The TrustManagerContext class represents context that the host would like the Trust Manager to consider when making 
38     // a run/no-run decision and when setting up the security on a new AppDomain in which to run an application.
39     // This class can be extended by trust managers so it is non-sealed.
40     //
41
42     [System.Runtime.InteropServices.ComVisible(true)]
43     public class TrustManagerContext {
44         private bool m_ignorePersistedDecision;
45         private TrustManagerUIContext m_uiContext;
46         private bool m_noPrompt;
47         private bool m_keepAlive;
48         private bool m_persist;
49         private ApplicationIdentity m_appId;
50
51         public TrustManagerContext () : this (TrustManagerUIContext.Run) {}
52
53         public TrustManagerContext (TrustManagerUIContext uiContext) {
54             m_ignorePersistedDecision = false;
55             m_uiContext = uiContext;
56             m_keepAlive = false;
57             m_persist = true;
58         }
59
60         public virtual TrustManagerUIContext UIContext {
61             get {
62                 return m_uiContext;
63             }
64             set {
65                 m_uiContext = value;
66             }
67         }
68
69         public virtual bool NoPrompt {
70             get {
71                 return m_noPrompt;
72             }
73             set {
74                 m_noPrompt = value;
75             }
76         }
77
78         public virtual bool IgnorePersistedDecision {
79             get {
80                 return m_ignorePersistedDecision;
81             }
82             set {
83                 m_ignorePersistedDecision = value;
84             }
85         }
86
87         public virtual bool KeepAlive {
88             get {
89                 return m_keepAlive;
90             }
91             set {
92                 m_keepAlive = value;
93             }
94         }
95
96         public virtual bool Persist {
97             get {
98                 return m_persist;
99             }
100             set {
101                 m_persist = value;
102             }
103         }
104
105         public virtual ApplicationIdentity PreviousApplicationIdentity {
106             get {
107                 return m_appId;
108             }
109             set {
110                 m_appId = value;
111             }
112         }
113     }
114 }