/** * Executes {@link Connection#commit()} and frees * the connection * @see org.geoserver.security.GeoServerRoleStore#store() */ public void store() throws IOException { // Simply commit the transaction try { getConnection().commit(); releaseConnection(); } catch (SQLException ex) { throw new IOException(ex); } setModified(false); }
/** * Executes {@link Connection#rollback() and * frees the connection object * * @see org.geoserver.security.jdbc.JDBCRoleService#load() */ public void load() throws IOException { // Simply roll back the transaction try { getConnection().rollback(); releaseConnection(); } catch (SQLException ex) { throw new IOException(ex); } setModified(false); }
public void initializeFromService(GeoServerRoleService service) throws IOException { JDBCRoleService jdbcService= (JDBCRoleService) service; this.name=service.getName(); this.adminRoleName=jdbcService.adminRoleName; this.groupAdminRoleName=jdbcService.groupAdminRoleName; this.datasource=jdbcService.datasource; this.ddlProps=jdbcService.ddlProps; this.dmlProps=jdbcService.dmlProps; this.securityManager=service.getSecurityManager(); try { getConnection().commit(); } catch (SQLException e) { throw new IOException(e); } } }
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 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 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); }
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 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 }
@Override public GeoServerRoleStore createStore(GeoServerRoleService service) throws IOException { JDBCRoleStore store = (JDBCRoleStore) super.createStore(service); try { JDBCTestSupport.dropExistingTables(store,store.getConnection()); } catch (SQLException e) { throw new IOException(e); } store.createTables(); store.store(); return store; }
@After public void dropExistingTables() throws Exception { if (store != null) { JDBCRoleStore jdbcStore = (JDBCRoleStore) store; JDBCTestSupport.dropExistingTables(jdbcStore, jdbcStore.getConnection()); store.store(); } }
@Override public GeoServerRoleStore createStore(GeoServerRoleService service) throws IOException { JDBCRoleStore store = (JDBCRoleStore) super.createStore(service); try { JDBCTestSupport.dropExistingTables(store, store.getConnection()); } catch (SQLException e) { throw new IOException(e); } store.createTables(); store.store(); return store; }
@Override public GeoServerRoleStore createStore(GeoServerRoleService service) throws IOException { JDBCRoleStore store = (JDBCRoleStore) super.createStore(service); try { JDBCTestSupport.dropExistingTables(store, store.getConnection()); } catch (SQLException e) { throw new IOException(e); } store.createTables(); store.store(); return store; }
@Override public GeoServerRoleStore createStore(GeoServerRoleService service) throws IOException { JDBCRoleStore store = (JDBCRoleStore) super.createStore(service); try { JDBCTestSupport.dropExistingTables(store,store.getConnection()); } catch (SQLException e) { throw new IOException(e); } store.createTables(); store.store(); return store; }
@Override public GeoServerRoleStore createStore(GeoServerRoleService service) throws IOException { JDBCRoleStore store = (JDBCRoleStore) super.createStore(service); try { JDBCTestSupport.dropExistingTables(store, store.getConnection()); } catch (SQLException e) { throw new IOException(e); } store.createTables(); store.store(); return store; }
@Override protected void tearDownInternal() throws Exception { super.tearDownInternal(); if (store!=null) { JDBCRoleStore jdbcStore =(JDBCRoleStore)store; JDBCTestSupport.dropExistingTables(jdbcStore,jdbcStore.getConnection()); store.store(); } }
@Override public GeoServerRoleStore createStore(GeoServerRoleService service) throws IOException { JDBCRoleStore store = (JDBCRoleStore) super.createStore(service); try { JDBCTestSupport.dropExistingTables(store,store.getConnection()); } catch (SQLException e) { throw new IOException(e); } store.createTables(); store.store(); return store; }
@Override protected void tearDownInternal() throws Exception { super.tearDownInternal(); JDBCRoleStore rs = (JDBCRoleStore) roleStore; JDBCTestSupport.dropExistingTables(rs, rs.getConnection()); roleStore.store(); JDBCUserGroupStore ugs = (JDBCUserGroupStore) ugStore; JDBCTestSupport.dropExistingTables(ugs, ugs.getConnection()); ugStore.store(); }
@Override protected void tearDownInternal() throws Exception { super.tearDownInternal(); if (roleStore!=null) { JDBCRoleStore jdbcStore1 =(JDBCRoleStore) roleStore; JDBCTestSupport.dropExistingTables(jdbcStore1,jdbcStore1.getConnection()); roleStore.store(); } if (usergroupStore!=null) { JDBCUserGroupStore jdbcStore2 =(JDBCUserGroupStore) usergroupStore; JDBCTestSupport.dropExistingTables(jdbcStore2,jdbcStore2.getConnection()); usergroupStore.store(); } }
@After public void dropTables() throws Exception { if (roleStore != null) { JDBCRoleStore jdbcStore1 = (JDBCRoleStore) roleStore; JDBCTestSupport.dropExistingTables(jdbcStore1, jdbcStore1.getConnection()); roleStore.store(); } if (usergroupStore != null) { JDBCUserGroupStore jdbcStore2 = (JDBCUserGroupStore) usergroupStore; JDBCTestSupport.dropExistingTables(jdbcStore2, jdbcStore2.getConnection()); usergroupStore.store(); } }