working
This commit is contained in:
parent
9671929787
commit
3a861f03c3
@ -46,7 +46,7 @@ public class CourseController {
|
|||||||
String url, @RequestParam(name = "name", required = false, defaultValue = "")
|
String url, @RequestParam(name = "name", required = false, defaultValue = "")
|
||||||
String name, Model model) {
|
String name, Model model) {
|
||||||
|
|
||||||
courseRepository.save(new Course(null, name, url, key, secret));
|
courseRepository.save(new Course(null, name, url, key, secret, null));
|
||||||
return "start"; //view
|
return "start"; //view
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,12 +38,6 @@ public class StartController {
|
|||||||
for (Course course : courses) {
|
for (Course course : courses) {
|
||||||
LtiSigner signer = new LtiOauthSigner();
|
LtiSigner signer = new LtiOauthSigner();
|
||||||
Map<String, String> parameters = new HashMap<>();
|
Map<String, String> parameters = new HashMap<>();
|
||||||
if (course.getUrl().contains("?")) {
|
|
||||||
for (String element : course.getUrl().split("\\?")[1].split("\\&")) {
|
|
||||||
String[] splitted = element.split("=");
|
|
||||||
parameters.put(splitted[0], splitted[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
parameters.put("lti_message_type", "basic-lti-launch-request");
|
parameters.put("lti_message_type", "basic-lti-launch-request");
|
||||||
parameters.put("lti_version", "LTI-1p0");
|
parameters.put("lti_version", "LTI-1p0");
|
||||||
parameters.put("resource_link_id", user.getUsername() + "_" + course.getCourse_key());
|
parameters.put("resource_link_id", user.getUsername() + "_" + course.getCourse_key());
|
||||||
@ -53,14 +47,11 @@ public class StartController {
|
|||||||
parameters.put("target", "frame");
|
parameters.put("target", "frame");
|
||||||
try {
|
try {
|
||||||
Map<String, String> signedParameters = signer.signParameters(parameters, course.getCourse_key(), course.getSecret(), course.getUrl(), "POST");
|
Map<String, String> signedParameters = signer.signParameters(parameters, course.getCourse_key(), course.getSecret(), course.getUrl(), "POST");
|
||||||
String link = course.getUrl();
|
/* String link = course.getUrl();
|
||||||
if (link.contains("?"))
|
link += "?oauth_nonce=" + signedParameters.get("oauth_nonce") + "&oauth_signature=" + signedParameters.get("oauth_signature") + "&oauth_consumer_key=" + signedParameters.get("oauth_consumer_key") + "&oauth_signature_method=" + signedParameters.get("oauth_signature_method") + "&oauth_timestamp=" + signedParameters.get("oauth_timestamp") + "&oauth_version=" + signedParameters.get("oauth_version") + "<i_message_type=" + signedParameters.get("lti_message_type") + "<i_version=" + signedParameters.get("lti_version") + "&resource_link_id=" + signedParameters.get("resource_link_id") + "&user_id=" + signedParameters.get("user_id") + "&lis_person_name_given=" + signedParameters.get("lis_person_name_given") + "&tool_consumer_instance_name=" + signedParameters.get("tool_consumer_instance_name") + "&target=" + signedParameters.get("target");
|
||||||
link += "&" + "oauth_nonce=" + signedParameters.get("oauth_nonce") + "&oauth_signature=" + signedParameters.get("oauth_signature") + "&oauth_consumer_key=" + signedParameters.get("oauth_consumer_key") + "&oauth_signature_method=" + signedParameters.get("oauth_signature_method") + "&oauth_timestamp=" + signedParameters.get("oauth_timestamp") + "&oauth_version=" + signedParameters.get("oauth_version") + "<i_message_type=" + signedParameters.get("lti_message_type") + "<i_version=" + signedParameters.get("lti_version") + "&resource_link_id=" + signedParameters.get("resource_link_id") + "&user_id=" + signedParameters.get("user_id") + "&lis_person_name_given=" + signedParameters.get("lis_person_name_given") + "&tool_consumer_instance_name=" + signedParameters.get("tool_consumer_instance_name") + "&target=" + signedParameters.get("target");
|
*/
|
||||||
else
|
|
||||||
link += "?" + "oauth_nonce=" + signedParameters.get("oauth_nonce") + "&oauth_signature=" + signedParameters.get("oauth_signature") + "&oauth_consumer_key=" + signedParameters.get("oauth_consumer_key") + "&oauth_signature_method=" + signedParameters.get("oauth_signature_method") + "&oauth_timestamp=" + signedParameters.get("oauth_timestamp") + "&oauth_version=" + signedParameters.get("oauth_version") + "<i_message_type=" + signedParameters.get("lti_message_type") + "<i_version=" + signedParameters.get("lti_version") + "&resource_link_id=" + signedParameters.get("resource_link_id") + "&user_id=" + signedParameters.get("user_id") + "&lis_person_name_given=" + signedParameters.get("lis_person_name_given") + "&tool_consumer_instance_name=" + signedParameters.get("tool_consumer_instance_name") + "&target=" + signedParameters.get("target");
|
|
||||||
course.setSecret(null);
|
course.setSecret(null);
|
||||||
course.setCourse_key(null);
|
course.setSignedParameters(signedParameters);
|
||||||
course.setUrl(link);
|
|
||||||
coursesToReturn.add(course);
|
coursesToReturn.add(course);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -5,10 +5,8 @@ import lombok.Getter;
|
|||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.*;
|
||||||
import javax.persistence.GeneratedValue;
|
import java.util.Map;
|
||||||
import javax.persistence.GenerationType;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@ -37,4 +35,9 @@ public class Course {
|
|||||||
@Setter
|
@Setter
|
||||||
private String secret;
|
private String secret;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Transient
|
||||||
|
private Map<String, String> signedParameters;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,12 +9,17 @@
|
|||||||
<link rel="stylesheet" th:href="@{/css/main.css}"/>
|
<link rel="stylesheet" th:href="@{/css/main.css}"/>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<tr th:each="course : ${courses}">
|
|
||||||
|
<tr th:each="course: ${courses}">
|
||||||
<form th:action="${course.url}" method="POST">
|
<form th:action="${course.url}" method="POST">
|
||||||
|
<th:block th:each="parameter : ${course.signedParameters}">
|
||||||
|
<input type="hidden" th:name="${parameter.key}" th:value="${parameter.value}" />
|
||||||
|
</th:block>
|
||||||
<input type="submit">Launch Tool</input>
|
<input type="submit">Launch Tool</input>
|
||||||
</form>
|
</form>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
<br><br><br>
|
<br><br><br>
|
||||||
<form th:action="@{/courses/addCourse}" method="GET">
|
<form th:action="@{/courses/addCourse}" method="GET">
|
||||||
<div><input type="submit" value="Add new content"/></div>
|
<div><input type="submit" value="Add new content"/></div>
|
||||||
|
Loading…
Reference in New Issue
Block a user