Package org.geoserver.security.impl

Examples of org.geoserver.security.impl.ServiceAccessRule


    protected Page newPage(Object...params) {
        return new  NewServiceAccessRulePage();
    }
    protected Page editPage(Object...params) {
        if (params.length==0) {
            return new  EditServiceAccessRulePage( new ServiceAccessRule());
        }
        else
            return new  EditServiceAccessRulePage( (ServiceAccessRule) params[0]);
    }
View Full Code Here


        return null;
    }

    @Override
    protected String getRemoveableObjectRegExp() throws Exception {
        ServiceAccessRule rule = getRemoveableObject();
        return ".*"+rule.getService() + ".*" + rule.getMethod()
                +".*" + "ROLE_AUTHENTICATED"+".*";               
    }
View Full Code Here

        form.submit("save");
       
        tester.assertErrorMessages(new String[0]);
        tester.assertRenderedPage(ServiceAccessRulePage.class);

        ServiceAccessRule rule = getRule("wms.GetMap");
        assertNotNull(rule);
        assertEquals(1,rule.getRoles().size());
        assertEquals(GeoServerRole.ANY_ROLE,rule.getRoles().iterator().next());       
    }
View Full Code Here

        // find the best matching rule. Rules are sorted by specificity so any rule matching
        // last will be more specific than the ones matching earlier (e.g., wms.GetMap is moer
        // specific than just wms.* which is more specific than *.*)
        List<ServiceAccessRule> rules = dao.getRules();
        ServiceAccessRule bestMatch = null;
        for (ServiceAccessRule rule : rules) {
            if(rule.getService().equals(ServiceAccessRule.ANY) || rule.getService().equalsIgnoreCase(service)) {
                if(rule.getMethod().equals(ServiceAccessRule.ANY) || rule.getMethod().equalsIgnoreCase(method)) {
                    bestMatch = rule;
                }
            }
        }
       
        // if there is a matching rule apply it
        if(bestMatch != null) {
            Set<String> allowedRoles = bestMatch.getRoles();
            // if the rule is not the kind that allows everybody in check if the current
            // user is authenticated and has one of the required roles
            if(!allowedRoles.contains(ServiceAccessRule.ANY) && !allowedRoles.isEmpty()) {
                Authentication user = SecurityContextHolder.getContext().getAuthentication();
               
View Full Code Here

      }

      protected void initializeServiceRules() throws IOException {
          ServiceAccessRuleDAO dao = ServiceAccessRuleDAO.get();
          dao.getRules();
          dao.addRule(new ServiceAccessRule("wms", "GetMap", "ROLE_AUTHENTICATED"));                   
          dao.addRule(new ServiceAccessRule("wms", "*", "ROLE_WMS"));
          dao.addRule(new ServiceAccessRule("wfs", "GetFeature", "ROLE_AUTHENTICATED"));                   
          dao.addRule(new ServiceAccessRule("wfs", "*", "ROLE_WFS"));
          dao.addRule(new ServiceAccessRule("*", "*", GeoServerRole.ADMIN_ROLE.getAuthority()));
          dao.storeRules();
      }
View Full Code Here

    }
   
    public void testRemoveDataAccessRule() {
        Set<String> roles = new HashSet<String>();
        roles.add("*");
        setupPanel(new ServiceAccessRule("*","*",roles));
       
        // print(tester.getLastRenderedPage(), true, true);
       
        tester.assertRenderedPage(FormTestPage.class);
        tester.assertNoErrorMessage();
View Full Code Here

TOP

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

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.