Beispiel #1
0
        public static ClientInputModel ToInputModel(this ClientModel model)
        {
            var inputModel = new ClientInputModel();

            if (model != null)
            {
                inputModel = new ClientInputModel()
                {
                    Id                    = model.Id,
                    ClientId              = model.ClientId,
                    ClientName            = model.ClientName,
                    ClientSecret          = model.DecryptedSecret,
                    Description           = model.Description,
                    AllowedGrantTypes     = model.AllowedGrantTypes.ToList() ?? new List <string>(),
                    AllowedScopes         = model.AllowedScopes.ToList() ?? new List <string>(),
                    RedirectUrl           = model.RedirectUris?.FirstOrDefault(),
                    PostLogoutRedirectUrl = model.PostLogoutRedirectUris?.FirstOrDefault()
                };
            }

            return(inputModel);
        }
        public static ClientData ToData(this ClientInputModel inputModel, IdentityServerCryptography cryptography)
        {
            var data = new ClientData();

            if (inputModel != null)
            {
                data = new ClientData()
                {
                    Id                    = inputModel.Id,
                    ClientId              = inputModel.ClientId,
                    ClientSecret          = cryptography.Encrypt(inputModel.ClientSecret),
                    AllowedGrantTypes     = inputModel.AllowedGrantTypes,
                    AllowedScopes         = inputModel.AllowedScopes,
                    RedirectUrl           = inputModel.RedirectUrl,
                    PostLogoutRedirectUrl = inputModel.PostLogoutRedirectUrl,
                    ClientName            = inputModel.ClientName,
                    Description           = inputModel.Description
                };
            }

            return(data);
        }