/
GwtCredential.java
196 lines (157 loc) · 5.64 KB
/
GwtCredential.java
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/*******************************************************************************
* Copyright (c) 2017, 2021 Eurotech and/or its affiliates and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Eurotech - initial API and implementation
*******************************************************************************/
package org.eclipse.kapua.app.console.module.authentication.shared.model;
import java.util.Date;
import org.eclipse.kapua.app.console.module.api.client.util.DateUtils;
import org.eclipse.kapua.app.console.module.api.shared.model.GwtUpdatableEntityModel;
public class GwtCredential extends GwtUpdatableEntityModel {
private static final long serialVersionUID = -469650746033310482L;
@Override
@SuppressWarnings({ "unchecked" })
public <X> X get(String property) {
if ("credentialTypeEnum".equals(property)) {
return (X) GwtCredentialType.valueOf(getCredentialType());
} else if ("statusEnum".equals(property)) {
return (X) GwtCredentialStatus.valueOf(getStatus());
} else if ("subjectTypeEnum".equals(property)) {
return (X) GwtSubjectType.valueOf(getSubjectType());
} else if ("credentialStatusEnum".equals(property)) {
return (X) GwtCredentialStatus.valueOf(getCredentialStatus());
} else if ("expirationDateFormatted".equals(property)) {
if (getExpirationDate() != null) {
return (X) ((DateUtils.formatDateTime(getExpirationDate())));
} else {
return (X) null;
}
} else if ("firstLoginFailureFormatted".equals(property)) {
if (getFirstLoginFailure() != null) {
return (X) (getFirstLoginFailure().toString());
} else {
return (X) "N/A";
}
} else if ("loginFailuresResetFormatted".equals(property)) {
if (getLoginFailuresReset() != null) {
return (X) (getLoginFailuresReset().toString());
} else {
return (X) "N/A";
}
} else if ("lockoutResetFormatted".equals(property)) {
if (getLockoutReset() != null) {
return (X) (getLockoutReset().toString());
} else {
return (X) "N/A";
}
} else {
return super.get(property);
}
}
public String getStatus() {
return (String) get("status");
}
public GwtCredential() {
super();
}
public String getUserId() {
return get("userId");
}
public void setUserId(String userId) {
set("userId", userId);
}
public String getCredentialType() {
return get("credentialType");
}
public GwtCredentialType getCredentialTypeEnum() {
return get("credentialTypeEnum");
}
public void setCredentialType(String credentialType) {
set("credentialType", credentialType);
}
public String getSubjectType() {
return get("subjectType");
}
public GwtSubjectType getSubjectTypeEnum() {
return get("subjectTypeEnum");
}
public void setSubjectType(String subjectType) {
set("subjectType", subjectType);
}
public String getCredentialKey() {
return get("credentialKey");
}
public void setCredentialKey(String credentialKey) {
set("credentialKey", credentialKey);
}
public String getUsername() {
return get("username");
}
public void setUsername(String username) {
set("username", username);
}
public String getCredentialStatus() {
return (String) get("credentialStatus");
}
public GwtCredentialStatus getCredentialStatusEnum() {
return (GwtCredentialStatus) get("credentialStatusEnum");
}
public void setCredentialStatus(String credentialStatus) {
set("credentialStatus", credentialStatus);
}
public Date getExpirationDate() {
return get("expirationDate");
}
public String getExpirationDateFormatted() {
return get("expirationDateFormatted");
}
public void setExpirationDate(Date expirationDate) {
set("expirationDate", expirationDate);
}
public String getFirstLoginFailureFormatted() {
return get("firstLoginFailureFormatted");
}
public Integer getLoginFailures() {
return get("loginFailures");
}
public void setLoginFailures(Integer loginFailures) {
set("loginFailures", loginFailures);
}
public Date getFirstLoginFailure() {
return get("firstLoginFailure");
}
public void setFirstLoginFailure(Date firstLoginFailure) {
set("firstLoginFailure", firstLoginFailure);
}
public String getLoginFailuresResetFormatted() {
return get("loginFailuresResetFormatted");
}
public Date getLoginFailuresReset() {
return get("loginFailuresReset");
}
public void setLoginFailuresReset(Date loginFailuresReset) {
set("loginFailuresReset", loginFailuresReset);
}
public String getLockoutResetFormatted() {
return get("lockoutResetFormatted");
}
public Date getLockoutReset() {
return get("lockoutReset");
}
public void setLockoutReset(Date lockoutReset) {
set("lockoutReset", lockoutReset);
}
public GwtMfaCredentialOptions getMfaOptions() {
return get("mfaOptions");
}
public void setMfaOptions(GwtMfaCredentialOptions mfaOptions) {
set("mfaOptions", mfaOptions);
}
}