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);
}
}
}
}
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);
}
}
}
}
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;
}
Aggregations