@Test public void testDeserializeVectorUsingPolicy() throws Exception { Vector<Object> vector = new Vector<Object>(); vector.add("pi"); vector.add(Integer.valueOf(314159)); vector.add(new Vector<String>()); vector.add(Boolean.FALSE); final JmsDefaultDeserializationPolicy policy = new JmsDefaultDeserializationPolicy(); ByteArrayInputStream input = new ByteArrayInputStream(serializeObject(vector)); TrustedClassFilter filter = new TrustedClassFilter() { @Override public boolean isTrusted(Class<?> clazz) { LOG.trace("Check for trust status of class: {}", clazz.getName()); return policy.isTrustedType(new JmsQueue(), clazz); } }; ClassLoadingAwareObjectInputStream reader = new ClassLoadingAwareObjectInputStream(input, filter); Object result = null; try { result = reader.readObject(); } catch (Exception ex) { fail("Should no throw any errors"); } finally { reader.close(); } assertNotNull(result); assertTrue(result instanceof Vector); assertEquals(4, ((Vector<?>) result).size()); }
@Override public boolean isTrustedType(JmsDestination destination, Class<?> clazz) { if (clazz == null) { return true; } String className = clazz.getCanonicalName(); if (className == null) { className = clazz.getName(); } for (String denyListEntry : denyList) { if (CATCH_ALL_WILDCARD.equals(denyListEntry)) { return false; } else if (isClassOrPackageMatch(className, denyListEntry)) { return false; } } for (String allowListEntry : allowList) { if (CATCH_ALL_WILDCARD.equals(allowListEntry)) { return true; } else if (isClassOrPackageMatch(className, allowListEntry)) { return true; } } return false; }
JmsDefaultDeserializationPolicy implements JmsDeserializationPolicy { @Override public boolean isTrustedType(JmsDestination destination, Class<?> clazz) { if (clazz == null) { return true; } String className = clazz.getCanonicalName(); if (className == null) { className = clazz.getName(); } for (String denyListEntry : denyList) { if (CATCH_ALL_WILDCARD.equals(denyListEntry)) { return false; } else if (isClassOrPackageMatch(className, denyListEntry)) { return false; } } for (String allowListEntry : allowList) { if (CATCH_ALL_WILDCARD.equals(allowListEntry)) { return true; } else if (isClassOrPackageMatch(className, allowListEntry)) { return true; } } return false; } }
JmsDefaultDeserializationPolicy implements JmsDeserializationPolicy { @Override public boolean isTrustedType(JmsDestination destination, Class<?> clazz) { if (clazz == null) { return true; } String className = clazz.getCanonicalName(); if (className == null) { className = clazz.getName(); } for (String denyListEntry : denyList) { if (CATCH_ALL_WILDCARD.equals(denyListEntry)) { return false; } else if (isClassOrPackageMatch(className, denyListEntry)) { return false; } } for (String allowListEntry : allowList) { if (CATCH_ALL_WILDCARD.equals(allowListEntry)) { return true; } else if (isClassOrPackageMatch(className, allowListEntry)) { return true; } } return false; } JmsDefaultDeserializationPolicy();  JmsDefaultDeserializationPolicy(JmsDefaultDeserializationPolicy source); }
JmsDefaultDeserializationPolicy implements JmsDeserializationPolicy { @Override public boolean isTrustedType(JmsDestination destination, Class<?> clazz) { if (clazz == null) { return true; } String className = clazz.getCanonicalName(); if (className == null) { className = clazz.getName(); } for (String denyListEntry : denyList) { if (CATCH_ALL_WILDCARD.equals(denyListEntry)) { return false; } else if (isClassOrPackageMatch(className, denyListEntry)) { return false; } } for (String allowListEntry : allowList) { if (CATCH_ALL_WILDCARD.equals(allowListEntry)) { return true; } else if (isClassOrPackageMatch(className, allowListEntry)) { return true; } } return false; } JmsDefaultDeserializationPolicy();  JmsDefaultDeserializationPolicy(JmsDefaultDeserializationPolicy source); @Override JmsDeserializationPolicy copy(); @Override boolean isTrustedType(JmsDestination destination, Class<?> clazz); @Deprecated String getWhiteList(); String getAllowList(); @Deprecated String getBlackList(); String getDenyList(); @Deprecated void setWhiteList(String allowList); void setAllowList(String allowList); @Deprecated void setBlackList(String denyList); void setDenyList(String denyList); @Override int hashCode(); @Override boolean equals(Object obj); }
JmsDefaultDeserializationPolicy implements JmsDeserializationPolicy { @Override public boolean isTrustedType(JmsDestination destination, Class<?> clazz) { if (clazz == null) { return true; } String className = clazz.getCanonicalName(); if (className == null) { className = clazz.getName(); } for (String denyListEntry : denyList) { if (CATCH_ALL_WILDCARD.equals(denyListEntry)) { return false; } else if (isClassOrPackageMatch(className, denyListEntry)) { return false; } } for (String allowListEntry : allowList) { if (CATCH_ALL_WILDCARD.equals(allowListEntry)) { return true; } else if (isClassOrPackageMatch(className, allowListEntry)) { return true; } } return false; } JmsDefaultDeserializationPolicy();  JmsDefaultDeserializationPolicy(JmsDefaultDeserializationPolicy source); @Override JmsDeserializationPolicy copy(); @Override boolean isTrustedType(JmsDestination destination, Class<?> clazz); @Deprecated String getWhiteList(); String getAllowList(); @Deprecated String getBlackList(); String getDenyList(); @Deprecated void setWhiteList(String allowList); void setAllowList(String allowList); @Deprecated void setBlackList(String denyList); void setDenyList(String denyList); @Override int hashCode(); @Override boolean equals(Object obj); static final String CATCH_ALL_WILDCARD; @Deprecated
    static final String DEPRECATED_ALLOWLIST_PROPERTY; @Deprecated
    static final String DEPRECATED_DENYLIST_PROPERTY; static final String ALLOWLIST_PROPERTY; static final String DENYLIST_PROPERTY; }