Class SerializationUtil


  • public final class SerializationUtil
    extends java.lang.Object
    Provides methods to increase the safety of object serialization/deserialization.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private SerializationUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void assertFiltered​(java.io.ObjectInputStream stream)  
      static java.lang.Object readWrappedObject​(java.io.ObjectInputStream in)  
      static java.lang.String stripArray​(java.lang.Class<?> clazz)
      Gets the class name of an array component recursively.
      static java.lang.String stripArray​(java.lang.String name)
      Gets the class name of an array component recursively.
      static void writeWrappedObject​(java.io.Serializable obj, java.io.ObjectOutputStream out)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_FILTER_CLASS

        private static final java.lang.String DEFAULT_FILTER_CLASS
        See Also:
        Constant Field Values
      • setObjectInputFilter

        private static final java.lang.reflect.Method setObjectInputFilter
      • getObjectInputFilter

        private static final java.lang.reflect.Method getObjectInputFilter
      • newObjectInputFilter

        private static final java.lang.reflect.Method newObjectInputFilter
      • REQUIRED_JAVA_CLASSES

        public static final java.util.List<java.lang.String> REQUIRED_JAVA_CLASSES
      • REQUIRED_JAVA_PACKAGES

        public static final java.util.List<java.lang.String> REQUIRED_JAVA_PACKAGES
    • Constructor Detail

      • SerializationUtil

        private SerializationUtil()
    • Method Detail

      • writeWrappedObject

        public static void writeWrappedObject​(java.io.Serializable obj,
                                              java.io.ObjectOutputStream out)
                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • readWrappedObject

        public static java.lang.Object readWrappedObject​(java.io.ObjectInputStream in)
                                                  throws java.io.IOException,
                                                         java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • assertFiltered

        public static void assertFiltered​(java.io.ObjectInputStream stream)
      • stripArray

        public static java.lang.String stripArray​(java.lang.Class<?> clazz)
        Gets the class name of an array component recursively.

        If clazz is not an array class its name is returned.

        Parameters:
        clazz - the binary name of a class.
      • stripArray

        public static java.lang.String stripArray​(java.lang.String name)
        Gets the class name of an array component recursively.

        If name is not the name of an array class it is returned unchanged.

        Parameters:
        name - the name of a class.
        See Also:
        Class.getName()