/** * Receives an object sent by {@link #writeObject(Object)} */ public <T> T readObject() throws IOException, ClassNotFoundException { ObjectInputStream ois = new ObjectInputStreamEx(in, getClass().getClassLoader(), ClassFilter.DEFAULT); return (T)ois.readObject(); }
public ObjectInputStreamEx(InputStream in, ClassLoader cl, ClassFilter filter) throws IOException { super(in); this.cl = cl; this.filter = filter; // by default, the resolveObject is not called enableResolveObject(true); }
private ConsoleAnnotator<T> createAnnotator(StaplerRequest req) throws IOException { try { String base64 = req!=null ? req.getHeader("X-ConsoleAnnotator") : null; if (base64!=null) { Cipher sym = PASSING_ANNOTATOR.decrypt(); ObjectInputStream ois = new ObjectInputStreamEx(new GZIPInputStream( new CipherInputStream(new ByteArrayInputStream(Base64.decode(base64.toCharArray())),sym)), Jenkins.getInstance().pluginManager.uberClassLoader); try { long timestamp = ois.readLong(); if (TimeUnit.HOURS.toMillis(1) > abs(System.currentTimeMillis()-timestamp)) // don't deserialize something too old to prevent a replay attack return (ConsoleAnnotator)ois.readObject(); } finally { ois.close(); } } } catch (ClassNotFoundException e) { throw new IOException(e); } // start from scratch return ConsoleAnnotator.initial(context); }
try (ObjectInputStream ois = new ObjectInputStreamEx(new GZIPInputStream(new ByteArrayInputStream(buf)), jenkins != null ? jenkins.pluginManager.uberClassLoader : ConsoleNote.class.getClassLoader(), ClassFilter.DEFAULT)) {
/*package*/ static Object deserialize(final Channel channel, byte[] data, ClassLoader defaultClassLoader) throws IOException, ClassNotFoundException { ByteArrayInputStream in = new ByteArrayInputStream(data); ObjectInputStream ois; if (channel.remoteCapability.supportsMultiClassLoaderRPC()) { // this code is coupled with the ObjectOutputStream subtype above ois = new MultiClassLoaderSerializer.Input(channel, in); } else { ois = new ObjectInputStreamEx(in, defaultClassLoader); } return ois.readObject(); }
/*package*/ static Object deserialize(final Channel channel, byte[] data, ClassLoader defaultClassLoader) throws IOException, ClassNotFoundException { ByteArrayInputStream in = new ByteArrayInputStream(data); ObjectInputStream ois; if (channel.remoteCapability.supportsMultiClassLoaderRPC()) { // this code is coupled with the ObjectOutputStream subtype above ois = new MultiClassLoaderSerializer.Input(channel, in); } else { ois = new ObjectInputStreamEx(in, defaultClassLoader); } return ois.readObject(); }
/*package*/ static Object deserialize(final Channel channel, byte[] data, ClassLoader defaultClassLoader) throws IOException, ClassNotFoundException { ByteArrayInputStream in = new ByteArrayInputStream(data); ObjectInputStream ois; if (channel.remoteCapability.supportsMultiClassLoaderRPC()) { // this code is coupled with the ObjectOutputStream subtype above ois = new MultiClassLoaderSerializer.Input(channel, in); } else { ois = new ObjectInputStreamEx(in, defaultClassLoader); } return ois.readObject(); }
/*package*/ static Object deserialize(final Channel channel, byte[] data, ClassLoader defaultClassLoader) throws IOException, ClassNotFoundException { ByteArrayInputStream in = new ByteArrayInputStream(data); ObjectInputStream ois; if (channel.remoteCapability.supportsMultiClassLoaderRPC()) { // this code is coupled with the ObjectOutputStream subtype above ois = new MultiClassLoaderSerializer.Input(channel, in); } else { ois = new ObjectInputStreamEx(in, defaultClassLoader, channel.classFilter); } return ois.readObject(); }
/** * Reads command from the specified payload. * @param channel Channel * @param istream Input stream * @param payloadSize Payload size to be read. Used only for logging * @return Read command * @throws IOException Read exception * @throws ClassNotFoundException Deserialization error: class not found */ /*package*/ static Command readFrom(@Nonnull Channel channel, @Nonnull InputStream istream, int payloadSize) throws IOException, ClassNotFoundException { Command cmd = Command.readFromObjectStream(channel, new ObjectInputStreamEx( istream, channel.baseClassLoader,channel.classFilter)); channel.notifyRead(cmd, payloadSize); return cmd; }
private ConsoleAnnotator createAnnotator(StaplerRequest req) throws IOException { try { String base64 = req!=null ? req.getHeader("X-ConsoleAnnotator") : null; if (base64!=null) { Cipher sym = PASSING_ANNOTATOR.decrypt(); ObjectInputStream ois = new ObjectInputStreamEx(new GZIPInputStream( new CipherInputStream(new ByteArrayInputStream(Base64.decode(base64.toCharArray())),sym)), Jenkins.getInstance().pluginManager.uberClassLoader); try { long timestamp = ois.readLong(); if (TimeUnit.HOURS.toMillis(1) > abs(System.currentTimeMillis()-timestamp)) // don't deserialize something too old to prevent a replay attack return (ConsoleAnnotator)ois.readObject(); } finally { ois.close(); } } } catch (ClassNotFoundException e) { throw new IOException(e); } // start from scratch return ConsoleAnnotator.initial(context==null ? null : context.getClass()); }
return null; // not a valid postamble ObjectInputStream ois = new ObjectInputStreamEx( new GZIPInputStream(new ByteArrayInputStream(buf)), Hudson.getInstance().pluginManager.uberClassLoader); return (ConsoleNote) ois.readObject();
return null; // not a valid postamble ObjectInputStream ois = new ObjectInputStreamEx( new GZIPInputStream(new ByteArrayInputStream(buf)), Hudson.getInstance().pluginManager.uberClassLoader); return (ConsoleNote) ois.readObject();
return null; // not a valid postamble ObjectInputStream ois = new ObjectInputStreamEx( new GZIPInputStream(new ByteArrayInputStream(buf)), Hudson.getInstance().pluginManager.uberClassLoader); return (ConsoleNote) ois.readObject();
private ConsoleAnnotator createAnnotator(StaplerRequest req) throws IOException { try { String base64 = req!=null ? req.getHeader("X-ConsoleAnnotator") : null; if (base64!=null) { Cipher sym = Secret.getCipher("AES"); sym.init(Cipher.DECRYPT_MODE, Hudson.getInstance().getSecretKeyAsAES128()); ObjectInputStream ois = new ObjectInputStreamEx(new GZIPInputStream( new CipherInputStream(new ByteArrayInputStream(Base64.decodeBase64(base64)),sym)), Hudson.getInstance().pluginManager.uberClassLoader); long timestamp = ois.readLong(); if (TimeUnit2.HOURS.toMillis(1) > abs(System.currentTimeMillis()-timestamp)) // don't deserialize something too old to prevent a replay attack return (ConsoleAnnotator)ois.readObject(); } } catch (GeneralSecurityException e) { throw new IOException2(e); } catch (ClassNotFoundException e) { throw new IOException2(e); } // start from scratch return ConsoleAnnotator.initial(context==null ? null : context.getClass()); }
private ConsoleAnnotator createAnnotator(StaplerRequest req) throws IOException { try { String base64 = req!=null ? req.getHeader("X-ConsoleAnnotator") : null; if (base64!=null) { Cipher sym = Secret.getCipher("AES"); sym.init(Cipher.DECRYPT_MODE, Hudson.getInstance().getSecretKeyAsAES128()); ObjectInputStream ois = new ObjectInputStreamEx(new GZIPInputStream( new CipherInputStream(new ByteArrayInputStream(Base64.decode(base64.toCharArray())),sym)), Hudson.getInstance().pluginManager.uberClassLoader); long timestamp = ois.readLong(); if (TimeUnit2.HOURS.toMillis(1) > abs(System.currentTimeMillis()-timestamp)) // don't deserialize something too old to prevent a replay attack return (ConsoleAnnotator)ois.readObject(); } } catch (GeneralSecurityException e) { throw new IOException2(e); } catch (ClassNotFoundException e) { throw new IOException2(e); } // start from scratch return ConsoleAnnotator.initial(context==null ? null : context.getClass()); }
private ConsoleAnnotator createAnnotator(StaplerRequest req) throws IOException { try { String base64 = req!=null ? req.getHeader("X-ConsoleAnnotator") : null; if (base64!=null) { Cipher sym = Secret.getCipher("AES"); sym.init(Cipher.DECRYPT_MODE, Hudson.getInstance().getSecretKeyAsAES128()); ObjectInputStream ois = new ObjectInputStreamEx(new GZIPInputStream( new CipherInputStream(new ByteArrayInputStream(Base64.decode(base64.toCharArray())),sym)), Hudson.getInstance().pluginManager.uberClassLoader); long timestamp = ois.readLong(); if (TimeUnit2.HOURS.toMillis(1) > abs(System.currentTimeMillis()-timestamp)) // don't deserialize something too old to prevent a replay attack return (ConsoleAnnotator)ois.readObject(); } } catch (GeneralSecurityException e) { throw new IOException2(e); } catch (ClassNotFoundException e) { throw new IOException2(e); } // start from scratch return ConsoleAnnotator.initial(context==null ? null : context.getClass()); }
private ConsoleAnnotator createAnnotator(StaplerRequest req) throws IOException { ObjectInputStream ois = null; try { String base64 = req != null ? req.getHeader("X-ConsoleAnnotator") : null; if (base64 != null) { Cipher sym = Secret.getCipher("AES"); sym.init(Cipher.DECRYPT_MODE, Hudson.getInstance().getSecretKeyAsAES128()); ois = new ObjectInputStreamEx(new GZIPInputStream( new CipherInputStream(new ByteArrayInputStream(Base64.decodeBase64(base64)), sym)), Hudson.getInstance().pluginManager.uberClassLoader); long timestamp = ois.readLong(); if (TimeUnit2.HOURS.toMillis(1) > abs(System.currentTimeMillis() - timestamp)) // don't deserialize something too old to prevent a replay attack { return (ConsoleAnnotator) ois.readObject(); } } } catch (GeneralSecurityException e) { throw new IOException2(e); } catch (ClassNotFoundException e) { throw new IOException2(e); } finally { IOUtils.closeQuietly(ois); } // start from scratch return ConsoleAnnotator.initial(context == null ? null : context.getClass()); }
try (ObjectInputStream ois = new ObjectInputStreamEx(new GZIPInputStream(new ByteArrayInputStream(buf)), jenkins != null ? jenkins.pluginManager.uberClassLoader : ConsoleNote.class.getClassLoader(), ClassFilter.DEFAULT)) {
return null; // not a valid postamble ois = new ObjectInputStreamEx( new GZIPInputStream(new ByteArrayInputStream(buf)), Hudson.getInstance().pluginManager.uberClassLoader); return (ConsoleNote) ois.readObject();
/** * Instantiate a transport. * * @param is * The negotiated input stream that hides * @param os * {@linkplain CommandTransport#getUnderlyingStream() the underlying stream}. * @param mode * The mode to create the transport in. * @param cap * Capabilities of the other side, as determined during the handshaking. */ protected CommandTransport makeTransport(InputStream is, OutputStream os, Mode mode, Capability cap) throws IOException { FlightRecorderInputStream fis = new FlightRecorderInputStream(is); if (cap.supportsChunking()) return new ChunkedCommandTransport(cap, mode.wrap(fis), mode.wrap(os), os); else { ObjectOutputStream oos = AnonymousClassWarnings.checkingObjectOutputStream(mode.wrap(os)); oos.flush(); // make sure that stream preamble is sent to the other end. avoids dead-lock return new ClassicCommandTransport( new ObjectInputStreamEx(mode.wrap(fis),getBaseLoader(),getClassFilter()), oos,fis,os,cap); } } }