Exemple #1
0
        public static RelyingParty ToDomainModel(this RelyingParties rpEntity)
        {
            var rp = new RelyingParty
            {
                Id            = rpEntity.Id.ToString(),
                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
            };

            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 void Delete(string id)
 {
     using (var entities = IdentityServerConfigurationContext.Get())
     {
         var rpEntity = new RelyingParties {
             Id = int.Parse(id)
         };
         entities.RelyingParties.Attach(rpEntity);
         entities.Entry(rpEntity).State = EntityState.Deleted;
         entities.SaveChanges();
     }
 }
Exemple #3
0
        public static RelyingParties ToEntity(this RelyingParty relyingParty)
        {
            var rpEntity = new RelyingParties
            {
                Name          = relyingParty.Name,
                Enabled       = relyingParty.Enabled,
                Realm         = relyingParty.Realm.AbsoluteUri,
                TokenType     = relyingParty.TokenType,
                TokenLifeTime = relyingParty.TokenLifeTime,
                ExtraData1    = relyingParty.ExtraData1,
                ExtraData2    = relyingParty.ExtraData2,
                ExtraData3    = relyingParty.ExtraData3
            };

            if (!string.IsNullOrEmpty(relyingParty.Id))
            {
                rpEntity.Id = int.Parse(relyingParty.Id);
            }

            if (relyingParty.ReplyTo != null)
            {
                rpEntity.ReplyTo = relyingParty.ReplyTo.AbsoluteUri;
            }

            if (relyingParty.EncryptingCertificate != null)
            {
                rpEntity.EncryptingCertificate = Convert.ToBase64String(relyingParty.EncryptingCertificate.RawData);
            }

            if (relyingParty.SymmetricSigningKey != null && relyingParty.SymmetricSigningKey.Length != 0)
            {
                rpEntity.SymmetricSigningKey = Convert.ToBase64String(relyingParty.SymmetricSigningKey);
            }

            return(rpEntity);
        }
Exemple #4
0
        public static RelyingParties ToEntity(this RelyingParty relyingParty)
        {
            var rpEntity = new RelyingParties
            {
                Name = relyingParty.Name,
                Enabled = relyingParty.Enabled,
                Realm = relyingParty.Realm.AbsoluteUri,
                TokenType = relyingParty.TokenType,
                TokenLifeTime = relyingParty.TokenLifeTime,
                ExtraData1 = relyingParty.ExtraData1,
                ExtraData2 = relyingParty.ExtraData2,
                ExtraData3 = relyingParty.ExtraData3
            };

            if (!string.IsNullOrEmpty(relyingParty.Id))
            {
                rpEntity.Id = int.Parse(relyingParty.Id);
            }

            if (relyingParty.ReplyTo != null)
            {
                rpEntity.ReplyTo = relyingParty.ReplyTo.AbsoluteUri;
            }

            if (relyingParty.EncryptingCertificate != null)
            {
                rpEntity.EncryptingCertificate = Convert.ToBase64String(relyingParty.EncryptingCertificate.RawData);
            }

            if (relyingParty.SymmetricSigningKey != null && relyingParty.SymmetricSigningKey.Length != 0)
            {
                rpEntity.SymmetricSigningKey = Convert.ToBase64String(relyingParty.SymmetricSigningKey);
            }

            return rpEntity;
        }