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.ServiceContext;
022    import com.liferay.portal.service.base.PasswordPolicyServiceBaseImpl;
023    import com.liferay.portal.service.permission.PasswordPolicyPermissionUtil;
024    import com.liferay.portal.service.permission.PortalPermissionUtil;
025    
026    /**
027     * @author Scott Lee
028     */
029    public class PasswordPolicyServiceImpl extends PasswordPolicyServiceBaseImpl {
030    
031            /**
032             * @deprecated As of 6.2.0, replaced by {@link #addPasswordPolicy(String,
033             *             String, boolean, boolean, long, boolean, boolean, int, int,
034             *             int, int, int, int, String, boolean, int, boolean, long,
035             *             long, int, boolean, int, long, long, long, ServiceContext)}
036             */
037            public PasswordPolicy addPasswordPolicy(
038                            String name, String description, boolean changeable,
039                            boolean changeRequired, long minAge, boolean checkSyntax,
040                            boolean allowDictionaryWords, int minAlphanumeric, int minLength,
041                            int minLowerCase, int minNumbers, int minSymbols, int minUpperCase,
042                            boolean history, int historyCount, boolean expireable, long maxAge,
043                            long warningTime, int graceLimit, boolean lockout, int maxFailure,
044                            long lockoutDuration, long resetFailureCount,
045                            long resetTicketMaxAge)
046                    throws PortalException, SystemException {
047    
048                    PortalPermissionUtil.check(
049                            getPermissionChecker(), ActionKeys.ADD_PASSWORD_POLICY);
050    
051                    return passwordPolicyLocalService.addPasswordPolicy(
052                            getUserId(), false, name, description, changeable, changeRequired,
053                            minAge, checkSyntax, allowDictionaryWords, minAlphanumeric,
054                            minLength, minLowerCase, minNumbers, minSymbols, minUpperCase,
055                            history, historyCount, expireable, maxAge, warningTime, graceLimit,
056                            lockout, maxFailure, lockoutDuration, resetFailureCount,
057                            resetTicketMaxAge);
058            }
059    
060            public PasswordPolicy addPasswordPolicy(
061                            String name, String description, boolean changeable,
062                            boolean changeRequired, long minAge, boolean checkSyntax,
063                            boolean allowDictionaryWords, int minAlphanumeric, int minLength,
064                            int minLowerCase, int minNumbers, int minSymbols, int minUpperCase,
065                            String regex, boolean history, int historyCount, boolean expireable,
066                            long maxAge, long warningTime, int graceLimit, boolean lockout,
067                            int maxFailure, long lockoutDuration, long resetFailureCount,
068                            long resetTicketMaxAge, ServiceContext serviceContext)
069                    throws PortalException, SystemException {
070    
071                    PortalPermissionUtil.check(
072                            getPermissionChecker(), ActionKeys.ADD_PASSWORD_POLICY);
073    
074                    return passwordPolicyLocalService.addPasswordPolicy(
075                            getUserId(), false, name, description, changeable, changeRequired,
076                            minAge, checkSyntax, allowDictionaryWords, minAlphanumeric,
077                            minLength, minLowerCase, minNumbers, minSymbols, minUpperCase,
078                            regex, history, historyCount, expireable, maxAge, warningTime,
079                            graceLimit, lockout, maxFailure, lockoutDuration, resetFailureCount,
080                            resetTicketMaxAge, serviceContext);
081            }
082    
083            public void deletePasswordPolicy(long passwordPolicyId)
084                    throws PortalException, SystemException {
085    
086                    PasswordPolicyPermissionUtil.check(
087                            getPermissionChecker(), passwordPolicyId, ActionKeys.DELETE);
088    
089                    passwordPolicyLocalService.deletePasswordPolicy(passwordPolicyId);
090            }
091    
092            /**
093             * @deprecated As of 6.2.0, replaced by {@link #updatePasswordPolicy(long,
094             *             String, String, boolean, boolean, long, boolean, boolean,
095             *             int, int, int, int, int, int, String, boolean, int, boolean,
096             *             long, long, int, boolean, int, long, long, long,
097             *             ServiceContext)}
098             */
099            public PasswordPolicy updatePasswordPolicy(
100                            long passwordPolicyId, String name, String description,
101                            boolean changeable, boolean changeRequired, long minAge,
102                            boolean checkSyntax, boolean allowDictionaryWords,
103                            int minAlphanumeric, int minLength, int minLowerCase,
104                            int minNumbers, int minSymbols, int minUpperCase, boolean history,
105                            int historyCount, boolean expireable, long maxAge, long warningTime,
106                            int graceLimit, boolean lockout, int maxFailure,
107                            long lockoutDuration, long resetFailureCount,
108                            long resetTicketMaxAge)
109                    throws PortalException, SystemException {
110    
111                    PasswordPolicyPermissionUtil.check(
112                            getPermissionChecker(), passwordPolicyId, ActionKeys.UPDATE);
113    
114                    return passwordPolicyLocalService.updatePasswordPolicy(
115                            passwordPolicyId, name, description, changeable, changeRequired,
116                            minAge, checkSyntax, allowDictionaryWords, minAlphanumeric,
117                            minLength, minLowerCase, minNumbers, minSymbols, minUpperCase,
118                            history, historyCount, expireable, maxAge, warningTime, graceLimit,
119                            lockout, maxFailure, lockoutDuration, resetFailureCount,
120                            resetTicketMaxAge);
121            }
122    
123            public PasswordPolicy updatePasswordPolicy(
124                            long passwordPolicyId, String name, String description,
125                            boolean changeable, boolean changeRequired, long minAge,
126                            boolean checkSyntax, boolean allowDictionaryWords,
127                            int minAlphanumeric, int minLength, int minLowerCase,
128                            int minNumbers, int minSymbols, int minUpperCase, String regex,
129                            boolean history, int historyCount, boolean expireable, long maxAge,
130                            long warningTime, int graceLimit, boolean lockout, int maxFailure,
131                            long lockoutDuration, long resetFailureCount,
132                            long resetTicketMaxAge, ServiceContext serviceContext)
133                    throws PortalException, SystemException {
134    
135                    PasswordPolicyPermissionUtil.check(
136                            getPermissionChecker(), passwordPolicyId, ActionKeys.UPDATE);
137    
138                    return passwordPolicyLocalService.updatePasswordPolicy(
139                            passwordPolicyId, name, description, changeable, changeRequired,
140                            minAge, checkSyntax, allowDictionaryWords, minAlphanumeric,
141                            minLength, minLowerCase, minNumbers, minSymbols, minUpperCase,
142                            regex, history, historyCount, expireable, maxAge, warningTime,
143                            graceLimit, lockout, maxFailure, lockoutDuration, resetFailureCount,
144                            resetTicketMaxAge, serviceContext);
145            }
146    
147    }