How to select X.509 Credentials as a custom Business Process Setting
I have created a custom Business Process setting called X509CredentialAlias in which I load the name of the credential alias to use for some background processes. I have looked through EnsPortal.Component but do not see an option for selecting X509 certs stored within IRIS. How might I adjust this setting to query all X509 certs saved within IRIS and offer a drop-down selection to the user within the business process? Similar to the EnsPortal.Component.sslConfigSelector.
.png)
You can see in the above X509CredentialAlias that I am manually typing the credential alias name. This is where I would like to have a dropdown list similar to the SSL selector above.
.png)
.png)
Comments
This post should give you details on how to implement it:
Dynamic/SQL Drop down list for Business Operation Property Setting
X509 credentials are stored in %SYS.X509Credentials.cls, you can use SQL or use a query defined in %SYS.X509Credentials class.
Create an object that extends %String, and override the VALUELIST with a class method that returns a string with comma-separated values.
Example:
Class App.X509CredentialAlias Extends%String
{
Parameter VALUELIST = {..GetValueList()};ClassMethod GetValueList() As%String
{
Set sql = "SELECT LIST(Alias) As ValueList FROM %SYS.X509Credentials"Set resultSet = ##class(%SQL.Statement).%ExecDirect(,sql)
If (resultSet.%Next())
{
Return","_resultSet.ValueList
}
Return""
}
}
Your BPL property must be the type of the created object
Class App.bp.Test Extends Ens.BusinessProcessBPL [ ClassType = persistent, ProcedureBlock ]
{
Property Example As App.X509CredentialAlias;Parameter SETTINGS = "Example:App";/*
my BPL
*/
}This worked perfectly. I had modify the string output of GetValueList() to wrap the list in quotes like this: ",Flight Vector,test"
ClassMethod GetValueList() As%String
{
Set sql = "SELECT LIST(Alias) As ValueList FROM %SYS.X509Credentials"Set resultSet = ##class(%SQL.Statement).%ExecDirect(,sql)
If (resultSet.%Next())
{
Return$char(34) _ "," _ resultSet.ValueList _ $char(34)
}
Return""
}.png)
I now have an issue with the App settings list within the Business Process not updating once a cert is removed from the certificate credentials manager. If I add a cert, it reflects in the list but once removed, the cert alias stays in the settings list. Any ideas on how I can update the property list that's being stored to reflect the current list state?
Using the Curly Braces a parameter is evaluated at compile time:
Parameter VALUELIST = {..GetValueList()};
You need to evaluate it at run time, in that case use COSEXPRESSION:
Parameter VALUELIST As COSEXPRESSION = "..GetValueList()";
The the relevant documentation is:
What am I missing here?
Class ECUH.BPL.ClassMethods.X509CredentialAlias Extends%String
{
Parameter VALUELIST As COSEXPRESSION = "..GetValueList()";ClassMethod GetValueList() As%String
{
Set sql = "SELECT LIST(Alias) As ValueList FROM %SYS.X509Credentials"Set resultSet = ##class(%SQL.Statement).%ExecDirect(,sql)
If (resultSet.%Next())
{
Return$char(34) _ "," _ resultSet.ValueList _ $char(34)
}
Return""
}
}
This currently returns:
.png)
Not sure I understand how a method can be passed into a COSEXPRESSION even after reading the ref. materials.
Parameter runtime computation works fine, you can test it from terminal:
w ##class(ECUH.BPL.ClassMethods.X509CredentialAlias).#VALUELIST
Long story short, you cannot use runtime computed VALUELIST in this context.
I suggest using the proper, officially documented way to implement your requirement, see my first answer above.