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