public static <T> T deserialize(final InputStream inputStream, final Class<T> clazz) {
        return Unchecked.supplier(() -> {
            try (val in = new ObjectInputStream(inputStream)) {
                val obj = in.readObject();

                if (!clazz.isAssignableFrom(obj.getClass())) {
                    throw new ClassCastException("Result [" + obj
                                                 + " is of type " + obj.getClass()
                                                 + " when we were expecting " + clazz);
                }
                return (T) obj;
            }
        }).get();
    }
Deserialize an object.

@param <T>         the type parameter
@param inputStream The stream to be de-serialized
@param clazz       the clazz
@return the object
@since 5.0.0
core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/serialization/SerializationUtils.java