mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-30 15:52:15 +00:00
SEC-145: Include nested exception.
This commit is contained in:
parent
2459858f48
commit
ea182f73fe
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -16,7 +16,9 @@
|
|||||||
package org.acegisecurity.providers.dao.salt;
|
package org.acegisecurity.providers.dao.salt;
|
||||||
|
|
||||||
import org.acegisecurity.AuthenticationServiceException;
|
import org.acegisecurity.AuthenticationServiceException;
|
||||||
|
|
||||||
import org.acegisecurity.providers.dao.SaltSource;
|
import org.acegisecurity.providers.dao.SaltSource;
|
||||||
|
|
||||||
import org.acegisecurity.userdetails.UserDetails;
|
import org.acegisecurity.userdetails.UserDetails;
|
||||||
|
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
@ -44,6 +46,14 @@ public class ReflectionSaltSource implements SaltSource, InitializingBean {
|
|||||||
|
|
||||||
//~ Methods ================================================================
|
//~ 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 <code>User</code> to obtain the salt.
|
* Performs reflection on the passed <code>User</code> to obtain the salt.
|
||||||
*
|
*
|
||||||
@ -62,15 +72,21 @@ public class ReflectionSaltSource implements SaltSource, InitializingBean {
|
|||||||
*/
|
*/
|
||||||
public Object getSalt(UserDetails user) {
|
public Object getSalt(UserDetails user) {
|
||||||
try {
|
try {
|
||||||
Method reflectionMethod = user.getClass().getMethod(this.userPropertyToUse,
|
Method reflectionMethod = user.getClass()
|
||||||
|
.getMethod(this.userPropertyToUse,
|
||||||
new Class[] {});
|
new Class[] {});
|
||||||
|
|
||||||
return reflectionMethod.invoke(user, new Object[] {});
|
return reflectionMethod.invoke(user, new Object[] {});
|
||||||
} catch (Exception exception) {
|
} 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
|
* The method name to call to obtain the salt. If your
|
||||||
* <code>UserDetails</code> contains a <code>UserDetails.getSalt()</code>
|
* <code>UserDetails</code> contains a <code>UserDetails.getSalt()</code>
|
||||||
@ -82,16 +98,4 @@ public class ReflectionSaltSource implements SaltSource, InitializingBean {
|
|||||||
public void setUserPropertyToUse(String userPropertyToUse) {
|
public void setUserPropertyToUse(String userPropertyToUse) {
|
||||||
this.userPropertyToUse = 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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user