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