public static RelyingPartyModel ToDomainModel(this RelyingPartyEntity rpEntity) { var rp = new RelyingPartyModel { 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 RelyingPartyModel ToDomainModel(this RelyingPartyViewModel model) { var rp = new RelyingPartyModel { 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 void Add(RelyingPartyModel model) { using (var entities = IdentityServerConfigurationContext.Get()) { entities.RelyingParties.Add(model.ToEntity()); entities.SaveChanges(); } }
public bool TryGet(string realm, out RelyingPartyModel model) { model = null; var strippedRealm = realm.StripProtocolMoniker(); var bestMatch = (from rp in _session.Query<RelyingParty>() where strippedRealm.Contains(rp.Realm) orderby rp.Realm descending select rp) .FirstOrDefault(); if (bestMatch != null) { model = bestMatch.ToModel(); return true; } return false; }
public void Update(RelyingPartyModel updatedModel) { var doc = _session.Load<RelyingParty>(updatedModel.Id); updatedModel.MergeWithDocument(doc); }
public void Add(RelyingPartyModel model) { var doc = model.ToDocument(); _session.Store(doc); }
public bool TryGet(string realm, out RelyingPartyModel model) { model = 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) { model = bestMatch.ToDomainModel(); return true; } } return false; }
public void Update(RelyingPartyModel updatedModel) { var rpEntity = updatedModel.ToEntity(); using (var entities = IdentityServerConfigurationContext.Get()) { entities.RelyingParties.Attach(rpEntity); entities.Entry(rpEntity).State = EntityState.Modified; entities.SaveChanges(); } }