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.security.auth;
016    
017    import com.liferay.portal.service.UserLocalServiceUtil;
018    
019    import java.util.Map;
020    
021    /**
022     * @author Brian Wing Shun Chan
023     * @author Scott Lee
024     */
025    public class LoginMaxFailures implements AuthFailure {
026    
027            @Override
028            public void onFailureByEmailAddress(
029                            long companyId, String emailAddress,
030                            Map<String, String[]> headerMap, Map<String, String[]> parameterMap)
031                    throws AuthException {
032    
033                    try {
034                            UserLocalServiceUtil.updateLockoutByEmailAddress(
035                                    companyId, emailAddress, true);
036                    }
037                    catch (Exception e) {
038                            throw new AuthException();
039                    }
040            }
041    
042            @Override
043            public void onFailureByScreenName(
044                            long companyId, String screenName, Map<String, String[]> headerMap,
045                            Map<String, String[]> parameterMap)
046                    throws AuthException {
047    
048                    try {
049                            UserLocalServiceUtil.updateLockoutByScreenName(
050                                    companyId, screenName, true);
051                    }
052                    catch (Exception e) {
053                            throw new AuthException();
054                    }
055            }
056    
057            @Override
058            public void onFailureByUserId(
059                            long companyId, long userId, Map<String, String[]> headerMap,
060                            Map<String, String[]> parameterMap)
061                    throws AuthException {
062    
063                    try {
064                            UserLocalServiceUtil.updateLockoutById(userId, true);
065                    }
066                    catch (Exception e) {
067                            throw new AuthException();
068                    }
069            }
070    
071    }