Search in sources :

Example 1 with ExplicitTypePermission

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

the class XStreamUtils method addPermissions.

public static void addPermissions(XStream xstream, String permissions) {
    for (String pterm : permissions.split(",")) {
        boolean aod;
        pterm = pterm.trim();
        if (pterm.startsWith("-")) {
            aod = false;
            pterm = pterm.substring(1);
        } else {
            aod = true;
            if (pterm.startsWith("+")) {
                pterm = pterm.substring(1);
            }
        }
        TypePermission typePermission = null;
        if ("*".equals(pterm)) {
            // accept or deny any
            typePermission = AnyTypePermission.ANY;
        } else if (pterm.indexOf('*') < 0) {
            // exact type
            typePermission = new ExplicitTypePermission(new String[] { pterm });
        } else if (pterm.length() > 0) {
            // wildcard type
            typePermission = new WildcardTypePermission(new String[] { pterm });
        }
        if (typePermission != null) {
            if (aod) {
                xstream.addPermission(typePermission);
            } else {
                xstream.denyPermission(typePermission);
            }
        }
    }
}
Also used : AnyTypePermission(com.thoughtworks.xstream.security.AnyTypePermission) TypePermission(com.thoughtworks.xstream.security.TypePermission) WildcardTypePermission(com.thoughtworks.xstream.security.WildcardTypePermission) ExplicitTypePermission(com.thoughtworks.xstream.security.ExplicitTypePermission) WildcardTypePermission(com.thoughtworks.xstream.security.WildcardTypePermission) ExplicitTypePermission(com.thoughtworks.xstream.security.ExplicitTypePermission)

Example 2 with ExplicitTypePermission

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

the class AbstractXStreamWrapper method addPermissions.

private static void addPermissions(XStream xstream, String permissions) {
    for (String pterm : permissions.split(",")) {
        boolean aod;
        pterm = pterm.trim();
        if (pterm.startsWith("-")) {
            aod = false;
            pterm = pterm.substring(1);
        } else {
            aod = true;
            if (pterm.startsWith("+")) {
                pterm = pterm.substring(1);
            }
        }
        TypePermission typePermission = null;
        if ("*".equals(pterm)) {
            // accept or deny any
            typePermission = AnyTypePermission.ANY;
        } else if (pterm.indexOf('*') < 0) {
            // exact type
            typePermission = new ExplicitTypePermission(new String[] { pterm });
        } else if (pterm.length() > 0) {
            // wildcard type
            typePermission = new WildcardTypePermission(new String[] { pterm });
        }
        if (typePermission != null) {
            if (aod) {
                xstream.addPermission(typePermission);
            } else {
                xstream.denyPermission(typePermission);
            }
        }
    }
}
Also used : AnyTypePermission(com.thoughtworks.xstream.security.AnyTypePermission) TypePermission(com.thoughtworks.xstream.security.TypePermission) ExplicitTypePermission(com.thoughtworks.xstream.security.ExplicitTypePermission) WildcardTypePermission(com.thoughtworks.xstream.security.WildcardTypePermission) WildcardTypePermission(com.thoughtworks.xstream.security.WildcardTypePermission) ExplicitTypePermission(com.thoughtworks.xstream.security.ExplicitTypePermission)

Example 3 with ExplicitTypePermission

use of com.thoughtworks.xstream.security.ExplicitTypePermission in project jbpm by kiegroup.

the class ObjectDataType method getXStream.

private XStream getXStream() {
    XStream xstream = createXStream();
    if (classLoader != null) {
        xstream.setClassLoader(classLoader);
        if (classLoader instanceof ProjectClassLoader) {
            Map<String, byte[]> store = ((ProjectClassLoader) classLoader).getStore();
            if (store != null) {
                String[] classes = store.keySet().stream().map(s -> s.replace('/', '.')).map(s -> s.endsWith(".class") ? s.substring(0, s.length() - ".class".length()) : s).toArray(String[]::new);
                xstream.addPermission(new ExplicitTypePermission(classes));
            }
        }
    }
    return xstream;
}
Also used : ProjectClassLoader(org.drools.core.common.ProjectClassLoader) XStream(com.thoughtworks.xstream.XStream) XStreamUtils.createXStream(org.kie.soup.commons.xstream.XStreamUtils.createXStream) DataType(org.jbpm.process.core.datatype.DataType) ObjectOutput(java.io.ObjectOutput) Map(java.util.Map) ProjectClassLoader(org.drools.core.common.ProjectClassLoader) IOException(java.io.IOException) ObjectInput(java.io.ObjectInput) ExplicitTypePermission(com.thoughtworks.xstream.security.ExplicitTypePermission) XStream(com.thoughtworks.xstream.XStream) XStreamUtils.createXStream(org.kie.soup.commons.xstream.XStreamUtils.createXStream) ExplicitTypePermission(com.thoughtworks.xstream.security.ExplicitTypePermission)

Aggregations

ExplicitTypePermission (com.thoughtworks.xstream.security.ExplicitTypePermission)3 AnyTypePermission (com.thoughtworks.xstream.security.AnyTypePermission)2 TypePermission (com.thoughtworks.xstream.security.TypePermission)2 WildcardTypePermission (com.thoughtworks.xstream.security.WildcardTypePermission)2 XStream (com.thoughtworks.xstream.XStream)1 IOException (java.io.IOException)1 ObjectInput (java.io.ObjectInput)1 ObjectOutput (java.io.ObjectOutput)1 Map (java.util.Map)1 ProjectClassLoader (org.drools.core.common.ProjectClassLoader)1 DataType (org.jbpm.process.core.datatype.DataType)1 XStreamUtils.createXStream (org.kie.soup.commons.xstream.XStreamUtils.createXStream)1