public void addGroup(GeoServerUserGroup group) throws IOException { Connection con = null; PreparedStatement ps = null; try { con = getConnection(); ps = getDMLStatement("groups.insert", con); ps.setString(1,group.getGroupname()); ps.setString(2,convertToString(group.isEnabled())); ps.execute(); } catch (SQLException ex) { throw new IOException(ex); } finally { closeFinally(con, ps, null); } setModified(true); }
@Test public void testUserGroupDatabaseSetup() throws IOException { JDBCUserGroupStore jdbcStore = (JDBCUserGroupStore) store; assertTrue(jdbcStore.tablesAlreadyCreated()); jdbcStore.checkDDLStatements(); jdbcStore.checkDMLStatements(); jdbcStore.clear(); jdbcStore.dropTables(); jdbcStore.store(); assertFalse(jdbcStore.tablesAlreadyCreated()); jdbcStore.load(); }
/** * * Executes {@link Connection#rollback() and * frees the connection object * @see org.geoserver.security.jdbc.JDBCUserGroupService#load() */ public void load() throws IOException { // Simply roll back the transaction try { getConnection().rollback(); releaseConnection(); } catch (SQLException ex) { throw new IOException(ex); } setModified(false); //fireUserGroupChangedEvent(); }
public void updateUser(GeoServerUser user) throws IOException,PasswordPolicyException { preparePassword(user); Connection con = null; PreparedStatement ps = null; try { con = getConnection(); ps = getDMLStatement("users.update", con); ps.setString(1,user.getPassword()); ps.setString(2,convertToString(user.isEnabled())); ps.setString(3,user.getUsername()); ps.execute(); ps.close(); ps = getDMLStatement("userprops.deleteForUser",con); ps.setString(1,user.getUsername()); ps.execute(); addUserProperties(user, con); } catch (SQLException ex) { throw new IOException(ex); } finally { closeFinally(con, ps, null); } setModified(true); }
@Override public GeoServerUserGroupStore createStore(GeoServerUserGroupService service) throws IOException { JDBCUserGroupStore store = (JDBCUserGroupStore) 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) { JDBCUserGroupStore jdbcStore = (JDBCUserGroupStore) store; JDBCTestSupport.dropExistingTables(jdbcStore, jdbcStore.getConnection()); store.store(); } }
/** * @see org.geoserver.security.GeoServerUserGroupStore#initializeFromServer(org.geoserver.security.GeoServerUserGroupService) */ public void initializeFromService(GeoServerUserGroupService service) throws IOException { jdbcService= (JDBCUserGroupService) service; setSecurityManager(service.getSecurityManager()); this.name=jdbcService.getName(); this.passwordEncoderName=service.getPasswordEncoderName(); this.passwordValidatorName=service.getPasswordValidatorName(); this.datasource=jdbcService.datasource; this.ddlProps=jdbcService.ddlProps; this.dmlProps=jdbcService.dmlProps; try { getConnection().commit(); } catch (SQLException e) { throw new IOException(); } }
@Override public GeoServerUserGroupStore createStore(GeoServerUserGroupService service) throws IOException { JDBCUserGroupStore store = (JDBCUserGroupStore) super.createStore(service); try { JDBCTestSupport.dropExistingTables(store,store.getConnection()); } catch (SQLException e) { throw new IOException(e); } store.createTables(); store.store(); return store; }
public void addUser(GeoServerUser user) throws IOException, PasswordPolicyException { preparePassword(user); Connection con = null; PreparedStatement ps = null; try { con = getConnection(); ps = getDMLStatement("users.insert", con); ps.setString(1,user.getUsername()); if (user.getPassword() != null) { ps.setString(2,user.getPassword()); } else { ps.setNull(2, Types.VARCHAR); } ps.setString(3,convertToString(user.isEnabled())); ps.execute(); addUserProperties(user, con); } catch (SQLException ex) { throw new IOException(ex); } finally { closeFinally(con, ps, null); } setModified(true); }
/** * Executes {@link Connection#commit()} and frees * the connection * * @see org.geoserver.security.GeoServerUserGroupStore#store() */ public void store() throws IOException { // Simply commit the transaction try { getConnection().commit(); releaseConnection(); } catch (SQLException ex) { throw new IOException(ex); } setModified(false); //fireUserGroupChangedEvent(); }
@Override protected void tearDownInternal() throws Exception { super.tearDownInternal(); if (store!=null) { JDBCUserGroupStore jdbcStore =(JDBCUserGroupStore)store; JDBCTestSupport.dropExistingTables(jdbcStore,jdbcStore.getConnection()); store.store(); } }
public void testUserGroupDatabaseSetup() { try { JDBCUserGroupStore jdbcStore = (JDBCUserGroupStore) store; assertTrue(jdbcStore.tablesAlreadyCreated()); jdbcStore.checkDDLStatements(); jdbcStore.checkDMLStatements(); jdbcStore.clear(); jdbcStore.dropTables(); jdbcStore.store(); assertFalse(jdbcStore.tablesAlreadyCreated()); jdbcStore.load(); } catch (IOException ex) { Assert.fail(ex.getMessage()); } }
public void updateGroup(GeoServerUserGroup group) throws IOException { Connection con = null; PreparedStatement ps = null; try { con = getConnection(); ps = getDMLStatement("groups.update", con); ps.setString(1,convertToString(group.isEnabled())); ps.setString(2,group.getGroupname()); ps.execute(); } catch (SQLException ex) { throw new IOException(ex); } finally { closeFinally(con, ps, null); } setModified(true); }
@Override public GeoServerUserGroupStore createStore(GeoServerUserGroupService service) throws IOException { JDBCUserGroupStore store = (JDBCUserGroupStore) 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(); }
public void associateUserToGroup(GeoServerUser user, GeoServerUserGroup group) throws IOException { Connection con = null; PreparedStatement ps = null; try { con = getConnection(); ps = getDMLStatement("groupmembers.insert", con); ps.setString(1,group.getGroupname()); ps.setString(2,user.getUsername()); ps.execute(); } catch (SQLException ex) { throw new IOException(ex); } finally { closeFinally(con, ps, null); } setModified(true); }
@Override public GeoServerUserGroupStore createStore(GeoServerUserGroupService service) throws IOException { JDBCUserGroupStore store = (JDBCUserGroupStore) 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 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(); } }
public void clear() throws IOException { Connection con = null; PreparedStatement ps = null; try { con = getConnection(); ps = getDMLStatement("groupmembers.deleteAll", con); ps.execute(); ps.close(); ps = getDMLStatement("groups.deleteAll", con); ps.execute(); ps.close(); ps = getDMLStatement("userprops.deleteAll", con); ps.execute(); ps.close(); ps = getDMLStatement("users.deleteAll", con); ps.execute(); } catch (SQLException ex) { throw new IOException(ex); } finally { closeFinally(con, ps, null); } setModified(true); } /**
@Override public GeoServerUserGroupStore createStore(GeoServerUserGroupService service) throws IOException { JDBCUserGroupStore store = (JDBCUserGroupStore) super.createStore(service); try { JDBCTestSupport.dropExistingTables(store,store.getConnection()); } catch (SQLException e) { throw new IOException(e); } store.createTables(); store.store(); return store; }