import java.util.List;
public interface ArgeoSecurityDao {
import java.util.List;
public interface ArgeoSecurityDao {
+ public ArgeoUser getCurrentUser();
+
public List<ArgeoUser> listUsers();
public List<String> listEditableRoles();
public List<ArgeoUser> listUsers();
public List<String> listEditableRoles();
import org.springframework.ldap.core.DirContextAdapter;
import org.springframework.ldap.core.DistinguishedName;
import org.springframework.ldap.core.LdapTemplate;
import org.springframework.ldap.core.DirContextAdapter;
import org.springframework.ldap.core.DistinguishedName;
import org.springframework.ldap.core.LdapTemplate;
+import org.springframework.security.Authentication;
+import org.springframework.security.context.SecurityContextHolder;
import org.springframework.security.ldap.DefaultLdapUsernameToDnMapper;
import org.springframework.security.ldap.LdapAuthoritiesPopulator;
import org.springframework.security.ldap.LdapUsernameToDnMapper;
import org.springframework.security.ldap.DefaultLdapUsernameToDnMapper;
import org.springframework.security.ldap.LdapAuthoritiesPopulator;
import org.springframework.security.ldap.LdapUsernameToDnMapper;
return createBasicArgeoUser(getDetails(uname));
}
return createBasicArgeoUser(getDetails(uname));
}
+ public ArgeoUser getCurrentUser() {
+ Authentication authentication = SecurityContextHolder.getContext()
+ .getAuthentication();
+ ArgeoUser argeoUser = ArgeoUserDetails.asArgeoUser(authentication);
+ if (argeoUser.getRoles().contains(defaultRole))
+ argeoUser.getRoles().remove(defaultRole);
+ return argeoUser;
+ }
+
@SuppressWarnings("unchecked")
public List<ArgeoUser> listUsers() {
List<String> usernames = (List<String>) ldapTemplate.listBindings(
@SuppressWarnings("unchecked")
public List<ArgeoUser> listUsers() {
List<String> usernames = (List<String>) ldapTemplate.listBindings(
public void setUserNatureMappers(List<UserNatureMapper> userNatureMappers) {
this.userNatureMappers = userNatureMappers;
}
public void setUserNatureMappers(List<UserNatureMapper> userNatureMappers) {
this.userNatureMappers = userNatureMappers;
}
+
+ public String getDefaultRole() {
+ return defaultRole;
+ }
import org.apache.commons.logging.LogFactory;
import org.argeo.security.ArgeoSecurityService;
import org.argeo.security.ArgeoUser;
import org.apache.commons.logging.LogFactory;
import org.argeo.security.ArgeoSecurityService;
import org.argeo.security.ArgeoUser;
-import org.argeo.security.SimpleArgeoUser;
-import org.argeo.security.core.ArgeoUserDetails;
import org.argeo.server.BooleanAnswer;
import org.argeo.server.BooleanAnswer;
-import org.argeo.server.DeserializingEditor;
import org.argeo.server.ServerAnswer;
import org.argeo.server.ServerDeserializer;
import org.argeo.server.mvc.MvcConstants;
import org.argeo.server.ServerAnswer;
import org.argeo.server.ServerDeserializer;
import org.argeo.server.mvc.MvcConstants;
-import org.springframework.security.Authentication;
-import org.springframework.security.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.WebDataBinder;
-import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
private ServerDeserializer userDeserializer = null;
private ServerDeserializer userDeserializer = null;
- @InitBinder
- public void initBinder(WebDataBinder binder) {
- binder.registerCustomEditor(SimpleArgeoUser.class,
- new DeserializingEditor(userDeserializer));
- }
+ // @InitBinder
+ // public void initBinder(WebDataBinder binder) {
+ // binder.registerCustomEditor(SimpleArgeoUser.class,
+ // new DeserializingEditor(userDeserializer));
+ // }
/* USER */
@RequestMapping("/getCredentials.security")
@ModelAttribute(ANSWER_MODEL_KEY)
public ArgeoUser getCredentials() {
/* USER */
@RequestMapping("/getCredentials.security")
@ModelAttribute(ANSWER_MODEL_KEY)
public ArgeoUser getCredentials() {
- Authentication authentication = SecurityContextHolder.getContext()
- .getAuthentication();
- return ArgeoUserDetails.asArgeoUser(authentication);
+ return securityService.getSecurityDao().getCurrentUser();
}
@RequestMapping("/getUsersList.security")
}
@RequestMapping("/getUsersList.security")