Skip to content

Commit f16d6dd

Browse files
j0hnth0mrkttu
authored andcommitted
Add support for setting access control on queue.
1 parent 0a75545 commit f16d6dd

11 files changed

Lines changed: 1334 additions & 1 deletion

Experimental.System.Messaging/Experimental.System.Messaging.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
55
<RootNamespace>Experimental.System</RootNamespace>
66
<PackageId>Experimental.System.Messaging</PackageId>
77
<Version>1.1.0</Version>
@@ -41,4 +41,8 @@ The source code for this package is excerpted from the .NET Framework reference
4141
</None>
4242
</ItemGroup>
4343

44+
<ItemGroup>
45+
<PackageReference Include="System.Security.Permissions" Version="6.0.0" />
46+
</ItemGroup>
47+
4448
</Project>
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
using System;
2+
using System.ComponentModel;
3+
4+
namespace Experimental.System.Messaging
5+
{
6+
/// <include file='doc\AccessControlEntry.uex' path='docs/doc[@for="AccessControlEntry"]/*' />
7+
/// <devdoc>
8+
/// <para>[To be supplied.]</para>
9+
/// </devdoc>
10+
public class AccessControlEntry
11+
{
12+
//const int customRightsMask = 0x0000ffff;
13+
const StandardAccessRights standardRightsMask = (StandardAccessRights)0x001f0000;
14+
const GenericAccessRights genericRightsMask = unchecked((GenericAccessRights)0xf0000000);
15+
16+
internal int accessFlags = 0;
17+
Trustee trustee = null;
18+
AccessControlEntryType entryType = AccessControlEntryType.Allow;
19+
20+
/// <include file='doc\AccessControlEntry.uex' path='docs/doc[@for="AccessControlEntry.AccessControlEntry"]/*' />
21+
/// <devdoc>
22+
/// <para>[To be supplied.]</para>
23+
/// </devdoc>
24+
public AccessControlEntry()
25+
{
26+
}
27+
28+
/// <include file='doc\AccessControlEntry.uex' path='docs/doc[@for="AccessControlEntry.AccessControlEntry1"]/*' />
29+
/// <devdoc>
30+
/// <para>[To be supplied.]</para>
31+
/// </devdoc>
32+
public AccessControlEntry(Trustee trustee)
33+
{
34+
this.Trustee = trustee;
35+
}
36+
37+
/// <include file='doc\AccessControlEntry.uex' path='docs/doc[@for="AccessControlEntry.AccessControlEntry2"]/*' />
38+
/// <devdoc>
39+
/// <para>[To be supplied.]</para>
40+
/// </devdoc>
41+
public AccessControlEntry(Trustee trustee, GenericAccessRights genericAccessRights, StandardAccessRights standardAccessRights, AccessControlEntryType entryType)
42+
{
43+
this.GenericAccessRights = genericAccessRights;
44+
this.StandardAccessRights = standardAccessRights;
45+
this.Trustee = trustee;
46+
this.EntryType = entryType;
47+
}
48+
49+
/// <include file='doc\AccessControlEntry.uex' path='docs/doc[@for="AccessControlEntry.EntryType"]/*' />
50+
/// <devdoc>
51+
/// <para>[To be supplied.]</para>
52+
/// </devdoc>
53+
public AccessControlEntryType EntryType
54+
{
55+
get { return entryType; }
56+
set
57+
{
58+
if (!ValidationUtility.ValidateAccessControlEntryType(value))
59+
throw new InvalidEnumArgumentException("value", (int)value, typeof(AccessControlEntryType));
60+
61+
entryType = value;
62+
}
63+
}
64+
65+
66+
67+
/// <include file='doc\AccessControlEntry.uex' path='docs/doc[@for="AccessControlEntry.CustomAccessRights"]/*' />
68+
/// <devdoc>
69+
/// <para>[To be supplied.]</para>
70+
/// </devdoc>
71+
protected int CustomAccessRights
72+
{
73+
get
74+
{
75+
return accessFlags;
76+
}
77+
set
78+
{
79+
accessFlags = value;
80+
}
81+
}
82+
83+
/// <include file='doc\AccessControlEntry.uex' path='docs/doc[@for="AccessControlEntry.GenericAccessRights"]/*' />
84+
/// <devdoc>
85+
/// <para>[To be supplied.]</para>
86+
/// </devdoc>
87+
public GenericAccessRights GenericAccessRights
88+
{
89+
get
90+
{
91+
return (GenericAccessRights)accessFlags & genericRightsMask;
92+
}
93+
set
94+
{
95+
// make sure these flags really are genericAccessRights
96+
if ((value & genericRightsMask) != value)
97+
throw new InvalidEnumArgumentException("value", (int)value, typeof(GenericAccessRights));
98+
99+
accessFlags = (accessFlags & (int)(~genericRightsMask)) | (int)value;
100+
}
101+
}
102+
103+
/// <include file='doc\AccessControlEntry.uex' path='docs/doc[@for="AccessControlEntry.StandardAccessRights"]/*' />
104+
/// <devdoc>
105+
/// <para>[To be supplied.]</para>
106+
/// </devdoc>
107+
public StandardAccessRights StandardAccessRights
108+
{
109+
get
110+
{
111+
return (StandardAccessRights)accessFlags & standardRightsMask;
112+
}
113+
set
114+
{
115+
// make sure these flags really are standardAccessRights
116+
if ((value & standardRightsMask) != value)
117+
throw new InvalidEnumArgumentException("value", (int)value, typeof(StandardAccessRights));
118+
119+
accessFlags = (accessFlags & (int)(~standardRightsMask)) | (int)value;
120+
}
121+
}
122+
123+
/// <include file='doc\AccessControlEntry.uex' path='docs/doc[@for="AccessControlEntry.Trustee"]/*' />
124+
/// <devdoc>
125+
/// <para>[To be supplied.]</para>
126+
/// </devdoc>
127+
public Trustee Trustee
128+
{
129+
get
130+
{
131+
return trustee;
132+
}
133+
set
134+
{
135+
if (value == null)
136+
throw new ArgumentNullException("value");
137+
138+
trustee = value;
139+
}
140+
}
141+
}
142+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using Experimental.System.Messaging.Interop;
2+
3+
namespace Experimental.System.Messaging
4+
{
5+
/// <include file='doc\AccessControlEntryType.uex' path='docs/doc[@for="AccessControlEntryType"]/*' />
6+
/// <devdoc>
7+
/// <para>[To be supplied.]</para>
8+
/// </devdoc>
9+
public enum AccessControlEntryType
10+
{
11+
/// <include file='doc\AccessControlEntryType.uex' path='docs/doc[@for="AccessControlEntryType.Allow"]/*' />
12+
/// <devdoc>
13+
/// <para>[To be supplied.]</para>
14+
/// </devdoc>
15+
Allow = NativeMethods.GRANT_ACCESS,
16+
/// <include file='doc\AccessControlEntryType.uex' path='docs/doc[@for="AccessControlEntryType.Set"]/*' />
17+
/// <devdoc>
18+
/// <para>[To be supplied.]</para>
19+
/// </devdoc>
20+
Set = NativeMethods.SET_ACCESS,
21+
/// <include file='doc\AccessControlEntryType.uex' path='docs/doc[@for="AccessControlEntryType.Deny"]/*' />
22+
/// <devdoc>
23+
/// <para>[To be supplied.]</para>
24+
/// </devdoc>
25+
Deny = NativeMethods.DENY_ACCESS,
26+
/// <include file='doc\AccessControlEntryType.uex' path='docs/doc[@for="AccessControlEntryType.Revoke"]/*' />
27+
/// <devdoc>
28+
/// <para>[To be supplied.]</para>
29+
/// </devdoc>
30+
Revoke = NativeMethods.REVOKE_ACCESS
31+
}
32+
}

0 commit comments

Comments
 (0)