JWT Connection
This connection implements JWT authentication.
Properties
Option | Type | Default | Description |
---|---|---|---|
| string | Â | ID of the connection. |
| string | Â | Base URL of the connection. A full path must be provided (e.g.:Â https://...). |
| java.util.Map | Â | Custom headers. |
| string | Â | Name of the certificate. |
| string | Â | Endpoint used for authentication purposes. This is often a separate endpoint which provides a token for further calls. A full path must be provided (e.g.: https://https://login.salesforce.com/services/oauth2/token). |
| string | Bearer | Prefix used in the authentication request header. Usually, the value is 'Bearer' in this kind of authentication. |
| string | Authentication | Header used for authentication. |
| string | Â | Content type of authentication request. This should adhere to the server requirements. Usually, 'application/x-www-form-urlencoded' is used for OAuth2-based authentications, whereas 'application/json' is used for JWT-based authentications. |
| string |  | Defines a key from which a token is parsed. E.g. if auth response is {'token': ‘aaa', 'expires':'155555'}, the actual token is in the 'token' key, thus the value of the field is 'token’. |
| string | Â | Token validity is often limited. If the response returns the token expiration, the key will be parsed and re-authentication will be automatically made once the token expires. E.g. if auth response is {'token': 'aaa', 'expires':'155555'}, the actual token is in the 'expires' key, thus the value of the field is 'expires'. The token will be automatically refreshed in 155555 milliseconds. |
| string | Â | Defines location of the field 'expires_in' (or other selected) when it is returned. The options are: body_json, body_plaintext, header_json, header_plaintext. E.g. body_json means that 'expires' is located in the JSON response body. Possible values are: body_json, body_property_based, header_json, header_plaintext. |
| string | Â | When a list of values separated by a comma is defined, whenever a certain code form list is returned from any request, the authorization is called again. This occurs for example in Salesforce. Example value: 400,401,404. |
| string | Â | Token expiration is handled in milliseconds by default. Specify a multiplier if the unit is different (1=ms, 1000=s, ...). |
| string | Â | Username for basic authentication. |
| string | Â | Password for basic authentication. |
| Â | Â | Â |
Examples
Define a new connection:
<bean id="basicConn" class="net.pricefx.integration.component.rest.domain.connection.JwtConnection">
<property name="url" value="https://thecompany.com"/>
<property name="authUrl" value="https://thecompany.com/auth"
<property name="authRequestHeaderBearer" value="Pricefx"/>
<property name="authRequestHeader" value="PartitionX"/>
<property name="username" value="pasta"/>
<property name="password" value="rasta"/>
</bean>
Use it in a route:
<route id="opendata2-create">
<from uri="direct:create"/>
<to uri="pfx-rest:post?uri=/A_SalesOrder&connection=basicConn"/>
<to uri="mock:create"/>
</route>
Results:
Request to https://thecompany.com/auth is done, auth response is parsed according to the properties definition. The token is extracted, expiration is extracted.
Request to https://thecompany.com/A_SalesOrder was done with the headerÂ
PartitionX
 and valueÂPricefx xxx
(xxx is retrieved token).Data are returned.
IntegrationManager version 5.8.0