VMware Cloud Community
nick800
Contributor
Contributor

Using an encrypted string for a password to a dynamically created(transient?) rest host

Trying to figure out if there's a way to do this without creating a custom plugin, but effectively I want to create a RestHost dynamically in the code, the call requires Basic Authentication so I'd like to store the credentials in a configuration element as an encrypted string. Unfortunately it does not appear possible as the RESTAuthenticationManager creates the authentication header using strings.

Create the restHost

var restHost = RESTHostManager.createHost("SomeName");

httpRestHost = RESTHostManager.createTransientHostFrom(restHost);

Apply Authentication

var authParams = ['Shared Session', user, password];

var authenticationObject = RESTAuthenticationManager.createAuthentication('Basic', authParams);

httpRestHost.authentication = authenticationObject;

This works with valid user/password, however there seems to be no way to pass an encrypted string as the password instead.

Has anyone been able to achieve this?

0 Kudos
1 Reply
prashant88
Contributor
Contributor

You could store the password in securestring format in configurations element.

if you want to store it in encrypted format then you would have to decrypt it before passing on to RestHost manager.

0 Kudos