public ActionResult Create(IdentityProvider model, IPCertInputModel cert) { if (cert != null && cert.Cert != null) { model.IssuerThumbprint = cert.Cert.Thumbprint; if (model.IssuerThumbprint != null) { ModelState["IssuerThumbprint"].Errors.Clear(); ModelState["IssuerThumbprint"].Value = new ValueProviderResult(model.IssuerThumbprint, model.IssuerThumbprint, ModelState["IssuerThumbprint"].Value.Culture); } } if (ModelState.IsValid) { try { this.identityProviderRepository.Add(model); TempData["Message"] = Resources.IPController.IdentityProviderCreated; return RedirectToAction("IP", new { id=model.ID }); } catch (ValidationException ex) { ModelState.AddModelError("", ex.Message); } catch { ModelState.AddModelError("", Resources.IPController.ErrorCreatingIdentityProvider); } } // if we're here, then we should clear name so the view thinks it's new model.ID = 0; return View("IP", model); }
public ActionResult Update(IdentityProvider model, IPCertInputModel cert, string action) { if (action == "delete") { this.identityProviderRepository.Delete(model.ID); TempData["Message"] = Resources.IPController.IdentityProvidersDeleted; return RedirectToAction("Index"); } if (cert != null && cert.Cert != null) { model.IssuerThumbprint = cert.Cert.Thumbprint; ModelState["IssuerThumbprint"].Errors.Clear(); } if (ModelState.IsValid) { try { this.identityProviderRepository.Update(model); TempData["Message"] = Resources.IPController.IdentityProviderUpdated; ; return RedirectToAction("IP", new { id = model.ID }); } catch (ValidationException ex) { ModelState.AddModelError("", ex.Message); } catch { ModelState.AddModelError("", Resources.IPController.ErrorUpdatingIdentityProvider); } } return View("IP", model); }
private ActionResult RedirectToOAuth2IdentityProvider(IdentityProvider ip, SignInRequestMessage request) { var ctx = new OAuth2Context { Wctx = request.Context, Realm = request.Realm, IdP = ip.ID }; SetOAuthContextCookie(ctx); var oauth2 = new OAuth2Client(GetProviderTypeFromOAuthProfileTypes(ip.ProviderType.Value), ip.ClientID, ip.ClientSecret); switch (ip.ProviderType) { case OAuth2ProviderTypes.Google: return new OAuth2ActionResult(oauth2, ProviderType.Google, null); case OAuth2ProviderTypes.Facebook: return new OAuth2ActionResult(oauth2, ProviderType.Facebook, null); case OAuth2ProviderTypes.Live: return new OAuth2ActionResult(oauth2, ProviderType.Live, null); case OAuth2ProviderTypes.LinkedIn: return new OAuth2ActionResult(oauth2, ProviderType.LinkedIn, null); } return View("Error"); }
public IEnumerable<Claim> ProcessClaims(ClaimsPrincipal incomingPrincipal, IdentityProvider identityProvider, RequestDetails details) { return incomingPrincipal.Claims; }
private ActionResult RedirectToWSFedIdentityProvider(IdentityProvider identityProvider, SignInRequestMessage request) { var message = new SignInRequestMessage(new Uri(identityProvider.WSFederationEndpoint), ConfigurationRepository.Global.IssuerUri); SetContextCookie(request.Context, request.Realm, identityProvider.WSFederationEndpoint); return new RedirectResult(message.WriteQueryString()); }