Skip to content

Commit

Permalink
Merge pull request #12 from Learnosity/LRN-10002
Browse files Browse the repository at this point in the history
[FEATURE] Add support for expire security parameter
  • Loading branch information
gonzalozawa authored Jun 22, 2016
2 parents fd2e1fc + 4671027 commit 900a1fa
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions LearnositySDK/Request/Init.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private void Initialize(string service, JsonObject securityPacket, string secret
this.action = action;

this.signRequestData = true;
this.validSecurityKeys = new string[4] { "consumer_key", "domain", "timestamp", "user_id" };
this.validSecurityKeys = new string[5] { "consumer_key", "domain", "timestamp", "expires", "user_id" };
this.validServices = new string[7] { "assess", "author", "data", "events", "items", "questions", "reports" };
this.algorithm = "sha256";

Expand Down Expand Up @@ -403,13 +403,23 @@ private void setServiceOptions()

JsonObject questionsApiActivity = new JsonObject();

string signature = this.hashValue( new string[] {
this.securityPacket.getString("consumer_key"),
domain,
this.securityPacket.getString("timestamp"),
this.securityPacket.getString("user_id"),
this.secret
} );
List<string> signatureList = new List<string>();

signatureList.Add(this.securityPacket.getString("consumer_key"));
signatureList.Add(domain);
signatureList.Add(this.securityPacket.getString("timestamp"));

if (Tools.array_key_exists("expires", this.securityPacket))
{
signatureList.Add(this.securityPacket.getString("expires"));
questionsApiActivity.set("expires", this.securityPacket.getString("expires"));
questionsApi.remove("expires");
}

signatureList.Add(this.securityPacket.getString("user_id"));
signatureList.Add(this.secret);

string signature = this.hashValue(signatureList.ToArray());

questionsApiActivity.set("consumer_key", this.securityPacket.getString("consumer_key"));
questionsApiActivity.set("timestamp", this.securityPacket.getString("timestamp"));
Expand Down

0 comments on commit 900a1fa

Please sign in to comment.