001    /**
002     * Copyright (c) 2000-present 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.security.permission.ActionKeys;
019    import com.liferay.portal.model.PasswordPolicy;
020    import com.liferay.portal.service.ServiceContext;
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                            String regex, boolean history, int historyCount, boolean expireable,
037                            long maxAge, long warningTime, int graceLimit, boolean lockout,
038                            int maxFailure, long lockoutDuration, long resetFailureCount,
039                            long resetTicketMaxAge, ServiceContext serviceContext)
040                    throws PortalException {
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                            regex, history, historyCount, expireable, maxAge, warningTime,
050                            graceLimit, lockout, maxFailure, lockoutDuration, resetFailureCount,
051                            resetTicketMaxAge, serviceContext);
052            }
053    
054            @Override
055            public void deletePasswordPolicy(long passwordPolicyId)
056                    throws PortalException {
057    
058                    PasswordPolicyPermissionUtil.check(
059                            getPermissionChecker(), passwordPolicyId, ActionKeys.DELETE);
060    
061                    passwordPolicyLocalService.deletePasswordPolicy(passwordPolicyId);
062            }
063    
064            @Override
065            public PasswordPolicy fetchPasswordPolicy(long passwordPolicyId)
066                    throws PortalException {
067    
068                    PasswordPolicy passwordPolicy =
069                            passwordPolicyLocalService.fetchPasswordPolicy(passwordPolicyId);
070    
071                    if (passwordPolicy != null) {
072                            PasswordPolicyPermissionUtil.check(
073                                    getPermissionChecker(), passwordPolicyId, ActionKeys.VIEW);
074                    }
075    
076                    return passwordPolicy;
077            }
078    
079            @Override
080            public PasswordPolicy updatePasswordPolicy(
081                            long passwordPolicyId, String name, String description,
082                            boolean changeable, boolean changeRequired, long minAge,
083                            boolean checkSyntax, boolean allowDictionaryWords,
084                            int minAlphanumeric, int minLength, int minLowerCase,
085                            int minNumbers, int minSymbols, int minUpperCase, String regex,
086                            boolean history, int historyCount, boolean expireable, long maxAge,
087                            long warningTime, int graceLimit, boolean lockout, int maxFailure,
088                            long lockoutDuration, long resetFailureCount,
089                            long resetTicketMaxAge, ServiceContext serviceContext)
090                    throws PortalException {
091    
092                    PasswordPolicyPermissionUtil.check(
093                            getPermissionChecker(), passwordPolicyId, ActionKeys.UPDATE);
094    
095                    return passwordPolicyLocalService.updatePasswordPolicy(
096                            passwordPolicyId, name, description, changeable, changeRequired,
097                            minAge, checkSyntax, allowDictionaryWords, minAlphanumeric,
098                            minLength, minLowerCase, minNumbers, minSymbols, minUpperCase,
099                            regex, history, historyCount, expireable, maxAge, warningTime,
100                            graceLimit, lockout, maxFailure, lockoutDuration, resetFailureCount,
101                            resetTicketMaxAge, serviceContext);
102            }
103    
104    }