Make User available from Authentication via DaoAuthenticationProvider.
This commit is contained in:
@@ -19,6 +19,7 @@ import net.sf.acegisecurity.AccessDeniedException;
|
||||
import net.sf.acegisecurity.Authentication;
|
||||
import net.sf.acegisecurity.context.ContextHolder;
|
||||
import net.sf.acegisecurity.context.SecureContext;
|
||||
import net.sf.acegisecurity.providers.dao.User;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
@@ -88,7 +89,13 @@ public class ContactManagerFacade implements ContactManager, InitializingBean {
|
||||
Authentication auth = ((SecureContext) ContextHolder.getContext())
|
||||
.getAuthentication();
|
||||
|
||||
if (auth.getPrincipal().toString().equals(result.getOwner())) {
|
||||
String username = auth.getPrincipal().toString();
|
||||
|
||||
if (auth.getPrincipal() instanceof User) {
|
||||
username = ((User) auth.getPrincipal()).getUsername();
|
||||
}
|
||||
|
||||
if (username.equals(result.getOwner())) {
|
||||
return result;
|
||||
} else {
|
||||
throw new AccessDeniedException(
|
||||
|
||||
Reference in New Issue
Block a user