@@ -10,14 +10,16 @@ namespace System.ServiceModel
10
10
{
11
11
public sealed class UnixDomainSocketSecurity
12
12
{
13
- internal const UnixDomainSocketSecurityMode DefaultMode = UnixDomainSocketSecurityMode . Transport ;
13
+ private static UnixDomainSocketSecurityMode s_defaultMode =
14
+ RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ?
15
+ UnixDomainSocketSecurityMode . Transport : UnixDomainSocketSecurityMode . TransportCredentialOnly ;
16
+
14
17
15
18
private UnixDomainSocketSecurityMode _mode ;
16
19
17
20
public UnixDomainSocketSecurity ( )
18
21
{
19
- _mode = RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ?
20
- UnixDomainSocketSecurityMode . Transport : UnixDomainSocketSecurityMode . TransportCredentialOnly ;
22
+ _mode = s_defaultMode ;
21
23
Transport = new UnixDomainSocketTransportSecurity ( ) ;
22
24
}
23
25
@@ -27,14 +29,14 @@ private UnixDomainSocketSecurity(UnixDomainSocketSecurityMode mode, UnixDomainSo
27
29
string . Format ( "Invalid SecurityMode value: {0} = {1} (default is {2} = {3})." ,
28
30
( int ) mode ,
29
31
mode . ToString ( ) ,
30
- ( int ) SecurityMode . Transport ,
31
- SecurityMode . Transport . ToString ( ) ) ) ;
32
+ ( int ) s_defaultMode ,
33
+ s_defaultMode . ToString ( ) ) ) ;
32
34
33
35
_mode = mode ;
34
36
Transport = transportSecurity ?? new UnixDomainSocketTransportSecurity ( ) ;
35
37
}
36
38
37
- [ DefaultValue ( DefaultMode ) ]
39
+
38
40
public UnixDomainSocketSecurityMode Mode
39
41
{
40
42
get { return _mode ; }
@@ -54,7 +56,9 @@ internal BindingElement CreateTransportSecurity()
54
56
{
55
57
if ( _mode == UnixDomainSocketSecurityMode . Transport || _mode == UnixDomainSocketSecurityMode . TransportCredentialOnly )
56
58
{
57
- if ( _mode == UnixDomainSocketSecurityMode . TransportCredentialOnly && Transport . ClientCredentialType != UnixDomainSocketClientCredentialType . PosixIdentity )
59
+ if ( ( _mode == UnixDomainSocketSecurityMode . TransportCredentialOnly && Transport . ClientCredentialType != UnixDomainSocketClientCredentialType . PosixIdentity )
60
+ ||
61
+ ( _mode == UnixDomainSocketSecurityMode . Transport && Transport . ClientCredentialType == UnixDomainSocketClientCredentialType . PosixIdentity ) )
58
62
{
59
63
throw DiagnosticUtility . ExceptionUtility . ThrowHelperError ( new NotSupportedException ( SR . Format ( SR . UnsupportedSecuritySetting , "Mode" , _mode ) ) ) ;
60
64
}
0 commit comments