예제 #1
0
        private void OutputTokenInfo(JwtPayload payload)
        {
            lblLaunchIssuer.Text   = payload.Val("iss");
            lblLaunchAudience.Text = payload.Val("aud");
            lblSubjectId.Text      = payload.Val("sub");
            lblNonce.Text          = payload.Val("nonce");
            lblKeySetUrl.Text      = OutOfBandData.PlatformKeySetUrl;

            lblEmail.Text    = payload.Val("email");
            lblUserName.Text = payload.Val("name");

            var        contextJson = payload.Val("https://purl.imsglobal.org/spec/lti/claim/context");
            LtiContext ctx         = JsonConvert.DeserializeObject <LtiContext>(contextJson);

            lblContextCourse.Text = $"({ctx.type[0]} {ctx.id}) {ctx.label}";

            var             resourceLinkJson = payload.Val("https://purl.imsglobal.org/spec/lti/claim/resource_link");
            LtiResourceLink rl = JsonConvert.DeserializeObject <LtiResourceLink>(resourceLinkJson);

            lblLaunchLink.Text = $"({rl.id}) {rl.description}";

            string imsRolesJson = payload.Val("https://purl.imsglobal.org/spec/lti/claim/roles");

            string[] imsRoles = JsonConvert.DeserializeObject <string[]>(imsRolesJson);
            foreach (string imsRole in imsRoles)
            {
                blRoles.Items.Add(new ListItem(imsRole));
            }

            string custom     = payload.Val("https://purl.imsglobal.org/spec/lti/claim/custom");
            var    customDict = JsonConvert.DeserializeObject <Dictionary <string, string> >(custom);

            foreach (var item in customDict)
            {
                blCustom.Items.Add(new ListItem($"{item.Key} = {item.Value}", item.Value));
            }

            // endpoint scopes
            string endpointsJson = payload.Val("https://purl.imsglobal.org/spec/lti-ags/claim/endpoint");
            var    endpoints     = JsonConvert.DeserializeObject <LtiEndpoint>(endpointsJson);

            foreach (string scope in endpoints.scope)
            {
                blScope.Items.Add(scope);
            }

            // platform
            string platformJson = payload.Val("https://purl.imsglobal.org/spec/lti/claim/tool_platform");
            var    platform     = JsonConvert.DeserializeObject <LtiPlatform>(platformJson);

            lblPlatform.Text = $"{platform.name}, {platform.version}";

            // launch presentation
            string presentationJson = payload.Val("https://purl.imsglobal.org/spec/lti/claim/launch_presentation");
            var    presentation     = JsonConvert.DeserializeObject <LtiLaunchPresentation>(presentationJson);

            lblLaunchPresentation.Text = $"{presentation.document_target}, {presentation.width}x{presentation.height}, {presentation.return_url}";
        }
예제 #2
0
        // how to test for roles????

        protected override void _ExtractClaims()
        {
            var payload = _jwtToken.Payload;

            this.UserLoginId = payload.Val("email");

            var        contextJson = payload.Val("https://purl.imsglobal.org/spec/lti/claim/context");
            LtiContext ctx         = JsonConvert.DeserializeObject <LtiContext>(contextJson);

            this.CourseName = $"({ctx.type[0]} {ctx.id}) {ctx.label}";

            string imsRolesJson = payload.Val("https://purl.imsglobal.org/spec/lti/claim/roles");

            string[] imsRoles = JsonConvert.DeserializeObject <string[]>(imsRolesJson);

            this.IsAdmin            = LISRoleValidator.ContainsContextPrincipalRole(imsRoles, LISRoleName.Administrator);
            this.IsCourseAdmin      = LISRoleValidator.ContainsContextPrincipalRole(imsRoles, LISRoleName.ContentDeveloper);
            this.IsCourseInstructor = LISRoleValidator.ContainsContextPrincipalRole(imsRoles, LISRoleName.Instructor);
            this.IsGroupAdmin       = LISRoleValidator.ContainsContextPrincipalRole(imsRoles, LISRoleName.Mentor);

            //string custom = payload.Val("https://purl.imsglobal.org/spec/lti/claim/custom");
            //var customDict = JsonConvert.DeserializeObject<Dictionary<string, string>>(custom);
            //foreach (var item in customDict)
            //{
            //    blCustom.Items.Add(new ListItem($"{item.Key} = {item.Value}", item.Value));
            //}

            //// endpoint scopes
            //string endpointsJson = payload.Val("https://purl.imsglobal.org/spec/lti-ags/claim/endpoint");
            //var endpoints = JsonConvert.DeserializeObject<LtiEndpoint>(endpointsJson);
            //foreach (string scope in endpoints.scope)
            //{
            //    blScope.Items.Add(scope);
            //}

            //// platform
            //string platformJson = payload.Val("https://purl.imsglobal.org/spec/lti/claim/tool_platform");
            //var platform = JsonConvert.DeserializeObject<LtiPlatform>(platformJson);
            //lblPlatform.Text = $"{platform.name}, {platform.version}";

            // launch presentation
            string presentationJson = payload.Val("https://purl.imsglobal.org/spec/lti/claim/launch_presentation");
            var    presentation     = JsonConvert.DeserializeObject <LtiLaunchPresentation>(presentationJson);

            this.LaunchPresentationURL = $"{presentation.document_target}, {presentation.width}x{presentation.height}, {presentation.return_url}";
        }