52 |
import java.security.PrivilegedAction; |
import java.security.PrivilegedAction; |
53 |
import java.util.Arrays; |
import java.util.Arrays; |
54 |
import java.util.Hashtable; |
import java.util.Hashtable; |
55 |
|
import java.util.Iterator; |
56 |
|
import java.util.TreeSet; |
57 |
import java.util.Vector; |
import java.util.Vector; |
58 |
|
|
59 |
public class ObjectInputStream extends InputStream |
public class ObjectInputStream extends InputStream |
92 |
} |
} |
93 |
|
|
94 |
this.resolveEnabled = false; |
this.resolveEnabled = false; |
|
this.isDeserializing = false; |
|
95 |
this.blockDataPosition = 0; |
this.blockDataPosition = 0; |
96 |
this.blockDataBytes = 0; |
this.blockDataBytes = 0; |
97 |
this.blockData = new byte[BUFFER_SIZE]; |
this.blockData = new byte[BUFFER_SIZE]; |
99 |
this.realInputStream = new DataInputStream(in); |
this.realInputStream = new DataInputStream(in); |
100 |
this.nextOID = baseWireHandle; |
this.nextOID = baseWireHandle; |
101 |
this.objectLookupTable = new Hashtable(); |
this.objectLookupTable = new Hashtable(); |
|
this.validators = new Vector(); |
|
102 |
this.classLookupTable = new Hashtable(); |
this.classLookupTable = new Hashtable(); |
103 |
setBlockDataMode(true); |
setBlockDataMode(true); |
104 |
readStreamHeader(); |
readStreamHeader(); |
126 |
if (this.useSubclassMethod) |
if (this.useSubclassMethod) |
127 |
return readObjectOverride(); |
return readObjectOverride(); |
128 |
|
|
|
boolean was_deserializing; |
|
|
|
|
129 |
Object ret_val; |
Object ret_val; |
|
was_deserializing = this.isDeserializing; |
|
|
|
|
130 |
boolean old_mode = setBlockDataMode(false); |
boolean old_mode = setBlockDataMode(false); |
|
|
|
|
this.isDeserializing = true; |
|
|
|
|
131 |
byte marker = this.realInputStream.readByte(); |
byte marker = this.realInputStream.readByte(); |
132 |
|
|
133 |
depth += 2; |
if (DEBUG) |
134 |
|
depth += 2; |
135 |
|
|
136 |
if(dump) dumpElement("MARKER: 0x" + Integer.toHexString(marker) + " "); |
if(dump) dumpElement("MARKER: 0x" + Integer.toHexString(marker) + " "); |
137 |
|
|
138 |
try |
try |
139 |
{ |
{ |
140 |
ret_val = parseContent(marker); |
ret_val = parseContent(marker); |
141 |
} |
} |
142 |
finally |
finally |
143 |
{ |
{ |
144 |
setBlockDataMode(old_mode); |
setBlockDataMode(old_mode); |
145 |
|
if (DEBUG) |
146 |
this.isDeserializing = was_deserializing; |
depth -= 2; |
147 |
|
} |
148 |
depth -= 2; |
|
149 |
|
return ret_val; |
150 |
if (! was_deserializing) |
} |
|
{ |
|
|
if (validators.size() > 0) |
|
|
invokeValidators(); |
|
|
} |
|
|
} |
|
|
|
|
|
return ret_val; |
|
|
} |
|
151 |
|
|
152 |
/** |
/** |
153 |
* Handles a content block within the stream, which begins with a marker |
* Handles a content block within the stream, which begins with a marker |
333 |
int handle = assignNewHandle(obj); |
int handle = assignNewHandle(obj); |
334 |
Object prevObject = this.currentObject; |
Object prevObject = this.currentObject; |
335 |
ObjectStreamClass prevObjectStreamClass = this.currentObjectStreamClass; |
ObjectStreamClass prevObjectStreamClass = this.currentObjectStreamClass; |
336 |
|
TreeSet prevObjectValidators = this.currentObjectValidators; |
337 |
|
|
338 |
this.currentObject = obj; |
this.currentObject = obj; |
339 |
|
this.currentObjectValidators = null; |
340 |
ObjectStreamClass[] hierarchy = |
ObjectStreamClass[] hierarchy = |
341 |
inputGetObjectStreamClasses(clazz); |
inputGetObjectStreamClasses(clazz); |
342 |
|
|
388 |
this.currentObject = prevObject; |
this.currentObject = prevObject; |
389 |
this.currentObjectStreamClass = prevObjectStreamClass; |
this.currentObjectStreamClass = prevObjectStreamClass; |
390 |
ret_val = processResolution(osc, obj, handle); |
ret_val = processResolution(osc, obj, handle); |
391 |
|
if (currentObjectValidators != null) |
392 |
|
invokeValidators(); |
393 |
|
this.currentObjectValidators = prevObjectValidators; |
394 |
|
|
395 |
break; |
break; |
396 |
} |
} |
397 |
|
|
723 |
throw new InvalidObjectException("attempt to add a null " |
throw new InvalidObjectException("attempt to add a null " |
724 |
+ "ObjectInputValidation object"); |
+ "ObjectInputValidation object"); |
725 |
|
|
726 |
this.validators.addElement(new ValidatorAndPriority (validator, |
if (currentObjectValidators == null) |
727 |
priority)); |
currentObjectValidators = new TreeSet(); |
728 |
|
|
729 |
|
currentObjectValidators.add(new ValidatorAndPriority(validator, priority)); |
730 |
} |
} |
731 |
|
|
732 |
|
|
1830 |
// on OBJ |
// on OBJ |
1831 |
private void invokeValidators() throws InvalidObjectException |
private void invokeValidators() throws InvalidObjectException |
1832 |
{ |
{ |
|
Object[] validators = new Object[this.validators.size()]; |
|
|
this.validators.copyInto (validators); |
|
|
Arrays.sort (validators); |
|
|
|
|
1833 |
try |
try |
1834 |
{ |
{ |
1835 |
for (int i=0; i < validators.length; i++) |
Iterator it = currentObjectValidators.iterator(); |
1836 |
((ObjectInputValidation)validators[i]).validateObject(); |
while(it.hasNext()) |
1837 |
|
{ |
1838 |
|
ValidatorAndPriority vap = (ValidatorAndPriority) it.next(); |
1839 |
|
ObjectInputValidation validator = vap.validator; |
1840 |
|
validator.validateObject(); |
1841 |
|
} |
1842 |
} |
} |
1843 |
finally |
finally |
1844 |
{ |
{ |
1845 |
this.validators.removeAllElements(); |
currentObjectValidators = null; |
1846 |
} |
} |
1847 |
} |
} |
1848 |
|
|
1891 |
private Hashtable objectLookupTable; |
private Hashtable objectLookupTable; |
1892 |
private Object currentObject; |
private Object currentObject; |
1893 |
private ObjectStreamClass currentObjectStreamClass; |
private ObjectStreamClass currentObjectStreamClass; |
1894 |
|
private TreeSet currentObjectValidators; |
1895 |
private boolean readDataFromBlock; |
private boolean readDataFromBlock; |
|
private boolean isDeserializing; |
|
1896 |
private boolean fieldsAlreadyRead; |
private boolean fieldsAlreadyRead; |
|
private Vector validators; |
|
1897 |
private Hashtable classLookupTable; |
private Hashtable classLookupTable; |
1898 |
private GetField prereadFields; |
private GetField prereadFields; |
1899 |
|
|