use of io.bastillion.manage.model.HostSystem in project KeyBox by skavanagh.
the class SystemStatusDB method getAllSystemStatus.
/**
* returns all key placement statuses
*
* @param userId user id
*/
public static List<HostSystem> getAllSystemStatus(Long userId) throws SQLException, GeneralSecurityException {
Connection con = DBUtils.getConn();
List<HostSystem> hostSystemList = getAllSystemStatus(con, userId);
DBUtils.closeConn(con);
return hostSystemList;
}
use of io.bastillion.manage.model.HostSystem in project KeyBox by skavanagh.
the class SystemStatusDB method getSystemStatus.
/**
* returns key placement status of system
*
* @param systemId system id
* @param userId user id
*/
public static HostSystem getSystemStatus(Long systemId, Long userId) throws SQLException, GeneralSecurityException {
HostSystem hostSystem = null;
Connection con = DBUtils.getConn();
PreparedStatement stmt = con.prepareStatement("select * from status where id=? and user_id=?");
stmt.setLong(1, systemId);
stmt.setLong(2, userId);
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
hostSystem = SystemDB.getSystem(con, rs.getLong("id"));
hostSystem.setStatusCd(rs.getString(STATUS_CD));
}
DBUtils.closeRs(rs);
DBUtils.closeStmt(stmt);
DBUtils.closeConn(con);
return hostSystem;
}
use of io.bastillion.manage.model.HostSystem in project KeyBox by skavanagh.
the class SystemStatusDB method getNextPendingSystem.
/**
* returns the first system that authorized keys has not been tried
*
* @param userId user id
* @return hostSystem systems for authorized_keys replacement
*/
public static HostSystem getNextPendingSystem(Long userId) throws SQLException, GeneralSecurityException {
HostSystem hostSystem = null;
Connection con = DBUtils.getConn();
PreparedStatement stmt = con.prepareStatement("select * from status where (status_cd like ? or status_cd like ? or status_cd like ?) and user_id=? order by id asc");
stmt.setString(1, HostSystem.INITIAL_STATUS);
stmt.setString(2, HostSystem.AUTH_FAIL_STATUS);
stmt.setString(3, HostSystem.PUBLIC_KEY_FAIL_STATUS);
stmt.setLong(4, userId);
ResultSet rs = stmt.executeQuery();
if (rs.next()) {
hostSystem = SystemDB.getSystem(con, rs.getLong("id"));
hostSystem.setStatusCd(rs.getString(STATUS_CD));
}
DBUtils.closeRs(rs);
DBUtils.closeStmt(stmt);
DBUtils.closeConn(con);
return hostSystem;
}
use of io.bastillion.manage.model.HostSystem in project KeyBox by skavanagh.
the class ProfileSystemsDB method getSystemsByProfile.
/**
* returns a list of systems for a given profile
*
* @param profileId profile id
* @return list of host systems
*/
public static List<HostSystem> getSystemsByProfile(Long profileId) throws SQLException, GeneralSecurityException {
Connection con = DBUtils.getConn();
List<HostSystem> hostSystemList = getSystemsByProfile(con, profileId);
DBUtils.closeConn(con);
return hostSystemList;
}
use of io.bastillion.manage.model.HostSystem in project KeyBox by skavanagh.
the class SSHUtil method distributePubKeysToProfile.
/**
* distributes public keys to all systems under profile
*
* @param profileId profile id
*/
public static void distributePubKeysToProfile(Long profileId) throws SQLException, GeneralSecurityException {
if (keyManagementEnabled) {
List<HostSystem> hostSystemList = ProfileSystemsDB.getSystemsByProfile(profileId);
for (HostSystem hostSystem : hostSystemList) {
hostSystem = SSHUtil.authAndAddPubKey(hostSystem, null, null);
SystemDB.updateSystem(hostSystem);
}
}
}
Aggregations