SABRA LANE: A secret prisoner, in a secret trial, sent to jail — in secret.

This morning, the ABC can reveal astonishing details about a case involving a man known as Witness J, a distinguished former military intelligence officer, convicted of mishandling classified information, for potentially revealing the identities of agents who had been recruited by Australian agencies.

This extraordinary episode in Australia's legal history has ignited a debate over the transparency of the legal system, and whether there is any place for secret trials and convictions in a free and open country such as Australia.

Political editor Andrew Probyn has this exclusive report.

ANDREW PROBYN: In the dark reaches of social media, a Twitter account appeared late last month. Its owner tweeted he had an incredible story tell.

TWEET 1 (VOICEOVER): Tonight, I want to do my best to answer your questions, but as a secret prisoner from a secret trial who's worked for a secret organisation, I am limited. I apologise.

ANDREW PROBYN: The man is known by the moniker “Witness J”.

TWEET 2 (VOICEOVER): I am deeply disappointed that my story cannot be told in full.

ANDREW PROBYN: His true identity can't be revealed, but an investigation by the ABC has uncovered the unprecedented circumstances of his arrest, prosecution and imprisonment.

Witness J was a Duntroon graduate who served in East Timor and Afghanistan as a military intelligence officer, as well as in Iraq.

The unravelling of his distinguished career came during a posting to a South-East Asian capital.

His Top Secret security clearance was under a routine review, but some anomalies in his answers triggered concerns he wasn't being entirely truthful about his behaviour as a single man on a foreign posting.

TWEET 3 (VOICEOVER): One day, I put my hand up for mental health support. It didn't come. I tried two more times. Six months later, I was jailed for 15 months.

ANDREW PROBYN: He got locked up because of how he reacted when his employer said his behaviour put him at risk of being compromised while overseas.

He was angry, firing off complaints by email and other unsecure means back to Australia, breaching all manner of security protocols.

In those emails, he named colleagues whose behaviour he believed was more egregious — and worse, identified agents who had been recruited for direction and control, practically unforgiveable sins in security circles.

By May 2018, he was known as Prisoner 123458, kept in isolation and then in the high security sex offenders' wing of Canberra's main jail, the Alexander Maconochie Centre, as he awaited trial.

There is no suggestion he was in fact a sex offender.

TWEET 4 (VOICEOVER): My case was unprecedented. How do I know? The open-mouthed gapes from my defence team and the director of public prosecutions as they waded through unwalked grounds.

ANDREW PROBYN: The sentencing before ACT Supreme Court Justice John Burns was held in secret, Witness J pleading guilty to five charges, and sentenced in February to two years and seven months' jail.

Justice Burns has since indicated that in light of the national security implications of the case, orders for the closure of the court and suppression of evidence were made at the request of the parties.

He said "the decision was not taken lightly", and acknowledged that such orders "would be generally undesirable".

The Territory's Justice and Corrections Minister Shane Rattenbury wasn't even aware this man was in his jail system when asked about the case.

SHANE RATTENBURY: I think the Commonwealth has a lot of questions to answer here, about both the nature of the process and even what the charges are.

ANDREW PROBYN: Barrister Bret Walker is a former independent national security legislation monitor.

BRETT WALKER: Permanently secret proceedings that we know nothing about is the hallmark of an entirely different society from ours.

ANDREW PROBYN: While he concedes some details of criminal and civil trials should and would always be kept secret, he argues the public has a right to know when information is being kept from them.

BRETT WALKER: It calls for compromise. I am surprised and disturbed that the compromise in this case would appear, deliberately or otherwise, to have produced secrecy about the whole proceedings, rather than simply about those aspects of the evidence which need to be kept confidential.

ANDREW PROBYN: Attorney-General Christian Porter says the court was closed to the public because the information disclosed was of a kind that could endanger the lives or safety of others.

Witness J left prison in August, having served 15 months, his story now less secret. But there lingers this question: could another legal episode like his happen again?

SABRA LANE: Political editor Andrew Probyn.