Search in sources :

Example 1 with NestedIOException

use of org.springframework.core.NestedIOException 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);
    }
}
Also used : NestedIOException(org.springframework.core.NestedIOException) ObjectStreamClass(java.io.ObjectStreamClass) ConfigurableObjectInputStream(org.springframework.core.ConfigurableObjectInputStream) ConfigurableObjectInputStream(org.springframework.core.ConfigurableObjectInputStream) ObjectInputStream(java.io.ObjectInputStream)

Example 2 with NestedIOException

use of org.springframework.core.NestedIOException in project spring-integration by spring-projects.

the class SftpSession method list.

@Override
public LsEntry[] list(String path) throws IOException {
    Assert.state(this.channel != null, "session is not connected");
    try {
        Vector<?> lsEntries = this.channel.ls(path);
        if (lsEntries != null) {
            LsEntry[] entries = new LsEntry[lsEntries.size()];
            for (int i = 0; i < lsEntries.size(); i++) {
                Object next = lsEntries.get(i);
                Assert.state(next instanceof LsEntry, "expected only LsEntry instances from channel.ls()");
                entries[i] = (LsEntry) next;
            }
            return entries;
        }
    } catch (SftpException e) {
        throw new NestedIOException("Failed to list files", e);
    }
    return new LsEntry[0];
}
Also used : NestedIOException(org.springframework.core.NestedIOException) SftpException(com.jcraft.jsch.SftpException) LsEntry(com.jcraft.jsch.ChannelSftp.LsEntry)

Example 3 with NestedIOException

use of org.springframework.core.NestedIOException in project spring-integration by spring-projects.

the class SftpSession method read.

@Override
public void read(String source, OutputStream os) throws IOException {
    Assert.state(this.channel != null, "session is not connected");
    try {
        InputStream is = this.channel.get(source);
        FileCopyUtils.copy(is, os);
    } catch (SftpException e) {
        throw new NestedIOException("failed to read file " + source, e);
    }
}
Also used : NestedIOException(org.springframework.core.NestedIOException) InputStream(java.io.InputStream) SftpException(com.jcraft.jsch.SftpException)

Aggregations

NestedIOException (org.springframework.core.NestedIOException)3 SftpException (com.jcraft.jsch.SftpException)2 LsEntry (com.jcraft.jsch.ChannelSftp.LsEntry)1 InputStream (java.io.InputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectStreamClass (java.io.ObjectStreamClass)1 ConfigurableObjectInputStream (org.springframework.core.ConfigurableObjectInputStream)1