-
Notifications
You must be signed in to change notification settings - Fork 159
Expand file tree
/
Copy pathOauth2CredentialsConverter.java
More file actions
104 lines (99 loc) · 3.35 KB
/
Oauth2CredentialsConverter.java
File metadata and controls
104 lines (99 loc) · 3.35 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package io.vertx.ext.auth.oauth2;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
/**
* Converter and mapper for {@link io.vertx.ext.auth.oauth2.Oauth2Credentials}.
* NOTE: This class has been automatically generated from the {@link io.vertx.ext.auth.oauth2.Oauth2Credentials} original class using Vert.x codegen.
*/
public class Oauth2CredentialsConverter {
static void fromJson(Iterable<java.util.Map.Entry<String, Object>> json, Oauth2Credentials obj) {
for (java.util.Map.Entry<String, Object> member : json) {
switch (member.getKey()) {
case "code":
if (member.getValue() instanceof String) {
obj.setCode((String)member.getValue());
}
break;
case "redirectUri":
if (member.getValue() instanceof String) {
obj.setRedirectUri((String)member.getValue());
}
break;
case "codeVerifier":
if (member.getValue() instanceof String) {
obj.setCodeVerifier((String)member.getValue());
}
break;
case "scopes":
if (member.getValue() instanceof JsonArray) {
java.util.ArrayList<java.lang.String> list = new java.util.ArrayList<>();
((Iterable<Object>)member.getValue()).forEach( item -> {
if (item instanceof String)
list.add((String)item);
});
obj.setScopes(list);
}
break;
case "jwt":
if (member.getValue() instanceof JsonObject) {
obj.setJwt(((JsonObject)member.getValue()).copy());
}
break;
case "assertion":
if (member.getValue() instanceof String) {
obj.setAssertion((String)member.getValue());
}
break;
case "password":
if (member.getValue() instanceof String) {
obj.setPassword((String)member.getValue());
}
break;
case "username":
if (member.getValue() instanceof String) {
obj.setUsername((String)member.getValue());
}
break;
case "flow":
if (member.getValue() instanceof String) {
obj.setFlow(io.vertx.ext.auth.oauth2.OAuth2FlowType.valueOf((String)member.getValue()));
}
break;
}
}
}
static void toJson(Oauth2Credentials obj, JsonObject json) {
toJson(obj, json.getMap());
}
static void toJson(Oauth2Credentials obj, java.util.Map<String, Object> json) {
if (obj.getCode() != null) {
json.put("code", obj.getCode());
}
if (obj.getRedirectUri() != null) {
json.put("redirectUri", obj.getRedirectUri());
}
if (obj.getCodeVerifier() != null) {
json.put("codeVerifier", obj.getCodeVerifier());
}
if (obj.getScopes() != null) {
JsonArray array = new JsonArray();
obj.getScopes().forEach(item -> array.add(item));
json.put("scopes", array);
}
if (obj.getJwt() != null) {
json.put("jwt", obj.getJwt());
}
if (obj.getAssertion() != null) {
json.put("assertion", obj.getAssertion());
}
if (obj.getPassword() != null) {
json.put("password", obj.getPassword());
}
if (obj.getUsername() != null) {
json.put("username", obj.getUsername());
}
if (obj.getFlow() != null) {
json.put("flow", obj.getFlow().name());
}
}
}