001    /**
002     * Copyright (c) 2000-2013 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            @Override
031            public PasswordPolicy addPasswordPolicy(
032                            String name, String description, boolean changeable,
033                            boolean changeRequired, long minAge, boolean checkSyntax,
034                            boolean allowDictionaryWords, int minAlphanumeric, int minLength,
035                            int minLowerCase, int minNumbers, int minSymbols, int minUpperCase,
036                            boolean history, int historyCount, boolean expireable, long maxAge,
037                            long warningTime, int graceLimit, boolean lockout, int maxFailure,
038                            long lockoutDuration, long resetFailureCount,
039                            long resetTicketMaxAge)
040                    throws PortalException, SystemException {
041    
042                    PortalPermissionUtil.check(
043                            getPermissionChecker(), ActionKeys.ADD_PASSWORD_POLICY);
044    
045                    return passwordPolicyLocalService.addPasswordPolicy(
046                            getUserId(), false, name, description, changeable, changeRequired,
047                            minAge, checkSyntax, allowDictionaryWords, minAlphanumeric,
048                            minLength, minLowerCase, minNumbers, minSymbols, minUpperCase,
049                            history, historyCount, expireable, maxAge, warningTime, graceLimit,
050                            lockout, maxFailure, lockoutDuration, resetFailureCount,
051                            resetTicketMaxAge);
052            }
053    
054            @Override
055            public void deletePasswordPolicy(long passwordPolicyId)
056                    throws PortalException, SystemException {
057    
058                    PasswordPolicyPermissionUtil.check(
059                            getPermissionChecker(), passwordPolicyId, ActionKeys.DELETE);
060    
061                    passwordPolicyLocalService.deletePasswordPolicy(passwordPolicyId);
062            }
063    
064            @Override
065            public PasswordPolicy updatePasswordPolicy(
066                            long passwordPolicyId, String name, String description,
067                            boolean changeable, boolean changeRequired, long minAge,
068                            boolean checkSyntax, boolean allowDictionaryWords,
069                            int minAlphanumeric, int minLength, int minLowerCase,
070                            int minNumbers, int minSymbols, int minUpperCase, boolean history,
071                            int historyCount, boolean expireable, long maxAge, long warningTime,
072                            int graceLimit, boolean lockout, int maxFailure,
073                            long lockoutDuration, long resetFailureCount,
074                            long resetTicketMaxAge)
075                    throws PortalException, SystemException {
076    
077                    PasswordPolicyPermissionUtil.check(
078                            getPermissionChecker(), passwordPolicyId, ActionKeys.UPDATE);
079    
080                    return passwordPolicyLocalService.updatePasswordPolicy(
081                            passwordPolicyId, name, description, changeable, changeRequired,
082                            minAge, checkSyntax, allowDictionaryWords, minAlphanumeric,
083                            minLength, minLowerCase, minNumbers, minSymbols, minUpperCase,
084                            history, historyCount, expireable, maxAge, warningTime, graceLimit,
085                            lockout, maxFailure, lockoutDuration, resetFailureCount,
086                            resetTicketMaxAge);
087            }
088    
089    }