Package org.geoserver.security.impl

Examples of org.geoserver.security.impl.DataAccessRule


    }
   
    @Test
    public void testStoreEscapedDots() throws Exception {
        dao.clear();
        dao.addRule(new DataAccessRule("it.geosolutions", "layer.dots",
                AccessMode.READ, Collections.singleton("ROLE_ABC")));
        Properties ps = dao.toProperties();
       
        assertEquals(2, ps.size());
        assertEquals("ROLE_ABC", ps.getProperty("it\\.geosolutions.layer\\.dots.r"));
View Full Code Here


public class DataAccessRuleTest {

    @Test
    public void testEqualRoot() {
        DataAccessRule rule1 = new DataAccessRule("*", "*", AccessMode.READ);
        DataAccessRule rule2 = new DataAccessRule("*", "*", AccessMode.READ);
        assertEquals(0, rule1.compareTo(rule2));
        assertEquals(rule1, rule2);
        assertEquals(rule1.hashCode(), rule2.hashCode());
    }
View Full Code Here

        assertEquals(rule1.hashCode(), rule2.hashCode());
    }
   
    @Test
    public void testDifferentRoot() {
        DataAccessRule rule1 = new DataAccessRule("*", "*", AccessMode.READ);
        DataAccessRule rule2 = new DataAccessRule("*", "*", AccessMode.WRITE);
        assertEquals(-1, rule1.compareTo(rule2));
        assertFalse(rule1.equals(rule2));
    }
View Full Code Here

        assertFalse(rule1.equals(rule2));
    }
   
    @Test
    public void testDifferenPath() {
        DataAccessRule rule1 = new DataAccessRule("topp", "layer1", AccessMode.READ);
        DataAccessRule rule2 = new DataAccessRule("topp", "layer2", AccessMode.READ);
        assertEquals(-1, rule1.compareTo(rule2));
        assertFalse(rule1.equals(rule2));
    }
View Full Code Here

                GeoServerSecurityManager secMgr = createNiceMock(GeoServerSecurityManager.class);

                GeoServerRoleStore roleStore = createRoleStore("test", secMgr, "role1", "parent1");
                expect(roleStore.removeRole(new GeoServerRole("unused"))).andReturn(true);

                DataAccessRule dataAccessRule = createNiceMock(DataAccessRule.class);
                expect(dataAccessRule.compareTo(dataAccessRule)).andReturn(0).anyTimes();
                expect(dataAccessRule.getKey()).andReturn("foo").anyTimes();
                expect(dataAccessRule.getRoles()).andReturn(new TreeSet<String>(Arrays.asList("role1"))).anyTimes();
                replay(dataAccessRule);

                DataAccessRuleDAO dataAccessDAO = createNiceMock(DataAccessRuleDAO.class);
                expect(dataAccessDAO.getRulesAssociatedWithRole("role1")).andReturn(
                    new TreeSet<DataAccessRule>(Arrays.asList(dataAccessRule))).anyTimes();
View Full Code Here

        }
    }

    protected void addLayerAccessRule(String workspace, String layer, AccessMode mode, String... roles) throws IOException {
        DataAccessRuleDAO dao = DataAccessRuleDAO.get();
        DataAccessRule rule = new DataAccessRule();
        rule.setWorkspace(workspace);
        rule.setLayer(layer);
        rule.setAccessMode(mode);
        rule.getRoles().addAll(Arrays.asList(roles));
        dao.addRule(rule);
        dao.storeRules();
    }
View Full Code Here

        // build the submit/cancel
        form.add(new SubmitLink("save") {
            @Override
            public void onSubmit() {
                DataAccessRule rule = (DataAccessRule) getForm().getModelObject();
                if (rolesFormComponent.isHasAnyRole()) {
                    rule.getRoles().clear();
                    rule.getRoles().add(GeoServerRole.ANY_ROLE.getAuthority());
                }
                onFormSubmit(rule);
            }
        });
        form.add(new BookmarkablePageLink<DataAccessRule>("cancel", DataSecurityPage.class));
View Full Code Here

*/
@SuppressWarnings("serial")
public class NewDataAccessRulePage extends AbstractDataAccessRulePage {

    public NewDataAccessRulePage() {
        super(new DataAccessRule());

        ((Form)get("form")).add(new DuplicateRuleValidator());
    }
View Full Code Here

            if (form.findSubmittingButton() != form.get("save")) { // only validate on final submit
                return;
            }

            updateModels();
            DataAccessRule rule = (DataAccessRule) form.getModelObject();
            //DataAccessRule rule = new DataAccessRule(model.getWorkspace(),
            //        model.getLayer(),model.getAccessMode(),
             //       rolesFormComponent.getRolesNamesForStoring());
            if (DataAccessRuleDAO.get().getRules().contains(rule)) {
                form.error(new ParamResourceModel("duplicateRule", getPage(), rule.getKey())
                        .getString());
            }
        }
View Full Code Here

    DataAccessRule orig;

    public EditDataAccessRulePage(DataAccessRule rule) {
        //pass a clone into parent to avoid changing original
        super(new DataAccessRule(rule));

        //save original
        this.orig = rule;
    }
View Full Code Here

TOP

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

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.