Package org.geoserver.security.impl

Examples of org.geoserver.security.impl.GeoServerUser


            while (rs.next()) {               
                String username = rs.getString(1);
                String password = rs.getString(2);
                String enabledString = rs.getString(3);
                boolean isEnabled= convertFromString(enabledString);
                GeoServerUser u = createUserObject(username,password, isEnabled);               
                map.put(username,u);        
               
            }
            rs.close();
            ps.close();
           
            ps = getDMLStatement("userprops.userPropsForGroup",con);
            ps.setString(1, group.getGroupname());
            rs = ps.executeQuery();
            while (rs.next()) {
                String userName = rs.getString(1);               
                String propName = rs.getString(2);
                Object propValue = rs.getObject(3);
                GeoServerUser u = map.get(userName);
                if (u!=null) {
                    u.getProperties().put(propName, propValue==null ? "" : propValue);
                }
            }                               

        } catch (SQLException ex) {
            throw new IOException(ex);
View Full Code Here


     * @see org.springframework.security.core.userdetails.UserDetailsService#loadUserByUsername(java.lang.String)
     */
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException,
            DataAccessException {
        GeoServerUser user=null;
        try {
            user = getUserByUsername(username);           
            if (user==null)
                throw new UsernameNotFoundException(userNotFoundMessage(username));
            RoleCalculator calculator = new RoleCalculator(this,
                    getSecurityManager().getActiveRoleService());
            user.setAuthorities(calculator.calculateRoles(user));
        } catch (IOException e) {
            throw new UsernameNotFoundException(userNotFoundMessage(username),e);
        }       
        return user;
    }
View Full Code Here

        chain.doFilter(req, res);
    }


    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;
    }
View Full Code Here

            while (rs.next()) {               
                String username = rs.getString(1);
                String password = rs.getString(2);
                String enabledString = rs.getString(3);
                boolean isEnabled= convertFromString(enabledString);
                GeoServerUser u = createUserObject(username,password, isEnabled);               
                map.put(username, u);
            }
           
            ps.close();
            rs.close();
           
            ps = getDMLStatement("userprops.usersHavingProperty",con);
            ps.setString(1, propname);
            rs = ps.executeQuery();
            while (rs.next()) {   
                String useName = rs.getString(1);
                String propName = rs.getString(2);
                Object propValue = rs.getString(3);
                GeoServerUser u = map.get(useName);
                if (u!=null) {
                    u.getProperties().put(propName, propValue==null ? "" : propValue);
                }
            }
        } catch (SQLException ex) {
            throw new IOException(ex);
        } finally {
View Full Code Here

            while (rs.next()) {               
                String username = rs.getString(1);
                String password = rs.getString(2);
                String enabledString = rs.getString(3);
                boolean isEnabled= convertFromString(enabledString);
                GeoServerUser u = createUserObject(username,password, isEnabled);               
                map.put(username, u);
            }
           
            ps.close();
            rs.close();
           
            ps = getDMLStatement("userprops.usersNotHavingProperty",con);
            ps.setString(1, propname);
            rs = ps.executeQuery();
            while (rs.next()) {   
                String useName = rs.getString(1);
                String propName = rs.getString(2);
                Object propValue = rs.getString(3);
                GeoServerUser u = map.get(useName);
                if (u!=null) {
                    u.getProperties().put(propName, propValue==null ? "" : propValue);
                }
            }
        } catch (SQLException ex) {
            throw new IOException(ex);
        } finally {
View Full Code Here

            while (rs.next()) {               
                String username = rs.getString(1);
                String password = rs.getString(2);
                String enabledString = rs.getString(3);
                boolean isEnabled= convertFromString(enabledString);
                GeoServerUser u = createUserObject(username,password, isEnabled);               
                map.put(username, u);
            }
           
            ps.close();
            rs.close();
           
            ps = getDMLStatement("userprops.usersHavingPropertyValue",con);
            ps.setString(1, propname);
            ps.setString(2,propvalue);
            rs = ps.executeQuery();
            while (rs.next()) {   
                String useName = rs.getString(1);
                String propName = rs.getString(2);
                Object propValue = rs.getString(3);
                GeoServerUser u = map.get(useName);
                if (u!=null) {
                    u.getProperties().put(propName, propValue==null ? "" : propValue);
                }
            }
        } catch (SQLException ex) {
            throw new IOException(ex);
        } finally {
View Full Code Here

            DataAccessException {
       
        if (GeoServerUser.ROOT_USERNAME.equals(username))
            return prepareForRootUser ();
       
        GeoServerUser user = (GeoServerUser) service.loadUserByUsername(username);           
        return prepareForUser(user);
    }
View Full Code Here

     *
     */
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException,
            DataAccessException {
        GeoServerUser user = (GeoServerUser) service.loadUserByUsername(username);
        if (user==null) return null;
        try {
            String decoded = encoder.decode(user.getPassword());
            return new UserDetailsPasswordWrapper(user, decoded);
        } catch (UnsupportedOperationException ex) {
            return new UserDetailsPasswordWrapper(user, user.getPassword());
        }
    }
View Full Code Here

        form.submit("save");

        tester.assertNoErrorMessage();
        tester.assertRenderedPage(SecurityNamedServiceEditPage.class);
       
        GeoServerUser user = ugService.getUserByUsername("testuser");
        assertNotNull(user);
        assertFalse(user.isEnabled());
       
        //assertEquals(1,user.getProperties().size());
        //assertEquals("10 10",user.getProperties().get("coord"));
        SortedSet<GeoServerUserGroup> groupList = ugService.getGroupsForUser(user);
        assertEquals(1,groupList.size());
View Full Code Here

       
        tester.assertErrorMessages(new String[0]);
        tester.assertRenderedPage(SecurityNamedServiceEditPage.class);
       
        GeoServerUser user = ugService.getUserByUsername("testuser");
        assertNotNull(user);
        assertTrue(user.isEnabled());
       
        SortedSet<GeoServerUserGroup> groupList = ugService.getGroupsForUser(user);
        assertEquals(0,groupList.size());
       
        SortedSet<GeoServerRole> roleList = gaService.getRolesForUser("testuser");
        assertEquals(1,roleList.size());
        assertTrue(roleList.contains(gaService.createRoleObject("ROLE_WMS")));

        user = (GeoServerUser) ugService.loadUserByUsername("testuser");
        assertEquals(2,user.getAuthorities().size());
        assertTrue(user.getAuthorities().contains(gaService.createRoleObject("ROLE_AUTHENTICATED")));
        assertTrue(user.getAuthorities().contains(gaService.createRoleObject("ROLE_WMS")));
       
    }
View Full Code Here

TOP

Related Classes of org.geoserver.security.impl.GeoServerUser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.