Mageia Bugzilla – Attachment 14461 Details for
Bug 30368
jackson-databind new security issues CVE-2020-36518 and CVE-2022-4200[34]
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
script to exercise jackson-dataformat
SimpleTest.java (text/x-csrc), 1.29 KB, created by
Len Lawrence
on 2024-03-15 16:37:53 CET
(
hide
)
Description:
script to exercise jackson-dataformat
Filename:
MIME Type:
Creator:
Len Lawrence
Created:
2024-03-15 16:37:53 CET
Size:
1.29 KB
patch
obsolete
>// SimpleTest.java for basic testing of jackson-dataformat-xml package >// Based on examples at github and input from Frank Griffin and Martin Whitaker. >/* > Compile to SimpleTest.class using: > $ javac -cp ".:/usr/share/java/*" SimpleTest.java >*/ >import javax.xml.stream.*; >import com.fasterxml.jackson.core.*; >import com.fasterxml.jackson.databind.*; >import com.fasterxml.jackson.dataformat.xml.*; > >/* The current directory should contain the file Simple.class > compiled from Simple.java which contains these lines: > > public class Simple { > public int x = 1; > public int y = 2; > } > > This is an example of a PlainOldJavaObject or POJO. > i.e. code without any external references or dependencies. > jackson-dataformat-xml turns an instance of this into a string in > XML format, sortof. >*/ >public class SimpleTest { > > public static void main( String args[ ] ) > throws Exception > { > // Create Simple object > Simple zed = new Simple( ); > // Important: create XmlMapper; it will use proper factories, workarounds > ObjectMapper xmlMapper = new XmlMapper(); > // Serialize the POJO to XML > String xml = xmlMapper.writeValueAsString( zed ); > System.out.println( "\nserialize" ); > System.out.println( xml ); > System.out.println( "working\n" ); > } >}
// SimpleTest.java for basic testing of jackson-dataformat-xml package // Based on examples at github and input from Frank Griffin and Martin Whitaker. /* Compile to SimpleTest.class using: $ javac -cp ".:/usr/share/java/*" SimpleTest.java */ import javax.xml.stream.*; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.dataformat.xml.*; /* The current directory should contain the file Simple.class compiled from Simple.java which contains these lines: public class Simple { public int x = 1; public int y = 2; } This is an example of a PlainOldJavaObject or POJO. i.e. code without any external references or dependencies. jackson-dataformat-xml turns an instance of this into a string in XML format, sortof. */ public class SimpleTest { public static void main( String args[ ] ) throws Exception { // Create Simple object Simple zed = new Simple( ); // Important: create XmlMapper; it will use proper factories, workarounds ObjectMapper xmlMapper = new XmlMapper(); // Serialize the POJO to XML String xml = xmlMapper.writeValueAsString( zed ); System.out.println( "\nserialize" ); System.out.println( xml ); System.out.println( "working\n" ); } }
View Attachment As Raw
Actions:
View
Attachments on
bug 30368
: 14461