PostAuthentication Plugins
Post Authentication Plugins allow you to do some processing after the authentication has been attempted. For example, you may want to keep track of how many failed authentications a username had and display a CAPTCHA response if its over a certain amount.
You can also use this API to return authentication related messages.
The API for the Post Authentication Plugins looks like this:
/** * Copyright (C) 2009 Jasig, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jasig.cas.server; import org.jasig.cas.server.authentication.AuthenticationResponse; import org.jasig.cas.server.login.LoginRequest; /** * A pluggable component for the {@link org.jasig.cas.server.CentralAuthenticationService} that allows you to execute a * set of actions after the AuthenticationResponse has been generated (regardless of success or failure). * * @author Scott Battaglia * @version $Revision $Date$ * @since 4.0.0 */ public interface AuthenticationResponsePlugin { /** * Perform an action after the authentication response has been generated. * * @param loginRequest the original login request. * @param response the corresponding authentication response. */ void handle(LoginRequest loginRequest, AuthenticationResponse response); }
The Post Authentication Plugins execute after authentication has completed. It allows you to perform some action afterwards.
Configuring Your Own
The DefaultCentralAuthenticationServiceImpl looks for any existing plugins via the Spring auto-wiring mechanism. If you have no concerns about specific ordering of plugins, you can configure your plugin in one of two ways:
- Use the @Component annotation on your plugin, which tells Spring to instantiate the object.
- Add a bean definition to your Spring XML configuration files.
In both cases, without explicitly telling the DefaultCentralAuthenticationServiceImpl, it will find and associate the appropriate plugins.