user.setAttribute(A_USER_PASSWORD_UR, userObject.getPassword()); user.setAttribute(A_USER_ENABLED_UR, String.valueOf(userObject.isEnabled()));
@Override protected String getPreAuthenticatedPrincipal(HttpServletRequest request) { // avoid retrieving the user name more than once if (request.getAttribute(UserNameAlreadyRetrieved) != null) return (String) request.getAttribute(UserName); String principal = getPreAuthenticatedPrincipalName(request); if (principal != null && principal.trim().length() == 0) principal = null; try { if (principal != null && PreAuthenticatedUserNameRoleSource.UserGroupService.equals( getRoleSource())) { GeoServerUserGroupService service = getSecurityManager().loadUserGroupService(getUserGroupServiceName()); GeoServerUser u = service.getUserByUsername(principal); if (u != null && u.isEnabled() == false) { principal = null; handleDisabledUser(u, request); } } } catch (IOException ex) { throw new RuntimeException(ex); } request.setAttribute(UserNameAlreadyRetrieved, Boolean.TRUE); if (principal != null) request.setAttribute(UserName, principal); return principal; }
store.createUserObject(user.getUsername(), encPassword, user.isEnabled()); for (Object key : user.getProperties().keySet()) { newUser.getProperties().put(key, user.getProperties().get(key));
protected void checkValuesModified(GeoServerUserGroupService userGroupService) throws IOException { GeoServerUser disableduser = userGroupService.getUserByUsername("disableduser"); assertTrue(disableduser.isEnabled()); GeoServerMultiplexingPasswordEncoder encoder = getEncoder(userGroupService); assertTrue(encoder.isPasswordValid(disableduser.getPassword(), "hallo", null)); assertEquals(1, disableduser.getProperties().size()); assertEquals("miller", disableduser.getProperties().getProperty("lastname")); GeoServerUser user2 = userGroupService.getUserByUsername("user2"); assertEquals(1, user2.getProperties().size()); assertEquals("11-22-33", user2.getProperties().getProperty("tel")); GeoServerUserGroup disabledgroup = userGroupService.getGroupByGroupname("disabledgroup"); assertTrue(disabledgroup.isEnabled()); GeoServerUserGroup group1 = userGroupService.getGroupByGroupname("group1"); GeoServerUser user1 = userGroupService.getUserByUsername("user1"); assertEquals(1, userGroupService.getUsersForGroup(group1).size()); assertTrue(userGroupService.getUsersForGroup(group1).contains(user1)); assertEquals(0, userGroupService.getGroupsForUser(user2).size()); assertEquals(0, userGroupService.getUsersHavingProperty("mail").size()); assertEquals(0, userGroupService.getUsersHavingPropertyValue("tel", "12-34-38").size()); assertEquals(1, userGroupService.getUsersHavingPropertyValue("tel", "11-22-33").size()); user2 = userGroupService.getUsersHavingPropertyValue("tel", "11-22-33").first(); assertEquals("11-22-33", user2.getProperties().getProperty("tel")); }
public JaxbUser(GeoServerUser user) { this.userName = user.getUsername(); this.enabled = new Boolean(user.isEnabled()); }
public void updateUser(GeoServerUser user) throws IOException,PasswordPolicyException { preparePassword(user); Connection con = null; PreparedStatement ps = null; try { con = getConnection(); ps = getDMLStatement("users.update", con); ps.setString(1,user.getPassword()); ps.setString(2,convertToString(user.isEnabled())); ps.setString(3,user.getUsername()); ps.execute(); ps.close(); ps = getDMLStatement("userprops.deleteForUser",con); ps.setString(1,user.getUsername()); ps.execute(); addUserProperties(user, con); } catch (SQLException ex) { throw new IOException(ex); } finally { closeFinally(con, ps, null); } setModified(true); }
public void addUser(GeoServerUser user) throws IOException, PasswordPolicyException { preparePassword(user); Connection con = null; PreparedStatement ps = null; try { con = getConnection(); ps = getDMLStatement("users.insert", con); ps.setString(1,user.getUsername()); if (user.getPassword() != null) { ps.setString(2,user.getPassword()); } else { ps.setNull(2, Types.VARCHAR); } ps.setString(3,convertToString(user.isEnabled())); ps.execute(); addUserProperties(user, con); } catch (SQLException ex) { throw new IOException(ex); } finally { closeFinally(con, ps, null); } setModified(true); }
getSecurityManager().loadUserGroupService(getUserGroupServiceName()); GeoServerUser u = service.getUserByUsername(principal); if (u != null && u.isEnabled() == false) { principal = null; handleDisabledUser(u, req);
@Test public void testDefault() throws Exception { GeoServerUserGroupService service = getSecurityManager().loadUserGroupService(XMLUserGroupService.DEFAULT_NAME); assertEquals(1, service.getUsers().size()); assertEquals(1, service.getUserCount()); assertEquals(0, service.getUserGroups().size()); assertEquals(0, service.getGroupCount()); GeoServerUser admin = service.getUserByUsername(GeoServerUser.ADMIN_USERNAME); assertNotNull(admin); assertEquals(GeoServerUser.AdminEnabled, admin.isEnabled()); GeoServerMultiplexingPasswordEncoder enc = getEncoder(service); assertTrue( enc.isPasswordValid(admin.getPassword(), GeoServerUser.DEFAULT_ADMIN_PASSWD, null)); assertEquals(admin.getProperties().size(), 0); assertEquals(0, service.getGroupsForUser(admin).size()); }