Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Commit 10d8b10

Browse files
committed
#69 Make auth APIs use IEnumerable instead of IList.
1 parent bc2cf12 commit 10d8b10

13 files changed

+72
-43
lines changed

src/Microsoft.AspNet.Http/HttpContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ public virtual AuthenticationResult Authenticate(string authenticationType)
5757
return Authenticate(new[] { authenticationType }).SingleOrDefault();
5858
}
5959

60-
public abstract IEnumerable<AuthenticationResult> Authenticate(IList<string> authenticationTypes);
60+
public abstract IEnumerable<AuthenticationResult> Authenticate(IEnumerable<string> authenticationTypes);
6161

6262
public virtual async Task<AuthenticationResult> AuthenticateAsync(string authenticationType)
6363
{
6464
return (await AuthenticateAsync(new[] { authenticationType })).SingleOrDefault();
6565
}
6666

67-
public abstract Task<IEnumerable<AuthenticationResult>> AuthenticateAsync(IList<string> authenticationTypes);
67+
public abstract Task<IEnumerable<AuthenticationResult>> AuthenticateAsync(IEnumerable<string> authenticationTypes);
6868

6969
public virtual Task<WebSocket> AcceptWebSocketAsync()
7070
{

src/Microsoft.AspNet.Http/HttpResponse.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ public virtual void Challenge(string authenticationType, AuthenticationPropertie
5555
Challenge(new[] { authenticationType }, properties);
5656
}
5757

58-
public virtual void Challenge(IList<string> authenticationTypes)
58+
public virtual void Challenge(IEnumerable<string> authenticationTypes)
5959
{
6060
Challenge(authenticationTypes, properties: null);
6161
}
6262

63-
public abstract void Challenge(IList<string> authenticationTypes, AuthenticationProperties properties);
63+
public abstract void Challenge(IEnumerable<string> authenticationTypes, AuthenticationProperties properties);
6464

6565
public virtual void SignIn(ClaimsIdentity identity)
6666
{
@@ -72,12 +72,12 @@ public virtual void SignIn(ClaimsIdentity identity, AuthenticationProperties pro
7272
SignIn(new[] { identity }, properties);
7373
}
7474

75-
public virtual void SignIn(IList<ClaimsIdentity> identities)
75+
public virtual void SignIn(IEnumerable<ClaimsIdentity> identities)
7676
{
7777
SignIn(identities, properties: null);
7878
}
7979

80-
public abstract void SignIn(IList<ClaimsIdentity> identities, AuthenticationProperties properties);
80+
public abstract void SignIn(IEnumerable<ClaimsIdentity> identities, AuthenticationProperties properties);
8181

8282
public virtual void SignOut()
8383
{
@@ -89,6 +89,6 @@ public virtual void SignOut(string authenticationType)
8989
SignOut(new[] { authenticationType });
9090
}
9191

92-
public abstract void SignOut(IList<string> authenticationTypes);
92+
public abstract void SignOut(IEnumerable<string> authenticationTypes);
9393
}
9494
}

src/Microsoft.AspNet.HttpFeature/Security/IAuthenticateContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Microsoft.AspNet.HttpFeature.Security
1010
[AssemblyNeutral]
1111
public interface IAuthenticateContext
1212
{
13-
IList<string> AuthenticationTypes { get; }
13+
IEnumerable<string> AuthenticationTypes { get; }
1414

1515
void Authenticated(ClaimsIdentity identity, IDictionary<string, string> properties, IDictionary<string, object> description);
1616

src/Microsoft.AspNet.HttpFeature/Security/IChallengeContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Microsoft.AspNet.HttpFeature.Security
99
[AssemblyNeutral]
1010
public interface IChallengeContext
1111
{
12-
IList<string> AuthenticationTypes {get;}
12+
IEnumerable<string> AuthenticationTypes {get;}
1313
IDictionary<string,string> Properties {get;}
1414

1515
void Accept(string authenticationType, IDictionary<string,object> description);

src/Microsoft.AspNet.HttpFeature/Security/ISignInContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Microsoft.AspNet.HttpFeature.Security
1010
[AssemblyNeutral]
1111
public interface ISignInContext
1212
{
13-
IList<ClaimsIdentity> Identities { get; }
13+
IEnumerable<ClaimsIdentity> Identities { get; }
1414
IDictionary<string, string> Properties { get; }
1515

1616
void Accept(string authenticationType, IDictionary<string, object> description);

src/Microsoft.AspNet.HttpFeature/Security/ISignOutContext .cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Microsoft.AspNet.HttpFeature.Security
99
[AssemblyNeutral]
1010
public interface ISignOutContext
1111
{
12-
IList<string> AuthenticationTypes { get; }
12+
IEnumerable<string> AuthenticationTypes { get; }
1313

1414
void Accept(string authenticationType, IDictionary<string, object> description);
1515
}

src/Microsoft.AspNet.PipelineCore/DefaultHttpContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public override IEnumerable<AuthenticationDescription> GetAuthenticationTypes()
178178
return authTypeContext.Results;
179179
}
180180

181-
public override IEnumerable<AuthenticationResult> Authenticate(IList<string> authenticationTypes)
181+
public override IEnumerable<AuthenticationResult> Authenticate(IEnumerable<string> authenticationTypes)
182182
{
183183
if (authenticationTypes == null)
184184
{
@@ -202,7 +202,7 @@ public override IEnumerable<AuthenticationResult> Authenticate(IList<string> aut
202202
return authenticateContext.Results;
203203
}
204204

205-
public override async Task<IEnumerable<AuthenticationResult>> AuthenticateAsync(IList<string> authenticationTypes)
205+
public override async Task<IEnumerable<AuthenticationResult>> AuthenticateAsync(IEnumerable<string> authenticationTypes)
206206
{
207207
if (authenticationTypes == null)
208208
{

src/Microsoft.AspNet.PipelineCore/DefaultHttpResponse.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public override Task WriteAsync(string data)
130130
return Body.WriteAsync(bytes, 0, bytes.Length);
131131
}
132132

133-
public override void Challenge(IList<string> authenticationTypes, AuthenticationProperties properties)
133+
public override void Challenge(IEnumerable<string> authenticationTypes, AuthenticationProperties properties)
134134
{
135135
if (authenticationTypes == null)
136136
{
@@ -153,7 +153,7 @@ public override void Challenge(IList<string> authenticationTypes, Authentication
153153
}
154154
}
155155

156-
public override void SignIn(IList<ClaimsIdentity> identities, AuthenticationProperties properties)
156+
public override void SignIn(IEnumerable<ClaimsIdentity> identities, AuthenticationProperties properties)
157157
{
158158
if (identities == null)
159159
{
@@ -175,7 +175,7 @@ public override void SignIn(IList<ClaimsIdentity> identities, AuthenticationProp
175175
}
176176
}
177177

178-
public override void SignOut(IList<string> authenticationTypes)
178+
public override void SignOut(IEnumerable<string> authenticationTypes)
179179
{
180180
if (authenticationTypes == null)
181181
{

src/Microsoft.AspNet.PipelineCore/Security/AuthTypeContext.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,21 @@ namespace Microsoft.AspNet.PipelineCore.Security
1010
{
1111
public class AuthTypeContext : IAuthTypeContext
1212
{
13+
private List<AuthenticationDescription> _results;
14+
1315
public AuthTypeContext()
1416
{
15-
Results = new List<AuthenticationDescription>();
17+
_results = new List<AuthenticationDescription>();
1618
}
1719

18-
public IList<AuthenticationDescription> Results { get; private set; }
20+
public IEnumerable<AuthenticationDescription> Results
21+
{
22+
get { return _results; }
23+
}
1924

2025
public void Accept(IDictionary<string, object> description)
2126
{
22-
Results.Add(new AuthenticationDescription(description));
27+
_results.Add(new AuthenticationDescription(description));
2328
}
2429
}
2530
}

src/Microsoft.AspNet.PipelineCore/Security/AuthenticateContext.cs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,42 @@ namespace Microsoft.AspNet.PipelineCore.Security
1414
{
1515
public class AuthenticateContext : IAuthenticateContext
1616
{
17-
public AuthenticateContext(IList<string> authenticationTypes)
17+
private List<AuthenticationResult> _results;
18+
private List<string> _accepted;
19+
20+
public AuthenticateContext(IEnumerable<string> authenticationTypes)
1821
{
1922
if (authenticationTypes == null)
2023
{
2124
throw new ArgumentNullException("authenticationType");
2225
}
2326
AuthenticationTypes = authenticationTypes;
24-
Results = new List<AuthenticationResult>();
25-
Accepted = new List<string>();
27+
_results = new List<AuthenticationResult>();
28+
_accepted = new List<string>();
2629
}
2730

28-
public IList<string> AuthenticationTypes { get; private set; }
31+
public IEnumerable<string> AuthenticationTypes { get; private set; }
2932

30-
public IList<AuthenticationResult> Results { get; private set; }
33+
public IEnumerable<AuthenticationResult> Results
34+
{
35+
get { return _results; }
36+
}
3137

32-
public IList<string> Accepted { get; private set; }
38+
public IEnumerable<string> Accepted
39+
{
40+
get { return _accepted; }
41+
}
3342

3443
public void Authenticated(ClaimsIdentity identity, IDictionary<string, string> properties, IDictionary<string, object> description)
3544
{
3645
var descrip = new AuthenticationDescription(description);
37-
Accepted.Add(descrip.AuthenticationType); // may not match identity.AuthType
38-
Results.Add(new AuthenticationResult(identity, new AuthenticationProperties(properties), descrip));
46+
_accepted.Add(descrip.AuthenticationType); // may not match identity.AuthType
47+
_results.Add(new AuthenticationResult(identity, new AuthenticationProperties(properties), descrip));
3948
}
4049

4150
public void NotAuthenticated(string authenticationType, IDictionary<string, string> properties, IDictionary<string, object> description)
4251
{
43-
Accepted.Add(authenticationType);
52+
_accepted.Add(authenticationType);
4453
}
4554
}
4655
}

src/Microsoft.AspNet.PipelineCore/Security/ChallengeContext.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,31 @@ namespace Microsoft.AspNet.PipelineCore.Security
1212
{
1313
public class ChallengeContext : IChallengeContext
1414
{
15-
public ChallengeContext(IList<string> authenticationTypes, IDictionary<string, string> properties)
15+
private List<string> _accepted;
16+
17+
public ChallengeContext(IEnumerable<string> authenticationTypes, IDictionary<string, string> properties)
1618
{
1719
if (authenticationTypes == null)
1820
{
1921
throw new ArgumentNullException();
2022
}
2123
AuthenticationTypes = authenticationTypes;
2224
Properties = properties ?? new Dictionary<string, string>(StringComparer.Ordinal);
23-
Accepted = new List<string>();
25+
_accepted = new List<string>();
2426
}
2527

26-
public IList<string> AuthenticationTypes { get; private set; }
28+
public IEnumerable<string> AuthenticationTypes { get; private set; }
2729

2830
public IDictionary<string, string> Properties { get; private set; }
2931

30-
public IList<string> Accepted { get; private set; }
32+
public IEnumerable<string> Accepted
33+
{
34+
get { return _accepted; }
35+
}
3136

3237
public void Accept(string authenticationType, IDictionary<string, object> description)
3338
{
34-
Accepted.Add(authenticationType);
39+
_accepted.Add(authenticationType);
3540
}
3641
}
3742
}

src/Microsoft.AspNet.PipelineCore/Security/SignInContext.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,31 @@ namespace Microsoft.AspNet.PipelineCore.Security
1010
{
1111
public class SignInContext : ISignInContext
1212
{
13-
public SignInContext(IList<ClaimsIdentity> identities, IDictionary<string, string> dictionary)
13+
private List<string> _accepted;
14+
15+
public SignInContext(IEnumerable<ClaimsIdentity> identities, IDictionary<string, string> dictionary)
1416
{
1517
if (identities == null)
1618
{
1719
throw new ArgumentNullException("identities");
1820
}
1921
Identities = identities;
2022
Properties = dictionary ?? new Dictionary<string, string>(StringComparer.Ordinal);
21-
Accepted = new List<string>();
23+
_accepted = new List<string>();
2224
}
2325

24-
public IList<ClaimsIdentity> Identities { get; private set; }
26+
public IEnumerable<ClaimsIdentity> Identities { get; private set; }
2527

2628
public IDictionary<string, string> Properties { get; private set; }
2729

28-
public IList<string> Accepted { get; private set; }
30+
public IEnumerable<string> Accepted
31+
{
32+
get { return _accepted; }
33+
}
2934

3035
public void Accept(string authenticationType, IDictionary<string, object> description)
3136
{
32-
Accepted.Add(authenticationType);
37+
_accepted.Add(authenticationType);
3338
}
3439
}
3540
}

src/Microsoft.AspNet.PipelineCore/Security/SignOutContext.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,28 @@ namespace Microsoft.AspNet.PipelineCore.Security
99
{
1010
public class SignOutContext : ISignOutContext
1111
{
12-
public SignOutContext(IList<string> authenticationTypes)
12+
private List<string> _accepted;
13+
14+
public SignOutContext(IEnumerable<string> authenticationTypes)
1315
{
1416
if (authenticationTypes == null)
1517
{
1618
throw new ArgumentNullException("authenticationTypes");
1719
}
1820
AuthenticationTypes = authenticationTypes;
19-
Accepted = new List<string>();
21+
_accepted = new List<string>();
2022
}
2123

22-
public IList<string> AuthenticationTypes { get; private set; }
24+
public IEnumerable<string> AuthenticationTypes { get; private set; }
2325

24-
public IList<string> Accepted { get; private set; }
26+
public IEnumerable<string> Accepted
27+
{
28+
get { return _accepted; }
29+
}
2530

2631
public void Accept(string authenticationType, IDictionary<string, object> description)
2732
{
28-
Accepted.Add(authenticationType);
33+
_accepted.Add(authenticationType);
2934
}
3035
}
3136
}

0 commit comments

Comments
 (0)