use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException in project eap-additional-testsuite by jboss-set.
the class SecurityDeserializationTestCase method testSecuirtyDatabind7.
@ATTest({ "modules/testcases/jdkAll/Wildfly/security/src/main/java#16.0.0.Beta1", "modules/testcases/jdkAll/WildflyRelease-17.0.0.Final/security/src/main/java", "modules/testcases/jdkAll/Eap71x-Proposed/security/src/main/java#7.1.6", "modules/testcases/jdkAll/Eap71x/security/src/main/java#7.1.6", "modules/testcases/jdkAll/Eap72x-Proposed/security/src/main/java#7.2.1", "modules/testcases/jdkAll/Eap72x/security/src/main/java#7.2.1" })
@Test
public void testSecuirtyDatabind7() throws Exception {
final String JSON = aposToQuotes("{'v':['org.apache.axis2.transport.jms.JMSOutTransportInfo','/tmp/foobar.txt']}");
ObjectMapper mapper = new ObjectMapper();
mapper.enableDefaultTyping();
try {
PolyWrapper sc = mapper.readValue(JSON, PolyWrapper.class);
fail("Should not be able to deserialize because of security prevention.");
} catch (JsonMappingException e) {
assertTrue("Fail because of security issues...", e.getMessage().contains("prevented for security reasons"));
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException in project BIMserver by opensourceBIM.
the class DownloadDescriptor method getCacheKey.
public String getCacheKey() {
Hasher hasher = hf.newHasher();
// TODO This serializerOid actually makes the cache a per-user cache... Maybe not the most useful feature
hasher.putLong(serializerOid);
for (long roid : roids) {
hasher.putLong(roid);
}
if (jsonQuery != null) {
// TODO This is based on the incoming JSON (if there is any), this should be replaced at some point by a canonical-form
hasher.putString(jsonQuery, Charsets.UTF_8);
HashCode hashcode = hasher.hash();
return hashcode.toString();
} else {
// TODO This does not work because the toJson function is not complete
ObjectNode json = new JsonQueryObjectModelConverter(packageMetaData).toJson(query);
try {
StringWriter stringWriter = new StringWriter();
OBJECT_MAPPER.writeValue(stringWriter, json);
System.out.println(query.toString());
hasher.putString(stringWriter.toString(), Charsets.UTF_8);
HashCode hashcode = hasher.hash();
return hashcode.toString();
} catch (JsonGenerationException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException in project core-util by WSO2Telco.
the class YamlReader method getConfiguration.
/**
* Gets the configuration.
*
* @return the configuration
*/
public static ConfigDTO getConfiguration() {
File file = new File(DEVICE_MGT_CONFIG_PATH);
ConfigDTO configPojo = new ConfigDTO();
// jackson databind
final ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
try {
configPojo = mapper.readValue(file, ConfigDTO.class);
} catch (JsonParseException e) {
log.error("Yaml Parsing Error", e);
} catch (JsonMappingException e) {
log.error("Yaml Mapping Error", e);
} catch (IOException e) {
log.error("Yaml File Error", e);
}
return configPojo;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException in project n4js by eclipse.
the class StartSessionResource method createEvent.
@Override
@SuppressWarnings("unchecked")
protected TestEvent createEvent(final String sessionId, final String body) throws ClientResourceException {
final Map<?, ?> values = newHashMap();
try {
if (!isNullOrEmpty(body)) {
values.putAll(mapper.readValue(body, Map.class));
}
} catch (JsonMappingException | JsonParseException e) {
throw new ClientResourceException(SC_UNPROCESSABLE_ENTITY);
} catch (final IOException e) {
throw new ClientResourceException(SC_BAD_REQUEST);
}
final Map<String, String> properties = newHashMap();
if (null != values.get(PROPERTIES)) {
if (!(values.get(PROPERTIES) instanceof Map)) {
throw new ClientResourceException(SC_UNPROCESSABLE_ENTITY);
} else {
((Map<?, ?>) values.get(PROPERTIES)).entrySet().forEach(new Consumer<Entry<?, ?>>() {
@Override
public void accept(final Entry<?, ?> entry) {
properties.put(valueOf(entry.getKey()), valueOf(entry.getValue()));
}
});
}
}
return new SessionStartedEvent(sessionId, properties);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException in project n4js by eclipse.
the class StartTestResource method createEvent.
@Override
@SuppressWarnings("unchecked")
protected TestEvent createEvent(final String sessionId, final String testId, final String body) throws ClientResourceException {
if (isNullOrEmpty(body))
throw new ClientResourceException(SC_BAD_REQUEST);
final Map<?, ?> values = newHashMap();
try {
values.putAll(mapper.readValue(body, Map.class));
} catch (JsonMappingException | JsonParseException e) {
throw new ClientResourceException(SC_UNPROCESSABLE_ENTITY);
} catch (final IOException e) {
throw new ClientResourceException(SC_BAD_REQUEST);
}
final Object value = values.get(TIMEOUT_KEY);
// incorrect schema
if (null == value) {
throw new ClientResourceException(SC_UNPROCESSABLE_ENTITY);
}
final Map<String, String> properties = newHashMap();
if (null != values.get(PROPERTIES)) {
if (!(values.get(PROPERTIES) instanceof Map)) {
throw new ClientResourceException(SC_UNPROCESSABLE_ENTITY);
} else {
((Map<?, ?>) values.get(PROPERTIES)).entrySet().forEach(new Consumer<Entry<?, ?>>() {
@Override
public void accept(final Entry<?, ?> entry) {
properties.put(valueOf(entry.getKey()), valueOf(entry.getValue()));
}
});
}
}
try {
final long timeout = parseLong(valueOf(value));
return new TestStartedEvent(sessionId, testId, timeout, properties);
} catch (final NumberFormatException e) {
// although schema was valid the data was indeed invalid
throw new ClientResourceException(SC_BAD_REQUEST);
}
}
Aggregations