public GeoServerUser(GeoServerUser other) { this.username = other.getUsername(); this.password = other.getPassword(); this.accountNonExpired = other.isAccountNonExpired(); this.accountNonLocked = other.isAccountNonLocked(); this.credentialsNonExpired = other.isCredentialsNonExpired(); this.authorities = other.getAuthorities() != null ? new ArrayList<GrantedAuthority>(other.getAuthorities()) : null; }
protected Authentication createAuthentication(HttpServletRequest request) { GeoServerUser anonymous = GeoServerUser.createAnonymous(); List<GrantedAuthority> roles = new ArrayList<GrantedAuthority>(); roles.addAll(anonymous.getAuthorities()); AnonymousAuthenticationToken auth = new AnonymousAuthenticationToken("geoserver", anonymous.getUsername(), roles); auth.setDetails(authenticationDetailsSource.buildDetails(request)); return auth; }
UserDetails prepareForUser(GeoServerUser user) { char[] pw = null; try { pw = enc.decodeToCharArray(user.getPassword()); } catch (UnsupportedOperationException ex) { pw = user.getPassword().toCharArray(); } String a1 = encodePasswordInA1Format(user.getUsername(), GeoServerSecurityManager.REALM, pw); manager.disposePassword(pw); List<GrantedAuthority> roles = new ArrayList<GrantedAuthority>(); roles.addAll(user.getAuthorities()); roles.add(GeoServerRole.AUTHENTICATED_ROLE); return new DigestUserDetails(user, a1, roles); }
assertNotNull(roleService.getRoleByName("ROLE_SERVICE_2")); assertEquals(2, admin.getAuthorities().size()); assertTrue(admin.getAuthorities().contains(role_admin)); assertTrue(admin.getAuthorities().contains(GeoServerRole.ADMIN_ROLE)); assertEquals(2, wfs.getAuthorities().size()); assertTrue(wfs.getAuthorities().contains(role_wfs_read)); assertTrue(wfs.getAuthorities().contains(role_wfs_write)); assertEquals(1, disabledUser.getAuthorities().size()); assertTrue(disabledUser.getAuthorities().contains(role_test));
assertEquals(user.getUsername(), "user1"); assertNotNull(user.getAuthorities()); assertEquals(2, user.getAuthorities().size()); assertTrue(user.getAuthorities().contains(new GeoServerRole("ROLE_MYROLE_1"))); assertTrue(user.getAuthorities().contains(new GeoServerRole("ROLE_MYROLE_2")));