/** * Accept class names that match the supplied pattern for * deserialization, unless they are otherwise rejected. * * @param pattern standard Java regexp * @return this object */ public ValidatingObjectInputStream accept(final Pattern pattern) { acceptMatchers.add(new RegexpClassNameMatcher(pattern)); return this; }
/** * Reject class names that match the supplied pattern for * deserialization, even if they are otherwise accepted. * * @param pattern standard Java regexp * @return this object */ public ValidatingObjectInputStream reject(final Pattern pattern) { rejectMatchers.add(new RegexpClassNameMatcher(pattern)); return this; }
@Test(expected=IllegalArgumentException.class) public void testNullPatternPattern() { new RegexpClassNameMatcher((Pattern)null); } }
@Test(expected=NullPointerException.class) public void testNullStringPattern() { new RegexpClassNameMatcher((String)null); }
@Test public void testSimplePatternFromPattern() { final ClassNameMatcher ca = new RegexpClassNameMatcher(Pattern.compile("foo.*")); assertTrue(ca.matches("foo.should.match")); assertFalse(ca.matches("bar.should.not.match")); }
@Test public void testSimplePatternFromString() { final ClassNameMatcher ca = new RegexpClassNameMatcher("foo.*"); assertTrue(ca.matches("foo.should.match")); assertFalse(ca.matches("bar.should.not.match")); }
@Test public void testOrPattern() { final ClassNameMatcher ca = new RegexpClassNameMatcher("foo.*|bar.*"); assertTrue(ca.matches("foo.should.match")); assertTrue(ca.matches("bar.should.match")); assertFalse(ca.matches("zoo.should.not.match")); }
/** * Reject class names that match the supplied pattern for * deserialization, even if they are otherwise accepted. * * @param pattern standard Java regexp * @return this object */ public ValidatingObjectInputStream reject(final Pattern pattern) { rejectMatchers.add(new RegexpClassNameMatcher(pattern)); return this; }
/** * Accept class names that match the supplied pattern for * deserialization, unless they are otherwise rejected. * * @param pattern standard Java regexp * @return this object */ public ValidatingObjectInputStream accept(final Pattern pattern) { acceptMatchers.add(new RegexpClassNameMatcher(pattern)); return this; }
/** * Accept class names that match the supplied pattern for * deserialization, unless they are otherwise rejected. * * @param pattern standard Java regexp * @return this object */ public ValidatingObjectInputStream accept(Pattern pattern) { acceptMatchers.add(new RegexpClassNameMatcher(pattern)); return this; }
/** * Reject class names that match the supplied pattern for * deserialization, even if they are otherwise accepted. * * @param pattern standard Java regexp * @return this object */ public ValidatingObjectInputStream reject(Pattern pattern) { rejectMatchers.add(new RegexpClassNameMatcher(pattern)); return this; }