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 */
019 package org.apache.shiro.authc;
020
021 import org.apache.shiro.subject.PrincipalCollection;
022
023 /**
024 * An {@code AuthenticationListener} listens for notifications while {@code Subject}s authenticate with the system.
025 *
026 * @author Les Hazlewood
027 * @since 0.9
028 */
029 public interface AuthenticationListener {
030
031 /**
032 * Callback triggered when an authentication attempt for a {@code Subject} has succeeded.
033 *
034 * @param token the authentication token submitted during the {@code Subject} (user)'s authentication attempt.
035 * @param info the authentication-related account data acquired after authentication for the corresponding {@code Subject}.
036 */
037 void onSuccess(AuthenticationToken token, AuthenticationInfo info);
038
039 /**
040 * Callback triggered when an authentication attempt for a {@code Subject} has failed.
041 *
042 * @param token the authentication token submitted during the {@code Subject} (user)'s authentication attempt.
043 * @param ae the {@code AuthenticationException} that occurred as a result of the attempt.
044 */
045 void onFailure(AuthenticationToken token, AuthenticationException ae);
046
047 /**
048 * Callback triggered when a {@code Subject} logs-out of the system.
049 * <p/>
050 * This method will only be triggered when a Subject explicitly logs-out of the session. It will not
051 * be triggered if their Session times out.
052 *
053 * @param principals the identifying principals of the Subject logging out.
054 */
055 void onLogout(PrincipalCollection principals);
056 }