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.model.PasswordPolicy;
019    import com.liferay.portal.security.permission.ActionKeys;
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            /**
031             * @deprecated As of 6.2.0, replaced by {@link #addPasswordPolicy(String,
032             *             String, boolean, boolean, long, boolean, boolean, int, int,
033             *             int, int, int, int, String, boolean, int, boolean, long,
034             *             long, int, boolean, int, long, long, long, ServiceContext)}
035             */
036            @Deprecated
037            @Override
038            public PasswordPolicy addPasswordPolicy(
039                            String name, String description, boolean changeable,
040                            boolean changeRequired, long minAge, boolean checkSyntax,
041                            boolean allowDictionaryWords, int minAlphanumeric, int minLength,
042                            int minLowerCase, int minNumbers, int minSymbols, int minUpperCase,
043                            boolean history, int historyCount, boolean expireable, long maxAge,
044                            long warningTime, int graceLimit, boolean lockout, int maxFailure,
045                            long lockoutDuration, long resetFailureCount,
046                            long resetTicketMaxAge)
047                    throws PortalException {
048    
049                    PortalPermissionUtil.check(
050                            getPermissionChecker(), ActionKeys.ADD_PASSWORD_POLICY);
051    
052                    return passwordPolicyLocalService.addPasswordPolicy(
053                            getUserId(), false, name, description, changeable, changeRequired,
054                            minAge, checkSyntax, allowDictionaryWords, minAlphanumeric,
055                            minLength, minLowerCase, minNumbers, minSymbols, minUpperCase,
056                            history, historyCount, expireable, maxAge, warningTime, graceLimit,
057                            lockout, maxFailure, lockoutDuration, resetFailureCount,
058                            resetTicketMaxAge);
059            }
060    
061            @Override
062            public PasswordPolicy addPasswordPolicy(
063                            String name, String description, boolean changeable,
064                            boolean changeRequired, long minAge, boolean checkSyntax,
065                            boolean allowDictionaryWords, int minAlphanumeric, int minLength,
066                            int minLowerCase, int minNumbers, int minSymbols, int minUpperCase,
067                            String regex, boolean history, int historyCount, boolean expireable,
068                            long maxAge, long warningTime, int graceLimit, boolean lockout,
069                            int maxFailure, long lockoutDuration, long resetFailureCount,
070                            long resetTicketMaxAge, ServiceContext serviceContext)
071                    throws PortalException {
072    
073                    PortalPermissionUtil.check(
074                            getPermissionChecker(), ActionKeys.ADD_PASSWORD_POLICY);
075    
076                    return passwordPolicyLocalService.addPasswordPolicy(
077                            getUserId(), false, name, description, changeable, changeRequired,
078                            minAge, checkSyntax, allowDictionaryWords, minAlphanumeric,
079                            minLength, minLowerCase, minNumbers, minSymbols, minUpperCase,
080                            regex, history, historyCount, expireable, maxAge, warningTime,
081                            graceLimit, lockout, maxFailure, lockoutDuration, resetFailureCount,
082                            resetTicketMaxAge, serviceContext);
083            }
084    
085            @Override
086            public void deletePasswordPolicy(long passwordPolicyId)
087                    throws PortalException {
088    
089                    PasswordPolicyPermissionUtil.check(
090                            getPermissionChecker(), passwordPolicyId, ActionKeys.DELETE);
091    
092                    passwordPolicyLocalService.deletePasswordPolicy(passwordPolicyId);
093            }
094    
095            @Override
096            public PasswordPolicy fetchPasswordPolicy(long passwordPolicyId)
097                    throws PortalException {
098    
099                    PasswordPolicy passwordPolicy =
100                            passwordPolicyLocalService.fetchPasswordPolicy(passwordPolicyId);
101    
102                    if (passwordPolicy != null) {
103                            PasswordPolicyPermissionUtil.check(
104                                    getPermissionChecker(), passwordPolicyId, ActionKeys.VIEW);
105                    }
106    
107                    return passwordPolicy;
108            }
109    
110            /**
111             * @deprecated As of 6.2.0, replaced by {@link #updatePasswordPolicy(long,
112             *             String, String, boolean, boolean, long, boolean, boolean,
113             *             int, int, int, int, int, int, String, boolean, int, boolean,
114             *             long, long, int, boolean, int, long, long, long,
115             *             ServiceContext)}
116             */
117            @Deprecated
118            @Override
119            public PasswordPolicy updatePasswordPolicy(
120                            long passwordPolicyId, String name, String description,
121                            boolean changeable, boolean changeRequired, long minAge,
122                            boolean checkSyntax, boolean allowDictionaryWords,
123                            int minAlphanumeric, int minLength, int minLowerCase,
124                            int minNumbers, int minSymbols, int minUpperCase, boolean history,
125                            int historyCount, boolean expireable, long maxAge, long warningTime,
126                            int graceLimit, boolean lockout, int maxFailure,
127                            long lockoutDuration, long resetFailureCount,
128                            long resetTicketMaxAge)
129                    throws PortalException {
130    
131                    PasswordPolicyPermissionUtil.check(
132                            getPermissionChecker(), passwordPolicyId, ActionKeys.UPDATE);
133    
134                    return passwordPolicyLocalService.updatePasswordPolicy(
135                            passwordPolicyId, name, description, changeable, changeRequired,
136                            minAge, checkSyntax, allowDictionaryWords, minAlphanumeric,
137                            minLength, minLowerCase, minNumbers, minSymbols, minUpperCase,
138                            history, historyCount, expireable, maxAge, warningTime, graceLimit,
139                            lockout, maxFailure, lockoutDuration, resetFailureCount,
140                            resetTicketMaxAge);
141            }
142    
143            @Override
144            public PasswordPolicy updatePasswordPolicy(
145                            long passwordPolicyId, String name, String description,
146                            boolean changeable, boolean changeRequired, long minAge,
147                            boolean checkSyntax, boolean allowDictionaryWords,
148                            int minAlphanumeric, int minLength, int minLowerCase,
149                            int minNumbers, int minSymbols, int minUpperCase, String regex,
150                            boolean history, int historyCount, boolean expireable, long maxAge,
151                            long warningTime, int graceLimit, boolean lockout, int maxFailure,
152                            long lockoutDuration, long resetFailureCount,
153                            long resetTicketMaxAge, ServiceContext serviceContext)
154                    throws PortalException {
155    
156                    PasswordPolicyPermissionUtil.check(
157                            getPermissionChecker(), passwordPolicyId, ActionKeys.UPDATE);
158    
159                    return passwordPolicyLocalService.updatePasswordPolicy(
160                            passwordPolicyId, name, description, changeable, changeRequired,
161                            minAge, checkSyntax, allowDictionaryWords, minAlphanumeric,
162                            minLength, minLowerCase, minNumbers, minSymbols, minUpperCase,
163                            regex, history, historyCount, expireable, maxAge, warningTime,
164                            graceLimit, lockout, maxFailure, lockoutDuration, resetFailureCount,
165                            resetTicketMaxAge, serviceContext);
166            }
167    
168    }