public int compareTo(GeoServerUser o) { if (o == null) return 1; return getUsername().compareTo(o.getUsername()); }
protected void checkUser(GeoServerUser user) throws IOException { if (helper.userMap.containsKey(user.getUsername()) == false) throw new IOException("User: " + user.getUsername() + " does not exist"); }
public void addUser(GeoServerUser user) throws IOException, PasswordPolicyException { if (helper.userMap.containsKey(user.getUsername())) throw new IllegalArgumentException( "The user " + user.getUsername() + " already exists"); preparePassword(user); helper.userMap.put(user.getUsername(), user); addUserToPropertyMap(user); setModified(true); }
public void updateUser(GeoServerUser user) throws IOException, PasswordPolicyException { if (helper.userMap.containsKey(user.getUsername()) == false) { throw new IllegalArgumentException( "The user " + user.getUsername() + " does not exist"); } preparePassword(user); helper.userMap.put(user.getUsername(), user); removeUserFromPropertyMap(user); addUserToPropertyMap(user); setModified(true); }
public SortedSet<GeoServerUserGroup> getGroupsForUser(GeoServerUser user) throws IOException { checkExistingUserName(user.getUsername()); return service.getGroupsForUser(user); }
public boolean removeUser(GeoServerUser user) throws IOException { Collection<GeoServerUserGroup> groups = helper.user_groupMap.get(user); if (groups != null) { Collection<GeoServerUserGroup> toBeRemoved = new ArrayList<GeoServerUserGroup>(); toBeRemoved.addAll(groups); for (GeoServerUserGroup group : toBeRemoved) { disAssociateUserFromGroup(user, group); } } boolean retValue = helper.userMap.remove(user.getUsername()) != null; if (retValue) { setModified(true); removeUserFromPropertyMap(user); } return retValue; }
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 void addUser(GeoServerUser user) throws IOException, PasswordPolicyException { checkNotExistingUserName(user.getUsername()); getStore().addUser(user); }
public void updateUser(GeoServerUser user) throws IOException, PasswordPolicyException { checkExistingUserName(user.getUsername()); getStore().updateUser(user); }
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()); Element member = doc.createElement(E_MEMBER_UR); group.appendChild(member); member.setAttribute(A_MEMBER_NAME_UR, userObject.getUsername());
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); }
/** * 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 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; }
helper.userMap.put(user.getUsername(), user);
public void associateUserToGroup(GeoServerUser user, GeoServerUserGroup group) throws IOException { checkExistingUserName(user.getUsername()); checkExistingGroupName(group.getGroupname()); getStore().associateUserToGroup(user, group); }
public void disAssociateUserFromGroup(GeoServerUser user, GeoServerUserGroup group) throws IOException { checkExistingUserName(user.getUsername()); checkExistingGroupName(group.getGroupname()); getStore().disAssociateUserFromGroup(user, group); }
LOGGER.warning( "Cannot recode user: " + user.getUsername() + " password: " + user.getPassword()); store.createUserObject(user.getUsername(), encPassword, user.isEnabled()); for (Object key : user.getProperties().keySet()) { newUser.getProperties().put(key, user.getProperties().get(key)); newUserDict.put(newUser.getUsername(), newUser); GeoServerUser newUser = newUserDict.get(member.getUsername()); store.associateUserToGroup(newUser, newGroup);
set1.addAll(getRoleService().getRolesForUser(user.getUsername())); addInheritedRoles(set1);
LOGGER.warning( "Cannot recode user: " + user.getUsername() + " with password: " + user.getPassword());
if (user2.getUsername().equals(user.getUsername())) { assertEquals(2, user.getProperties().size()); assertEquals(user.getProperties().getProperty("mail"), "user2@gmx.com"); if (user2.getUsername().equals(user.getUsername())) { assertEquals(2, user.getProperties().size()); assertEquals(user.getProperties().getProperty("mail"), "user2@gmx.com"); if (user2.getUsername().equals(user.getUsername())) { assertEquals(2, user.getProperties().size()); assertEquals(user.getProperties().getProperty("mail"), "user2@gmx.com");