Refactor User to an interface.
This commit is contained in:
@@ -19,7 +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 net.sf.acegisecurity.providers.dao.UserDetails;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
@@ -91,8 +91,8 @@ public class ContactManagerFacade implements ContactManager, InitializingBean {
|
||||
|
||||
String username = auth.getPrincipal().toString();
|
||||
|
||||
if (auth.getPrincipal() instanceof User) {
|
||||
username = ((User) auth.getPrincipal()).getUsername();
|
||||
if (auth.getPrincipal() instanceof UserDetails) {
|
||||
username = ((UserDetails) auth.getPrincipal()).getUsername();
|
||||
}
|
||||
|
||||
if (username.equals(result.getOwner())) {
|
||||
|
||||
@@ -18,7 +18,7 @@ package sample.contact;
|
||||
import net.sf.acegisecurity.Authentication;
|
||||
import net.sf.acegisecurity.ConfigAttribute;
|
||||
import net.sf.acegisecurity.ConfigAttributeDefinition;
|
||||
import net.sf.acegisecurity.providers.dao.User;
|
||||
import net.sf.acegisecurity.providers.dao.UserDetails;
|
||||
import net.sf.acegisecurity.vote.AccessDecisionVoter;
|
||||
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
@@ -99,8 +99,8 @@ public class ContactSecurityVoter implements AccessDecisionVoter {
|
||||
if (passedOwner != null) {
|
||||
String username = authentication.getPrincipal().toString();
|
||||
|
||||
if (authentication.getPrincipal() instanceof User) {
|
||||
username = ((User) authentication.getPrincipal())
|
||||
if (authentication.getPrincipal() instanceof UserDetails) {
|
||||
username = ((UserDetails) authentication.getPrincipal())
|
||||
.getUsername();
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import net.sf.acegisecurity.AuthenticationCredentialsNotFoundException;
|
||||
import net.sf.acegisecurity.GrantedAuthority;
|
||||
import net.sf.acegisecurity.context.ContextHolder;
|
||||
import net.sf.acegisecurity.context.SecureContext;
|
||||
import net.sf.acegisecurity.providers.dao.User;
|
||||
import net.sf.acegisecurity.providers.dao.UserDetails;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
@@ -80,8 +80,8 @@ public class SecureIndexController implements Controller, InitializingBean {
|
||||
Authentication auth = secureContext.getAuthentication();
|
||||
String username = auth.getPrincipal().toString();
|
||||
|
||||
if (auth.getPrincipal() instanceof User) {
|
||||
username = ((User) auth.getPrincipal()).getUsername();
|
||||
if (auth.getPrincipal() instanceof UserDetails) {
|
||||
username = ((UserDetails) auth.getPrincipal()).getUsername();
|
||||
}
|
||||
|
||||
boolean supervisor = false;
|
||||
|
||||
@@ -18,7 +18,7 @@ package sample.contact;
|
||||
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 net.sf.acegisecurity.providers.dao.UserDetails;
|
||||
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.mvc.SimpleFormController;
|
||||
@@ -61,8 +61,8 @@ public class WebContactAddController extends SimpleFormController {
|
||||
.getAuthentication();
|
||||
String owner = auth.getPrincipal().toString();
|
||||
|
||||
if (auth.getPrincipal() instanceof User) {
|
||||
owner = ((User) auth.getPrincipal()).getUsername();
|
||||
if (auth.getPrincipal() instanceof UserDetails) {
|
||||
owner = ((UserDetails) auth.getPrincipal()).getUsername();
|
||||
}
|
||||
|
||||
Contact contact = new Contact(contactManager.getNextId(), name, email,
|
||||
|
||||
Reference in New Issue
Block a user