Just 13 words are all there are on the public record to note one of the most extraordinary episodes in Australian legal history.

Key points: Witness J was a prisoner who was tried, sentenced and imprisoned in secret

Witness J was a prisoner who was tried, sentenced and imprisoned in secret The former military intelligence officer worked in various parts of the sprawling military and defence network

The former military intelligence officer worked in various parts of the sprawling military and defence network He has been accused of acting so dangerously he was imperilling lives and national security

After a secret trial of a secret prisoner, the sentence was delivered — you guessed it — in complete secrecy.

You have to know what you're looking for, but even when you find those 13 words, they are not at all illuminating. In fact, they would defeat the purpose of being there at all, were it not for the legal tease they present.

"Before Justice Burns, in Court Room SC4, at 10:00am," it starts promisingly enough.

Then comes the inevitable punchline: "Sentence: Matter Suppressed."

The date was February 19 of this year. The venue was the ACT Supreme Court in Canberra.

Exactly why the Commonwealth and the justice system should conspire to allow such exceptional measures has unnerved legal experts and dismayed former judges.

"Permanently secret legal proceedings is not the kind of conduct we want an Australian justice system to include," said barrister Bret Walker, a former independent national security legislation monitor.

An investigation by the ABC has uncovered the remarkable events that led to the secret trial, the unravelling of a man's impressive career and the circumstances of his arrest, which led to a jail sentence of two years and seven months for serious national security offences.

ACT Chief Magistrate Lorraine Walker remanded Witness J in custody in May 2018. ( ABC News: Tegan Osborne )

The secret case of Prisoner 123458

By February 19, the defendant had already been locked up for nine months as Prisoner 123458. He had been remanded in custody by ACT Chief Magistrate Lorraine Walker in mid-May 2018.

After a month in solitary confinement, he was placed in the high-security sex offenders' wing of Canberra's Alexander Maconochie Centre (AMC).

He was not a sex offender. Not at all. Housing him with convicted paedophiles and rapists was deemed a better option than putting him alongside murderers, gangsters and other hardened criminals in the other wing.

The legal proceedings before his sentencing had not gone entirely unnoticed. That was impossible with two burly security guards sitting outside the courtroom, barring the curious from entry.

Two professionally curious court reporters, the ABC's Michael Inman and The Canberra Times' Alexandra Back, jointly wondered what was happening inside SC4.

It was decided Back should make an inquiry with the Chief Justice, Helen Murrell.

The response, which came from Justice John Burns, seemed regretful, practically apologetic, for what he described as the "generally undesirable" and "unusual" security arrangements.

Justice Burns said that on November 19, 2018, he had agreed, at the request of the parties to the proceeding, to make "consent orders" under the National Security (Criminal and Civil Proceedings) Act 2004, closing the court to the public "during the taking of evidence and submissions".

"The particularly sensitive nature of the material to be exposed in the proceeding, and the grave harm that could occur if the material became public, outweighed the desirability of ensuring that proceedings before the Court are open to the public," Justice Burns said in a note to the reporters.

"The decision to close the Court was not taken lightly," he told them, adding that he regretted not being able to say any more.

The nation's chief law officer insists secrecy was needed to protect national security.

"The court determined, consistent with the Government submission, that it was contrary to the public interest that the information be disclosed and the information was of a kind that could endanger the lives or safety of others," Attorney-General Christian Porter told the ABC.

The raid that led to a secret becoming public

What happened to Witness J, as he has become known, might not have become known were it not for the fact that the day before he was sentenced by Justice Burns, his cell was raided by Australian Federal Police officers under court warrant, looking for a memoir Witness J had written during his time locked up alongside sex offenders.

What can be gleaned publicly about Witness J came almost by accident, when he took action in the ACT courts to complain about his treatment and what he claimed was a breach of his human rights.

The action failed, at his own considerable cost, but it did at least drag Witness J's fate from the darkest shadows into the half-light.

Little is known about Witness J's appearances in court. ( ABC News: Emma Machan )

Witness J was convicted under the myriad security laws that can trigger wide-ranging suppression of any outside scrutiny or media reporting.

Since his civil action against the ACT Government became public last month, a person purporting to be Witness J has been testing the bounds of the suppression orders, taking to Twitter to claim he is the victim of an unfair prosecution.

"Persecuted. Jailed after asking for mental health support three times, and falling through the floor," he has tweeted.

A former military intelligence officer, Witness J is a Duntroon graduate in his mid 30s who served in East Timor, Afghanistan and Iraq. He has a distinguished record.

Witness J worked in various parts of the sprawling military and intelligence network.

But Witness J's downfall began during a civilian posting in a South-East Asian country when he was undergoing a re-validation of his Top Secret security clearance, which by practice is about every five years.

He would have been one of 25 or so people in his service undergoing a re-validation process that month and the questions from the vetting officer would have been standard, including about his financial and personal circumstances.

But there were some anomalies in his answers that prompted more and more inquiry. Truthfulness is key in these interviews.

A Twitter account belonging to a "Witness J" appeared in November.

It is understood his lack of candour prompted concerns being raised with Witness J about how he was conducting himself as a single man in the South-East Asian capital. There was a worry he could be compromised.

This coincided with a mental health crisis, which is not uncommon with people who have given many years' service in hostile environments.

Witness J sought internal help on three occasions for his mental health but his security clearance prevented seeking help outside his employment.

Internal complaint lands Witness J in the crosshairs

The ABC has been told Witness J was infuriated by the accusation that his behaviour while overseas had made him a compromise risk. He complained internally to the head of security and a departmental psychologist back in Australia.

It was an unwise decision delivered dangerously. It is understood his complaints were communicated by email and other unsecure electronic means.

Witness J immediately found himself in the crosshairs of an organisation that had been his employer for five years.

In his complaints, he accused fellow case officers of behaviour which he believed was more egregious than his own. Worse, he identified agents who had been recruited for direction and control. These were grave, unforgivable sins in his line of work.

His employer said Witness J had breached secrecy provisions. It believed he was acting so dangerously, he was imperilling lives, national security and the very working environment of his colleagues.

According to one person, Witness J had to be "shut down".

On Twitter, "Witness J" claims his case was unprecedented. From what the ABC has uncovered, he is probably right.

"How do I know? The open-mouthed gapes from my defence team and the DPP as they waded through unwalked ground," he has tweeted.

However, he did not contest the five charges and he pleaded guilty, as advised by his barrister Kieran Ginges, even though Witness J had argued there had been no public disclosure and no release of information outside his employer.

That is not how the prosecution or his employer saw it.

"The orders provided for a mechanism for closure of the court in circumstances where highly sensitive national security information would have been disclosed, but did not prevent the defendant or his counsel from accessing the information," Mr Porter said.

Release prompts complaints about treatment

Witness J's complaints had put critically sensitive information within the potential grasp of rival espionage capability, if the unsecure communications were electronically "triangulated".

Witness J was released from jail on August 16, some 16 months or so before the expiry of his sentence. It is understood there are conditions attached to his release, including six-monthly regular psychological testing and an overseas travel ban without prior permission.

By negotiation, he is able to describe his convictions as having been for "mishandled classified information". Other descriptors of his crimes, perhaps less damning, had been offered to him, in the hope it would help him find employment.

The prisoner was held in secret at the Alexander Maconochie Centre in Canberra. ( ABC News: Ian Cutmore )

Since his release, Witness J has complained about his treatment to the inspector-general of Intelligence and Security. She, however, has no power to overturn his convictions.

Witness J appears to claim being the victim of an injustice; that what should have been treated as an internal complaint left him with a criminal conviction and serious mental health issues.

Witness J admitted to serious breaches of security protocols, but observers say his secret dispatch by Australia's legal regime raises considerable concern for a robust democracy.

Calls for secrecy to be explained

John Dowd, a former NSW Liberal leader, attorney-general and Supreme Court judge, said there needed to be an explanation for the secret trial.

"Society has to be very careful in the circumstance in which we hold limited-publicity trials and it's important that we know the extent of such trials and the reasons for them," Mr Dowd said.

"There are obvious circumstances where trials have to be limited in terms of publicity but these should be extremely rare.

"There needs to be some explanation to the public as to why this has occurred — and if it's not a matter explained to the public, then the matter should be explained to the Parliament."

Bret Walker fears our national security legislation is not working. ( Supplied: The Kings School )

Mr Walker's criticism is similar: "The public has an interest to know when information is being kept secret from them — it's not good enough for the public to be told 'it's in your interests that you are not told'."

"What the [Witness J] case has produced is a concrete example of the dangers of not publishing, in real time as they occur, the fact of the orders being made; it's a really interesting example of the way in which a perfectly well-intentioned piece of national security legislation might not be operating in the way one would like."

Federal independent MP Andrew Wilkie, a former military analyst, is circumspect about the Witness J case, perhaps surprisingly so given he has been outspoken in his criticism of the pursuit of Witness K and his lawyer Bernard Collaery.

"I have made my own inquiries and decided not to comment," is all Mr Wilkie will say of the Witness J case.

Independent MP Andrew Wilkie has made his own inquiries. ( ABC News: Matt Roberts )

But this opaque episode provokes big questions for Australia's legal regime.

Even if there are serious matters of national security at issue, should questions of wrongdoing be held entirely in secret and covered by blanket suppression orders?

And how is it that a man who has given considerably to his nation over a decade and a half — and has the physical and mental scars to show for it — should have his contribution effectively scrubbed out in 13 words?

"I am you. I am an Australian," the man purporting to be Witness J said on Twitter.

"The quiet person you pass in the street. Tonight, I want to do my best to answer your questions, but as a secret prisoner from a secret trial who worked for a secret organisation, I am limited."

But as one informed person observed: "Some secrets must remain secret."