From ea182f73fef186193d2643d4b36c476d176df956 Mon Sep 17 00:00:00 2001 From: Ben Alex Date: Fri, 27 Jan 2006 05:17:13 +0000 Subject: [PATCH] SEC-145: Include nested exception. --- .../dao/salt/ReflectionSaltSource.java | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/core/src/main/java/org/acegisecurity/providers/dao/salt/ReflectionSaltSource.java b/core/src/main/java/org/acegisecurity/providers/dao/salt/ReflectionSaltSource.java index e6f50beab4..d6c87afcc9 100644 --- a/core/src/main/java/org/acegisecurity/providers/dao/salt/ReflectionSaltSource.java +++ b/core/src/main/java/org/acegisecurity/providers/dao/salt/ReflectionSaltSource.java @@ -1,4 +1,4 @@ -/* Copyright 2004, 2005 Acegi Technology Pty Limited +/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,9 @@ package org.acegisecurity.providers.dao.salt; import org.acegisecurity.AuthenticationServiceException; + import org.acegisecurity.providers.dao.SaltSource; + import org.acegisecurity.userdetails.UserDetails; import org.springframework.beans.factory.InitializingBean; @@ -44,6 +46,14 @@ public class ReflectionSaltSource implements SaltSource, InitializingBean { //~ Methods ================================================================ + public void afterPropertiesSet() throws Exception { + if ((this.getUserPropertyToUse() == null) + || "".equals(this.getUserPropertyToUse())) { + throw new IllegalArgumentException( + "A userPropertyToUse must be set"); + } + } + /** * Performs reflection on the passed User to obtain the salt. * @@ -62,15 +72,21 @@ public class ReflectionSaltSource implements SaltSource, InitializingBean { */ public Object getSalt(UserDetails user) { try { - Method reflectionMethod = user.getClass().getMethod(this.userPropertyToUse, + Method reflectionMethod = user.getClass() + .getMethod(this.userPropertyToUse, new Class[] {}); return reflectionMethod.invoke(user, new Object[] {}); } catch (Exception exception) { - throw new AuthenticationServiceException(exception.getMessage()); + throw new AuthenticationServiceException(exception.getMessage(), + exception); } } + public String getUserPropertyToUse() { + return userPropertyToUse; + } + /** * The method name to call to obtain the salt. If your * UserDetails contains a UserDetails.getSalt() @@ -82,16 +98,4 @@ public class ReflectionSaltSource implements SaltSource, InitializingBean { public void setUserPropertyToUse(String userPropertyToUse) { this.userPropertyToUse = userPropertyToUse; } - - public String getUserPropertyToUse() { - return userPropertyToUse; - } - - public void afterPropertiesSet() throws Exception { - if ((this.getUserPropertyToUse() == null) - || "".equals(this.getUserPropertyToUse())) { - throw new IllegalArgumentException( - "A userPropertyToUse must be set"); - } - } }