How to delete credential store and alias using JBoss CLI

Latest response

I am trying to create credential store and an alias using JBoss CLI script and then delete them using script. I am doing it as follows:

I have the following script: jboss-credential-store-add.cli

batch

/subsystem=elytron/credential-store=credential_store_vsit:add(location="credentials_vsit/csstore.jceks", relative-to=jboss.server.data.dir,  credential-reference={clear-text=credential_mypassword},create=true)

/subsystem=elytron/credential-store=credential_store_vsit:add-alias(alias=credential-store-alias_vsit, secret-value="certificate-password")

run-batch

I run the following command to execute the above script, I get the following output.
./jboss-cli.sh --connect --file=jboss-credential-store-add.cli

The batch executed successfully

I have another script: jboss-credential-store-remove.cli

/subsystem=elytron/credential-store=credential_store_vsit:remove-alias(alias=credential-store-alias-vsit)

/subsystem=elytron/credential-store=credential_store_vsit:remove()

when I try to run it as follows:
./jboss-cli.sh --connect --file=jboss-credential-store-remove.cli,
I get the following error.

{
    "outcome" => "failed",
    "result" => undefined,
    "failure-description" => "WFLYELY00920: Credential alias 'credential-store-alias-vsit' of credential type 'org.wildfly.security.credential.PasswordCredential' does not exist in the store",
    "rolled-back" => true
}

I have tried a lot of things for jboss-credential-store-remove.cli like changing order of the commands in above script / running as batch etc. but it is not working.

Basically I want to perform clean up using jboss-credential-store-remove.cli what was created using jboss-credential-store-add.cli

How can I achieve it.

Thanks.

Responses