1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.service.impl;
16  
17  import com.liferay.portal.kernel.exception.PortalException;
18  import com.liferay.portal.kernel.exception.SystemException;
19  import com.liferay.portal.model.PasswordPolicy;
20  import com.liferay.portal.security.permission.ActionKeys;
21  import com.liferay.portal.service.base.PasswordPolicyServiceBaseImpl;
22  import com.liferay.portal.service.permission.PasswordPolicyPermissionUtil;
23  import com.liferay.portal.service.permission.PortalPermissionUtil;
24  
25  /**
26   * <a href="PasswordPolicyServiceImpl.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author Scott Lee
29   */
30  public class PasswordPolicyServiceImpl extends PasswordPolicyServiceBaseImpl {
31  
32      public PasswordPolicy addPasswordPolicy(
33              String name, String description, boolean changeable,
34              boolean changeRequired, long minAge, boolean checkSyntax,
35              boolean allowDictionaryWords, int minLength, boolean history,
36              int historyCount, boolean expireable, long maxAge, long warningTime,
37              int graceLimit, boolean lockout, int maxFailure,
38              long lockoutDuration, long resetFailureCount)
39          throws PortalException, SystemException {
40  
41          PortalPermissionUtil.check(
42              getPermissionChecker(), ActionKeys.ADD_PASSWORD_POLICY);
43  
44          return passwordPolicyLocalService.addPasswordPolicy(
45              getUserId(), false, name, description, changeable, changeRequired,
46              minAge, checkSyntax, allowDictionaryWords, minLength, history,
47              historyCount, expireable, maxAge, warningTime, graceLimit, lockout,
48              maxFailure, lockoutDuration, resetFailureCount);
49      }
50  
51      public void deletePasswordPolicy(long passwordPolicyId)
52          throws PortalException, SystemException {
53  
54          PasswordPolicyPermissionUtil.check(
55              getPermissionChecker(), passwordPolicyId, ActionKeys.DELETE);
56  
57          passwordPolicyLocalService.deletePasswordPolicy(passwordPolicyId);
58      }
59  
60      public PasswordPolicy updatePasswordPolicy(
61              long passwordPolicyId, String name, String description,
62              boolean changeable, boolean changeRequired, long minAge,
63              boolean checkSyntax, boolean allowDictionaryWords, int minLength,
64              boolean history, int historyCount, boolean expireable, long maxAge,
65              long warningTime, int graceLimit, boolean lockout, int maxFailure,
66              long lockoutDuration, long resetFailureCount)
67          throws PortalException, SystemException {
68  
69          PasswordPolicyPermissionUtil.check(
70              getPermissionChecker(), passwordPolicyId, ActionKeys.UPDATE);
71  
72          return passwordPolicyLocalService.updatePasswordPolicy(
73              passwordPolicyId, name, description, changeable, changeRequired,
74              minAge, checkSyntax, allowDictionaryWords, minLength, history,
75              historyCount, expireable, maxAge, warningTime, graceLimit, lockout,
76              maxFailure, lockoutDuration, resetFailureCount);
77      }
78  
79  }