BANGOR, Maine — A Glenburn woman whose 17-year plea deal on sex charges was rejected last month by a District Court judge was sentenced Friday to 23 years in prison, followed by 15 years of supervised release on charges in connection with the sexual abuse of a now 9-year-old boy.

Katie Dube, 27, who originally pleaded guilty in October, pleaded guilty again on Friday just before being sentenced on five counts of gross sexual assault and two counts of sexual exploitation of a minor.

On Dec. 3, Judge Bruce Jordan rejected a plea agreement that called for Dube to spend 17 years in prison in exchange for her guilty pleas. Dube, who has no prior criminal record, withdrew her guilty pleas then but recently decided to plead guilty again, according to her attorney, Hunter Tzovarras of Bangor.

Under Maine law, if a judge rejects a plea agreement, a defendant may withdraw a guilty plea.

Dube was arrested with her live-in boyfriend, Terrence A. Pinkham, 27, of Bangor, in May on charges that they sexually abused the child in early 2011.

Both have been held at the Penobscot County Jail since their arrests. Pinkham’s case is pending.

The child, now 9, lives with a relative in rural Penobscot County and is related to Dube, according to court documents and information presented in court to Jordan on Dec. 3.

The Bangor Daily News is not naming the relationship between the defendant and the victim nor is the paper identifying the family he now lives with in order to avoid identifying him.

Under Maine law, Dube will be required to register as a sex offender for the rest of her life. Conditions of her supervised release include no unsupervised contact with children under the age of 18, no access to the Internet without permission from her probation officer, undergoing sex offender treatment, no use of drugs or alcohol, and random searches and testing for those substances.

Jordan said Friday that “23 years is an appropriate sentence.” He did not further outline his reasons for accepting the plea agreement but noted he had said last month that he would accept a sentence of between 21 and 24 years.

In rejecting the plea agreement last month, Jordan said the Legislature has said gross sexual assault on a child under the age of 12 is so severe a crime that it is punishable by any number of years. He also said Dube chose to resume a relationship with Pinkham, who has a history of drug abuse and domestic violence, when he was released from prison in early 2010 after five years in a stable relationship with another man.

“She initiated contact with Pinkham,” Jordan said in December. “She said that she went back to him for his looks and the drugs.”

As she did last month, Dube cried throughout Friday’s hearing. In December, she described a life of drugs and violence with Pinkham, who she said forced her to engage in sexual abuse of the child.

“I’m extremely ashamed,” she told Jordan before the judge told her he was rejecting her plea deal. “A lot of things can be replaced but kids aren’t one of them.”

She apologized to the victim and the dozen or so family members in the courtroom last month.

She did not address the court Friday.

Dube faced up to life in prison and a fine of up to $50,000 on each count, as does Pinkham.