1 package com.atlassian.seraph.auth; 2 3 import com.atlassian.seraph.util.GroupCache; 4 import com.atlassian.seraph.config.SecurityConfig; 5 6 import javax.servlet.http.HttpServletRequest ; 7 import java.util.Collection ; 8 import java.util.Map ; 9 import java.security.Principal ; 10 11 16 public class GroupRoleMapper implements RoleMapper 17 { 18 public void init(Map params, SecurityConfig config) 19 { 20 } 21 22 25 public boolean hasRole(Principal user, HttpServletRequest request, String role) 26 { 27 Collection groups = GroupCache.getGroups(request); 28 29 if (groups == null && role == null) 30 return true; 31 else if (groups == null) 32 return false; 33 else 34 return groups.contains(role); 35 } 36 37 41 public boolean canLogin(Principal user, HttpServletRequest request) 42 { 43 return user != null; 44 } 45 } 46 | Popular Tags |