Configuration

Extensions: Getting Started

An ExtensionPoint will typically need some user-supplied configuration.

For example, an extension point might reach out to an external service and query whether or not the user on the registration request is still employed by the company. The extension point might need an API URL and an API authentication token.Β The extension can specify configuration attributes needed for its operation.

Custom Configuration

Each ExtensionPoint can specify configuration expected from the user. Once deployed, CC will present an auto-generated configuration UI.

To specify configuration:

  • Extend ExtensionPoint from theΒ ConfigurableExtensionPointΒ class
  • Override theΒ List<ExtensionConfigAttribute> getConfigAttributes()Β method to return a list of ExtensionConfigAttributeΒ needed by the extension
  • At runtime the server will invoke the setConfigAttributes(List<ExtensionConfigAttribute> config) method and pass the user supplied configuration to the ExtensionPoint

πŸ“˜

NOTE

Configuration is on a per-extension basis. If multiple RPApplications are associated with an extension, the same configuration is used across all of them.

Configuration across Multiple ExtensionPoints

Each ExtensionPoint can supply ExtensionConfigAttributes
.
All attributes from the all ExtensionPoints in an Extension are aggregated on the UI. Each ExtensionPoint is provided with all the config attributes on the setConfigAttributes(). This allows us to capture the common configuration only once.

Updating Config via CC UI

Once the extension is deployed successfully, it can be configured via the CC UI. See Control Center Advanced: Global Settings: Intelligent Extensions. Once you save your changes:

  • The configuration is passed to the extension and saved in the database
  • The extension will receive this configuration on subsequent extension restarts

ConfigAttribute

ConfigurationΒ is supplied by overriding the List<ExtensionConfigAttribute> getConfigAttributes() in the ConfigurableExtensionPoint interface:

Each instance of ExtensionConfigAttribute in the list is a configuration attribute.

The code below explains the various attributes on ExtensionConfigAttribute.

ExtensionConfigAttribute {

    private String name;
    private Object value;
    private ExtensionConfigAttributeType type = ExtensionConfigAttributeType.STRING;
    private Object defaultValue = null;
    private String description = "";

    /**
     * Is this confidential info? Example a password or API token
     */
    private Boolean sensitive = false;

    /**
     * Is this attribute not supplied in its entirety for security reasons?
     * Users are able to update redacted attributes by setting this to false on the update request
     */
    private Boolean redacted = false;

    private Boolean required = true;

    /**
     * Indicates more granular config, typically shown in an advanced section
     */
    private Boolean advancedConfig = false;

    /**
     * An array containing the list of values allowed for the parameter.
     * Can be used to display a dropdown selection
     */
    private List<String> allowedValues = null;

    /**
     * A regular expression that represents the patterns to allow for _String_ type
     */
    private Pattern allowedPattern = Pattern.compile(".*");

    /**
     * A numeric value that determines the smallest _numeric_ value you want to allow for Number types.
     */
    private Integer minValue = null;

    /**
     * A numeric value that determines the largest _numeric_ value you want to allow for Number types.
     */
    private Integer maxValue = null;

    /**
     * Any additional metadata to tbe passed on to the reciever
     */
    private Map<String, String> metadata = new HashMap<>(); 
}

Sample Configuration

String

ExtensionConfigAttribute serviceUrl = new ExtensionConfigAttribute();
serviceUrl.setName(SERVICE_ENDPOINT_PARAM.name());
serviceUrl.setDescription("REST API endpoint for  service");
serviceUrl.setDefaultValue("https://sample.com/api/");

// Inidicate mandatory
serviceUrl.setRequired(true);   

// This defines the type
serviceUrl.setType(STRING);

The above snippet is rendered on the CC UI as:

1140

Number

ExtensionConfigAttribute failThreshold = new ExtensionConfigAttribute();
failThreshold.setName(FAIL_THRESHOLD_PARAM.name());
failThreshold.setDescription("Number of breaches to allow before stopping registration");
failThreshold.setMinValue(5);
failThreshold.setMaxValue(50);
failThreshold.setType(NUMBER);

The above snippet is rendered on the CC UI as:

1132

Boolean

ExtensionConfigAttribute warnOnly = new ExtensionConfigAttribute();
warnOnly.setName(WARN_ONLY_PARAM.name());
warnOnly.setDescription("Only log warning instead of failing the registration");
warnOnly.setRequired(true);
warnOnly.setDefaultValue("false");
warnOnly.setType(BOOLEAN);

The above snippet is rendered on the CC UI as:

1136

Multiple Choice

ExtensionConfigAttribute country = new ExtensionConfigAttribute();
country.setName(COUNTRY_PARAM.name());
country.setDescription("Check for breaches in this Country");

// This indicates multiple choice attribute
country.setAllowedValues(Arrays.asList("US", "UK", "AUS", "CAN", "MEX", "RUS", "IND"));

country.setDefaultValue("US");
country.setType(STRING);
1136