When developing custom servlet plugins, there are certain use cases that require access to the Third Party Credentials Store (SCS) in order to achieve an integration or specific business use case. Currently, direct access to the SCS is not supported in servlet plugins. This article details a workaround that uses a Cloud supported approach to gain access to SCS values from inside the servlet.
public String getSecureCredentialValue( ServiceContext sc, SecureCredentialsStore scs, @Parameter String systemKey, @Parameter String fieldKey) { try { Map<String, String> credentials = scs.getSystemSecuredValues(systemKey); String fieldValue = credentials.get(fieldKey); return fieldValue; } catch (Exception e) { return null; }}
SYSTEM_KEY
FIELD_KEY
ServiceContext context = WebServiceContextFactory.getServiceContext(req);ProcessDesignService pds = ServiceLocator.getProcessDesignService(context);String scsFunction = String.format("getSecureCredentialValue(\"%s\",\"%s\")", SYSTEM_KEY, FIELD_KEY);
TypedValue scsCallResult = pds.evaluateExpression(scsFunction);String value = scsCallResult.getValue().toString();
value
Note: The provided code are examples and should be updated to conform to best practices regarding logging and exception handling.
This article applies to all versions of Appian.
Last Reviewed: March 2018