001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.apache.shiro.authc; 020 021import org.apache.shiro.subject.PrincipalCollection; 022 023/** 024 * An {@code AuthenticationListener} listens for notifications while {@code Subject}s authenticate with the system. 025 * 026 * @since 0.9 027 */ 028public interface AuthenticationListener { 029 030 /** 031 * Callback triggered when an authentication attempt for a {@code Subject} has succeeded. 032 * 033 * @param token the authentication token submitted during the {@code Subject} (user)'s authentication attempt. 034 * @param info the authentication-related account data acquired after authentication for the corresponding {@code Subject}. 035 */ 036 void onSuccess(AuthenticationToken token, AuthenticationInfo info); 037 038 /** 039 * Callback triggered when an authentication attempt for a {@code Subject} has failed. 040 * 041 * @param token the authentication token submitted during the {@code Subject} (user)'s authentication attempt. 042 * @param ae the {@code AuthenticationException} that occurred as a result of the attempt. 043 */ 044 void onFailure(AuthenticationToken token, AuthenticationException ae); 045 046 /** 047 * Callback triggered when a {@code Subject} logs-out of the system. 048 * <p/> 049 * This method will only be triggered when a Subject explicitly logs-out of the session. It will not 050 * be triggered if their Session times out. 051 * 052 * @param principals the identifying principals of the Subject logging out. 053 */ 054 void onLogout(PrincipalCollection principals); 055}