001
014
015 package com.liferay.portal.model.impl;
016
017 import com.liferay.portal.kernel.util.StringBundler;
018 import com.liferay.portal.kernel.util.StringPool;
019 import com.liferay.portal.model.CacheModel;
020 import com.liferay.portal.model.PasswordPolicy;
021
022 import java.io.Externalizable;
023 import java.io.IOException;
024 import java.io.ObjectInput;
025 import java.io.ObjectOutput;
026
027 import java.util.Date;
028
029
036 public class PasswordPolicyCacheModel implements CacheModel<PasswordPolicy>,
037 Externalizable {
038 @Override
039 public String toString() {
040 StringBundler sb = new StringBundler(69);
041
042 sb.append("{uuid=");
043 sb.append(uuid);
044 sb.append(", passwordPolicyId=");
045 sb.append(passwordPolicyId);
046 sb.append(", companyId=");
047 sb.append(companyId);
048 sb.append(", userId=");
049 sb.append(userId);
050 sb.append(", userName=");
051 sb.append(userName);
052 sb.append(", createDate=");
053 sb.append(createDate);
054 sb.append(", modifiedDate=");
055 sb.append(modifiedDate);
056 sb.append(", defaultPolicy=");
057 sb.append(defaultPolicy);
058 sb.append(", name=");
059 sb.append(name);
060 sb.append(", description=");
061 sb.append(description);
062 sb.append(", changeable=");
063 sb.append(changeable);
064 sb.append(", changeRequired=");
065 sb.append(changeRequired);
066 sb.append(", minAge=");
067 sb.append(minAge);
068 sb.append(", checkSyntax=");
069 sb.append(checkSyntax);
070 sb.append(", allowDictionaryWords=");
071 sb.append(allowDictionaryWords);
072 sb.append(", minAlphanumeric=");
073 sb.append(minAlphanumeric);
074 sb.append(", minLength=");
075 sb.append(minLength);
076 sb.append(", minLowerCase=");
077 sb.append(minLowerCase);
078 sb.append(", minNumbers=");
079 sb.append(minNumbers);
080 sb.append(", minSymbols=");
081 sb.append(minSymbols);
082 sb.append(", minUpperCase=");
083 sb.append(minUpperCase);
084 sb.append(", regex=");
085 sb.append(regex);
086 sb.append(", history=");
087 sb.append(history);
088 sb.append(", historyCount=");
089 sb.append(historyCount);
090 sb.append(", expireable=");
091 sb.append(expireable);
092 sb.append(", maxAge=");
093 sb.append(maxAge);
094 sb.append(", warningTime=");
095 sb.append(warningTime);
096 sb.append(", graceLimit=");
097 sb.append(graceLimit);
098 sb.append(", lockout=");
099 sb.append(lockout);
100 sb.append(", maxFailure=");
101 sb.append(maxFailure);
102 sb.append(", lockoutDuration=");
103 sb.append(lockoutDuration);
104 sb.append(", requireUnlock=");
105 sb.append(requireUnlock);
106 sb.append(", resetFailureCount=");
107 sb.append(resetFailureCount);
108 sb.append(", resetTicketMaxAge=");
109 sb.append(resetTicketMaxAge);
110 sb.append("}");
111
112 return sb.toString();
113 }
114
115 @Override
116 public PasswordPolicy toEntityModel() {
117 PasswordPolicyImpl passwordPolicyImpl = new PasswordPolicyImpl();
118
119 if (uuid == null) {
120 passwordPolicyImpl.setUuid(StringPool.BLANK);
121 }
122 else {
123 passwordPolicyImpl.setUuid(uuid);
124 }
125
126 passwordPolicyImpl.setPasswordPolicyId(passwordPolicyId);
127 passwordPolicyImpl.setCompanyId(companyId);
128 passwordPolicyImpl.setUserId(userId);
129
130 if (userName == null) {
131 passwordPolicyImpl.setUserName(StringPool.BLANK);
132 }
133 else {
134 passwordPolicyImpl.setUserName(userName);
135 }
136
137 if (createDate == Long.MIN_VALUE) {
138 passwordPolicyImpl.setCreateDate(null);
139 }
140 else {
141 passwordPolicyImpl.setCreateDate(new Date(createDate));
142 }
143
144 if (modifiedDate == Long.MIN_VALUE) {
145 passwordPolicyImpl.setModifiedDate(null);
146 }
147 else {
148 passwordPolicyImpl.setModifiedDate(new Date(modifiedDate));
149 }
150
151 passwordPolicyImpl.setDefaultPolicy(defaultPolicy);
152
153 if (name == null) {
154 passwordPolicyImpl.setName(StringPool.BLANK);
155 }
156 else {
157 passwordPolicyImpl.setName(name);
158 }
159
160 if (description == null) {
161 passwordPolicyImpl.setDescription(StringPool.BLANK);
162 }
163 else {
164 passwordPolicyImpl.setDescription(description);
165 }
166
167 passwordPolicyImpl.setChangeable(changeable);
168 passwordPolicyImpl.setChangeRequired(changeRequired);
169 passwordPolicyImpl.setMinAge(minAge);
170 passwordPolicyImpl.setCheckSyntax(checkSyntax);
171 passwordPolicyImpl.setAllowDictionaryWords(allowDictionaryWords);
172 passwordPolicyImpl.setMinAlphanumeric(minAlphanumeric);
173 passwordPolicyImpl.setMinLength(minLength);
174 passwordPolicyImpl.setMinLowerCase(minLowerCase);
175 passwordPolicyImpl.setMinNumbers(minNumbers);
176 passwordPolicyImpl.setMinSymbols(minSymbols);
177 passwordPolicyImpl.setMinUpperCase(minUpperCase);
178
179 if (regex == null) {
180 passwordPolicyImpl.setRegex(StringPool.BLANK);
181 }
182 else {
183 passwordPolicyImpl.setRegex(regex);
184 }
185
186 passwordPolicyImpl.setHistory(history);
187 passwordPolicyImpl.setHistoryCount(historyCount);
188 passwordPolicyImpl.setExpireable(expireable);
189 passwordPolicyImpl.setMaxAge(maxAge);
190 passwordPolicyImpl.setWarningTime(warningTime);
191 passwordPolicyImpl.setGraceLimit(graceLimit);
192 passwordPolicyImpl.setLockout(lockout);
193 passwordPolicyImpl.setMaxFailure(maxFailure);
194 passwordPolicyImpl.setLockoutDuration(lockoutDuration);
195 passwordPolicyImpl.setRequireUnlock(requireUnlock);
196 passwordPolicyImpl.setResetFailureCount(resetFailureCount);
197 passwordPolicyImpl.setResetTicketMaxAge(resetTicketMaxAge);
198
199 passwordPolicyImpl.resetOriginalValues();
200
201 return passwordPolicyImpl;
202 }
203
204 @Override
205 public void readExternal(ObjectInput objectInput) throws IOException {
206 uuid = objectInput.readUTF();
207 passwordPolicyId = objectInput.readLong();
208 companyId = objectInput.readLong();
209 userId = objectInput.readLong();
210 userName = objectInput.readUTF();
211 createDate = objectInput.readLong();
212 modifiedDate = objectInput.readLong();
213 defaultPolicy = objectInput.readBoolean();
214 name = objectInput.readUTF();
215 description = objectInput.readUTF();
216 changeable = objectInput.readBoolean();
217 changeRequired = objectInput.readBoolean();
218 minAge = objectInput.readLong();
219 checkSyntax = objectInput.readBoolean();
220 allowDictionaryWords = objectInput.readBoolean();
221 minAlphanumeric = objectInput.readInt();
222 minLength = objectInput.readInt();
223 minLowerCase = objectInput.readInt();
224 minNumbers = objectInput.readInt();
225 minSymbols = objectInput.readInt();
226 minUpperCase = objectInput.readInt();
227 regex = objectInput.readUTF();
228 history = objectInput.readBoolean();
229 historyCount = objectInput.readInt();
230 expireable = objectInput.readBoolean();
231 maxAge = objectInput.readLong();
232 warningTime = objectInput.readLong();
233 graceLimit = objectInput.readInt();
234 lockout = objectInput.readBoolean();
235 maxFailure = objectInput.readInt();
236 lockoutDuration = objectInput.readLong();
237 requireUnlock = objectInput.readBoolean();
238 resetFailureCount = objectInput.readLong();
239 resetTicketMaxAge = objectInput.readLong();
240 }
241
242 @Override
243 public void writeExternal(ObjectOutput objectOutput)
244 throws IOException {
245 if (uuid == null) {
246 objectOutput.writeUTF(StringPool.BLANK);
247 }
248 else {
249 objectOutput.writeUTF(uuid);
250 }
251
252 objectOutput.writeLong(passwordPolicyId);
253 objectOutput.writeLong(companyId);
254 objectOutput.writeLong(userId);
255
256 if (userName == null) {
257 objectOutput.writeUTF(StringPool.BLANK);
258 }
259 else {
260 objectOutput.writeUTF(userName);
261 }
262
263 objectOutput.writeLong(createDate);
264 objectOutput.writeLong(modifiedDate);
265 objectOutput.writeBoolean(defaultPolicy);
266
267 if (name == null) {
268 objectOutput.writeUTF(StringPool.BLANK);
269 }
270 else {
271 objectOutput.writeUTF(name);
272 }
273
274 if (description == null) {
275 objectOutput.writeUTF(StringPool.BLANK);
276 }
277 else {
278 objectOutput.writeUTF(description);
279 }
280
281 objectOutput.writeBoolean(changeable);
282 objectOutput.writeBoolean(changeRequired);
283 objectOutput.writeLong(minAge);
284 objectOutput.writeBoolean(checkSyntax);
285 objectOutput.writeBoolean(allowDictionaryWords);
286 objectOutput.writeInt(minAlphanumeric);
287 objectOutput.writeInt(minLength);
288 objectOutput.writeInt(minLowerCase);
289 objectOutput.writeInt(minNumbers);
290 objectOutput.writeInt(minSymbols);
291 objectOutput.writeInt(minUpperCase);
292
293 if (regex == null) {
294 objectOutput.writeUTF(StringPool.BLANK);
295 }
296 else {
297 objectOutput.writeUTF(regex);
298 }
299
300 objectOutput.writeBoolean(history);
301 objectOutput.writeInt(historyCount);
302 objectOutput.writeBoolean(expireable);
303 objectOutput.writeLong(maxAge);
304 objectOutput.writeLong(warningTime);
305 objectOutput.writeInt(graceLimit);
306 objectOutput.writeBoolean(lockout);
307 objectOutput.writeInt(maxFailure);
308 objectOutput.writeLong(lockoutDuration);
309 objectOutput.writeBoolean(requireUnlock);
310 objectOutput.writeLong(resetFailureCount);
311 objectOutput.writeLong(resetTicketMaxAge);
312 }
313
314 public String uuid;
315 public long passwordPolicyId;
316 public long companyId;
317 public long userId;
318 public String userName;
319 public long createDate;
320 public long modifiedDate;
321 public boolean defaultPolicy;
322 public String name;
323 public String description;
324 public boolean changeable;
325 public boolean changeRequired;
326 public long minAge;
327 public boolean checkSyntax;
328 public boolean allowDictionaryWords;
329 public int minAlphanumeric;
330 public int minLength;
331 public int minLowerCase;
332 public int minNumbers;
333 public int minSymbols;
334 public int minUpperCase;
335 public String regex;
336 public boolean history;
337 public int historyCount;
338 public boolean expireable;
339 public long maxAge;
340 public long warningTime;
341 public int graceLimit;
342 public boolean lockout;
343 public int maxFailure;
344 public long lockoutDuration;
345 public boolean requireUnlock;
346 public long resetFailureCount;
347 public long resetTicketMaxAge;
348 }