Exemplo n.º 1
0
        /// <summary>
        /// Initialize entities for scenario
        /// </summary>
        public override void InitializeEntities()
        {
            //Inizializzazione base
            base.InitializeEntities();

            //Aggiungo l'amministrator
            Users.Add(new User
            {
                Id             = Guid.NewGuid().ToString("D"),
                UserName       = "******",
                Email          = "*****@*****.**",
                IsEnabled      = true,
                IsLocked       = false,
                PersonName     = "Mario",
                PersonSurname  = "Rossi",
                PasswordHash   = ShaProcessor.Sha256Encrypt("password"),
                LastAccessDate = DateTime.UtcNow.AddDays(-1),
                PhotoBinary    = new byte[] { }
            });

            //Creo l'audience corrente (Nativa)
            Audiences.Add(new Audience
            {
                Id                      = Guid.NewGuid().ToString("D"),
                Name                    = "Sample Resource",
                ClientId                = "sample.resource",
                ClientSecret            = "_IqrVEUhwO19o9nQ-9DtOfzYAL5THZrGcWgCO1-Xa0k",
                HasAdministrativeAccess = false,
                IsEnabled               = true,
                IsNative                = true,
                AllowedOrigin           = "*",
                RefreshTokenLifeTime    = 30
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initialize entities for scenario
        /// </summary>
        public override void InitializeEntities()
        {
            //Aggiungo l'amministrator
            Users.Add(new User
            {
                Id             = Guid.NewGuid().ToString("D"),
                UserName       = "******",
                Email          = "*****@*****.**",
                IsEnabled      = true,
                IsLocked       = false,
                PersonName     = "Digital",
                PersonSurname  = "ZenProgramming",
                PasswordHash   = ShaProcessor.Sha256Encrypt("password"),
                LastAccessDate = DateTime.UtcNow.AddDays(-1),
                PhotoBinary    = new byte[] {}
            });

            //Creo l'audience corrente (Nativa)
            Audiences.Add(new Audience
            {
                Id                      = Guid.NewGuid().ToString("D"),
                Name                    = "Heimdallr Api",
                ClientId                = "heimdallr.api",
                ClientSecret            = "IxrAjDoa2FqElO7IhrSrUJELhUckePEPVpaePlS_Xaw",
                HasAdministrativeAccess = true,
                IsEnabled               = true,
                IsNative                = true,
                AllowedOrigin           = "*",
                RefreshTokenLifeTime    = 30
            });
        }
Exemplo n.º 3
0
        public AddLecturesViewModel()
        {
            foreach (var uniqueGroup in _lecturesStorageModel.UniqueGroups)
            {
                Audiences.Add(uniqueGroup);
            }

            foreach (var uniqueTeacher in _lecturesStorageModel.UniqueTeachers)
            {
                Lecturers.Add(uniqueTeacher);
            }

            foreach (var combinedLecture in _lecturesStorageModel.CombinedLectures)
            {
                Lectures.Add(combinedLecture);
            }
            _lectures = new List <Lecture>(_lecturesStorageModel.Lectures);

            if (_lecturesStorageModel.CombinedLectures != null && _lecturesStorageModel.CombinedLectures.Count > 0)
            {
                FillCombinedLectures();
            }

            UpdateLists();
            UpdateLectures();
        }
Exemplo n.º 4
0
        private void AudienceTextBox_DropDownOpened(object sender, EventArgs e)
        {
            var ownerEditorWindowInstance = (this.Owner as LessonsWindow).Owner as EditorWindow;
            var data = ownerEditorWindowInstance.HomePage.AudiencesWindowInstance?.AudiencesList.Items;

            if (data != null)
            {
                foreach (var item in data)
                {
                    Audiences.Add(item as SchoolAudience);
                }
            }
        }
Exemplo n.º 5
0
        public IHttpActionResult RequestToken()
        {
            var     content      = Request.Content.ReadAsStringAsync().Result;
            dynamic json         = JsonConvert.DeserializeObject(content);
            long    pkSystemUser = json.PKSystemUser.Value;
            string  clientId     = json.ClientId.Value;
            string  publicKey    = json.PublicKey;

            if (!Audiences.Exists(clientId))
            {
                var key = Aparte.Security.Cryptography.SymmetricKey.GenerateSymmetricKey();
                try
                {
                    Audiences.Add(clientId, publicKey, key);
                }
                catch (Exception ex)
                {
                }
            }
            var encryptedToken = ProduceToken(pkSystemUser, clientId, new ApiContext());

            return(Ok <string>(encryptedToken));
        }
Exemplo n.º 6
0
        private static JWT GetBasicAuthorizationHeader(HttpRequestMessage request)
        {
            var content = request.Headers.Authorization.Parameter;

            if (content == null)
            {
                return(null);
            }

            var jwt            = JWT.ParseFromBase64Url(content);
            var jwtDestination = jwt.Audience;
            var jwtIssuer      = jwt.Issuer;

            if (jwtDestination != KeyFile.AUTHENTICATION_SERVER_NAME)
            {
                return(null);
            }

            if (jwtIssuer != KeyFile.JEDIX_WIN_CLIENT_NAME)
            {
                //using (var dbContext = new ApiDbContext())
                //{
                //    var issuer = dbContext.Clients.Where(a => a.Name == jwtIssuer).FirstOrDefault();
                //    if (issuer == null)
                //        return null;
                //}
            }
            var publicKey = jwt[JWTConstant.CLAIM_PUBLIC_KEY];

            if (!Audiences.Exists(jwtIssuer))
            {
                var key = Security.Cryptography.SymmetricKey.GenerateSymmetricKey();
                Audiences.Add(jwtIssuer, publicKey, key);
            }
            return(jwt);
        }