SEC-94: DaoAuthenticationProvider to include UserDetails in BadCredentialsException.
This commit is contained in:
parent
509ae1ccc9
commit
55f5093ec7
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright 2004 Acegi Technology Pty Limited
|
/* Copyright 2004, 2005 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.
|
||||||
|
@ -24,6 +24,10 @@ package net.sf.acegisecurity;
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class BadCredentialsException extends AuthenticationException {
|
public class BadCredentialsException extends AuthenticationException {
|
||||||
|
//~ Instance fields ========================================================
|
||||||
|
|
||||||
|
private Object extraInformation;
|
||||||
|
|
||||||
//~ Constructors ===========================================================
|
//~ Constructors ===========================================================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,6 +40,11 @@ public class BadCredentialsException extends AuthenticationException {
|
||||||
super(msg);
|
super(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BadCredentialsException(String msg, Object extraInformation) {
|
||||||
|
super(msg);
|
||||||
|
this.extraInformation = extraInformation;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a <code>BadCredentialsException</code> with the specified
|
* Constructs a <code>BadCredentialsException</code> with the specified
|
||||||
* message and root cause.
|
* message and root cause.
|
||||||
|
@ -46,4 +55,16 @@ public class BadCredentialsException extends AuthenticationException {
|
||||||
public BadCredentialsException(String msg, Throwable t) {
|
public BadCredentialsException(String msg, Throwable t) {
|
||||||
super(msg, t);
|
super(msg, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//~ Methods ================================================================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Any additional information about the exception. Generally a
|
||||||
|
* <code>UserDetails</code> object.
|
||||||
|
*
|
||||||
|
* @return extra information or <code>null</code>
|
||||||
|
*/
|
||||||
|
public Object getExtraInformation() {
|
||||||
|
return extraInformation;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,7 @@ public class DaoAuthenticationProvider
|
||||||
|
|
||||||
if (!passwordEncoder.isPasswordValid(userDetails.getPassword(),
|
if (!passwordEncoder.isPasswordValid(userDetails.getPassword(),
|
||||||
authentication.getCredentials().toString(), salt)) {
|
authentication.getCredentials().toString(), salt)) {
|
||||||
throw new BadCredentialsException("Bad credentials");
|
throw new BadCredentialsException("Bad credentials", userDetails);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue