-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathLtiUser.java
More file actions
69 lines (57 loc) · 1.74 KB
/
LtiUser.java
File metadata and controls
69 lines (57 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package org.imsglobal.lti.launch;
import javax.servlet.http.HttpServletRequest;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
/**
* Created by paul on 5/28/14.
*/
public class LtiUser {
private String id;
private List<String> roles;
public LtiUser(HttpServletRequest request) {
this.id = request.getParameter("user_id");
this.roles = new LinkedList<>();
if(request.getParameter("roles") != null) {
for (String role : request.getParameter("roles").split(",")) {
this.roles.add(role.trim());
}
}
}
public LtiUser(Map<String, String> parameters) {
this.id = parameters.get("user_id");
this.roles = new LinkedList<>();
if(parameters.get("roles") != null) {
for (String role : parameters.get("roles").split(",")) {
this.roles.add(role.trim());
}
}
}
public LtiUser(Collection<? extends Map.Entry> parameters) {
this.id = LtiOauthVerifier.getKey(parameters, "user_id");
this.roles = new LinkedList<>();
String parameterRoles = LtiOauthVerifier.getKey(parameters, "roles");
if(parameterRoles != null) {
for (String role : parameterRoles.split(",")) {
this.roles.add(role.trim());
}
}
}
public LtiUser(String id, List<String> roles) {
this.id = id;
this.roles = roles;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public List<String> getRoles() {
return roles;
}
public void setRoles(List<String> roles) {
this.roles = roles;
}
}