java.io.ObjectInputValidation Java Examples

The following examples show how to use java.io.ObjectInputValidation. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ObjectCopier.java    From verigreen with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public T pasteObject() {
    
    try {
        ByteArrayInputStream bai = new ByteArrayInputStream(objectHolder);
        ObjectInputStream oi = new ObjectInputStream(bai);
        T resourceList = (T) oi.readObject();
        if (resourceList instanceof ObjectInputValidation) {
            ((ObjectInputValidation) resourceList).validateObject();
        }
        
        return resourceList;
    } catch (Exception e) {
        throw new RuntimeException("Failed To Paste Object", e); //$NON-NLS-1$
    }
}
 
Example #2
Source File: LocalFileSystem.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
* @param in the input stream to read from
* @exception IOException error during read
* @exception ClassNotFoundException when class not found
*/
private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException, java.lang.ClassNotFoundException {
    in.defaultReadObject();

    in.registerValidation(
        new ObjectInputValidation() {
            public void validateObject() {
                if (attr.getClass() == DefaultAttributes.class) {
                    Impl impl = new Impl(LocalFileSystem.this);
                    attr = new InnerAttrs(LocalFileSystem.this, impl, impl, impl);
                }
            }
        }, 0
    );
}
 
Example #3
Source File: DataEditorSupport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void readObject (ObjectInputStream ois) throws ClassNotFoundException, IOException {
    ois.defaultReadObject ();
    ois.registerValidation(new ObjectInputValidation() {
        public void validateObject() throws InvalidObjectException {
            warnedFiles.add(getFileImpl());
        }
    }, 0);
}
 
Example #4
Source File: XStream.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates an ObjectInputStream that deserializes a stream of objects from a reader using XStream.
 *
 * @see #createObjectOutputStream(com.thoughtworks.xstream.io.HierarchicalStreamWriter, String)
 * @see #createObjectInputStream(com.thoughtworks.xstream.io.HierarchicalStreamReader)
 * @since 1.4.10
 */
public ObjectInputStream createObjectInputStream(final HierarchicalStreamReader reader, final DataHolder dataHolder)
        throws IOException {
    return new CustomObjectInputStream(new CustomObjectInputStream.StreamCallback() {
        public Object readFromStream() throws EOFException {
            if (!reader.hasMoreChildren()) {
                throw new EOFException();
            }
            reader.moveDown();
            final Object result = unmarshal(reader, dataHolder);
            reader.moveUp();
            return result;
        }

        public Map readFieldsFromStream() throws IOException {
            throw new NotActiveException("not in call to readObject");
        }

        public void defaultReadObject() throws NotActiveException {
            throw new NotActiveException("not in call to readObject");
        }

        public void registerValidation(ObjectInputValidation validation, int priority)
            throws NotActiveException {
            throw new NotActiveException("stream inactive");
        }

        public void close() {
            reader.close();
        }
    }, classLoaderReference);
}
 
Example #5
Source File: IIOPInputStream.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public final synchronized void registerValidation(ObjectInputValidation obj,
                                                  int prio)
    throws NotActiveException, InvalidObjectException{
    // XXX I18N, logging needed.
    throw new Error("Method registerValidation not supported");
}
 
Example #6
Source File: OptimizedObjectInputStream.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public void registerValidation(ObjectInputValidation obj, int pri) {
    // No-op.
}
 
Example #7
Source File: IIOPInputStream.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public final synchronized void registerValidation(ObjectInputValidation obj,
                                                  int prio)
    throws NotActiveException, InvalidObjectException{
    // XXX I18N, logging needed.
    throw new Error("Method registerValidation not supported");
}
 
Example #8
Source File: IIOPInputStream.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public final synchronized void registerValidation(ObjectInputValidation obj,
                                                  int prio)
    throws NotActiveException, InvalidObjectException{
    // XXX I18N, logging needed.
    throw new Error("Method registerValidation not supported");
}
 
Example #9
Source File: IIOPInputStream.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public final synchronized void registerValidation(ObjectInputValidation obj,
                                                  int prio)
    throws NotActiveException, InvalidObjectException{
    // XXX I18N, logging needed.
    throw new Error("Method registerValidation not supported");
}
 
Example #10
Source File: IIOPInputStream.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public final synchronized void registerValidation(ObjectInputValidation obj,
                                                  int prio)
    throws NotActiveException, InvalidObjectException{
    // XXX I18N, logging needed.
    throw new Error("Method registerValidation not supported");
}
 
Example #11
Source File: IIOPInputStream.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public final synchronized void registerValidation(ObjectInputValidation obj,
                                                  int prio)
    throws NotActiveException, InvalidObjectException{
    // XXX I18N, logging needed.
    throw new Error("Method registerValidation not supported");
}
 
Example #12
Source File: CustomObjectInputStream.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public void registerValidation(ObjectInputValidation validation, int priority) throws NotActiveException, InvalidObjectException {
    peekCallback().registerValidation(validation, priority);
}
 
Example #13
Source File: IIOPInputStream.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public final synchronized void registerValidation(ObjectInputValidation obj,
                                                  int prio)
    throws NotActiveException, InvalidObjectException{
    // XXX I18N, logging needed.
    throw new Error("Method registerValidation not supported");
}
 
Example #14
Source File: IIOPInputStream.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
public final synchronized void registerValidation(ObjectInputValidation obj,
                                                  int prio)
    throws NotActiveException, InvalidObjectException{
    // XXX I18N, logging needed.
    throw new Error("Method registerValidation not supported");
}
 
Example #15
Source File: IIOPInputStream.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public final synchronized void registerValidation(ObjectInputValidation obj,
                                                  int prio)
    throws NotActiveException, InvalidObjectException{
    // XXX I18N, logging needed.
    throw new Error("Method registerValidation not supported");
}
 
Example #16
Source File: IIOPInputStream.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
public final synchronized void registerValidation(ObjectInputValidation obj,
                                                  int prio)
    throws NotActiveException, InvalidObjectException{
    // XXX I18N, logging needed.
    throw new Error("Method registerValidation not supported");
}
 
Example #17
Source File: CustomObjectInputStream.java    From lams with GNU General Public License v2.0 votes vote down vote up
void registerValidation(ObjectInputValidation validation, int priority) throws NotActiveException, InvalidObjectException;