1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.service.impl;
21  
22  import com.liferay.portal.PortalException;
23  import com.liferay.portal.SystemException;
24  import com.liferay.portal.model.PasswordPolicy;
25  import com.liferay.portal.security.permission.ActionKeys;
26  import com.liferay.portal.service.base.PasswordPolicyServiceBaseImpl;
27  import com.liferay.portal.service.permission.PasswordPolicyPermissionUtil;
28  import com.liferay.portal.service.permission.PortalPermissionUtil;
29  
30  /**
31   * <a href="PasswordPolicyServiceImpl.java.html"><b><i>View Source</i></b></a>
32   *
33   * @author Scott Lee
34   *
35   */
36  public class PasswordPolicyServiceImpl extends PasswordPolicyServiceBaseImpl {
37  
38      public PasswordPolicy addPasswordPolicy(
39              String name, String description, boolean changeable,
40              boolean changeRequired, long minAge, boolean checkSyntax,
41              boolean allowDictionaryWords, int minLength, boolean history,
42              int historyCount, boolean expireable, long maxAge, long warningTime,
43              int graceLimit, boolean lockout, int maxFailure,
44              long lockoutDuration, long resetFailureCount)
45          throws PortalException, SystemException {
46  
47          PortalPermissionUtil.check(
48              getPermissionChecker(), ActionKeys.ADD_PASSWORD_POLICY);
49  
50          return passwordPolicyLocalService.addPasswordPolicy(
51              getUserId(), false, name, description, changeable, changeRequired,
52              minAge, checkSyntax, allowDictionaryWords, minLength, history,
53              historyCount, expireable, maxAge, warningTime, graceLimit, lockout,
54              maxFailure, lockoutDuration, resetFailureCount);
55      }
56  
57      public void deletePasswordPolicy(long passwordPolicyId)
58          throws PortalException, SystemException {
59  
60          PasswordPolicyPermissionUtil.check(
61              getPermissionChecker(), passwordPolicyId, ActionKeys.DELETE);
62  
63          passwordPolicyLocalService.deletePasswordPolicy(passwordPolicyId);
64      }
65  
66      public PasswordPolicy updatePasswordPolicy(
67              long passwordPolicyId, String name, String description,
68              boolean changeable, boolean changeRequired, long minAge,
69              boolean checkSyntax, boolean allowDictionaryWords, int minLength,
70              boolean history, int historyCount, boolean expireable, long maxAge,
71              long warningTime, int graceLimit, boolean lockout, int maxFailure,
72              long lockoutDuration, long resetFailureCount)
73          throws PortalException, SystemException {
74  
75          PasswordPolicyPermissionUtil.check(
76              getPermissionChecker(), passwordPolicyId, ActionKeys.UPDATE);
77  
78          return passwordPolicyLocalService.updatePasswordPolicy(
79              passwordPolicyId, name, description, changeable, changeRequired,
80              minAge, checkSyntax, allowDictionaryWords, minLength, history,
81              historyCount, expireable, maxAge, warningTime, graceLimit, lockout,
82              maxFailure, lockoutDuration, resetFailureCount);
83      }
84  
85  }