public int compareTo(GeoServerUser o) { if (o == null) return 1; return getUsername().compareTo(o.getUsername()); }
Element user = doc.createElement(E_USER_UR); users.appendChild(user); user.setAttribute(A_USER_NAME_UR, userObject.getUsername()); if (userObject.getPassword() != null) { user.setAttribute(A_USER_PASSWORD_UR, userObject.getPassword()); user.setAttribute(A_USER_ENABLED_UR, String.valueOf(userObject.isEnabled())); for (Object key : userObject.getProperties().keySet()) { Element property = doc.createElement(E_PROPERTY_UR); user.appendChild(property); property.setAttribute(A_PROPERTY_NAME_UR, key.toString()); property.setTextContent(userObject.getProperties().getProperty(key.toString())); Element member = doc.createElement(E_MEMBER_UR); group.appendChild(member); member.setAttribute(A_MEMBER_NAME_UR, userObject.getUsername());
public GeoServerUser createUserObject(String username, String password, boolean isEnabled) throws IOException { GeoServerUser user = new GeoServerUser(username); user.setEnabled(isEnabled); user.setPassword(password); return user; }
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; }
public static GeoServerUser createAnonymous() { GeoServerUser anon = new GeoServerUser(GeoServerUser.ANONYMOUS_USERNAME); anon.setPassword(null); anon.setEnabled(true); Set<GrantedAuthority> roles = new HashSet<GrantedAuthority>(); roles.add(GeoServerRole.ANONYMOUS_ROLE); anon.setAuthorities(roles); return anon; }
new Model(user.getPassword())) { @Override public boolean isRequired() { try { roles = new ArrayList( getSecurityManager().getActiveRoleService().getRolesForUser(user.getUsername())); } catch (IOException e) { throw new WicketRuntimeException(e); List<GeoServerUserGroup> adminGroups = new ArrayList(); if (isGroupAdmin) { for (String groupName : GroupAdminProperty.get(user.getProperties())) { try { adminGroups.add(ugService.getGroupByGroupname(groupName));
/** * Takes the role set for a user and personalizes the roles (matching user properties and role * parameters) * * @param user * @param roles * @throws IOException */ public SortedSet<GeoServerRole> personalizeRoles( GeoServerUser user, Collection<GeoServerRole> roles) throws IOException { SortedSet<GeoServerRole> set = new TreeSet<GeoServerRole>(); for (GeoServerRole role : roles) { Properties personalizedProps = getRoleService() .personalizeRoleParams( role.getAuthority(), role.getProperties(), user.getUsername(), user.getProperties()); if (personalizedProps == null) { set.add(role); } else { // create personalized role GeoServerRole pRole = getRoleService().createRoleObject(role.getAuthority()); pRole.setUserName(user.getUsername()); for (Object key : personalizedProps.keySet()) pRole.getProperties().put(key, personalizedProps.get(key)); set.add(pRole); } } return set; } }
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); }
protected void addUserToPropertyMap(GeoServerUser user) { for (Object key : user.getProperties().keySet()) { SortedSet<GeoServerUser> users = helper.propertyMap.get(key); if (users == null) { users = new TreeSet<GeoServerUser>(); helper.propertyMap.put((String) key, users); } users.add(user); } }
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")); }
roleStore.associateRoleToUser(GeoServerRole.ADMIN_ROLE, sa.getUsername()); roleStore.store(); getSecurityManager().setActiveRoleService(roleService); sa.setEnabled(false); ugStore.updateUser(sa); ugStore.store();
new GeoServerMultiplexingPasswordEncoder(store.getSecurityManager(), store); for (GeoServerUser user : store.getUsers()) { if (encoder.isResponsibleForEncoding(user.getPassword())) continue; // nothing to do try { String rawpass = mEncoder.decode(user.getPassword()); user.setPassword(encPass); try { store.updateUser(user); LOGGER.warning( "Cannot recode user: " + user.getUsername() + " with password: " + user.getPassword());
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); }
public GeoServerUser copy() { return new GeoServerUser(this); }
public void modifyValues(GeoServerUserGroupStore userGroupStore) throws Exception { GeoServerUser disableduser = userGroupStore.getUserByUsername("disableduser"); disableduser.setEnabled(true); disableduser.setPassword("hallo"); disableduser.getProperties().put("lastname", "miller"); userGroupStore.updateUser(disableduser); GeoServerUser user2 = userGroupStore.getUserByUsername("user2"); user2.getProperties().remove("mail"); user2.getProperties().put("tel", "11-22-33"); userGroupStore.updateUser(user2); GeoServerUserGroup disabledgroup = userGroupStore.getGroupByGroupname("disabledgroup"); disabledgroup.setEnabled(true); userGroupStore.updateGroup(disabledgroup); GeoServerUserGroup group1 = userGroupStore.getGroupByGroupname("group1"); userGroupStore.disAssociateUserFromGroup(user2, group1); }
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; }
public JaxbUser(GeoServerUser user) { this.userName = user.getUsername(); this.enabled = new Boolean(user.isEnabled()); }
new UserGroupStoreValidationWrapper(ugService.createStore()); user.setPassword(newpass); ugStore.updateUser(user); ugService.load(); LOGGER.log(Level.INFO, "Changed password for user {0}", user.getUsername());
@Override public GeoServerUser createUserObject(String username, String password, boolean isEnabled) throws IOException { GeoServerUser user = new MemoryGeoserverUser(username, this); user.setEnabled(isEnabled); user.setPassword(password); return user; }
/** * validates and encodes the password. Do nothing for a not changed password of an existing user * * @param user * @throws IOException */ protected void preparePassword(GeoServerUser user) throws IOException, PasswordPolicyException { char[] passwordArray = user.getPassword() != null ? user.getPassword().toCharArray() : null; if (PasswordValidatorImpl.passwordStartsWithEncoderPrefix(passwordArray) != null) return; // do nothing, password already encoded // we have a plain text password // validate it getSecurityManager() .loadPasswordValidator(getPasswordValidatorName()) .validatePassword(passwordArray); // validation ok, initializer encoder and set encoded password GeoServerPasswordEncoder enc = getSecurityManager().loadPasswordEncoder(getPasswordEncoderName()); enc.initializeFor(this); user.setPassword(enc.encodePassword(user.getPassword(), null)); }