001    /**
002     * Copyright (c) 2000-2010 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            public void onFailureByEmailAddress(
028                            long companyId, String emailAddress,
029                            Map<String, String[]> headerMap, Map<String, String[]> parameterMap)
030                    throws AuthException {
031    
032                    try {
033                            UserLocalServiceUtil.updateLockoutByEmailAddress(
034                                    companyId, emailAddress, true);
035                    }
036                    catch (Exception e) {
037                            throw new AuthException();
038                    }
039            }
040    
041            public void onFailureByScreenName(
042                            long companyId, String screenName, Map<String, String[]> headerMap,
043                            Map<String, String[]> parameterMap)
044                    throws AuthException {
045    
046                    try {
047                            UserLocalServiceUtil.updateLockoutByScreenName(
048                                    companyId, screenName, true);
049                    }
050                    catch (Exception e) {
051                            throw new AuthException();
052                    }
053            }
054    
055            public void onFailureByUserId(
056                            long companyId, long userId, Map<String, String[]> headerMap,
057                            Map<String, String[]> parameterMap)
058                    throws AuthException {
059    
060                    try {
061                            UserLocalServiceUtil.updateLockoutById(userId, true);
062                    }
063                    catch (Exception e) {
064                            throw new AuthException();
065                    }
066            }
067    
068    }