Package org.frankframework.http.rest
Class ApiListener
java.lang.Object
org.frankframework.http.PushingListenerAdapter
org.frankframework.http.rest.ApiListener
- All Implemented Interfaces:
HasPhysicalDestination
,IConfigurable
,IConfigurationAware
,IListener<Message>
,INamedObject
,IPushingListener<Message>
,IScopeProvider
,ReceiverAware<Message>
,ServiceClient
,org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
public class ApiListener
extends PushingListenerAdapter
implements HasPhysicalDestination, ReceiverAware<Message>
Listener that allows a
Receiver
to receive messages as a REST webservice.
Prepends the configured URI pattern with api/
. The structure of REST messages is described
by OpenAPI specifications. The Frank!Framework generates an OpenAPI specification for each ApiListener and
for all ApiListeners in all configurations combined. You can
find them in the Frank!Console under main menu item Webservices, heading Available ApiListeners.
The generated OpenAPI specifications have servers
and paths
objects and
therefore they document the full URLs of the provided services.
It is possible to automatically generate eTags over the listener result. This can be controlled by globally
setting the property api.etag.enabled
or by setting the attribute updateEtag="true"
.
When enabled the listener will respond to the If-Match
, If-None-Match
headers and may return status code 304.
In order to enable eTags for multiple nodes you must configure Memcached to store the eTags. The following properties will need to be set:
etag.cache.server=ip or hostname:port
etag.cache.type=memcached
etag.cache.username
etag.cache.password
etag.cache.authalias
- Author:
- Niels Meijer
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
static enum
-
Field Summary
Fields inherited from class org.frankframework.http.PushingListenerAdapter
log
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Match request 'Accept' header to produces enum to see if the client accepts the messagevoid
initialize listener and registerthis
to the JNDIreturns the clear pattern, replaces everything between{}
to*
org.springframework.util.MimeType
JwtValidator<com.nimbusds.jose.proc.SecurityContext>
boolean
isConsumable
(String contentType) Match request 'Content-Type' (eg. on POST) to consumes enum to see if the listener accepts the messageboolean
static boolean
isValidUriPattern
(String uriPattern) void
setAnyMatchClaims
(String string) Comma separated key value pairs to one-of match with JWT payload. e.g.void
setAuthenticationMethod
(ApiListener.AuthenticationMethods authenticationMethod) Enables security for this listener.void
setAuthenticationRoles
(String authRoles) Only active when AuthenticationMethod=AUTHROLE.void
setCharacterEncoding
(String charset) The specified character encoding on the response contentType header.void
setConsumes
(MediaTypes value) The required contentType on requests, if it doesn't match a415
status (Unsupported Media Type) is returned.void
Session key that provides theContent-Disposition
header in the responsevoid
setCorrelationIdHeader
(String correlationIdHeader) Name of the header which contains the Correlation-Id.void
setExactMatchClaims
(String string) Comma separated key value pairs to exactly match with JWT payload. e.g.void
setHeaderParams
(String headerParams) Comma separated list of parameters passed as http header.void
setJwksURL
(String string) Keysource URL to validate JWTvoid
setJwtHeader
(String string) Header to extract JWT fromvoid
setMessageIdHeader
(String messageIdHeader) Name of the header which contains the Message-Id.void
setMethod
(ApiListener.HttpMethod method) HTTP method to listen tovoid
setMethods
(ApiListener.HttpMethod... methods) HTTP method(s) to listen to.void
setMultipartBodyName
(String multipartBodyName) Specify the form-part you wish to enter the pipelinevoid
setOperationId
(String operationId) Unique string used to identify the operation.void
setPrincipalNameClaim
(String principalNameClaim) Claim name which specifies the principal name (maps toGetPrincipalPipe
)void
setProduces
(MediaTypes value) The specified contentType on response.void
setReceiver
(Receiver<Message> receiver) void
setRequiredClaims
(String string) Comma separated list of required claimsvoid
setRequiredIssuer
(String issuer) Issuer to validate JWTvoid
setResponseFirstBodyPartName
(String responseFirstBodyPartName) If response is sent as Multipart (HttpEntityType.FORMDATA
orHttpEntityType.MTOM
), when this option is set the pipeline result message will be prepended as first Multipart Bodypart with this name.void
setResponseMtomContentTransferEncoding
(String responseMtomContentTransferEncoding) If the response is sent asHttpEntityType.MTOM
, optionally specify the transfer-encoding of the first part.void
setResponseMultipartXmlSessionKey
(String responseMultipartXmlSessionKey) If response is sent as Multipart (HttpEntityType.FORMDATA
orHttpEntityType.MTOM
) an optional session key can describe the Multipart contents in XML.void
setResponseType
(HttpEntityType responseType) Optional configuration setting to have more control over how to send the response.void
setRoleClaim
(String roleClaim) Claim name which specifies the role (maps toIsUserInRolePipe
)void
setServletManager
(ServletManager servletManager) void
setUpdateEtag
(boolean updateEtag) Automatically generate and validate etagsvoid
setUriPattern
(String uriPattern) URI pattern to register this listener on, eq.void
start()
Prepares the listener for receiving messages.void
stop()
Close all resources used for listening.toString()
Methods inherited from class org.frankframework.http.PushingListenerAdapter
afterMessageProcessed, extractMessage, getApplicationContext, getConfigurationClassLoader, getName, isApplicationFaultsAsExceptions, isRunning, processRequest, setApplicationContext, setApplicationFaultsAsExceptions, setExceptionListener, setHandler, setName, setRunning, wrapRawMessage
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.context.ApplicationContextAware
setApplicationContext
Methods inherited from interface org.frankframework.core.IConfigurationAware
getApplicationContext, getName
Methods inherited from interface org.frankframework.core.IListener
afterMessageProcessed, extractMessage
Methods inherited from interface org.frankframework.core.INamedObject
getName, setName
Methods inherited from interface org.frankframework.core.IScopeProvider
getConfigurationClassLoader
-
Constructor Details
-
ApiListener
public ApiListener()
-
-
Method Details
-
configure
initialize listener and registerthis
to the JNDI- Specified by:
configure
in interfaceIConfigurable
- Specified by:
configure
in interfaceIListener<Message>
- Overrides:
configure
in classPushingListenerAdapter
- Throws:
ConfigurationException
-
start
public void start()Description copied from interface:IListener
Prepares the listener for receiving messages.open()
is called once each time the listener is started.- Specified by:
start
in interfaceIListener<Message>
- Overrides:
start
in classPushingListenerAdapter
-
stop
public void stop()Description copied from interface:IListener
Close all resources used for listening. Called once each time the listener is stopped.- Specified by:
stop
in interfaceIListener<Message>
- Overrides:
stop
in classPushingListenerAdapter
-
getCleanPattern
returns the clear pattern, replaces everything between{}
to*
- Returns:
- null if no pattern is found
-
isConsumable
Match request 'Content-Type' (eg. on POST) to consumes enum to see if the listener accepts the message -
accepts
Match request 'Accept' header to produces enum to see if the client accepts the message -
setMethod
HTTP method to listen to- Default value
- GET
-
getAllMethods
-
setMethods
HTTP method(s) to listen to. Inside XML Configurations: for multiple values, use a comma as separator.- Default value
- GET
-
setUriPattern
URI pattern to register this listener on, eq./my-listener/{something}/here
-
setConsumes
The required contentType on requests, if it doesn't match a415
status (Unsupported Media Type) is returned.- Default value
- ANY
-
setProduces
The specified contentType on response. WhenANY
the response will determine the content-type when it's known and will never calculate it. If no match is found*/*
will be used. WhenDETECT
the framework attempts to detect the MimeType (as well as charset) when not known.- Default value
- ANY
-
setCharacterEncoding
The specified character encoding on the response contentType header. NULL or empty values will be ignored.- Default value
- UTF-8
-
setUpdateEtag
public void setUpdateEtag(boolean updateEtag) Automatically generate and validate etags- Default value
false
, can be changed by setting the propertyapi.etag.enabled
.
-
setAuthenticationMethod
Enables security for this listener. If you wish to use the application servers authorization roles [AUTHROLE], you need to enable them globally for all ApiListeners with theservlet.ApiListenerServlet.securityRoles=IbisTester,IbisWebService
property- Default value
NONE
-
setAuthenticationRoles
Only active when AuthenticationMethod=AUTHROLE. Comma separated list of authorization roles which are granted for this service, eq.IbisTester,IbisObserver
-
getAuthenticationRoleList
-
setMultipartBodyName
Specify the form-part you wish to enter the pipeline- Default value
- name of the first form-part
-
getMultipartBodyName
-
setMessageIdHeader
Name of the header which contains the Message-Id. -
setCorrelationIdHeader
Name of the header which contains the Correlation-Id. -
setOperationId
Unique string used to identify the operation. The id MUST be unique among all operations described in the OpenApi schema. -
setHeaderParams
Comma separated list of parameters passed as http header. Parameters will be stored in 'headers' sessionkey. -
setContentDispositionHeaderSessionKey
Session key that provides theContent-Disposition
header in the response -
setRequiredIssuer
Issuer to validate JWT -
setJwksURL
Keysource URL to validate JWT -
setJwtHeader
Header to extract JWT from- Default value
Authorization
-
setRequiredClaims
Comma separated list of required claims -
setExactMatchClaims
Comma separated key value pairs to exactly match with JWT payload. e.g.sub=UnitTest, aud=test
-
setAnyMatchClaims
Comma separated key value pairs to one-of match with JWT payload. e.g.appid=a,appid=b
-
setRoleClaim
Claim name which specifies the role (maps toIsUserInRolePipe
) -
setPrincipalNameClaim
Claim name which specifies the principal name (maps toGetPrincipalPipe
) -
setResponseType
Optional configuration setting to have more control over how to send the response. Set this to return data as Multipart formdata or MTOM. SeeHttpEntityType
for all supported values and how to use them.- Default value
HttpEntityType.BINARY
.
-
setResponseMultipartXmlSessionKey
If response is sent as Multipart (HttpEntityType.FORMDATA
orHttpEntityType.MTOM
) an optional session key can describe the Multipart contents in XML. SeeHttpSender.setMultipartXmlSessionKey(String)
for details on the XML format specification. -
setResponseFirstBodyPartName
If response is sent as Multipart (HttpEntityType.FORMDATA
orHttpEntityType.MTOM
), when this option is set the pipeline result message will be prepended as first Multipart Bodypart with this name. -
setResponseMtomContentTransferEncoding
If the response is sent asHttpEntityType.MTOM
, optionally specify the transfer-encoding of the first part. -
toString
- Overrides:
toString
in classPushingListenerAdapter
-
isValidUriPattern
-
getDomain
- Specified by:
getDomain
in interfaceHasPhysicalDestination
-
getUriPattern
-
isUpdateEtag
public boolean isUpdateEtag() -
getOperationId
-
getAuthenticationMethod
-
getConsumes
-
getProduces
-
getContentType
public org.springframework.util.MimeType getContentType() -
getReceiver
- Specified by:
getReceiver
in interfaceReceiverAware<Message>
-
setReceiver
- Specified by:
setReceiver
in interfaceReceiverAware<Message>
-
getMessageIdHeader
-
getCorrelationIdHeader
-
getHeaderParams
-
getContentDispositionHeaderSessionKey
-
getCharset
-
getRequiredIssuer
-
getJwksUrl
-
getJwtHeader
-
getRequiredClaims
-
getExactMatchClaims
-
getAnyMatchClaims
-
getRoleClaim
-
getPrincipalNameClaim
-
getPhysicalDestinationName
- Specified by:
getPhysicalDestinationName
in interfaceHasPhysicalDestination
-
getJwtValidator
-
setServletManager
-
getResponseType
-
getResponseMultipartXmlSessionKey
-
getResponseFirstBodyPartName
-
getResponseMtomContentTransferEncoding
-
getResponseEntityBuilder
-