CA API Gateway - Policy DateTime Format Issue

book

Article ID: 193090

calendar_today

Updated On:

Products

CA API Gateway API SECURITY CA API Gateway Precision API Monitoring Module for API Gateway (Layer 7) CA API Gateway Enterprise Service Manager (Layer 7) STARTER PACK-7 CA Microgateway

Issue/Introduction

Gateway 9.4

Trying to validate datetime format in API Gateway to allow only specific format. Providing valid datetime range format below using set context variable..

YYYY-MM-DDTHH:mm:ss
YYYY-MM-DDTHH:mm:ssZ

We tried to validate datetime format then service throws following exception.

20200518 14:53:27.090 INFO   9680 Unable to parse date string: 2020-01-01T00:00:00

 

20200518 14:53:27.090 INFO   9680 Unable to parse date string: 2020-01-01T00:00:00Z

Would like to understand why API Gateway application is not supporting above datetime formats?

During my further testing, I have found the following anomalies

Not allowed:
YYYY-MM-DDTHH:mm:ss.S
YYYY-MM-DDTHH:mm:ssZ 
YYYY-MM-DDTHH:mm:ss
YYYY-MM-DDTHH:mmZ

Allowed:
YYYY-MM-DD HH:mm:ss.SSS  --- success
YYYY-MM-DD HH:mm:ss  --- success

Not allowed:
YYYY-MM-DDTHH:mm:ss
YYYY-MM-DDTHH:mm:ssZ

using the following payloads:
https://xx.xx.xx.xx/ddformat?startDate=2020-02-02&endDate=2020-02-03
https://xx.xx.xx.xx/ddformat?startDate=2020-02-02 00:00:00.000&endDate=2020-02-03 00:00:00.000

YYYY-MM-DD
https://xx.xx.xx.xx/ddformat?startDate=2020-02-02&endDate=2020-02-03
yyyy-MM-dd HH:mm:ss

https://xx.xx.xx.xx/ddformat?startDate=2020-02-02 00:00:00&endDate=2020-02-03 00:00:00

yyyy-MM-dd HH:mm:ss.SSS
https://xx.xx.xx.xx/ddformat?startDate=2020-02-02 00:00:00.000&endDate=2020-02-03 00:00:00.000

yyyy-MM-dd HH:mm:ss.SSSZ
https://xx.xx.xx.xx/ddformat?startDate=2020-02-02 00:00:00.000Z&endDate=2020-02-03 00:00:00.000Z

YYYY-MM-DD'T'HH:mm:ss
https://xx.xx.xx.xx/ddformat?startDate=2020-09-11'T'00:00:00&endDate=2020-09-11'T'00:00:00

Environment

Release : 9.4

Component : API GATEWAY

Resolution

Considering the below example service,

https://localhost:8443/datetimeformat?startDate=2020-02-02 000:00:00.000&endDate=2020-02-03 000:00:00.000

With format as YYYY-MM-DD HH:mm:ss.SSS,

we get a failure.

then I changed the format to yyyy-MM-dd HH:mm:ss.SSS, and it processed it successfully.

The actual solution is: users should be providing yyyy in small case so YYYY and DD should be in small case as yyyy and dd.