| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.config;
|
1 |
package com.spice.profitmandi.web.config;
|
| 2 |
|
2 |
|
| 3 |
import com.fasterxml.jackson.core.JsonParser;
|
3 |
import com.fasterxml.jackson.core.JsonParser;
|
| - |
|
4 |
import com.fasterxml.jackson.databind.BeanProperty;
|
| 4 |
import com.fasterxml.jackson.databind.DeserializationContext;
|
5 |
import com.fasterxml.jackson.databind.DeserializationContext;
|
| 5 |
import com.fasterxml.jackson.databind.DeserializationFeature;
|
6 |
import com.fasterxml.jackson.databind.DeserializationFeature;
|
| - |
|
7 |
import com.fasterxml.jackson.databind.JsonDeserializer;
|
| 6 |
import com.fasterxml.jackson.databind.ObjectMapper;
|
8 |
import com.fasterxml.jackson.databind.ObjectMapper;
|
| - |
|
9 |
import com.fasterxml.jackson.databind.deser.ContextualDeserializer;
|
| 7 |
import com.fasterxml.jackson.databind.deser.std.StringDeserializer;
|
10 |
import com.fasterxml.jackson.databind.deser.std.StringDeserializer;
|
| 8 |
import com.fasterxml.jackson.databind.module.SimpleModule;
|
11 |
import com.fasterxml.jackson.databind.module.SimpleModule;
|
| 9 |
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
|
12 |
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
|
| 10 |
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
13 |
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
| 11 |
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
|
14 |
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
|
| Line 102... |
Line 105... |
| 102 |
attributesMap.put("dateMonthYearFormatter", dateMonthYearFormatter);
|
105 |
attributesMap.put("dateMonthYearFormatter", dateMonthYearFormatter);
|
| 103 |
attributesMap.put("dateMonthChYear", dateMonthChYear);
|
106 |
attributesMap.put("dateMonthChYear", dateMonthChYear);
|
| 104 |
attributesMap.put("decimalFormatter", decimalFormatter);
|
107 |
attributesMap.put("decimalFormatter", decimalFormatter);
|
| 105 |
attributesMap.put("noData", "<tr><td colspan=\"20\" style=\"text-align:center;\">No results found for the given criteria</td></tr>");
|
108 |
attributesMap.put("noData", "<tr><td colspan=\"20\" style=\"text-align:center;\">No results found for the given criteria</td></tr>");
|
| 106 |
attributesMap.put("dateTimeFormatter", dateTimeFormatter);
|
109 |
attributesMap.put("dateTimeFormatter", dateTimeFormatter);
|
| 107 |
attributesMap.put("version", "377");
|
110 |
attributesMap.put("version", "378");
|
| 108 |
attributesMap.put("cssVersion", "52");
|
111 |
attributesMap.put("cssVersion", "52");
|
| 109 |
attributesMap.put("isDev", getActiveProfile().equals("dev"));
|
112 |
attributesMap.put("isDev", getActiveProfile().equals("dev"));
|
| 110 |
attributesMap.put("vmUtils", new Utils());
|
113 |
attributesMap.put("vmUtils", new Utils());
|
| 111 |
//attributesMap.put("esc", new EscapeTool());
|
114 |
//attributesMap.put("esc", new EscapeTool());
|
| 112 |
attributesMap.put("ru", RoundingMode.HALF_UP);
|
115 |
attributesMap.put("ru", RoundingMode.HALF_UP);
|
| Line 334... |
Line 337... |
| 334 |
.registerModule(new ParameterNamesModule()).registerModule(new Jdk8Module()).registerModule(jtm)
|
337 |
.registerModule(new ParameterNamesModule()).registerModule(new Jdk8Module()).registerModule(jtm)
|
| 335 |
.registerModule(stringModule); // new module, NOT JSR310Module
|
338 |
.registerModule(stringModule); // new module, NOT JSR310Module
|
| 336 |
return mapper;
|
339 |
return mapper;
|
| 337 |
}
|
340 |
}
|
| 338 |
|
341 |
|
| - |
|
342 |
class CustomStringDeserializer extends StringDeserializer implements ContextualDeserializer {
|
| - |
|
343 |
|
| - |
|
344 |
// Fields whose exact bytes matter — never normalize (credentials, tokens, payloads).
|
| - |
|
345 |
private final java.util.regex.Pattern SENSITIVE_FIELD =
|
| - |
|
346 |
java.util.regex.Pattern.compile("(?i)(password|passwd|pwd|otp|pin|token|secret|signature|hash|base64|apikey|api_key)");
|
| - |
|
347 |
|
| - |
|
348 |
private final boolean normalize;
|
| - |
|
349 |
|
| - |
|
350 |
CustomStringDeserializer() {
|
| - |
|
351 |
this(true);
|
| - |
|
352 |
}
|
| - |
|
353 |
|
| 339 |
class CustomStringDeserializer extends StringDeserializer {
|
354 |
CustomStringDeserializer(boolean normalize) {
|
| - |
|
355 |
this.normalize = normalize;
|
| - |
|
356 |
}
|
| - |
|
357 |
|
| - |
|
358 |
@Override
|
| - |
|
359 |
public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) {
|
| - |
|
360 |
if (property != null && SENSITIVE_FIELD.matcher(property.getName()).find()) {
|
| - |
|
361 |
return new CustomStringDeserializer(false);
|
| - |
|
362 |
}
|
| - |
|
363 |
return this;
|
| - |
|
364 |
}
|
| - |
|
365 |
|
| 340 |
@Override
|
366 |
@Override
|
| 341 |
public String deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
|
367 |
public String deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
|
| 342 |
String text = super.deserialize(p, ctxt);
|
368 |
String text = super.deserialize(p, ctxt);
|
| 343 |
//clean up value
|
369 |
if (!normalize) {
|
| 344 |
return text.trim();
|
370 |
return text;
|
| - |
|
371 |
}
|
| - |
|
372 |
// trim + NBSP/tab/zero-width -> single space + collapse doubles
|
| - |
|
373 |
return com.spice.profitmandi.common.util.StringUtils.normalizeWhitespace(text);
|
| 345 |
}
|
374 |
}
|
| 346 |
}
|
375 |
}
|
| 347 |
|
376 |
|
| 348 |
|
377 |
|
| 349 |
}
|
378 |
}
|
| 350 |
|
379 |
|