We investigate the physical-layer security of an uplink wireless time-division multiple-access channel with energy-harvesting source nodes. We consider a set of source nodes equipped with rechargeable batteries and information buffers communicating confidentially with a base station, Bob, in the presence of a passive eavesdropper, Eve. An energy-harvesting rechargeable-battery cooperative jammer is assumed to assist the source nodes to confidentially send their information messages. We propose a two-level optimization formulation to improve the system's security performance. At the first optimization level, we propose a jamming scheme under energy constraints at different nodes to reduce the secrecy outage probabilities without relying on the eavesdropper's instantaneous channel state information. At the second optimization level, we optimize the number of energy packets used at the source nodes and the cooperative jammer as well as the time-slot allocation probabilities to maximize the secure throughput under the network's queues stability constraints and an application-specific secure throughput for each legitimate source node. The numerical results show the significant performance gains of our proposed optimization relative to two important benchmarks. We verify our theoretical findings through simulations and quantify the impact of key system design parameters on the security performance.