public static RelyingParty ToDomainModel(this RelyingPartyModel model) { var rp = new RelyingParty { Id = model.Id, Name = model.Name, Realm = new Uri(model.Realm), ExtraData1 = model.ExtraData1, ExtraData2 = model.ExtraData2, ExtraData3 = model.ExtraData3, }; if (!string.IsNullOrWhiteSpace(model.ReplyTo)) { rp.ReplyTo = new Uri(model.ReplyTo); } if (!string.IsNullOrWhiteSpace(model.EncryptingCertificate)) { rp.EncryptingCertificate = new X509Certificate2(Convert.FromBase64String(model.EncryptingCertificate)); } if (!string.IsNullOrWhiteSpace(model.SymmetricSigningKey)) { rp.SymmetricSigningKey = Convert.FromBase64String(model.SymmetricSigningKey); } return rp; }
public static RelyingParty ToDomainModel(this RelyingParties rpEntity) { var rp = new RelyingParty { Id = rpEntity.Id.ToString(), Name = rpEntity.Name, Realm = new Uri("http://" + rpEntity.Realm), ExtraData1 = rpEntity.ExtraData1, ExtraData2 = rpEntity.ExtraData2, ExtraData3 = rpEntity.ExtraData3 }; if (!string.IsNullOrWhiteSpace(rpEntity.ReplyTo)) { rp.ReplyTo = new Uri(rpEntity.ReplyTo); } if (!string.IsNullOrWhiteSpace(rpEntity.EncryptingCertificate)) { rp.EncryptingCertificate = new X509Certificate2(Convert.FromBase64String(rpEntity.EncryptingCertificate)); } if (!string.IsNullOrWhiteSpace(rpEntity.SymmetricSigningKey)) { rp.SymmetricSigningKey = Convert.FromBase64String(rpEntity.SymmetricSigningKey); } return rp; }
public static RelyingParty ToDomainModel(this RelyingPartyEntity entity) { var model = new RelyingParty { Id = entity.RowKey, Realm = new Uri("http://" + entity.RealmHost + entity.RealmPath), Name = entity.Description, ExtraData1 = entity.ExtraData1, ExtraData2 = entity.ExtraData2, ExtraData3 = entity.ExtraData3 }; if (entity.EncryptingCertificate != null) { model.EncryptingCertificate = new X509Certificate2(Convert.FromBase64String(entity.EncryptingCertificate)); } if (!string.IsNullOrWhiteSpace(entity.ReplyToAddress)) { model.ReplyTo = new Uri(entity.ReplyToAddress); } if (!string.IsNullOrWhiteSpace(entity.SymmetricSigningKey)) { model.SymmetricSigningKey = Convert.FromBase64String(entity.SymmetricSigningKey); } return model; }
public void Add(RelyingParty relyingParty) { using (var entities = DatabaseContext.Get()) { entities.RelyingParties.Add(relyingParty.ToEntity()); entities.SaveChanges(); } }
public void Add(RelyingParty relyingParty) { using (var entities = IdentityServerConfigurationContext.Get()) { entities.RelyingParties.Add(relyingParty.ToEntity()); entities.SaveChanges(); } }
public bool TryGet(string realm, out RelyingParty relyingParty) { relyingParty = (from rp in _rps where rp.Realm.AbsoluteUri.Equals(realm, StringComparison.OrdinalIgnoreCase) select rp) .FirstOrDefault(); return (relyingParty != null); }
public void Update(RelyingParty relyingParty) { var rpEntity = relyingParty.ToEntity(); using (var entities = IdentityServerConfigurationContext.Get()) { entities.RelyingParties.Attach(rpEntity); entities.Entry(rpEntity).State = EntityState.Modified; entities.SaveChanges(); } }
public HrdViewModel(System.IdentityModel.Services.SignInRequestMessage message, IEnumerable<Models.IdentityProvider> idps, RelyingParty rp) { this.OriginalSigninUrl = message.WriteQueryString(); this.Providers = idps.Select(x => new HRDIdentityProvider { DisplayName = x.DisplayName, ID = x.Name, IconUrl = x.IconUrl, UseIconAsButton = x.UseIconAsButton }).ToArray(); Party = new RelyingPartyInfo { Name = rp.Name, Description = rp.Description, ImageUrl = rp.ImageUrl }; RelyingPartyDescription = rp.ExtraData1; }
public IHttpActionResult Post(RelyingParty relyingParty) { // if (ModelState.IsValid) // will always fail because it says Id is required...even though it is not. // { _relyingPartyRepository.Add(relyingParty); return Ok(); // } //else // { // return BadRequest(ModelState); // } }
public bool TryGet(string realm, out RelyingParty relyingParty) { relyingParty = new RelyingParty { Enabled = true, Realm = new Uri(realm), Name = "Oceanic Airline", SymmetricSigningKey = Convert.FromBase64String("L6aMge6UHG5IJ+Ah10Nhw9wsmkWC9ZBUEHT2lciAwSw=") }; return true; }
public bool TryGet(string realm, out RelyingParty relyingParty) { relyingParty = null; relyingParty = _apiClient.Get<RelyingParty>("api/relyingparty/realm/" + HttpUtility.UrlEncode(realm) + "/"); if(relyingParty == null) { return false; } else { return true; } }
private ClaimsIdentity ValidateJwtToken(JwtSecurityToken jwt, RelyingParty rp) { var handler = new JwtSecurityTokenHandler(); var validationParameters = new TokenValidationParameters() { //AudienceUriMode = AudienceUriMode.Never, SigningToken = new BinarySecretSecurityToken(rp.SymmetricSigningKey), ValidIssuer = ConfigurationRepository.Global.IssuerUri, AllowedAudience = jwt.Audience }; var principal = handler.ValidateToken(jwt, validationParameters); return principal.Identities.First(); }
public bool TryGet(string realm, out RelyingParty relyingParty) { relyingParty = null; using (var entities = IdentityServerConfigurationContext.Get()) { var match = (from rp in entities.RelyingParties where rp.Realm.StartsWith(realm) orderby rp.Realm descending select rp) .FirstOrDefault(); if (match != null) { relyingParty = match.ToDomainModel(); return true; } } return false; }
public bool TryGet(string realm, out RelyingParty relyingParty) { relyingParty = null; using (var entities = IdentityServerConfigurationContext.Get()) { var match = (from rp in entities.RelyingParties where rp.Realm.Equals(realm, StringComparison.OrdinalIgnoreCase) && rp.Enabled == true orderby rp.Realm descending select rp) .FirstOrDefault(); if (match != null) { relyingParty = match.ToDomainModel(); return true; } } return false; }
public bool TryGet(string realm, out RelyingParty relyingParty) { relyingParty = null; var rps = GetRelyingPartiesForServer(realm); var strippedRealm = realm.ToLowerInvariant().StripProtocolMoniker(); var bestMatch = (from rp in rps let strippedConfig = rp.Realm.AbsoluteUri.ToLowerInvariant().StripProtocolMoniker() where strippedRealm.Contains(strippedConfig) orderby rp.Realm.AbsoluteUri.Length descending select rp) .FirstOrDefault(); if (bestMatch != null) { relyingParty = bestMatch; return true; } return false; }
public bool TryGet(string realm, out RelyingParty relyingParty) { relyingParty = null; using (var entities = IdentityServerConfigurationContext.Get()) { var strippedRealm = realm.StripProtocolMoniker(); var bestMatch = (from rp in entities.RelyingParties where strippedRealm.Contains(rp.Realm) orderby rp.Realm descending select rp) .FirstOrDefault(); if (bestMatch != null) { relyingParty = bestMatch.ToDomainModel(); return true; } } return false; }
public void Add(RelyingParty relyingParty) { NewContext.AddRelyingParty(relyingParty.ToEntity()); }
public ActionResult RP(string id) { RelyingParty rp = null; if (id == null) rp = new RelyingParty(); else rp = this.RelyingPartyRepository.Get(id); if (rp == null) return HttpNotFound(); return View("RP", rp); }
private ActionResult SaveRP(string id, RelyingParty rp, RPCertInputModel cert) { if (cert.RemoveCert == true) { rp.EncryptingCertificate = null; } else if (cert.Cert != null) { rp.EncryptingCertificate = cert.Cert; } else { var origRP = this.RelyingPartyRepository.Get(id); rp.EncryptingCertificate = origRP.EncryptingCertificate; } if (ModelState.IsValid) { try { this.RelyingPartyRepository.Update(rp); TempData["Message"] = Resources.RPController.UpdateSuccessful; return RedirectToAction("RP", new { id }); } catch (ValidationException ex) { ModelState.AddModelError("", ex.Message); } catch { ModelState.AddModelError("", Resources.RPController.ErrorUpdatingRelyingParty); } } return View("RP", rp); }
private ActionResult CreateRP(RelyingParty rp, RPCertInputModel cert) { // ID is not required for create ModelState["ID"].Errors.Clear(); rp.Id = null; rp.EncryptingCertificate = cert.Cert; if (ModelState.IsValid) { try { this.RelyingPartyRepository.Add(rp); TempData["Message"] = Resources.RPController.CreateSuccessful; return RedirectToAction("Index"); } catch (ValidationException ex) { ModelState.AddModelError("", ex.Message); } catch { ModelState.AddModelError("", Resources.RPController.ErrorCreatingRelyingParty); } } return View("RP", rp); }
public void Update(RelyingParty relyingParty) { throw new NotImplementedException(); }
public IHttpActionResult Put(RelyingParty relyingParty) { if(ModelState.IsValid) { _relyingPartyRepository.Update(relyingParty); return Ok(); } else { return BadRequest(ModelState); } }
public void Update(RelyingParty relyingParty) { _apiClient.Put<RelyingParty>("api/relyingparty", relyingParty); }
public void Update(RelyingParty relyingParty) { NewContext.UpdateRelyingParty(relyingParty.ToEntity(relyingParty.Id)); }
public void Add(RelyingParty relyingParty) { _apiClient.Post<RelyingParty>("api/relyingparty", relyingParty); }
public static RelyingParty ToDomainModel(this RelyingParties rpEntity) { var rp = new RelyingParty { Id = rpEntity.Id.ToString(CultureInfo.InvariantCulture), Name = rpEntity.Name, Enabled = rpEntity.Enabled, TokenType = rpEntity.TokenType, TokenLifeTime = rpEntity.TokenLifeTime, Realm = new Uri(rpEntity.Realm), ExtraData1 = rpEntity.ExtraData1, ExtraData2 = rpEntity.ExtraData2, ExtraData3 = rpEntity.ExtraData3, Description = rpEntity.Description, ImageUrl = rpEntity.ImageUrl }; if (!string.IsNullOrWhiteSpace(rpEntity.ReplyTo)) { rp.ReplyTo = new Uri(rpEntity.ReplyTo); } if (!string.IsNullOrWhiteSpace(rpEntity.EncryptingCertificate)) { rp.EncryptingCertificate = new X509Certificate2(Convert.FromBase64String(rpEntity.EncryptingCertificate)); } if (!string.IsNullOrWhiteSpace(rpEntity.SymmetricSigningKey)) { rp.SymmetricSigningKey = Convert.FromBase64String(rpEntity.SymmetricSigningKey); } return rp; }