Search in sources :

Example 6 with ForbiddenClassException

use of com.thoughtworks.xstream.security.ForbiddenClassException in project camel by apache.

the class XStreamDataFormatPermissionsTest method testAllowAnyAndDeny.

@Test
public void testAllowAnyAndDeny() {
    XStreamDataFormat xStreamDataFormat = new XStreamDataFormat();
    xStreamDataFormat.setPermissions("*,-org.apache.camel.dataformat.xstream.PurchaseOrder");
    XStream xStream = xStreamDataFormat.createXStream(context.getClassResolver(), context.getApplicationContextClassLoader());
    try {
        xStream.fromXML(XML_PURCHASE_ORDER);
        fail("should fail to unmarshall");
    } catch (ForbiddenClassException e) {
    // OK
    }
}
Also used : XStream(com.thoughtworks.xstream.XStream) ForbiddenClassException(com.thoughtworks.xstream.security.ForbiddenClassException) Test(org.junit.Test)

Aggregations

XStream (com.thoughtworks.xstream.XStream)6 ForbiddenClassException (com.thoughtworks.xstream.security.ForbiddenClassException)6 Test (org.junit.Test)6