Configure and use credential allow password annotation

Use the provided CredentialTypeDemo.java package SDK file and configure the CredentialAllowPassword annotation for the password field in Automation 360 locker actions.

Example: Review the CredentialTypeDemo.java

Use the following CredentialTypeDemo.java file located at: <latest package-sdk>2.0.9\src\main\java\com\automationanywhere\botcommand\samples\commands\basic\types as an example on how to configure the credential attribute.

@BotCommand
@CommandPkg(label = "[[CredentialTypeDemo.label]]", 
description = "[[CredentialTypeDemo.description]]", icon = "sample.svg", name = "credentialTypeDemo")
public class CredentialTypeDemo {

	private static Logger logger = LogManager.getLogger(CredentialTypeDemo.class);

	/**
	 * To accept credentials the {@link AttributeType} in index should be
	 * {@link AttributeType.CREDENTIAL CREDENTIAL}. A {@link SecureString} is
	 * provided for any credentials type.
	 */
	@Execute
	public void printCredentials(@Idx(index = "1", type = AttributeType.CREDENTIAL)
	@Pkg(label = "[[CredentialTypeDemo.credentials.label]]")
	SecureString credentials) {
		// SecureString provides multiple way to access the data inside.
		// Let's try to get the user name and print it in logs.

		// To get the username as String
		String userName = credentials.getInsecureString();
		logger.trace("User name from getInsecureString : {}", userName);
Example: Configure the credential attributes @Execute

Configure the index, type, label, optional description, and the credentialAllowPasswordAttribute. When creating a new or updating an existing package, use the CredentialAllowPassword annotation to allow the credential picker to pick a credential attribute marked as a password field.

@Execute
	public void printCredentials(@Idx(index = "2", type = AttributeType.CREDENTIAL)
	@Pkg(label = "[[CredentialTypeDemo.credentialsAllowPasswordAttribute.label]]")
	@CredentialAllowPassword SecureString credentialAllowPasswordAttribute) {
Configure the attributes in the Control Room

In the Attribute name field, enter password and an optional description, in Input field, select Standard, and enter the Value. In the Security field, select Use attribute only on Password or Masked fields.

Use the credential attribute in Control Room
  • In the Pick a credential field, select credential. In the Attribute field, select username. In the Provide the credential for the user (optional) field, select Credential, and then Pick.
  • In the Attribute field, select password. In the Provide the credential for the password (optional) field, select Credential, and then Pick.