API Key description in EVAL Script of Pattern
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi,
for some reason the OTb pattern for Purity FlashArrays does not recognize the affinity to retrieve a valid API Key from the credential table.So, we decided to write a new step and use a EVAL script to set the token variable.
The credential record is name dafte rthe IP address of the device and we find the record.
we only have a hard time to decypt the token. Various proposed methods do not seem to work.
Below listed is the latest approach. Could anyone help please?
var rtrn = "";
CTX.log("=== PATTERN START - DEBUGGING ===");
var ipAddress = CTX.getManagementIP();
// 1. Query the credentials table
var credSetGR = new GlideRecord('discovery_credentials');
credSetGR.addQuery('name', ipAddress);
credSetGR.query();
if (credSetGR.next()) {
// 2. Retrieve the raw encrypted string from the password/key field
var encryptedValue = credSetGR.getValue("api_key")
if (encryptedValue) {
try {
// 3. Use the MID-server compatible DBPasswordHelper to decrypt the string
// This is the native OOTB Java wrapper exposed in the MID Server environment
rtrn = new SNC.DBPasswordHelper().decrypt(encryptedValue);
// Clean/remove reference in log output for security
CTX.log("=== Credential decrypted successfully inside pattern context ===");
} catch (e) {
rtrn = "Error: Decryption helper failed: " + e.message;
CTX.log("Decryption exception: " + e.message);
}
} else {
rtrn = "Error: Encrypted field is empty";
}
} else {
rtrn = ipAddress + ": no credential set found";
}
CTX.log("=== PATTERN END - DEBUGGING ===");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
22m ago
Soory, it´s a typo in the description, it should be "decryption".