Problem creating a Password Alias in Custom JNDI Resource

81 views
Skip to first unread message

Ulrich Mayring

unread,
Jul 11, 2017, 6:16:27 PM7/11/17
to Payara Forum
I have created a password alias:

asadmin --interactive=false --user admin --passwordfile=./mypasswords.txt create-password-alias my-password

The password file contains:
AS_ADMIN_PASSWORD=superSecretPassword
AS_ADMIN_ALIASPASSWORD=changeit

I would expect that "my-password" now contains "changeit", but of course there is no way of knowing except that asadmin tells me it has successfully created the alias.

So then I created a custom JNDI resource:

asadmin --interactive=false --user admin --passwordfile=./mypasswords.txt create-custom-resource --property username=admin:password=${ALIAS=my-password} --restype com.example.MyResource --factoryclass com.example.MyResourceFactory my/jndiname

Upon logging in to the admin console I can see that my custom JNDI resource was created successfully, but in the password field it contains the string "my-password" instead of "${ALIAS=my-password}". Is that a bug or do I need to quote some characters?

Many thanks in advance for any pointers,

Ulrich

ondrej....@gmail.com

unread,
Jul 12, 2017, 9:38:23 AM7/12/17
to Ulrich Mayring, Payara Forum

Did u run asadmin from console or shell script?

You have to either escape $ and { characters or put the whole expression into single quotes,like this:

 

'${ALIAS=my-password}'

 

I guess that the shell evaluate the expression to my-password before it executed the asadmin command


Ondro

--
You received this message because you are subscribed to the Google Groups "Payara Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to payara-forum...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/payara-forum/bc4622da-b9f8-424a-98a4-351d27174ac9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

 

Ulrich Mayring

unread,
Jul 12, 2017, 11:29:30 AM7/12/17
to Payara Forum, real...@gmail.com
I ran asadmin from a shell script. Putting single quotes around the parameter like you suggested resulted in the following error message:

remote failure: Invalid property syntax, "=" in value: password=${ALIAS=my-password}

The same goes for several types of escaping I've tried.

Hence my question here, what is the correct way of escaping?

Ulrich

Ulrich Mayring

unread,
Jul 12, 2017, 6:02:20 PM7/12/17
to Payara Forum, real...@gmail.com
Patting myself on the back, I actually managed to get this done. You need to enclose the entire password with single quotes and then *additionally* escape the problematic characters like so:

password='\$\{ALIAS\=my-password\}'

Ulrich
Reply all
Reply to author
Forward
0 new messages