Created
November 4, 2012 19:54
-
-
Save andyfmiller/4013359 to your computer and use it in GitHub Desktop.
BuildLtiRequestViewBag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void BuildLtiRequestViewBag(Assignment assignment) | |
{ | |
// Start with the basic and required parameters | |
var parameters = BuildBaseLtiRequestData(assignment); | |
// Add recommended and optional parameters | |
AddOptionalParameters(assignment, parameters); | |
// Add version specific parameters | |
if (assignment.LtiVersionId == LtiVersion.Version10) | |
AddLti10Parameters(assignment, parameters); | |
if (assignment.LtiVersionId == LtiVersion.Version11) | |
AddLti11Parameters(assignment, parameters); | |
// Finally, calculate the OAuth signature and send the data over to the view | |
// for rendering in the client browser. See Views/Assignment/Launch | |
var uri = new Uri(assignment.Url); | |
var signatureBase = SignatureBase.Create("POST", uri, parameters); | |
var signatureProvider = new HmacSha1SigningProvider(); | |
ViewBag.Signature = signatureProvider.ComputeSignature(signatureBase, assignment.Secret, | |
string.Empty); | |
ViewBag.Action = uri.ToString(); | |
ViewBag.NameValues = HttpUtility.ParseQueryString(parameters.ToQueryStringFormat()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment