protected void removeAllProfiles() throws NotFoundServiceEx { List<ShortGroup> list = userGroupAdminService.getList(null, null, null); for (ShortGroup item : list) { LOGGER.info("Removing " + item); boolean ret = userGroupAdminService.delete(item.getId()); if (!ret) throw new IllegalStateException("Group not removed"); } if (userGroupAdminService.getCount(null) != 0) throw new IllegalStateException("Groups have not been properly deleted"); }
public void afterPropertiesSet() throws Exception { /** * ********************************************************************* * * <p>WARNING, READ CAREFULLY BEFORE CHANGING ANYTHING IN THIS SETUP * * <p>This test setup is used for the ResorceAccessManager integration tests, which expect the * webtest to be running in Jetty with these exact contents. If you need to add more or modify * the contents please also make sure you're not breaking the build in those tests. If you * blinding modify the class and I find the tests got broken this is the destiny that awaits * you: http://en.wikipedia.org/wiki/Impalement * * <p>Signed: Andrea Vlad Dracul Aime * * <p>********************************************************************* */ LOGGER.info("===== RESETTING DB DATA ====="); removeAll(); LOGGER.info("===== Creating Profiles (not actually needed while testing GS) ====="); ShortGroup shortProfile = new ShortGroup(); shortProfile.setName("basic"); long pid1 = userGroupAdminService.insert(shortProfile); UserGroup p1 = userGroupAdminService.get(pid1); ShortGroup shortProfile2 = new ShortGroup(); shortProfile2.setName("advanced"); long pid2 = userGroupAdminService.insert(shortProfile2); UserGroup p2 = userGroupAdminService.get(pid2); LOGGER.info("===== Creating Users ====="); GSUser cite = createUser("cite"); cite.getGroups().add(p1); userAdminService.insert(cite); GSUser wmsUser = createUser("wmsuser"); wmsUser.getGroups().add(p1); userAdminService.insert(wmsUser); GSUser areaUser = createUser("area"); areaUser.getGroups().add(p1); userAdminService.insert(areaUser); GSUser uStates = createUser("u-states"); uStates.getGroups().add(p1); userAdminService.insert(uStates); LOGGER.info("===== Creating Rules ====="); LayerDetails ld1 = new LayerDetails(); ld1.getAllowedStyles().add("style1"); ld1.getAllowedStyles().add("style2"); ld1.getAttributes().add(new LayerAttribute("attr1", AccessType.NONE)); ld1.getAttributes().add(new LayerAttribute("attr2", AccessType.READONLY)); ld1.getAttributes().add(new LayerAttribute("attr3", AccessType.READWRITE)); int priority = 0; /* Cite user rules */ // allow user cite full control over the cite workspace ruleAdminService.insert( new Rule(priority++, cite, null, null, null, null, null, "cite", null, GrantType.ALLOW)); // allow only getmap, getcapatbilities and reflector usage on workspace sf ruleAdminService.insert( (new Rule( priority++, cite, null, null, null, "wms", "GetMap", "sf", null, GrantType.ALLOW))); ruleAdminService.insert( (new Rule( priority++, cite, null, null, null, "wms", "GetCapabilities", "sf", null, GrantType.ALLOW))); ruleAdminService.insert( (new Rule( priority++, cite, null, null, null, "wms", "reflect", "sf", null, GrantType.ALLOW))); // allow only GetMap and GetFeature the topp workspace /* wms user rules */ ruleAdminService.insert( (new Rule( priority++, wmsUser, null, null, null, "wms", null, null, null, GrantType.ALLOW))); /* all powerful but only in a restricted area */ Rule areaRestriction = new Rule(priority++, areaUser, null, null, null, null, null, null, null, GrantType.LIMIT); RuleLimits limits = new RuleLimits(); limits.setAllowedArea((MultiPolygon) new WKTReader().read(MULTIPOLYGONWKT)); long ruleId = ruleAdminService.insert(areaRestriction); ruleAdminService.setLimits(ruleId, limits); ruleAdminService.insert( (new Rule( priority++, areaUser, null, null, null, null, null, null, null, GrantType.ALLOW))); /* some users for interactive testing with the default data directory */ // uStates can do whatever, but only on topp:states ruleAdminService.insert( new Rule( priority++, uStates, null, null, null, null, null, "topp", "states", GrantType.ALLOW)); // deny everything else ruleAdminService.insert( new Rule(priority++, null, null, null, null, null, null, null, null, GrantType.DENY)); new Thread( new Runnable() { @Override public void run() { boolean success = false; int cnt = 5; while (!success && cnt-- > 0) { try { LOGGER.info("Waiting 5 secs..."); Thread.sleep(5000); LOGGER.info("Trying creating spring remoting client..."); instantiateAndRunSpringRemoting(); success = true; } catch (InterruptedException ex) { } catch (Exception e) { LOGGER.warn("Failed creating spring remoting client..." + e.getMessage()); } } } }) .start(); try { LOGGER.info("===== User List ====="); List<ShortUser> users = userAdminService.getList(null, null, null); for (ShortUser loop : users) { LOGGER.info(" User -> " + loop); } LOGGER.info("===== Rules ====="); List<ShortRule> rules = ruleAdminService.getAll(); for (ShortRule shortRule : rules) { LOGGER.info(" Rule -> " + shortRule); } } finally { } }