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