Thursday, June 4, 2020

Secure Password Input in ANT

While doing ANT deployment in salesforce, in general we have to store user name and password in file which is also a big concern for organization in terms of security. Since we are storing the credential in a file, so there may have chance of unauthorized person to access SF due to inappropriate handle of the local machine.

So I am trying to find out a solution in which we do not need to store username and password in

We will do some modification in the build.xml file which will eventually ask user to enter user name and password in every ANT command.

Added the following script withing the every <target> tag in build.xml file.

            <input message="User Name :" addproperty="username"/>
            <input message="Password :" addproperty="password">
            <handler type="secure"/>

So the build.xml file will looks like-

Note that you do not need to store the credential in file.

Now run your ANT command in command prompt-

Here I am running ant deployCode command to deploy the package.xml

Then it will prompt for user name inputà input your user name and press Enter

Input your password and press Enter

Here the password that you will type will not be visible.