Package org.frankframework.http.rest
Class ApiListener
java.lang.Object
org.frankframework.http.PushingListenerAdapter
org.frankframework.http.rest.ApiListener
- All Implemented Interfaces:
FrankElement,HasApplicationContext,HasName,HasPhysicalDestination,IConfigurable,IListener<Message>,IPushingListener<Message>,IScopeProvider,NameAware,RequestReplyListener,ReceiverAware<Message>,ServiceClient,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
@DestinationType(HTTP)
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:portetag.cache.type=memcached
etag.cache.usernameetag.cache.passwordetag.cache.authalias
customViews.names=MyApplication.
Specify details for each view, the url is either a relative path from the web-content folder or an external url, eq. http://google.com/.
customViews.MyApplication.name=Custom View
customViews.MyApplication.url=myWebapp- Author:
- Niels Meijer
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic enumNested classes/interfaces inherited from interface org.frankframework.core.RequestReplyListener
RequestReplyListener.ExceptionHandlingMethod -
Field Summary
FieldsModifier and TypeFieldDescriptionThese are names that are never allowed as HTTP parameters, because the Frank!Fields inherited from class org.frankframework.http.PushingListenerAdapter
log -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanMatch request 'Accept' header to produces enum to see if the client accepts the messagevoidinitialize listener and registerthisto the JNDIreturns the clear pattern, replaces everything between{}to*booleanbooleanisConsumable(String contentType) Match request 'Content-Type' (eg. on POST) to consumes enum to see if the listener accepts the messagebooleanisParameterAllowed(String parameterName) static booleanisValidUriPattern(String uriPattern) voidsetAllowAllParams(boolean allowAllParams) For backwards compatibility with configurations that have not yet been updated, by default all parameters are allowed until removal of this flag.voidsetAllowedParameters(String paramWhitelist) Whitelist of request parameters (Query and POST Parameters) that are allowed to be copied into the session.voidsetAnyMatchClaims(String string) Comma separated key value pairs to one-of match with JWT payload. e.g.voidsetAuthenticationMethod(ApiListener.AuthenticationMethods authenticationMethod) Enables security for this listener.voidsetAuthenticationRoles(String authRoles) Only active when AuthenticationMethod=AUTHROLE.voidsetCharacterEncoding(String charset) The specified character encoding on the response contentType header.voidsetConsumes(MediaTypes value) The required contentType on requests, if it doesn't match a415status (Unsupported Media Type) is returned.voidSession key that provides theContent-Dispositionheader in the responsevoidsetCorrelationIdHeader(String correlationIdHeader) Name of the header which contains the Correlation-Id.voidsetExactMatchClaims(String string) Comma separated key value pairs to exactly match with JWT payload. e.g.voidsetHeaderParams(String headerParams) Comma separated list of parameters passed as http header.voidsetJwksURL(String string) Keysource URL to validate JWTvoidsetJwtHeader(String string) Header to extract JWT fromvoidsetMessageIdHeader(String messageIdHeader) Name of the header which contains the Message-Id.voidsetMethod(ApiListener.HttpMethod method) HTTP method to listen tovoidsetMethods(ApiListener.HttpMethod... methods) HTTP method(s) to listen to.voidsetMultipartBodyName(String multipartBodyName) Specify the form-part you wish to enter the pipeline.voidsetOperationId(String operationId) Unique string used to identify the operation.voidsetPrincipalNameClaim(String principalNameClaim) Claim name which specifies the principal name (maps toGetPrincipalPipe)voidsetProduces(MediaTypes value) The specified contentType on response.voidsetRequiredClaims(String string) Comma separated list of required claimsvoidsetRequiredIssuer(String issuer) Issuer to validate JWTvoidsetResponseFirstBodyPartName(String responseFirstBodyPartName) If response is sent as Multipart (HttpEntityType.FORMDATAorHttpEntityType.MTOM), when this option is set the pipeline result message will be prepended as first Multipart Bodypart with this name.voidsetResponseMtomContentTransferEncoding(String responseMtomContentTransferEncoding) If the response is sent asHttpEntityType.MTOM, optionally specify the transfer-encoding of the first part.voidsetResponseMultipartXmlSessionKey(String responseMultipartXmlSessionKey) If response is sent as Multipart (HttpEntityType.FORMDATAorHttpEntityType.MTOM) an optional session key can describe the Multipart contents in XML.voidsetResponseType(HttpEntityType responseType) Optional configuration setting to have more control over how to send the response.voidsetRoleClaim(String roleClaim) Claim name which specifies the role (maps toIsUserInRolePipe)voidsetUpdateEtag(boolean updateEtag) Automatically generate and validate etagsvoidsetUriPattern(String uriPattern) URI pattern to register this listener on, eq.voidstart()Prepares the listener for receiving messages.voidstop()Close all resources used for listening.toString()Methods inherited from class org.frankframework.http.PushingListenerAdapter
afterMessageProcessed, extractMessage, processRequest, setApplicationFaultsAsExceptions, setExceptionListener, setHandler, setName, setRunning, wrapRawMessageMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationContextAware
setApplicationContextMethods inherited from interface org.frankframework.core.FrankElement
addConfigWarningMethods inherited from interface org.frankframework.core.HasApplicationContext
getApplicationContext, getConfigurationClassLoaderMethods inherited from interface org.frankframework.core.HasPhysicalDestination
getPhysicalDestinationNameMethods inherited from interface org.frankframework.core.IListener
afterMessageProcessed, extractMessageMethods inherited from interface org.frankframework.receivers.ReceiverAware
getReceiver, setReceiverMethods inherited from interface org.frankframework.core.RequestReplyListener
getOnException, setOnException
-
Field Details
-
RESERVED_NAMES
These are names that are never allowed as HTTP parameters, because the Frank!Framework sets these names as session variables.
-
-
Constructor Details
-
ApiListener
public ApiListener()
-
-
Method Details
-
configure
initialize listener and registerthisto the JNDI- Specified by:
configurein interfaceIConfigurable- Overrides:
configurein classPushingListenerAdapter- Throws:
ConfigurationException- in case it was not able to configure the component.
-
start
public void start()Description copied from interface:IListenerPrepares the listener for receiving messages.start()is called once each time the listener is started.- Specified by:
startin interfaceIListener<Message>- Overrides:
startin classPushingListenerAdapter
-
stop
public void stop()Description copied from interface:IListenerClose all resources used for listening. Called once each time the listener is stopped.- Specified by:
stopin interfaceIListener<Message>- Overrides:
stopin 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 -
isParameterAllowed
-
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.
Pattern variables like{something}in this example are added to the PipeLineSession with their actual value in the request URI.
Pattern variables are not allowed to have the same name as any of theRESERVED_NAMES. -
setConsumes
The required contentType on requests, if it doesn't match a415status (Unsupported Media Type) is returned.- Default value
- ANY
-
setProduces
The specified contentType on response. WhenANYthe response will determine the content-type when it's known and will never calculate it. If no match is found*/*will be used. WhenDETECTthe 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,IbisWebServiceproperty- 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.
ThemultipartBodyNameor the names of any other multipart fields may not be one of theRESERVED_NAMES.- 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-Dispositionheader in the response -
setAllowedParameters
Whitelist of request parameters (Query and POST Parameters) that are allowed to be copied into the session.
Entered as a comma-separated value.
If the list contains any names that are inRESERVED_NAMES, these will be removed from the list.
If left empty, then all HTTP parameters are copied into the session, which can pose a security risk and is therefore discouraged. The risk is that parameters could be sent, that overwrite system session variables.
This only works as a backwards-compatibility feature and can be switched off settingsetAllowAllParams(boolean)tofalse.- Parameters:
paramWhitelist- Comma-separated list of allowed HTTP parameters.
-
setAllowAllParams
public void setAllowAllParams(boolean allowAllParams) For backwards compatibility with configurations that have not yet been updated, by default all parameters are allowed until removal of this flag. Copying all POST and query parameters to the session is considered a security risk, so this should not be left enabled.
Even so, names listed inRESERVED_NAMESwill never be copied from the HTTP parameters to the session.
When settingsetAllowedParameters(String), this value is ignored. This value is only used when the allowed parameter list has not been set, or set empty.
For backwards compatibility, this istrueby default.- Default value
- true
-
isAllowAllParams
public boolean isAllowAllParams() -
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. SeeHttpEntityTypefor all supported values and how to use them.- Default value
HttpEntityType.BINARY.
-
setResponseMultipartXmlSessionKey
If response is sent as Multipart (HttpEntityType.FORMDATAorHttpEntityType.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.FORMDATAorHttpEntityType.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:
toStringin classPushingListenerAdapter
-
isValidUriPattern
-