public void clear() throws IOException { Connection con = null; PreparedStatement ps = null; try { con = getConnection(); ps = getDMLStatement("grouproles.deleteAll", con); ps.execute(); ps.close(); ps = getDMLStatement("userroles.deleteAll", con); ps.execute(); ps.close(); ps = getDMLStatement("roleprops.deleteAll", con); ps.execute(); ps.close(); ps = getDMLStatement("roles.deleteAll", con); ps.execute(); } catch (SQLException ex) { throw new IOException(ex); } finally { closeFinally(con, ps, null); } setModified(true); }
protected void addRoleProperties(GeoServerRole role, Connection con) throws SQLException,IOException { if (role.getProperties().size()==0) return; // nothing to do PreparedStatement ps = getDMLStatement("roleprops.insert", con); try { for (Object key : role.getProperties().keySet()) { Object propertyVal = role.getProperties().get(key); ps.setString(1,role.getAuthority()); ps.setString(2,key.toString()); ps.setObject(3,propertyVal); ps.execute(); } } finally { closeFinally(null, ps, null); } }
public void associateRoleToUser(GeoServerRole role, String username) throws IOException{ Connection con = null; PreparedStatement ps = null; try { con = getConnection(); ps = getDMLStatement("userroles.insert", con); ps.setString(1,role.getAuthority()); ps.setString(2,username); ps.execute(); } catch (SQLException ex) { throw new IOException(ex); } finally { closeFinally(con, ps, null); } setModified(true); }
public void disAssociateRoleFromUser(GeoServerRole role, String username) throws IOException{ Connection con = null; PreparedStatement ps = null; try { con = getConnection(); ps = getDMLStatement("userroles.delete", con); ps.setString(1,role.getAuthority()); ps.setString(2,username); ps.execute(); } catch (SQLException ex) { throw new IOException(ex); } finally { closeFinally(con, ps, null); } setModified(true); }
try { con = getConnection(); ps = getDMLStatement("roles.delete", con); ps.setString(1,role.getAuthority()); ps.execute(); ps = getDMLStatement("userroles.deleteRole",con); ps.setString(1,role.getAuthority()); ps.execute(); ps = getDMLStatement("grouproles.deleteRole",con); ps.setString(1,role.getAuthority()); ps.execute(); ps = getDMLStatement("roleprops.deleteForRole", con); ps.setString(1,role.getAuthority()); ps.execute(); ps = getDMLStatement("roles.deleteParent", con); ps.setString(1,role.getAuthority()); ps.execute();
public void associateRoleToGroup(GeoServerRole role, String groupname) throws IOException{ Connection con = null; PreparedStatement ps = null; try { con = getConnection(); ps = getDMLStatement("grouproles.insert", con); ps.setString(1,role.getAuthority()); ps.setString(2,groupname); ps.execute(); } catch (SQLException ex) { throw new IOException(ex); } finally { closeFinally(con, ps, null); } setModified(true); }
public void disAssociateRoleFromGroup(GeoServerRole role, String groupname) throws IOException{ Connection con = null; PreparedStatement ps = null; try { con = getConnection(); ps = getDMLStatement("grouproles.delete", con); ps.setString(1,role.getAuthority()); ps.setString(2,groupname); ps.execute(); } catch (SQLException ex) { throw new IOException(ex); } finally { closeFinally(con, ps, null); } setModified(true); }
public void updateRole(GeoServerRole role) throws IOException { // No attributes for update Connection con = null; PreparedStatement ps = null; try { con = getConnection(); ps = getDMLStatement("roles.update", con); ps.setString(1,role.getAuthority()); ps.execute(); ps.close(); ps = getDMLStatement("roleprops.deleteForRole",con); ps.setString(1,role.getAuthority()); ps.execute(); addRoleProperties(role, con); } catch (SQLException ex) { throw new IOException(ex); } finally { closeFinally(con, ps, null); } setModified(true); // we do as if there was an update }
public void addRole(GeoServerRole role) throws IOException{ Connection con = null; PreparedStatement ps = null; try { con = getConnection(); ps = getDMLStatement("roles.insert", con); ps.setString(1,role.getAuthority()); //ps.setNull(2, Types.VARCHAR); ps.execute(); addRoleProperties(role, con); } catch (SQLException ex) { throw new IOException(ex); } finally { closeFinally(con, ps, null); } setModified(true); }
public void setParentRole(GeoServerRole role, GeoServerRole parentRole) throws IOException { RoleHierarchyHelper helper = new RoleHierarchyHelper(getParentMappings()); if (helper.isValidParent(role.getAuthority(), parentRole==null ? null : parentRole.getAuthority())==false) throw new IOException(parentRole.getAuthority() + " is not a valid parent for " + role.getAuthority()); Connection con = null; PreparedStatement ps = null; try { con = getConnection(); ps = getDMLStatement("roles.parentUpdate", con); if (parentRole == null) ps.setNull(1, Types.VARCHAR); else ps.setString(1,parentRole.getAuthority()); ps.setString(2,role.getAuthority()); ps.execute(); } catch (SQLException ex) { throw new IOException(ex); } finally { closeFinally(con, ps, null); } setModified(true); }