@Test public void testSessionEmails() throws Exception { buildWithEmailType(Arrays.asList("Work")); Map<String, Object> response = (Map<String, Object>) resource.sessionCheck(); assertEquals("Work@Work.com", response.get("email")); buildWithEmailType(Arrays.asList("Organization")); response = (Map<String, Object>) resource.sessionCheck(); assertEquals("Organization@Organization.com", response.get("email")); buildWithEmailType(Arrays.asList("Organization", "Work", "Other")); response = (Map<String, Object>) resource.sessionCheck(); assertEquals("Work@Work.com", response.get("email")); buildWithEmailType(Arrays.asList("Organization", "Other")); response = (Map<String, Object>) resource.sessionCheck(); assertEquals("Organization@Organization.com", response.get("email")); EntityBody body = new EntityBody(); body.put("name", new ArrayList<String>()); Entity e = Mockito.mock(Entity.class); Mockito.when(e.getBody()).thenReturn(body); injector.setCustomContext("MerpTest", "Merp Test", "IL", Arrays.asList(SecureRoleRightAccessImpl.EDUCATOR), e, "merpmerpmerp"); response = (Map<String, Object>) resource.sessionCheck(); assertNull(response.get("email")); }
@GET @Path("check") public Object sessionCheck() { final Map<String, Object> sessionDetails = new TreeMap<String, Object>(); if (isAuthenticated(SecurityContextHolder.getContext())) { sessionDetails.put("authenticated", true); SLIPrincipal principal = (SLIPrincipal) SecurityContextHolder.getContext().getAuthentication() .getPrincipal(); sessionDetails.put("user_id", principal.getId()); sessionDetails.put("full_name", principal.getName()); sessionDetails.put("granted_authorities", principal.getRoles()); sessionDetails.put("realm", principal.getRealm()); sessionDetails.put("edOrg", principal.getEdOrg()); sessionDetails.put("edOrgId", principal.getEdOrgId()); sessionDetails.put("sliRoles", principal.getRoles()); sessionDetails.put("tenantId", principal.getTenantId()); sessionDetails.put("external_id", principal.getExternalId()); sessionDetails.put("email", getUserEmail(principal)); sessionDetails.put("rights", SecurityContextHolder.getContext().getAuthentication().getAuthorities()); sessionDetails.put("selfRights", principal.getSelfRights()); sessionDetails.put("adminRealmAuthenticated", principal.isAdminRealmAuthenticated()); sessionDetails.put("isAdminUser", principal.isAdminUser()); sessionDetails.put("userType", principal.getEntity().getType()); sessionDetails.put("edOrgRoles", principal.getEdOrgRoles()); sessionDetails.put("edOrgRights", principal.getEdOrgRights()); if (principal.getFirstName() != null) { sessionDetails.put("first_name", principal.getFirstName()); } if (principal.getLastName() != null) { sessionDetails.put("last_name", principal.getLastName()); } if (principal.getVendor() != null) { sessionDetails.put("vendor", principal.getVendor()); } } else { sessionDetails.put("authenticated", false); sessionDetails.put("redirect_user", realmPage); } return sessionDetails; }
SecuritySessionResource { @GET @Path("check") public Object sessionCheck() { final Map<String, Object> sessionDetails = new TreeMap<String, Object>(); if (isAuthenticated(SecurityContextHolder.getContext())) { sessionDetails.put("authenticated", true); SLIPrincipal principal = (SLIPrincipal) SecurityContextHolder.getContext().getAuthentication() .getPrincipal(); sessionDetails.put("user_id", principal.getId()); sessionDetails.put("full_name", principal.getName()); sessionDetails.put("granted_authorities", principal.getRoles()); sessionDetails.put("realm", principal.getRealm()); sessionDetails.put("edOrg", principal.getEdOrg()); sessionDetails.put("edOrgId", principal.getEdOrgId()); sessionDetails.put("sliRoles", principal.getRoles()); sessionDetails.put("tenantId", principal.getTenantId()); sessionDetails.put("external_id", principal.getExternalId()); sessionDetails.put("email", getUserEmail(principal)); sessionDetails.put("rights", SecurityContextHolder.getContext().getAuthentication().getAuthorities()); sessionDetails.put("selfRights", principal.getSelfRights()); sessionDetails.put("adminRealmAuthenticated", principal.isAdminRealmAuthenticated()); sessionDetails.put("isAdminUser", principal.isAdminUser()); sessionDetails.put("userType", principal.getEntity().getType()); sessionDetails.put("edOrgRoles", principal.getEdOrgRoles()); sessionDetails.put("edOrgRights", principal.getEdOrgRights()); if (principal.getFirstName() != null) { sessionDetails.put("first_name", principal.getFirstName()); } if (principal.getLastName() != null) { sessionDetails.put("last_name", principal.getLastName()); } if (principal.getVendor() != null) { sessionDetails.put("vendor", principal.getVendor()); } } else { sessionDetails.put("authenticated", false); sessionDetails.put("redirect_user", realmPage); } return sessionDetails; } }
SecuritySessionResource { @GET @Path("check") public Object sessionCheck() { final Map<String, Object> sessionDetails = new TreeMap<String, Object>(); if (isAuthenticated(SecurityContextHolder.getContext())) { sessionDetails.put("authenticated", true); SLIPrincipal principal = (SLIPrincipal) SecurityContextHolder.getContext().getAuthentication() .getPrincipal(); sessionDetails.put("user_id", principal.getId()); sessionDetails.put("full_name", principal.getName()); sessionDetails.put("granted_authorities", principal.getRoles()); sessionDetails.put("realm", principal.getRealm()); sessionDetails.put("edOrg", principal.getEdOrg()); sessionDetails.put("edOrgId", principal.getEdOrgId()); sessionDetails.put("sliRoles", principal.getRoles()); sessionDetails.put("tenantId", principal.getTenantId()); sessionDetails.put("external_id", principal.getExternalId()); sessionDetails.put("email", getUserEmail(principal)); sessionDetails.put("rights", SecurityContextHolder.getContext().getAuthentication().getAuthorities()); sessionDetails.put("selfRights", principal.getSelfRights()); sessionDetails.put("adminRealmAuthenticated", principal.isAdminRealmAuthenticated()); sessionDetails.put("isAdminUser", principal.isAdminUser()); sessionDetails.put("userType", principal.getEntity().getType()); sessionDetails.put("edOrgRoles", principal.getEdOrgRoles()); sessionDetails.put("edOrgRights", principal.getEdOrgRights()); if (principal.getFirstName() != null) { sessionDetails.put("first_name", principal.getFirstName()); } if (principal.getLastName() != null) { sessionDetails.put("last_name", principal.getLastName()); } if (principal.getVendor() != null) { sessionDetails.put("vendor", principal.getVendor()); } } else { sessionDetails.put("authenticated", false); sessionDetails.put("redirect_user", realmPage); } return sessionDetails; }  }
SecuritySessionResource { @GET @Path("check") public Object sessionCheck() { final Map<String, Object> sessionDetails = new TreeMap<String, Object>(); if (isAuthenticated(SecurityContextHolder.getContext())) { sessionDetails.put("authenticated", true); SLIPrincipal principal = (SLIPrincipal) SecurityContextHolder.getContext().getAuthentication() .getPrincipal(); sessionDetails.put("user_id", principal.getId()); sessionDetails.put("full_name", principal.getName()); sessionDetails.put("granted_authorities", principal.getRoles()); sessionDetails.put("realm", principal.getRealm()); sessionDetails.put("edOrg", principal.getEdOrg()); sessionDetails.put("edOrgId", principal.getEdOrgId()); sessionDetails.put("sliRoles", principal.getRoles()); sessionDetails.put("tenantId", principal.getTenantId()); sessionDetails.put("external_id", principal.getExternalId()); sessionDetails.put("email", getUserEmail(principal)); sessionDetails.put("rights", SecurityContextHolder.getContext().getAuthentication().getAuthorities()); sessionDetails.put("selfRights", principal.getSelfRights()); sessionDetails.put("adminRealmAuthenticated", principal.isAdminRealmAuthenticated()); sessionDetails.put("isAdminUser", principal.isAdminUser()); sessionDetails.put("userType", principal.getEntity().getType()); sessionDetails.put("edOrgRoles", principal.getEdOrgRoles()); sessionDetails.put("edOrgRights", principal.getEdOrgRights()); if (principal.getFirstName() != null) { sessionDetails.put("first_name", principal.getFirstName()); } if (principal.getLastName() != null) { sessionDetails.put("last_name", principal.getLastName()); } if (principal.getVendor() != null) { sessionDetails.put("vendor", principal.getVendor()); } } else { sessionDetails.put("authenticated", false); sessionDetails.put("redirect_user", realmPage); } return sessionDetails; }  @GET @Path("logout") Map<String, Object> logoutUser(@Context HttpHeaders headers, @Context UriInfo uriInfo); @GET @Path("debug") SecurityContext sessionDebug(); @GET @Path("check") Object sessionCheck(); }
SecuritySessionResource { @GET @Path("check") public Object sessionCheck() { final Map<String, Object> sessionDetails = new TreeMap<String, Object>(); if (isAuthenticated(SecurityContextHolder.getContext())) { sessionDetails.put("authenticated", true); SLIPrincipal principal = (SLIPrincipal) SecurityContextHolder.getContext().getAuthentication() .getPrincipal(); sessionDetails.put("user_id", principal.getId()); sessionDetails.put("full_name", principal.getName()); sessionDetails.put("granted_authorities", principal.getRoles()); sessionDetails.put("realm", principal.getRealm()); sessionDetails.put("edOrg", principal.getEdOrg()); sessionDetails.put("edOrgId", principal.getEdOrgId()); sessionDetails.put("sliRoles", principal.getRoles()); sessionDetails.put("tenantId", principal.getTenantId()); sessionDetails.put("external_id", principal.getExternalId()); sessionDetails.put("email", getUserEmail(principal)); sessionDetails.put("rights", SecurityContextHolder.getContext().getAuthentication().getAuthorities()); sessionDetails.put("selfRights", principal.getSelfRights()); sessionDetails.put("adminRealmAuthenticated", principal.isAdminRealmAuthenticated()); sessionDetails.put("isAdminUser", principal.isAdminUser()); sessionDetails.put("userType", principal.getEntity().getType()); sessionDetails.put("edOrgRoles", principal.getEdOrgRoles()); sessionDetails.put("edOrgRights", principal.getEdOrgRights()); if (principal.getFirstName() != null) { sessionDetails.put("first_name", principal.getFirstName()); } if (principal.getLastName() != null) { sessionDetails.put("last_name", principal.getLastName()); } if (principal.getVendor() != null) { sessionDetails.put("vendor", principal.getVendor()); } } else { sessionDetails.put("authenticated", false); sessionDetails.put("redirect_user", realmPage); } return sessionDetails; }  @GET @Path("logout") Map<String, Object> logoutUser(@Context HttpHeaders headers, @Context UriInfo uriInfo); @GET @Path("debug") SecurityContext sessionDebug(); @GET @Path("check") Object sessionCheck();  }