001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.impl;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.model.PasswordPolicy;
020    import com.liferay.portal.security.permission.ActionKeys;
021    import com.liferay.portal.service.base.PasswordPolicyServiceBaseImpl;
022    import com.liferay.portal.service.permission.PasswordPolicyPermissionUtil;
023    import com.liferay.portal.service.permission.PortalPermissionUtil;
024    
025    /**
026     * @author Scott Lee
027     */
028    public class PasswordPolicyServiceImpl extends PasswordPolicyServiceBaseImpl {
029    
030            public PasswordPolicy addPasswordPolicy(
031                            String name, String description, boolean changeable,
032                            boolean changeRequired, long minAge, boolean checkSyntax,
033                            boolean allowDictionaryWords, int minAlphanumeric, int minLength,
034                            int minLowerCase, int minNumbers, int minSymbols, int minUpperCase,
035                            boolean history, int historyCount, boolean expireable, long maxAge,
036                            long warningTime, int graceLimit, boolean lockout, int maxFailure,
037                            long lockoutDuration, long resetFailureCount,
038                            long resetTicketMaxAge)
039                    throws PortalException, SystemException {
040    
041                    PortalPermissionUtil.check(
042                            getPermissionChecker(), ActionKeys.ADD_PASSWORD_POLICY);
043    
044                    return passwordPolicyLocalService.addPasswordPolicy(
045                            getUserId(), false, name, description, changeable, changeRequired,
046                            minAge, checkSyntax, allowDictionaryWords, minAlphanumeric,
047                            minLength, minLowerCase, minNumbers, minSymbols, minUpperCase,
048                            history, historyCount, expireable, maxAge, warningTime, graceLimit,
049                            lockout, maxFailure, lockoutDuration, resetFailureCount,
050                            resetTicketMaxAge);
051            }
052    
053            public void deletePasswordPolicy(long passwordPolicyId)
054                    throws PortalException, SystemException {
055    
056                    PasswordPolicyPermissionUtil.check(
057                            getPermissionChecker(), passwordPolicyId, ActionKeys.DELETE);
058    
059                    passwordPolicyLocalService.deletePasswordPolicy(passwordPolicyId);
060            }
061    
062            public PasswordPolicy updatePasswordPolicy(
063                            long passwordPolicyId, String name, String description,
064                            boolean changeable, boolean changeRequired, long minAge,
065                            boolean checkSyntax, boolean allowDictionaryWords,
066                            int minAlphanumeric, int minLength, int minLowerCase,
067                            int minNumbers, int minSymbols, int minUpperCase, boolean history,
068                            int historyCount, boolean expireable, long maxAge,
069                            long warningTime, int graceLimit, boolean lockout, int maxFailure,
070                            long lockoutDuration, long resetFailureCount,
071                            long resetTicketMaxAge)
072                    throws PortalException, SystemException {
073    
074                    PasswordPolicyPermissionUtil.check(
075                            getPermissionChecker(), passwordPolicyId, ActionKeys.UPDATE);
076    
077                    return passwordPolicyLocalService.updatePasswordPolicy(
078                            passwordPolicyId, name, description, changeable, changeRequired,
079                            minAge, checkSyntax, allowDictionaryWords, minAlphanumeric,
080                            minLength, minLowerCase, minNumbers, minSymbols, minUpperCase,
081                            history, historyCount, expireable, maxAge, warningTime, graceLimit,
082                            lockout, maxFailure, lockoutDuration, resetFailureCount,
083                            resetTicketMaxAge);
084            }
085    
086    }