blob: 5c5a52663607fed7b1421900a724e6e57e3dc4ad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
//-----------------------------------------------------------------------
// <copyright file="IAccessTokenAnalyzer.cs" company="Outercurve Foundation">
// Copyright (c) Outercurve Foundation. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.OAuth2 {
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using DotNetOpenAuth.Messaging;
/// <summary>
/// An interface that resource server hosts should implement if they accept access tokens
/// issued by non-DotNetOpenAuth authorization servers.
/// </summary>
[ContractClass((typeof(IAccessTokenAnalyzerContract)))]
public interface IAccessTokenAnalyzer {
/// <summary>
/// Reads an access token to find out what data it authorizes access to.
/// </summary>
/// <param name="message">The message carrying the access token.</param>
/// <param name="accessToken">The access token's serialized representation.</param>
/// <returns>The deserialized, validated token.</returns>
/// <exception cref="ProtocolException">Thrown if the access token is expired, invalid, or from an untrusted authorization server.</exception>
AccessToken DeserializeAccessToken(IDirectedProtocolMessage message, string accessToken);
}
/// <summary>
/// Code contract for the <see cref="IAccessTokenAnalyzer"/> interface.
/// </summary>
[ContractClassFor(typeof(IAccessTokenAnalyzer))]
internal abstract class IAccessTokenAnalyzerContract : IAccessTokenAnalyzer {
/// <summary>
/// Prevents a default instance of the <see cref="IAccessTokenAnalyzerContract"/> class from being created.
/// </summary>
private IAccessTokenAnalyzerContract() {
}
/// <summary>
/// Reads an access token to find out what data it authorizes access to.
/// </summary>
/// <param name="message">The message carrying the access token.</param>
/// <param name="accessToken">The access token's serialized representation.</param>
/// <returns>The deserialized, validated token.</returns>
/// <exception cref="ProtocolException">Thrown if the access token is expired, invalid, or from an untrusted authorization server.</exception>
AccessToken IAccessTokenAnalyzer.DeserializeAccessToken(IDirectedProtocolMessage message, string accessToken) {
Requires.NotNull(message, "message");
Requires.NotNullOrEmpty(accessToken, "accessToken");
Contract.Ensures(Contract.Result<AccessToken>() != null);
throw new NotImplementedException();
}
}
}
|