Question Bransen Smith · Mar 14, 2024

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. 

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.

Product version: IRIS 2021.2

Comments

Rodolfo Moreira dos Santos · Mar 14, 2024

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
*/
}
0
Bransen Smith  Mar 15, 2024 to Rodolfo Moreira dos Santos

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""
}

0
Bransen Smith  Mar 15, 2024 to Rodolfo Moreira dos Santos

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?

0
Enrico Parisi  Mar 15, 2024 to Bransen Smith

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:

Defining and Referring to Class Parameters

0
Bransen Smith  Mar 15, 2024 to Enrico Parisi

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:

 

Not sure I understand how a method can be passed into a COSEXPRESSION even after reading the ref. materials.

0
Enrico Parisi  Mar 16, 2024 to Bransen Smith

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.

0