use of com.fasterxml.jackson.databind.JsonMappingException in project eap-additional-testsuite by jboss-set.
the class JaxbProviderDeserializationSecurityCheckTestCase method testApplicationContext.
@Test
public void testApplicationContext() throws Exception {
String result = performCall("rest/jaxb/appcontext");
try {
BogusApplicationContext jaxbModel = new ObjectMapper().configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false).readValue(result, BogusApplicationContext.class);
Assert.fail("Should prevente json deserialization because of security reasons.");
} catch (JsonMappingException e) {
Assert.assertTrue("Should prevente json deserialization because of security reasons.", e.getMessage().contains("Illegal type"));
}
}
use of com.fasterxml.jackson.databind.JsonMappingException in project eap-additional-testsuite by jboss-set.
the class SecurityDeserializationTestCase method testSecuirtyDatabind3.
@Test
@Ignore
public void testSecuirtyDatabind3() throws Exception {
final String JSON = aposToQuotes("{'v':['java.rmi.server.UnicastRemoteObject','/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 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 com.fasterxml.jackson.databind.JsonMappingException in project BIMserver by opensourceBIM.
the class JsonQueryObjectModelConverter method getDefineFromFile.
// TODO thread safety and cache invalidation on file updates
public Include getDefineFromFile(String includeName) throws QueryException {
Include include = CACHED_DEFINES.get(includeName);
if (include != null) {
return include;
}
String namespaceString = includeName.substring(0, includeName.indexOf(":"));
String singleIncludeName = includeName.substring(includeName.indexOf(":") + 1);
URL resource;
try {
resource = getClass().getClassLoader().loadClass("org.bimserver.database.queries.StartFrame").getResource("json/" + namespaceString + ".json");
if (resource == null) {
throw new QueryException("Could not find '" + namespaceString + "' namespace in predefined queries");
}
} catch (ClassNotFoundException e1) {
throw new QueryException("Could not find '" + namespaceString + "' namespace in predefined queries");
}
OBJECT_MAPPER.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
try {
ObjectNode predefinedQuery = OBJECT_MAPPER.readValue(resource, ObjectNode.class);
JsonQueryObjectModelConverter converter = new JsonQueryObjectModelConverter(packageMetaData);
Query query = converter.parseJson(namespaceString, predefinedQuery);
Include define = query.getDefine(singleIncludeName);
if (define == null) {
throw new QueryException("Could not find '" + singleIncludeName + "' in defines in namespace " + query.getName());
}
CACHED_DEFINES.put(includeName, define);
return define;
} catch (JsonParseException e) {
throw new QueryException(e);
} catch (JsonMappingException e) {
throw new QueryException(e);
} catch (IOException e) {
throw new QueryException(e);
}
}
use of com.fasterxml.jackson.databind.JsonMappingException in project BIMserver by opensourceBIM.
the class GetNrPrimitivesDatabaseAction method execute.
@Override
public Long execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException, ServerException {
Revision revision = getDatabaseSession().get(roid, OldQuery.getDefault());
PackageMetaData packageMetaData = bimServer.getMetaDataManager().getPackageMetaData(revision.getProject().getSchema());
if (packageMetaData == null) {
throw new UserException("Schema not fond");
}
try {
Query query = new Query("test", packageMetaData);
QueryPart queryPart = query.createQueryPart();
queryPart.addType(packageMetaData.getEClassIncludingDependencies("GeometryInfo"), true);
QueryObjectProvider queryObjectProvider = new QueryObjectProvider(getDatabaseSession(), bimServer, query, java.util.Collections.singleton(roid), packageMetaData);
HashMapVirtualObject next = queryObjectProvider.next();
long totalPrimitives = 0;
while (next != null) {
int nrPrimitives = (int) next.get("primitiveCount");
totalPrimitives += nrPrimitives;
next = queryObjectProvider.next();
}
return totalPrimitives;
} catch (QueryException e) {
e.printStackTrace();
} catch (JsonParseException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
Aggregations