throw new RestException("Not a valid mode: " + mode, HttpStatus.UNPROCESSABLE_ENTITY); ruleDAO.setCatalogMode(modeValue); ruleDAO.storeRules();
@Override public void onSubmit() { try { DataAccessRuleDAO dao = DataAccessRuleDAO.get(); CatalogMode newMode = dao.getByAlias(catalogModeChoice.getValue()); dao.setCatalogMode(newMode); dao.storeRules(); doReturn(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Error occurred while saving user", e); error(new ParamResourceModel("saveError", getPage(), e.getMessage())); } } });
@Override public void onSubmit() { try { DataAccessRuleDAO dao = DataAccessRuleDAO.get(); CatalogMode newMode = dao.getByAlias(catalogModeChoice.getValue()); dao.setCatalogMode(newMode); dao.storeRules(); doReturn(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Error occurred while saving user", e); error(new ParamResourceModel("saveError", getPage(), e.getMessage())); } } });
@Override public void onSubmit() { try { DataAccessRuleDAO dao = DataAccessRuleDAO.get(); CatalogMode newMode = dao.getByAlias(catalogModeChoice.getValue()); dao.setCatalogMode(newMode); dao.storeRules(); doReturn(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Error occurred while saving user", e); error(new ParamResourceModel("saveError", getPage(), e.getMessage())); } } });
@Override public void onSubmit() { try { DataAccessRuleDAO dao = DataAccessRuleDAO.get(); CatalogMode newMode = dao.getByAlias(catalogModeChoice.getValue()); dao.setCatalogMode(newMode); dao.storeRules(); doReturn(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Error occurred while saving user", e); error(new ParamResourceModel("saveError", getPage(), e.getMessage())); } } });
@Override public void onSubmit() { try { DataAccessRuleDAO dao = DataAccessRuleDAO.get(); CatalogMode newMode = dao.getByAlias(catalogModeChoice.getValue()); dao.setCatalogMode(newMode); dao.storeRules(); doReturn(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Error occurred while saving user", e); error(new ParamResourceModel("saveError", getPage(), e.getMessage())); } } });
@Override public void onSubmit() { try { DataAccessRuleDAO dao = DataAccessRuleDAO.get(); CatalogMode newMode = dao.getByAlias(catalogModeChoice.getValue()); dao.setCatalogMode(newMode); dao.storeRules(); doReturn(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Error occurred while saving user", e); error(new ParamResourceModel("saveError", getPage(), e.getMessage())); } } });
@Test public void testInvalidAuthChallenge() throws Exception { DataAccessRuleDAO dao = GeoServerExtensions.bean(DataAccessRuleDAO.class, applicationContext); dao.setCatalogMode(CatalogMode.CHALLENGE); MockHttpServletRequest request = createRequest( "wfs?request=GetFeature&version=1.0.0&service=wfs&typeName=" + getLayerId(SystemTestData.BUILDINGS)); request.addHeader( "Authorization", "Basic " + new String(Base64.encodeBase64("cite:wrongpassword".getBytes()))); MockHttpServletResponse resp = dispatch(request); assertEquals(401, resp.getStatus()); assertEquals("Basic realm=\"GeoServer Realm\"", resp.getHeader("WWW-Authenticate")); }
private void checkValidAuth(String username, String password) throws Exception, ParserConfigurationException, SAXException, IOException, XpathException { DataAccessRuleDAO dao = GeoServerExtensions.bean(DataAccessRuleDAO.class, applicationContext); dao.setCatalogMode(CatalogMode.CHALLENGE); setRequestAuth(username, password); Document doc = getAsDOM( "wfs?request=GetFeature&version=1.0.0&service=wfs&typeName=" + getLayerId(SystemTestData.BUILDINGS)); // print(doc); assertXpathEvaluatesTo("1", "count(/wfs:FeatureCollection)", doc); } }
@Test public void testGetNoAuthHide() throws Exception { DataAccessRuleDAO dao = GeoServerExtensions.bean(DataAccessRuleDAO.class, applicationContext); dao.setCatalogMode(CatalogMode.HIDE); // no auth, hide mode, we should get an error stating the layer is not there Document doc = getAsDOM( "wfs?request=GetFeature&version=1.1.0&service=wfs&typeName=" + getLayerId(SystemTestData.BUILDINGS)); // print(doc); checkOws10Exception(doc); assertXpathEvaluatesTo("Unknown namespace [cite]", "//ows:ExceptionText/text()", doc); }
@Test public void testGetNoAuthChallenge() throws Exception { DataAccessRuleDAO dao = GeoServerExtensions.bean(DataAccessRuleDAO.class, applicationContext); dao.setCatalogMode(CatalogMode.CHALLENGE); // this test seems to fail on the build server without storing the rules... dao.storeRules(); MockHttpServletResponse resp = getAsServletResponse( "wfs?request=GetFeature&version=1.0.0&service=wfs&typeName=" + getLayerId(SystemTestData.BUILDINGS)); assertEquals(401, resp.getStatus()); assertEquals("Basic realm=\"GeoServer Realm\"", resp.getHeader("WWW-Authenticate")); }