@Test public void addUserPrivilegesToSession() { String roleAdd = "ROLE_ADD"; String privilege = "privilege"; Map<String, Boolean> privilegeMap = new HashMap<>(); privilegeMap.put(privilege, Boolean.TRUE); List<String> privilegeList = Arrays.asList(privilege); AcmGrantedAuthority authority = new AcmGrantedAuthority(roleAdd); expect((List<AcmGrantedAuthority>) mockAuthentication.getAuthorities()).andReturn(Arrays.asList(authority)).atLeastOnce(); expect(mockPluginManager.getPrivilegesForRole(roleAdd)).andReturn(privilegeList); expect(mockRequest.getSession(true)).andReturn(mockSession); mockSession.setAttribute("acm_privileges", privilegeMap); replayAll(); unit.addPrivilegesToSession(mockRequest, mockAuthentication); verifyAll(); }
protected void addPrivilegesToSession(HttpServletRequest request, Authentication authentication) { List<String> allPrivileges = new ArrayList<>(); if (authentication.getAuthorities() != null) { for (GrantedAuthority authority : authentication.getAuthorities()) { List<String> privileges = getAcmPluginManager().getPrivilegesForRole(authority.getAuthority()); allPrivileges.addAll(privileges); } } Map<String, Boolean> privilegeMap = new HashMap<>(); for (String privilege : allPrivileges) { privilegeMap.put(privilege, Boolean.TRUE); } HttpSession session = request.getSession(true); session.setAttribute("acm_privileges", privilegeMap); log.debug("Added {} privileges to user session.", privilegeMap.size()); }
AcmLoginSuccessOperations { protected void addPrivilegesToSession(HttpServletRequest request, Authentication authentication) { List<String> allPrivileges = new ArrayList<>(); if (authentication.getAuthorities() != null) { for (GrantedAuthority authority : authentication.getAuthorities()) { List<String> privileges = getAcmPluginManager().getPrivilegesForRole(authority.getAuthority()); allPrivileges.addAll(privileges); } } Map<String, Boolean> privilegeMap = new HashMap<>(); for (String privilege : allPrivileges) { privilegeMap.put(privilege, Boolean.TRUE); } HttpSession session = request.getSession(true); session.setAttribute("acm_privileges", privilegeMap); log.debug("Added {} privileges to user session.", privilegeMap.size()); } }
AcmLoginSuccessOperations { protected void addPrivilegesToSession(HttpServletRequest request, Authentication authentication) { List<String> allPrivileges = new ArrayList<>(); if (authentication.getAuthorities() != null) { for (GrantedAuthority authority : authentication.getAuthorities()) { List<String> privileges = getAcmPluginManager().getPrivilegesForRole(authority.getAuthority()); allPrivileges.addAll(privileges); } } Map<String, Boolean> privilegeMap = new HashMap<>(); for (String privilege : allPrivileges) { privilegeMap.put(privilege, Boolean.TRUE); } HttpSession session = request.getSession(true); session.setAttribute("acm_privileges", privilegeMap); log.debug("Added {} privileges to user session.", privilegeMap.size()); }  }
AcmLoginSuccessOperations { protected void addPrivilegesToSession(HttpServletRequest request, Authentication authentication) { List<String> allPrivileges = new ArrayList<>(); if (authentication.getAuthorities() != null) { for (GrantedAuthority authority : authentication.getAuthorities()) { List<String> privileges = getAcmPluginManager().getPrivilegesForRole(authority.getAuthority()); allPrivileges.addAll(privileges); } } Map<String, Boolean> privilegeMap = new HashMap<>(); for (String privilege : allPrivileges) { privilegeMap.put(privilege, Boolean.TRUE); } HttpSession session = request.getSession(true); session.setAttribute("acm_privileges", privilegeMap); log.debug("Added {} privileges to user session.", privilegeMap.size()); }  void onSuccessfulAuthentication(HttpServletRequest request, Authentication authentication); AcmPluginManager getAcmPluginManager(); void setAcmPluginManager(AcmPluginManager acmPluginManager); AcmApplication getAcmApplication(); void setAcmApplication(AcmApplication acmApplication); UserDao getUserDao(); void setUserDao(UserDao userDao); AuditPropertyEntityAdapter getAuditPropertyEntityAdapter(); void setAuditPropertyEntityAdapter(AuditPropertyEntityAdapter auditPropertyEntityAdapter); ObjectConverter getObjectConverter(); void setObjectConverter(ObjectConverter objectConverter); }
AcmLoginSuccessOperations { protected void addPrivilegesToSession(HttpServletRequest request, Authentication authentication) { List<String> allPrivileges = new ArrayList<>(); if (authentication.getAuthorities() != null) { for (GrantedAuthority authority : authentication.getAuthorities()) { List<String> privileges = getAcmPluginManager().getPrivilegesForRole(authority.getAuthority()); allPrivileges.addAll(privileges); } } Map<String, Boolean> privilegeMap = new HashMap<>(); for (String privilege : allPrivileges) { privilegeMap.put(privilege, Boolean.TRUE); } HttpSession session = request.getSession(true); session.setAttribute("acm_privileges", privilegeMap); log.debug("Added {} privileges to user session.", privilegeMap.size()); }  void onSuccessfulAuthentication(HttpServletRequest request, Authentication authentication); AcmPluginManager getAcmPluginManager(); void setAcmPluginManager(AcmPluginManager acmPluginManager); AcmApplication getAcmApplication(); void setAcmApplication(AcmApplication acmApplication); UserDao getUserDao(); void setUserDao(UserDao userDao); AuditPropertyEntityAdapter getAuditPropertyEntityAdapter(); void setAuditPropertyEntityAdapter(AuditPropertyEntityAdapter auditPropertyEntityAdapter); ObjectConverter getObjectConverter(); void setObjectConverter(ObjectConverter objectConverter);  }