配置和使用凭据允许密码注解
- Updated: 2021/05/21
使用提供的 CredentialTypeDemo.java 包 SDK 文件,并在 Automation 360 locker 操作中的密码字段配置 CredentialAllowPassword 注解。
使用位于 <latest package-sdk>2.0.9\src\main\java\com\automationanywhere\botcommand\samples\commands\basic\types 的以下 CredentialTypeDemo.java 文件作为配置凭据属性的示例。
@BotCommand @CommandPkg(label = "[[CredentialTypeDemo.label]]", description = "[[CredentialTypeDemo.description]]", icon = "sample.svg", name = "credentialTypeDemo") public class CredentialTypeDemo { private static Logger logger = LogManager.getLogger(CredentialTypeDemo.class); /** * 要接受凭据,索引中的 {@link AttributeType} 应为 * {@link AttributeType.CREDENTIAL CREDENTIAL}. 一个 {@link SecureString} * 为任何凭据类型提供。 */ @Execute public void printCredentials(@Idx(index = "1", type = AttributeType.CREDENTIAL) @Pkg(label = "[[CredentialTypeDemo.credentials.label]]") SecureString credentials) { // SecureString 提供了多种访问内部数据的方法。 // 让我们尝试获取用户名并将其打印到日志中。 // 将用户名作为字符串获取 String userName = credentials.getInsecureString(); logger.trace("从 getInsecureString 获取的用户名: {}", userName);
配置索引、类型、标签、可选的描述和 credentialAllowPasswordAttribute。 在创建新包或更新现有包时,使用 CredentialAllowPassword 注解以允许凭据选择器选择标记为密码字段的凭据属性。
@Execute public void printCredentials(@Idx(index = "2", type = AttributeType.CREDENTIAL) @Pkg(label = "[[CredentialTypeDemo.credentialsAllowPasswordAttribute.label]]") @CredentialAllowPassword SecureString credentialAllowPasswordAttribute) {
在
Control Room 中配置属性
在属性名称字段中,输入密码和可选的描述,在输入字段中,选择标准,并输入值。 在安全字段中,选择仅在密码或掩码字段上使用属性。
在
Control Room 中使用凭据属性
- 在选择一个凭据字段中,选择凭据。 在属性字段中,选择用户名。 在为用户提供凭据(可选)字段中,选择凭据,然后选择。
- 在属性字段中,选择密码。 在提供密码凭据(可选)字段中,选择凭据,然后选择。