1

I'm trying to use Mule Credentials Vault security feature. I've created .properties file, Security Property Placeholder and defined the key and encryption algorithm. Now I want to use some of the properties from the file when I return HTTP response.

I have the file src/main/resources/data.properties that contains for example:

In my canvas, under Configuration XML I added:

<secure-property-placeholder:config name="Secure_Property_Placeholder" key="24681357" location="data.properties" doc:name="Secure Property Placeholder" encryptionAlgorithm="DES"/>

<set-variable variableName="card.number" value="${number}" />

In my canvas I have message flow that builds xml 'Create XML response based on User'. The value in settings is:

This doesn't work. The error I get is:

-> org.mule.module.launcher.DeploymentInitException: IllegalArgumentException: Could not resolve placeholder 'key' in string value "${key}"

-> Caused by: org.mule.api.lifecycle.InitialisationException: Invalid bean definition with name 'org.mule.autogen.bean.13' defined in null: Could not resolve placeholder 'key' in string value "${key}"; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'key' in string value "${key}"

-> Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'key' in string value "${key}"

Does anyone know how can I read the properties from .properties file (credentials vault)? And then use it in my flow?

Thanks, Keren

KerenSi
  • 389
  • 7
  • 20
  • The example code you provide does not seem to match the error message you pasted. Can you provide a more complete example that shows where you use the property §{key} – Pontus Ullgren Jan 05 '15 at 09:45
  • @Pontus Ullgren. I added screenshots, do they help? I trying to lean how to use Mule Credentials Vault upon Mule's example: http://www.mulesoft.org/documentation/display/current/Anypoint+Enterprise+Security+Example+Application – KerenSi Jan 05 '15 at 10:34
  • One obvious mistake I spot is how you try to access the variable card.number . You should not use §{card.number} instead you should use #[flowVars.'card.number']. However it still doesn't explain the missing key property. – Pontus Ullgren Jan 05 '15 at 10:35
  • @Pontus Ullgren. What helped me was doing in the Configuration XML the same as you suggested: "#[number] instead of "${number}". The outcome is . Thanks! – KerenSi Jan 05 '15 at 10:53
  • When I parsed the XML what I got in the output was "#[flowVars.'card.number']" hardcoded... The answers were helpful with the error, but I didn't get the XML I wanted. – KerenSi Jan 05 '15 at 14:28
  • It is still not clear what you try to achieve. If you simply want to add the number from the properties file into the response then I've posted an answer for this below. If this is not what you are looking for you should rephrase your question to clearly state what your objective is and provide more code example, in XML, not images. – Pontus Ullgren Jan 05 '15 at 19:18

4 Answers4

1

If you simply want to get the value for the property number and add it into the XML you can use ${number} from .properties. No need to define any other variables in Configuration XML.

<set-payload value="&lt;user&gt;&lt;name&gt;Royal Bank of Canada&lt;/name&gt;&lt;id&gt;Royal_Bank_Of_Canada&lt;/id&gt;&lt;cc&gt;&lt;company&gt;&gt;Visa&lt;/company&gt;&lt;number&gt;${number}&lt;/number&gt;&lt;secret&gt;123&lt;/secret&gt;&lt;/cc&gt;&lt;/user&gt;" doc:name="Set Payload"/>

However note that the property placeholder is resolved at startup so you will not be able to dynamically retrieve a property based on some user input. For this you will have to do some Java coding. This SO post gives you some hints on how this can be achieved. Based on those answers I have created a simple example on how this can be done with a very simple helper bean.

Community
  • 1
  • 1
Pontus Ullgren
  • 697
  • 6
  • 24
0

I'm afraid you just can't. The Mule Credentials Vault is an enterprise feature and therefore tipically you won't have access to the source code unless you are a MuleSoft customer.

Even if you were a customer, the api you'd use would be sort of unsupported. I suggest to manually create a custom java component levearing your code and Jasypt (not as a property placeholder but as a library).

The other option, if you are a customer (I guess you are given you are using the credentials vault) is to contact the official support so they take care of it for you.

Víctor Romero
  • 5,107
  • 2
  • 22
  • 32
  • So basically you say that Mule customers can't use the Mule Credentials Vault? As I stated, my requirements are to use this Mule security feature, and I'm trying to figure out how to work with it. – KerenSi Jan 05 '15 at 14:28
  • I say the opposite, only mule customers can use the credentials vault as it is an enterprise feature. – Víctor Romero Jan 05 '15 at 14:52
  • But you say that even if I am an enterprise user I should work with Java and Jasypt... I want to understand how to draw information from the .properties files, it seems like a basic operation. It doesn't have a simple solution? – KerenSi Jan 05 '15 at 14:57
  • I say so because what the credentials vault offer is just a property placeholder configuration, not a supported API to access properties on the fly. – Víctor Romero Jan 05 '15 at 15:05
  • And Mule has an API that supports access properties on the fly? I searched your documentation and didn't find how to do it. – KerenSi Jan 05 '15 at 15:19
  • No it doenst, you need to use the aforementioned libraries. – Víctor Romero Jan 05 '15 at 15:30
0

The property placeholder is used resolve at startup so you will not be able to dynamically retrieve a property based on some user input.

Use ${propertyName} from .properties in MEL to access particular property

0

From Dataweave you can read it as given below p('variablename') where variablename is defined in property files ex: variablename = 15

Srinivas
  • 92
  • 3
  • Is there any mention of Dataweave in the question? Unless I'm missing something this is not the answer to the original question. – lolbas Feb 27 '18 at 06:49