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

Commit a16b9b9

Browse files
committed
Merge branch 'master' into master-Dev10
Conflicts: build.proj lib/DotNetOpenAuth.BuildTasks.dll lib/DotNetOpenAuth.BuildTasks.pdb src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs src/DotNetOpenAuth.Test/Messaging/MultiPartPostPartTests.cs src/DotNetOpenAuth.sln src/DotNetOpenAuth.vsmdi src/DotNetOpenAuth/OAuth/OAuthStrings.Designer.cs
2 parents 9a77154 + cdb850c commit a16b9b9

94 files changed

Lines changed: 2306 additions & 187 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build.proj

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<UsingTask AssemblyFile="$(ProjectRoot)lib\MSBuild.Community.Tasks.dll" TaskName="NUnit" />
2525

2626
<ItemGroup>
27-
<SampleProjects Include="$(ProjectRoot)samples\**\*.csproj" />
27+
<SampleProjects Include="$(ProjectRoot)samples\**\*.csproj;$(ProjectRoot)samples\**\*.vbproj" />
2828
<SampleSites Include="OAuthConsumer;OAuthServiceProvider;InfoCardRelyingParty" />
2929
<ProjectTemplates Include="$(ProjectRoot)projecttemplates\**\*.csproj" />
3030
<ILMergeInputAssemblies Include="$(OutputPath)$(ProductName).dll;
@@ -113,22 +113,27 @@
113113

114114
<ItemGroup>
115115
<ToolProjects Include="$(ProjectRoot)Samples\OpenIdOfflineProvider\OpenIdOfflineProvider.csproj" />
116+
</ItemGroup>
117+
118+
<MSBuild Projects="@(ToolProjects)" />
119+
120+
<ItemGroup>
116121
<OfflineProvider Include="
117-
$(ProjectRoot)Samples\OpenIdOfflineProvider\bin\$(TargetFrameworkVersion)\$(Configuration)\**\*.dll;
118-
$(ILMergeOutputAssembly).*;
119-
$(ProjectRoot)Samples\OpenIdOfflineProvider\bin\$(TargetFrameworkVersion)\$(Configuration)\OpenIdOfflineProvider.exe"
120-
Exclude="
121-
$(ProjectRoot)Samples\OpenIdOfflineProvider\bin\$(TargetFrameworkVersion)\$(Configuration)\$(ProductName).*;
122+
$(OutputPath)**\*.dll;
123+
$(OutputPath)OpenIdOfflineProvider.exe"
124+
Exclude="
125+
$(OutputPath)$(ProductName).*;
126+
$(ILMergeOutputAssembly);
122127
"/>
123128
<OfflineProviderTargets Include="
124129
@(OfflineProvider->'$(ToolsDirectory)%(RecursiveDir)%(FileName)%(Extension)')"/>
130+
<OfflineProvider Include="$(ILMergeOutputAssembly)" />
131+
<OfflineProviderTargets Include="$(ToolsDirectory)$(ProductName).dll" />
125132

126133
<AllToolSources Include="@(OfflineProvider)" />
127134
<AllToolTargets Include="@(OfflineProviderTargets)" />
128135
</ItemGroup>
129136

130-
<MSBuild Projects="@(ToolProjects)" />
131-
132137
<MakeDir Directories="@(ToolsDirectory)" />
133138
<Copy SourceFiles="@(AllToolSources)" DestinationFiles="@(AllToolTargets)" SkipUnchangedFiles="true" />
134139

lib/DotNetOpenAuth.BuildTasks.dll

1 KB
Binary file not shown.

lib/DotNetOpenAuth.BuildTasks.pdb

2 KB
Binary file not shown.

samples/DotNetOpenAuth.ApplicationBlock/TwitterConsumer.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace DotNetOpenAuth.ApplicationBlock {
88
using System;
99
using System.Collections.Generic;
1010
using System.IO;
11+
using System.Net;
1112
using System.Xml;
1213
using System.Xml.Linq;
1314
using DotNetOpenAuth.Messaging;
@@ -38,6 +39,18 @@ public static class TwitterConsumer {
3839
/// </summary>
3940
private static readonly MessageReceivingEndpoint GetFriendTimelineStatusEndpoint = new MessageReceivingEndpoint("http://twitter.com/statuses/friends_timeline.xml", HttpDeliveryMethods.GetRequest);
4041

42+
private static readonly MessageReceivingEndpoint UpdateProfileBackgroundImageEndpoint = new MessageReceivingEndpoint("http://twitter.com/account/update_profile_background_image.xml", HttpDeliveryMethods.PostRequest | HttpDeliveryMethods.AuthorizationHeaderRequest);
43+
44+
private static readonly MessageReceivingEndpoint UpdateProfileImageEndpoint = new MessageReceivingEndpoint("http://twitter.com/account/update_profile_image.xml", HttpDeliveryMethods.PostRequest | HttpDeliveryMethods.AuthorizationHeaderRequest);
45+
46+
/// <summary>
47+
/// Initializes static members of the <see cref="TwitterConsumer"/> class.
48+
/// </summary>
49+
static TwitterConsumer() {
50+
// Twitter can't handle the Expect 100 Continue HTTP header.
51+
ServicePointManager.FindServicePoint(GetFavoritesEndpoint.Location).Expect100Continue = false;
52+
}
53+
4154
public static XDocument GetUpdates(ConsumerBase twitter, string accessToken) {
4255
IncomingWebResponse response = twitter.PrepareAuthorizedRequestAndSend(GetFriendTimelineStatusEndpoint, accessToken);
4356
return XDocument.Load(XmlReader.Create(response.GetResponseReader()));
@@ -47,5 +60,32 @@ public static XDocument GetFavorites(ConsumerBase twitter, string accessToken) {
4760
IncomingWebResponse response = twitter.PrepareAuthorizedRequestAndSend(GetFavoritesEndpoint, accessToken);
4861
return XDocument.Load(XmlReader.Create(response.GetResponseReader()));
4962
}
63+
64+
public static XDocument UpdateProfileBackgroundImage(ConsumerBase twitter, string accessToken, string image, bool tile) {
65+
var parts = new[] {
66+
MultipartPostPart.CreateFormFilePart("image", image, "image/" + Path.GetExtension(image).Substring(1).ToLowerInvariant()),
67+
MultipartPostPart.CreateFormPart("tile", tile.ToString().ToLowerInvariant()),
68+
};
69+
HttpWebRequest request = twitter.PrepareAuthorizedRequest(UpdateProfileBackgroundImageEndpoint, accessToken, parts);
70+
request.ServicePoint.Expect100Continue = false;
71+
IncomingWebResponse response = twitter.Channel.WebRequestHandler.GetResponse(request);
72+
string responseString = response.GetResponseReader().ReadToEnd();
73+
return XDocument.Parse(responseString);
74+
}
75+
76+
public static XDocument UpdateProfileImage(ConsumerBase twitter, string accessToken, string pathToImage) {
77+
string contentType = "image/" + Path.GetExtension(pathToImage).Substring(1).ToLowerInvariant();
78+
return UpdateProfileImage(twitter, accessToken, File.OpenRead(pathToImage), contentType);
79+
}
80+
81+
public static XDocument UpdateProfileImage(ConsumerBase twitter, string accessToken, Stream image, string contentType) {
82+
var parts = new[] {
83+
MultipartPostPart.CreateFormFilePart("image", "twitterPhoto", contentType, image),
84+
};
85+
HttpWebRequest request = twitter.PrepareAuthorizedRequest(UpdateProfileImageEndpoint, accessToken, parts);
86+
IncomingWebResponse response = twitter.Channel.WebRequestHandler.GetResponse(request);
87+
string responseString = response.GetResponseReader().ReadToEnd();
88+
return XDocument.Parse(responseString);
89+
}
5090
}
5191
}

samples/OAuthConsumer/Twitter.aspx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,19 @@
1616
</asp:View>
1717
<asp:View runat="server">
1818
<h2>Updates</h2>
19-
<p>Ok, Twitter has authorized us to download your feeds. Click 'Get updates' to download
20-
updates to this sample. Notice how we never asked you for your Twitter username
21-
or password. </p>
19+
<p>Ok, Twitter has authorized us to download your feeds. Notice how we never asked
20+
you for your Twitter username or password. </p>
21+
<p>
22+
Upload a new profile photo:
23+
<asp:FileUpload ID="profilePhoto" runat="server" />
24+
&nbsp;<asp:Button ID="uploadProfilePhotoButton" runat="server"
25+
onclick="uploadProfilePhotoButton_Click" Text="Upload photo" />
26+
&nbsp;<asp:Label ID="photoUploadedLabel" runat="server" EnableViewState="False"
27+
Text="Done!" Visible="False"></asp:Label>
28+
</p>
29+
<p>
30+
Click &#39;Get updates&#39; to download updates to this sample.
31+
</p>
2232
<asp:Button ID="downloadUpdates" runat="server" Text="Get updates" OnClick="downloadUpdates_Click" />
2333
<asp:PlaceHolder runat="server" ID="resultsPlaceholder" />
2434
</asp:View>

samples/OAuthConsumer/Twitter.aspx.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,20 @@ protected void downloadUpdates_Click(object sender, EventArgs e) {
7575
tableBuilder.Append("</table>");
7676
resultsPlaceholder.Controls.Add(new Literal { Text = tableBuilder.ToString() });
7777
}
78+
79+
protected void uploadProfilePhotoButton_Click(object sender, EventArgs e) {
80+
if (profilePhoto.PostedFile.ContentType == null) {
81+
photoUploadedLabel.Visible = true;
82+
photoUploadedLabel.Text = "Select a file first.";
83+
return;
84+
}
85+
86+
var twitter = new WebConsumer(TwitterConsumer.ServiceDescription, this.TokenManager);
87+
XDocument imageResult = TwitterConsumer.UpdateProfileImage(
88+
twitter,
89+
this.AccessToken,
90+
profilePhoto.PostedFile.InputStream,
91+
profilePhoto.PostedFile.ContentType);
92+
photoUploadedLabel.Visible = true;
93+
}
7894
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
Imports DotNetOpenAuth.OpenId.Extensions.ProviderAuthenticationPolicy
2+
Imports DotNetOpenAuth.OpenId.Extensions.SimpleRegistration
3+
Imports DotNetOpenAuth.OpenId.Extensions.AttributeExchange
4+
5+
Public Class State
6+
Public Shared Property ProfileFields() As ClaimsResponse
7+
Get
8+
Return HttpContext.Current.Session("ProfileFields")
9+
End Get
10+
Set(ByVal value As ClaimsResponse)
11+
HttpContext.Current.Session("ProfileFields") = value
12+
End Set
13+
End Property
14+
15+
Public Shared Property FetchResponse() As FetchResponse
16+
Get
17+
Return HttpContext.Current.Session("FetchResponse")
18+
End Get
19+
Set(ByVal value As FetchResponse)
20+
HttpContext.Current.Session("FetchResponse") = value
21+
End Set
22+
End Property
23+
24+
Public Shared Property FriendlyLoginName() As String
25+
Get
26+
Return HttpContext.Current.Session("FriendlyLoginName")
27+
End Get
28+
Set(ByVal value As String)
29+
HttpContext.Current.Session("FriendlyLoginName") = value
30+
End Set
31+
End Property
32+
33+
Public Shared Property PapePolicies() As PolicyResponse
34+
Get
35+
Return HttpContext.Current.Session("PapePolicies")
36+
End Get
37+
Set(ByVal value As PolicyResponse)
38+
HttpContext.Current.Session("PapePolicies") = value
39+
End Set
40+
End Property
41+
42+
Public Shared Sub Clear()
43+
FriendlyLoginName = Nothing
44+
End Sub
45+
46+
End Class
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Imports System.IO
2+
3+
Public Class TracePageAppender
4+
Inherits log4net.Appender.AppenderSkeleton
5+
6+
Protected Overrides Sub Append(ByVal loggingEvent As log4net.Core.LoggingEvent)
7+
Dim sw As StringWriter = New StringWriter(Global_asax.LogMessages)
8+
Layout.Format(sw, loggingEvent)
9+
End Sub
10+
End Class
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="OpenIdRelyingPartyWebFormsVB._Default"
2+
MasterPageFile="~/Site.Master" %>
3+
4+
<%@ Register Assembly="DotNetOpenAuth" Namespace="DotNetOpenAuth" TagPrefix="openid" %>
5+
<asp:Content runat="server" ContentPlaceHolderID="head">
6+
<openid:XrdsPublisher ID="XrdsPublisher1" runat="server" XrdsUrl="~/xrds.aspx" />
7+
</asp:Content>
8+
<asp:Content runat="server" ContentPlaceHolderID="main">
9+
<h2>
10+
Relying Party
11+
</h2>
12+
<p>
13+
Visit the
14+
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/MembersOnly/Default.aspx"
15+
Text="Members Only" />
16+
area. (This will trigger a login demo).
17+
</p>
18+
</asp:Content>

samples/OpenIdRelyingPartyWebFormsVB/Default.aspx.designer.vb

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)