Package org.geoserver.security.impl

Examples of org.geoserver.security.impl.ServiceAccessRule


*/
@SuppressWarnings("serial")
public class NewServiceAccessRulePage extends AbstractServiceAccessRulePage {

  public NewServiceAccessRulePage() {
    super(new ServiceAccessRule());
    form.add(new DuplicateRuleValidator());
  }
View Full Code Here


  @Override
  protected void onFormSubmit() {
    try {
      String roles = parseRole(rolesForComponent.getRolePalette()
          .getDefaultModelObjectAsString());
      ServiceAccessRule rule = new ServiceAccessRule((String) service
          .getConvertedInput(), (String) method
          .getConvertedInput(), roles);
      ServiceAccessRuleDAO dao = ServiceAccessRuleDAO.get();
      dao.addRule(rule);
      dao.storeRules();
View Full Code Here

   * @author aaime
   *
   */
  class DuplicateRuleValidator extends AbstractFormValidator {
    public void validate(Form form) {
      ServiceAccessRule rule = new ServiceAccessRule((String) service
          .getConvertedInput(), (String) method
          .getConvertedInput(), rolesForComponent.getRolePalette()
          .getDefaultModelObjectAsString());
      if (ServiceAccessRuleDAO.get().getRules().contains(rule)) {
        form.error(new ParamResourceModel("duplicateRule", getPage(),
            rule.getKey()).getString());
      }
    }
View Full Code Here

    RolesFormComponent rolesForComponent;

    Form form;

    public AbstractServiceAccessRulePage(ServiceAccessRule rule) {
        setDefaultModel(new CompoundPropertyModel(new ServiceAccessRule(rule)));

        // build the form
        form = new Form("ruleForm");
        add(form);
        form.add(service = new DropDownChoice("service", getServiceNames()));
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

    @Override
    protected void setUpInternal() throws Exception {
        dao = ServiceAccessRuleDAO.get();
        dao.getRules();
        rule = new ServiceAccessRule("wms", "GetMap", "ROLE_ADMINISTRATOR");
        dao.addRule(rule);
        login();
        tester.startPage(ServiceAccessRulePage.class);
    }
View Full Code Here

public class EditServiceAccessRulePage extends AbstractServiceAccessRulePage {
   
    ServiceAccessRule orig;
   
    public EditServiceAccessRulePage(ServiceAccessRule rule) {
        super(new ServiceAccessRule(rule));
       
        //save the original
        this.orig = rule;

        //set drop downs to disabled
View Full Code Here

*/
@SuppressWarnings("serial")
public class NewServiceAccessRulePage extends AbstractServiceAccessRulePage {

    public NewServiceAccessRulePage() {
        super(new ServiceAccessRule());
       
        ((Form)get("form")).add(new DuplicateRuleValidator());
    }
View Full Code Here

            if (form.findSubmittingButton() != form.get("save")) {
                return;
            }

            updateModels();
            ServiceAccessRule rule = (ServiceAccessRule) form.getModelObject();
            if (ServiceAccessRuleDAO.get().getRules().contains(rule)) {
                form.error(new ParamResourceModel("duplicateRule", getPage(), rule
                        .getKey()).getString());
            }
        }
View Full Code Here

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

        ServiceAccessRule foundRule=null;
        for (ServiceAccessRule rule : ServiceAccessRuleDAO.get().getRules()) {
            if ("wms".equals(rule.getService())&& "GetStyles".equals(rule.getMethod())) {
                foundRule = rule;
                break;
            }
        }
        assertNotNull(foundRule);
        assertEquals(1,foundRule.getRoles().size());
        assertEquals("ROLE_NEW",foundRule.getRoles().iterator().next());       
    }
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.