| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||||||
| AuthenticationDetailsSourceImpl |
|
| 3.5;3.5 |
| 1 | /* Copyright 2004, 2005, 2006 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.ui; |
|
| 17 | ||
| 18 | import org.springframework.util.Assert; |
|
| 19 | import org.springframework.util.ReflectionUtils; |
|
| 20 | ||
| 21 | import java.lang.reflect.Constructor; |
|
| 22 | import java.lang.reflect.InvocationTargetException; |
|
| 23 | ||
| 24 | import javax.servlet.http.HttpServletRequest; |
|
| 25 | ||
| 26 | ||
| 27 | /** |
|
| 28 | * Base implementation of {@link AuthenticationDetailsSource}.<P>By default will create an instance of |
|
| 29 | * <code>WebAuthenticationDetails</code>. Any object that accepts a <code>HttpServletRequest</code> as its sole |
|
| 30 | * constructor can be used instead of this default.</p> |
|
| 31 | * |
|
| 32 | * @author Ben Alex |
|
| 33 | * @version $Id: AuthenticationDetailsSourceImpl.java 1496 2006-05-23 13:38:33Z benalex $ |
|
| 34 | */ |
|
| 35 | 98 | public class AuthenticationDetailsSourceImpl implements AuthenticationDetailsSource { |
| 36 | //~ Instance fields ================================================================================================ |
|
| 37 | ||
| 38 | 100 | private Class clazz = WebAuthenticationDetails.class; |
| 39 | ||
| 40 | //~ Methods ======================================================================================================== |
|
| 41 | ||
| 42 | public Object buildDetails(HttpServletRequest request) { |
|
| 43 | try { |
|
| 44 | 29 | Constructor constructor = clazz.getConstructor(new Class[] {HttpServletRequest.class}); |
| 45 | ||
| 46 | 29 | return constructor.newInstance(new Object[] {request}); |
| 47 | 0 | } catch (NoSuchMethodException ex) { |
| 48 | 0 | ReflectionUtils.handleReflectionException(ex); |
| 49 | 0 | } catch (InvocationTargetException ex) { |
| 50 | 0 | ReflectionUtils.handleReflectionException(ex); |
| 51 | 0 | } catch (InstantiationException ex) { |
| 52 | 0 | ReflectionUtils.handleReflectionException(ex); |
| 53 | 0 | } catch (IllegalAccessException ex) { |
| 54 | 0 | ReflectionUtils.handleReflectionException(ex); |
| 55 | 0 | } |
| 56 | ||
| 57 | 0 | return null; |
| 58 | } |
|
| 59 | ||
| 60 | public void setClazz(Class clazz) { |
|
| 61 | 0 | Assert.notNull(clazz, "Class required"); |
| 62 | 0 | this.clazz = clazz; |
| 63 | 0 | } |
| 64 | } |