Hi @iamology and @BBR1 and everyone,
Here we would like to use external trigger worfklow to send the temporary password created in JDBC provisioning rule to the end user.
Please refer to the below rule code and workflow code and provide your feedback.
Please refer the below code for JDBC create account operation:
final int PASSWORD_LENGTH = 24;
String upperChars = “ABCDEFGHIJKLMNOPQRSTUVWXYZ”;
String lowerChars = “abcdefghijklmnopqrstuvwxyz”;
String digits = “0123456789”;
String specialChars = “!@#$%&*()-_=+{};:,.<>?”;
String allChars = upperChars + lowerChars + digits + specialChars;
Random rnd = new Random();
// Build password with guaranteed complexity
StringBuilder password = new StringBuilder(PASSWORD_LENGTH);
// 1. Uppercase
password.append(upperChars.charAt(rnd.nextInt(upperChars.length())));
// 2. Lowercase
password.append(lowerChars.charAt(rnd.nextInt(lowerChars.length())));
// 3. Digit
password.append(digits.charAt(rnd.nextInt(digits.length())));
// 4. Special
password.append(specialChars.charAt(rnd.nextInt(specialChars.length())));
// 5. Fill the rest — ensuring total length >= PASSWORD_LENGTH
for (int i = 4; i < PASSWORD_LENGTH; i++) {
password.append(allChars.charAt(rnd.nextInt(allChars.length())));
}
// Shuffle characters for randomness
char pwdArray = password.toString().toCharArray();
for (int i = 0; i < pwdArray.length; i++) {
int randomPos = rnd.nextInt(pwdArray.length);
char temp = pwdArray[i];
pwdArray[i] = pwdArray[randomPos];
pwdArray[randomPos] = temp;
}
String newPassword = new String(pwdArray);
// BUILD SQL
String createUser =
“CREATE USER “” + nativeIdentity + “” IDENTIFIED BY “” + newPassword +
“” TEMPORARY TABLESPACE TEMP2 PROFILE test”;
PreparedStatement ps = null;
try {
ps = connection.prepareStatement(createUser);
ps.executeUpdate();
} finally {
if (ps != null) ps.close();
}
// Grant CREATE SESSION
ps = null;
try {
ps = connection.prepareStatement(
“GRANT CREATE SESSION TO “” + nativeIdentity + “””
);
ps.executeUpdate();
} finally {
if (ps != null) ps.close();
}
// Grant SELECT ANY TABLE
ps = null;
try {
ps = connection.prepareStatement(
“GRANT SELECT ANY TABLE TO “” + nativeIdentity + “””
);
ps.executeUpdate();
} finally {
if (ps != null) ps.close();
}
// Grant SELECT ANY DICTIONARY
ps = null;
try {
ps = connection.prepareStatement(
“GRANT SELECT ANY DICTIONARY TO “” + nativeIdentity + “””
);
ps.executeUpdate();
} finally {
if (ps != null) ps.close();
}
result.setStatus(ProvisioningResult.STATUS_COMMITTED);
String workflowId = “1234”;
String email = getAttributeRequestValue(account, “email”);
String workflowUrl = “https://sailpoint.api.identitynow.com/v2024/workflows/”
URL url = new URL(workflowUrl);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod(“POST”);
conn.setDoOutput(true);
conn.setRequestProperty(“Content-Type”, “application/json”);
String jsonInput = “{”
- ““input”:{”
- ““email”:“” + email + “”,”
- ““newPassword”:“” + newPassword + “”,”
- ““nativeIdentity”:“” + nativeIdentity + “””
- “}”
- “}”;
OutputStream os = conn.getOutputStream();
os.write(jsonInput.getBytes(“UTF-8”));
os.flush();
os.close();
int responseCode = conn.getResponseCode();
log.info("Workflow Response Code: " + responseCode);
Workflow code:
{
“name”: “EBS DB Email Notify”,
“description”: “EBS DB Email Notify”,
“definition”: {
“start”: “Send Email”,
“steps”: {
“Send Email”: {
“actionId”: “sp:send-email”,
“attributes”: {
“body”: “Hello {{$.trigger.nativeIdentity}},\nYour Oracle test - JDBC DV3 DB account has been successfully created.\nSource: Oracle test - JDBC DV3 - JDBC DV3\nYou can now log in to corporate systems using your test - JDBC DV3 DB credentials $.trigger.newPassword and change password.\nRegards,
IAM Team”,
“context”: {},
“from”: “no-reply-stage@identity.test4567.com”,
“recipientEmailList.$”: “$.trigger.email”,
“subject”: “Your Oracle Oracle test - JDBC DV3 Account is Ready”
},
“displayName”: “”,
“type”: “action”,
“versionNumber”: 2
}
}
},
“trigger”: {
“type”: “EXTERNAL”,
“attributes”: {
“id”: “idn:external-http”
}
}
}
Thanks