public boolean isAnonymous() { return getUserName() == null; }
public String toString() { if (getUserName() != null) { StringBuffer buff = new StringBuffer(role); buff.append(" for user ").append(getUserName()); return buff.toString(); } else return role; }
public int hashCode() { int hash = getAuthority().hashCode(); if (getUserName() != null) hash += getUserName().hashCode(); return hash; }
public int compareTo(GeoServerRole o) { if (o == null) return 1; if (getAuthority().equals(o.getAuthority())) { if (getUserName() == null && o.getUserName() == null) return 0; if (getUserName() == null) return -1; if (o.getUserName() == null) return 1; return getUserName().compareTo(o.getUserName()); } return getAuthority().compareTo(o.getAuthority()); }
public boolean equals(Object obj) { if (obj == null) return false; if (obj instanceof String && getUserName() == null) { return equalsWithoutUserName(obj); } if (obj instanceof GrantedAuthority && getUserName() == null) { if (obj instanceof GeoServerRole == false) return equalsWithoutUserName(obj); } if (obj instanceof GeoServerRole) { return compareTo((GeoServerRole) obj) == 0; } return false; }
public EditRolePage(String roleServiceName, GeoServerRole role) { // parent role name not known at this moment, parent // constructor will do the job super(roleServiceName, role); get("form:name").setEnabled(false); // do we have a personalized role? if (role.getUserName() != null) { get("form:properties").setEnabled(false); get("form:parent").setEnabled(false); get("form:save").setEnabled(false); } }
public EditRolePage(String roleServiceName,GeoServerRole role) { // parent role name not known at this moment, parent // constructor will do the job super(roleServiceName, role); get("form:name").setEnabled(false); // do we have a personalized role? if (role.getUserName()!=null ) { get("form:properties").setEnabled(false); get("form:parent").setEnabled(false); get("form:save").setEnabled(false); } }
public EditRolePage(String roleServiceName,GeoServerRole role) { // parent role name not known at this moment, parent // constructor will do the job super(roleServiceName, role); get("form:name").setEnabled(false); // do we have a personalized role? if (role.getUserName()!=null ) { get("form:properties").setEnabled(false); get("form:parent").setEnabled(false); get("form:save").setEnabled(false); } }
if (role.getUserName() == null) { descriptionModel = new StringResourceModel("anonymousRole", getPage(), null); new Object[]{role.getUserName()});
@Override protected void onFormSubmit(GeoServerRole role) throws IOException { GeoServerRoleStore store = null; try { store = new RoleStoreValidationWrapper(getRoleStore(roleServiceName)); //copy into a new one so we can set the name properly GeoServerRole newRole= store.createRoleObject(get("form:name").getDefaultModelObjectAsString()); newRole.setUserName(role.getUserName()); newRole.getProperties().putAll(role.getProperties()); role = newRole; store.addRole(role); String parentRoleName = get("form:parent").getDefaultModelObjectAsString(); if (parentRoleName != null) { GeoServerRole parentRole = store.getRoleByName(parentRoleName); store.setParentRole(role, parentRole); } store.store(); } catch (IOException ex) { try {store.load(); } catch (IOException ex2) {}; throw ex; } }
@Override protected void onFormSubmit(GeoServerRole role) throws IOException { GeoServerRoleStore store = null; try { //copy into a new one so we can set the name properly GeoServerRole newRole = new GeoServerRole(get("form:name").getDefaultModelObjectAsString()); newRole.setUserName(role.getUserName()); newRole.getProperties().putAll(role.getProperties()); role = newRole; store = new RoleStoreValidationWrapper(getRoleStore(roleServiceName)); store.addRole(role); String parentRoleName = get("form:parent").getDefaultModelObjectAsString(); if (parentRoleName != null) { GeoServerRole parentRole = store.getRoleByName(parentRoleName); store.setParentRole(role, parentRole); } store.store(); } catch (IOException ex) { try {store.load(); } catch (IOException ex2) {}; throw ex; } }
if (role.getUserName() != null) { descriptionModel = new StringResourceModel("personalizedRole", getPage(), null, new Object[]{role.getUserName()});
newRole.setUserName(role.getUserName()); newRole.getProperties().putAll(role.getProperties()); role = newRole;
assertEquals("r1_v1", r.getProperties().get("r1_p1")); assertEquals("r1_v2", r.getProperties().get("r1_p2")); assertEquals("testuser", r.getUserName()); for (GrantedAuthority auth : resColl) { r = (GeoServerRole) auth; assertNull(r.getUserName()); if ("r3".equals(r.getAuthority())) continue; if ("r2".equals(r.getAuthority())) {
if (role.getUserName() != null) { descriptionModel = new StringResourceModel("personalizedRole", getPage()) .setParameters(role.getUserName()); } else { descriptionModel = new StringResourceModel("anonymousRole", getPage());
assertFalse(role == anonymousRole); assertFalse(role.equals(anonymousRole)); assertTrue(theUser.getUsername().equals(role.getUserName())); assertNull(anonymousRole.getUserName());