Some tiny technical changes to controllers
[proteocache.git] / server / compbio / controllers / BasicController.java
index 389a0f7..32703aa 100644 (file)
@@ -12,16 +12,15 @@ public class BasicController {
                Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
                if (principal instanceof UserDetails) {
                        UserDetails details = (UserDetails) principal;
-                       String ldapprefix = "";
+                       String rolefix = "";
                        String role = details.getUsername();
                        Collection<? extends GrantedAuthority> au = details.getAuthorities();
                        for (GrantedAuthority ga : au) {
-                               System.out.println("role -> " + ga.getAuthority());
                                if (ga.getAuthority().equals("ROLE_LDAP_USER")) {
-                                       ldapprefix = "LDAP:";
+                                       rolefix = "LDAP:";
                                }
                        }
-                       return ldapprefix + role;
+                       return rolefix + role;
                }
                return principal.toString();
        }
@@ -41,4 +40,19 @@ public class BasicController {
                return false;
        }
 
+       protected boolean isAdminRole() {
+               Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
+               if (principal instanceof UserDetails) {
+                       UserDetails details = (UserDetails) principal;
+                       Collection<? extends GrantedAuthority> au = details.getAuthorities();
+                       for (GrantedAuthority ga : au) {
+                               if (ga.getAuthority().equals("ROLE_ADMIN")) {
+                                       return true;
+                               }
+                       }
+                       return false;
+               }
+               return false;
+       }
+       
 }