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
PartitionXand valuePricefx xxx(xxx is retrieved token). -
Data are returned.