Clover coverage report - Acegi Security System for Spring - 1.0.0-RC1
Coverage timestamp: Mon Dec 5 2005 09:05:15 EST
file stats: LOC: 63   Methods: 1
NCLOC: 16   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
JaasPasswordCallbackHandler.java 100% 100% 100% 100%
coverage
 1    /* Copyright 2004 Acegi Technology Pty Limited
 2    *
 3    * Licensed under the Apache License, Version 2.0 (the "License");
 4    * you may not use this file except in compliance with the License.
 5    * You may obtain a copy of the License at
 6    *
 7    * http://www.apache.org/licenses/LICENSE-2.0
 8    *
 9    * Unless required by applicable law or agreed to in writing, software
 10    * distributed under the License is distributed on an "AS IS" BASIS,
 11    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12    * See the License for the specific language governing permissions and
 13    * limitations under the License.
 14    */
 15   
 16    package org.acegisecurity.providers.jaas;
 17   
 18    import org.acegisecurity.Authentication;
 19   
 20    import java.io.IOException;
 21   
 22    import javax.security.auth.callback.Callback;
 23    import javax.security.auth.callback.PasswordCallback;
 24    import javax.security.auth.callback.UnsupportedCallbackException;
 25   
 26   
 27    /**
 28    * The most basic Callbacks to be handled when using a LoginContext from JAAS,
 29    * are the NameCallback and PasswordCallback. The acegi security framework
 30    * provides the JaasPasswordCallbackHandler specifically tailored to handling
 31    * the PasswordCallback. <br>
 32    *
 33    * @author Ray Krueger
 34    * @version $Id: JaasPasswordCallbackHandler.java,v 1.4 2005/11/17 00:55:52 benalex Exp $
 35    *
 36    * @see <a
 37    * href="http://java.sun.com/j2se/1.4.2/docs/api/javax/security/auth/callback/Callback.html">Callback</a>
 38    * @see <a
 39    * href="http://java.sun.com/j2se/1.4.2/docs/api/javax/security/auth/callback/PasswordCallback.html">PasswordCallback</a>
 40    */
 41    public class JaasPasswordCallbackHandler
 42    implements JaasAuthenticationCallbackHandler {
 43    //~ Methods ================================================================
 44   
 45    /**
 46    * If the callback passed to the 'handle' method is an instance of
 47    * PasswordCallback, the JaasPasswordCallbackHandler will call,
 48    * callback.setPassword(authentication.getCredentials().toString()).
 49    *
 50    * @param callback
 51    * @param auth
 52    *
 53    * @throws IOException
 54    * @throws UnsupportedCallbackException
 55    */
 56  18 public void handle(Callback callback, Authentication auth)
 57    throws IOException, UnsupportedCallbackException {
 58  18 if (callback instanceof PasswordCallback) {
 59  6 PasswordCallback pc = (PasswordCallback) callback;
 60  6 pc.setPassword(auth.getCredentials().toString().toCharArray());
 61    }
 62    }
 63    }