This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ActionResult OpenId() | |
{ | |
var response = openId.GetResponse(); | |
if (response == null) | |
{ | |
return RedirectToAction("Index"); | |
} | |
switch (response.Status) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ Page Language="C#" AutoEventWireup="true" ContentType="application/xrds+xml" %> | |
<%@ OutputCache Duration="86400" VaryByParam="none" Location="Any" %><?xml version="1.0" encoding="UTF-8"?> | |
<%-- | |
This XRDS view is used for both the OP identifier and the user identity pages. | |
Only a couple of conditional checks are required to share the view, but sharing the view | |
makes it very easy to ensure that all the Type URIs that this server supports are included | |
for all XRDS discovery. | |
--%> | |
<xrds:XRDS | |
xmlns:xrds="xri://$xrds" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal static OpenIdProvider OpenIdProvider = new OpenIdProvider(); | |
public ActionResult Id() | |
{ | |
if (Request.AcceptTypes != null && Request.AcceptTypes.Contains("application/xrds+xml")) | |
{ | |
ViewData["OPIdentifier"] = true; | |
} | |
return View(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ActionResult ProcessAuthRequest() | |
{ | |
if (ProviderEndpoint.PendingRequest == null) | |
{ | |
return RedirectToAction("About"); | |
} | |
// Try responding immediately if possible. | |
ActionResult response = AutoRespondIfPossibleAsync(); | |
if (response != null) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DocumentationController : Controller | |
{ | |
private const string DefaultDocPage = "Overview"; | |
public ActionResult Index(string id = null) | |
{ | |
ViewBag.HomeLinkPage = string.IsNullOrEmpty(id) || id == DefaultDocPage ? string.Empty : DefaultDocPage; | |
if (string.IsNullOrEmpty(ViewBag.HomeLinkPage)) | |
{ | |
id = DefaultDocPage; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (OSStatus)extractIdentity:(CFDataRef)inP12Data :(SecIdentityRef*)identity { | |
OSStatus securityError = errSecSuccess; | |
CFStringRef password = CFSTR("MyCertificatePassword"); | |
const void *keys[] = { kSecImportExportPassphrase }; | |
const void *values[] = { password }; | |
CFDictionaryRef options = CFDictionaryCreate(NULL, keys, values, 1, NULL, NULL); | |
CFArrayRef items = CFArrayCreate(NULL, 0, 0, NULL); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { | |
// gets a certificate from local resources | |
NSString *thePath = [[NSBundle mainBundle] pathForResource:@"MyCertificate" ofType:@"pfx"]; | |
NSData *PKCS12Data = [[NSData alloc] initWithContentsOfFile:thePath]; | |
CFDataRef inPKCS12Data = (CFDataRef)PKCS12Data; | |
SecIdentityRef identity; | |
// extract the ideneity from the certificate | |
[self extractIdentity :inPKCS12Data :&identity]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSURL *serverURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@", [options objectForKey:@"host"]]]; | |
NSMutableURLRequest *connectionRequest = [NSMutableURLRequest requestWithURL:serverURL | |
[connectionRequest setHTTPMethod:@"POST"]; | |
[connectionRequest setValue:@"text/xml" forHTTPHeaderField:@"Content-Type"]; | |
[connectionRequest setHTTPBody:[[options objectForKey:@"data"] dataUsingEncoding:NSUTF8StringEncoding]]; | |
NSURLConnection * aConnection = [[NSURLConnection alloc] initWithRequest:connectionRequest delegate:self]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private string username; | |
public string Username | |
{ | |
get | |
{ | |
return username; | |
} | |
set | |
{ | |
username = value; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public string GetUsername() | |
{ | |
var url = new Uri(API_URL_BASE); | |
var client = new HttpClient() { BaseAddress = url }; | |
var response = client.GetAsync(url).Result; | |
response.EnsureSuccessStatusCode(); | |
return response.Content.ReadAsStringAsync().Result; | |
} |