use of org.springframework.core.ConfigurableObjectInputStream in project spring-security-oauth by spring-projects.
the class SerializationUtils method deserialize.
public static <T> T deserialize(byte[] byteArray) {
ObjectInputStream oip = null;
try {
oip = new ConfigurableObjectInputStream(new ByteArrayInputStream(byteArray), Thread.currentThread().getContextClassLoader());
@SuppressWarnings("unchecked") T result = (T) oip.readObject();
return result;
} catch (IOException e) {
throw new IllegalArgumentException(e);
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException(e);
} finally {
if (oip != null) {
try {
oip.close();
} catch (IOException e) {
// eat it
}
}
}
}
use of org.springframework.core.ConfigurableObjectInputStream in project spring-integration by spring-projects.
the class WhiteListDeserializingConverter method deserialize.
protected Object deserialize(ByteArrayInputStream inputStream) throws IOException {
try {
ObjectInputStream objectInputStream = new ConfigurableObjectInputStream(inputStream, this.defaultDeserializerClassLoader) {
@Override
protected Class<?> resolveClass(ObjectStreamClass classDesc) throws IOException, ClassNotFoundException {
Class<?> clazz = super.resolveClass(classDesc);
checkWhiteList(clazz);
return clazz;
}
};
return objectInputStream.readObject();
} catch (ClassNotFoundException ex) {
throw new NestedIOException("Failed to deserialize object type", ex);
}
}
Aggregations