Skip to content

Commit

Permalink
Windows 10 Version 1703 - September 2018 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
oldnewthing committed Sep 13, 2018
1 parent b2611b3 commit 0b646eb
Show file tree
Hide file tree
Showing 19 changed files with 1,514 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ For additional Windows samples, see [Windows on GitHub](http://microsoft.github.
<td><a href="Samples/WiFiDirectServices">Wi-Fi Direct services</a></td>
</tr>
<tr>
<td><a href="Samples/HotspotAuthentication">Wi-Fi hotspot authentication</a></td>
<td><a href="Samples/WiFiScan">Wi-Fi scanning</a></td>
</tr>
</table>
Expand Down
2 changes: 1 addition & 1 deletion Samples/BluetoothLE/cs/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</Properties>

<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.14393.0" MaxVersionTested="10.0.15063.0" />
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.15063.0" MaxVersionTested="10.0.15063.0" />
</Dependencies>

<Resources>
Expand Down
111 changes: 111 additions & 0 deletions Samples/HotspotAuthentication/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<!---
category: NetworkingAndWebServices
samplefwlink: http://go.microsoft.com/fwlink/p/?LinkId=2019043
--->

# Hotspot authentication sample

Shows how to provision and register a hotspot profile and perform either WISPr or custom authentication.

> **Note:** This sample is part of a large collection of UWP feature samples.
> If you are unfamiliar with Git and GitHub, you can download the entire collection as a
> [ZIP file](https://github.com/Microsoft/Windows-universal-samples/archive/master.zip), but be
> sure to unzip everything to access shared dependencies. For more info on working with the ZIP file,
> the samples collection, and GitHub, see [Get the UWP samples from GitHub](https://aka.ms/ovu2uq).
> For more samples, see the [Samples portal](https://aka.ms/winsamples) on the Windows Dev Center.
This sample demonstrates the following operations:

- Provision a hotspot profile and register the corresponding background task.
- Authenticate as a foreground app with default WISPr authentication or custom authentication.
- Authenticate in a background task

The background task requires that the profile be provisioned and registered.
The task is triggered once the Wi-Fi is connected to the hotspot as a part of post Wi-Fi connection.
When a device initially connects, the hotspot usually has a limited connection,
and post-connection authentication is done by a background task to enable the full Internet connection.

In order to invoke the hotspot authentication flow (background task),
the access point being connected to must provide a captive portal response
with WISPr support claimed in the XML blob being returned to the client.

Authentication can be completed in one of two ways.
- Issuing WISPr credentials using IssueCredentialsAsync API, which uses the default WISPr implementation.
- Performing a custom WISPr authentication using the information obtained through HotspotAuthenticationContext.TryGetAuthenticationContext. In this case, you must call HotspotAuthenticationContext.SkipAuthentication API to skip the default WISPr authentication process once the custom authentication is complete.

## Related topics

### Conceptual

[Windows 8 hotspot authentication sample](https://code.msdn.microsoft.com/windowsapps/Wi-Fi-hotspot-authenticatio-943569eb)

### Reference

[Mobile Broadband on the Windows Hardware Dev Center](https://docs.microsoft.com/en-us/windows-hardware/drivers/mobilebroadband/index)

[HotspotAuthenticationContext](https://docs.microsoft.com/en-us/uwp/api/Windows.Networking.NetworkOperators.HotspotAuthenticationContext)

[HotspotAuthenticationEventDetails ](https://docs.microsoft.com/en-us/uwp/api/Windows.Networking.NetworkOperators.HotspotAuthenticationEventDetails)

[IBackgroundTask](https://docs.microsoft.com/en-us/uwp/api/Windows.ApplicationModel.Background.IBackgroundTask)

[IBackgroundTaskInstance](https://docs.microsoft.com/en-us/uwp/api/Windows.ApplicationModel.Background.IBackgroundTaskInstance)

## System requirements

The system must have a Wi-Fi adapter for this sample to be meaningful.

**Client:** Windows 10

**Server:** Windows Server 2016 Technical Preview

**Phone:** Windows 10

## Build the sample

1. If you download the samples ZIP, be sure to unzip the entire archive, not just the folder with the sample you want to build.
2. Start Microsoft Visual Studio 2017 and select **File** \> **Open** \> **Project/Solution**.
3. Starting in the folder where you unzipped the samples, go to the Samples subfolder, then the subfolder for this specific sample, then the subfolder for the programming language. Double-click the Visual Studio Solution (.sln) file.
4. Press Ctrl+Shift+B, or select **Build** \> **Build Solution**.

## Run the sample

The Wi-Fi hotspot authentication sample has following requirements:

Windows must trigger the application when authenticating with a certain hotspot. This is achieved by provisioning a WLAN profile with a corresponding configuration.

1. The app must declare background task and corresponding entry point must match with the actual background task.
2. The app must declare networkConnectionManagerProvisioning capability to provision hotspot profile xml. The capability belongs to restrictedcapabilities namespace and needs to be manually added to the Package.appxmanifest file since Visaul Studio UI doesn't support it.
3. The provisioning XML built into this application must be modified to match the hotspot's SSID.

The steps for completing these requirements and running the sample are described below:

1. Modify the Provisioning Metadata XML file to match your hotspot by opening ProvisioningData.xml and adjusting the following fields:

* CarrierProvisioning\Global\CarrierID: If writing a mobile broadband operator app, use the same GUID that you specified as the Service Number in the metadata authoring wizard.
If writing a hotspot-only app, generate a new GUID with Visual Studio. On the Tools menu, click Create GUID. Click Copy to transfer the new GUID to the Clipboard.

* CarrierProvisioning\Global\SubscriberID: If writing a mobile broadband operator app, use the International Mobile Subscriber Identity (IMSI) of the mobile broadband SIM.
If writing a hotspot-only app, use any unique identifier appropriate to your service, such as a username or account number.

* CarrierProvisioning\WLANProfiles\WLANProfile\name: Name of your service or test Access Point (AP).

* CarrierProvisioning\WLANProfiles\WLANProfile\SSIDConfig\SSID\name: Configured SSID of your test hotspot.

* CarrierProvisioning\WLANProfiles\WLANProfile\MSM\security\HotspotProfile\ExtAuth\ExtensionId:
Package family name of the application. To retrieve this name, open package.appmanifest in Visual Studio. Click on the Packaging tab. Copy the Package Family Name.

2. Provide appropriate credentials for your test AP

* If the test AP uses fixed credentials: Modify HotspotAuthenticationTask\ConfigStore.cs to return a valid username and password for your test AP.
* If the test AP uses dynamic credentials: In HotspotAuthenticationTask\BackgroundTask.cs, replace the reference to ConfigStore with your own business logic to generate/retrieve appropriate credentials for the network.

The next steps depend on whether you just want to deploy the sample or you want to both deploy and run it.

**Deploying the sample**
1. Select **Build** \> **Deploy Solution**.

**Deploying and running the sample**
1. To debug the sample and then run it, press F5 or select **Debug** \> **Start Debugging**. To run the sample without debugging, press Ctrl+F5 or select **Debug** \> **Start Without Debugging**.


57 changes: 57 additions & 0 deletions Samples/HotspotAuthentication/cs/HotspotAuthentication.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2027
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotspotAuthenticationApp", "HotspotAuthenticationApp.csproj", "{8F134D66-D37D-5D95-8312-F9730FB97B1B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotspotAuthenticationTask", "HotspotAuthenticationTask\HotspotAuthenticationTask.csproj", "{39343226-E6E6-5D21-B5B0-F0BEA809ABF2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM = Debug|ARM
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|ARM = Release|ARM
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8F134D66-D37D-5D95-8312-F9730FB97B1B}.Debug|ARM.ActiveCfg = Debug|ARM
{8F134D66-D37D-5D95-8312-F9730FB97B1B}.Debug|ARM.Build.0 = Debug|ARM
{8F134D66-D37D-5D95-8312-F9730FB97B1B}.Debug|ARM.Deploy.0 = Debug|ARM
{8F134D66-D37D-5D95-8312-F9730FB97B1B}.Debug|x64.ActiveCfg = Debug|x64
{8F134D66-D37D-5D95-8312-F9730FB97B1B}.Debug|x64.Build.0 = Debug|x64
{8F134D66-D37D-5D95-8312-F9730FB97B1B}.Debug|x64.Deploy.0 = Debug|x64
{8F134D66-D37D-5D95-8312-F9730FB97B1B}.Debug|x86.ActiveCfg = Debug|x86
{8F134D66-D37D-5D95-8312-F9730FB97B1B}.Debug|x86.Build.0 = Debug|x86
{8F134D66-D37D-5D95-8312-F9730FB97B1B}.Debug|x86.Deploy.0 = Debug|x86
{8F134D66-D37D-5D95-8312-F9730FB97B1B}.Release|ARM.ActiveCfg = Release|ARM
{8F134D66-D37D-5D95-8312-F9730FB97B1B}.Release|ARM.Build.0 = Release|ARM
{8F134D66-D37D-5D95-8312-F9730FB97B1B}.Release|ARM.Deploy.0 = Release|ARM
{8F134D66-D37D-5D95-8312-F9730FB97B1B}.Release|x64.ActiveCfg = Release|x64
{8F134D66-D37D-5D95-8312-F9730FB97B1B}.Release|x64.Build.0 = Release|x64
{8F134D66-D37D-5D95-8312-F9730FB97B1B}.Release|x64.Deploy.0 = Release|x64
{8F134D66-D37D-5D95-8312-F9730FB97B1B}.Release|x86.ActiveCfg = Release|x86
{8F134D66-D37D-5D95-8312-F9730FB97B1B}.Release|x86.Build.0 = Release|x86
{8F134D66-D37D-5D95-8312-F9730FB97B1B}.Release|x86.Deploy.0 = Release|x86
{39343226-E6E6-5D21-B5B0-F0BEA809ABF2}.Debug|ARM.ActiveCfg = Debug|ARM
{39343226-E6E6-5D21-B5B0-F0BEA809ABF2}.Debug|ARM.Build.0 = Debug|ARM
{39343226-E6E6-5D21-B5B0-F0BEA809ABF2}.Debug|x64.ActiveCfg = Debug|x64
{39343226-E6E6-5D21-B5B0-F0BEA809ABF2}.Debug|x64.Build.0 = Debug|x64
{39343226-E6E6-5D21-B5B0-F0BEA809ABF2}.Debug|x86.ActiveCfg = Debug|x86
{39343226-E6E6-5D21-B5B0-F0BEA809ABF2}.Debug|x86.Build.0 = Debug|x86
{39343226-E6E6-5D21-B5B0-F0BEA809ABF2}.Release|ARM.ActiveCfg = Release|ARM
{39343226-E6E6-5D21-B5B0-F0BEA809ABF2}.Release|ARM.Build.0 = Release|ARM
{39343226-E6E6-5D21-B5B0-F0BEA809ABF2}.Release|x64.ActiveCfg = Release|x64
{39343226-E6E6-5D21-B5B0-F0BEA809ABF2}.Release|x64.Build.0 = Release|x64
{39343226-E6E6-5D21-B5B0-F0BEA809ABF2}.Release|x86.ActiveCfg = Release|x86
{39343226-E6E6-5D21-B5B0-F0BEA809ABF2}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {82A66FCD-859A-40F5-A8CC-402F20E50B26}
EndGlobalSection
EndGlobal
198 changes: 198 additions & 0 deletions Samples/HotspotAuthentication/cs/HotspotAuthenticationApp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProjectGuid>{8F134D66-D37D-5D95-8312-F9730FB97B1B}</ProjectGuid>
<OutputType>AppContainerExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SDKTemplate</RootNamespace>
<AssemblyName>HotspotApp</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion>10.0.15063.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.15063.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>15</MinimumVisualStudioVersion>
<EnableDotNetNativeCompatibleProfile>true</EnableDotNetNativeCompatibleProfile>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<RuntimeIdentifiers>win10-arm;win10-arm-aot;win10-x86;win10-x86-aot;win10-x64;win10-x64-aot</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
<OutputPath>bin\ARM\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\..\SharedContent\cs\App.xaml.cs">
<Link>App.xaml.cs</Link>
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="..\..\..\SharedContent\cs\MainPage.xaml.cs">
<Link>MainPage.xaml.cs</Link>
<DependentUpon>MainPage.xaml</DependentUpon>
</Compile>
<Compile Include="..\..\..\SharedContent\cs\AssemblyInfo.cs">
<Link>Properties\AssemblyInfo.cs</Link>
</Compile>
<Compile Include="SampleConfiguration.cs" />
<Compile Include="Scenario1_Initialization.xaml.cs">
<DependentUpon>Scenario1_Initialization.xaml</DependentUpon>
</Compile>
<Compile Include="Scenario2_BackgroundTask.xaml.cs">
<DependentUpon>Scenario2_BackgroundTask.xaml</DependentUpon>
</Compile>
<Compile Include="Scenario3_ForegroundApp.xaml.cs">
<DependentUpon>Scenario3_ForegroundApp.xaml</DependentUpon>
</Compile>
<Compile Include="ScenarioCommon.cs" />
</ItemGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="..\..\..\SharedContent\xaml\App.xaml">
<Link>App.xaml</Link>
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="..\..\..\SharedContent\cs\MainPage.xaml">
<Link>MainPage.xaml</Link>
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Scenario1_Initialization.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Scenario2_BackgroundTask.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Scenario3_ForegroundApp.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="..\..\..\SharedContent\xaml\Styles.xaml">
<Link>Styles\Styles.xaml</Link>
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<Content Include="..\..\..\SharedContent\cs\Default.rd.xml">
<Link>Properties\Default.rd.xml</Link>
</Content>
<Content Include="..\..\..\SharedContent\media\microsoft-sdk.png">
<Link>Assets\microsoft-sdk.png</Link>
</Content>
<Content Include="..\..\..\SharedContent\media\smalltile-sdk.png">
<Link>Assets\smallTile-sdk.png</Link>
</Content>
<Content Include="..\..\..\SharedContent\media\splash-sdk.png">
<Link>Assets\splash-sdk.png</Link>
</Content>
<Content Include="..\..\..\SharedContent\media\squaretile-sdk.png">
<Link>Assets\squareTile-sdk.png</Link>
</Content>
<Content Include="..\..\..\SharedContent\media\storelogo-sdk.png">
<Link>Assets\storeLogo-sdk.png</Link>
</Content>
<Content Include="..\..\..\SharedContent\media\tile-sdk.png">
<Link>Assets\tile-sdk.png</Link>
</Content>
<Content Include="..\..\..\SharedContent\media\windows-sdk.png">
<Link>Assets\windows-sdk.png</Link>
</Content>
<Content Include="ProvisioningData.xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>5.0.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="HotspotAuthenticationTask\HotspotAuthenticationTask.csproj">
<Project>{f0f4e04a-1851-45f4-9899-4986677874fa}</Project>
<Name>HotspotAuthenticationTask</Name>
</ProjectReference>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '15.0' ">
<VisualStudioVersion>15.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
Loading

0 comments on commit 0b646eb

Please sign in to comment.