Search in sources :

Example 1 with TypePermission

use of com.thoughtworks.xstream.security.TypePermission 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 TypePermission

use of com.thoughtworks.xstream.security.TypePermission 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)

Aggregations

AnyTypePermission (com.thoughtworks.xstream.security.AnyTypePermission)2 ExplicitTypePermission (com.thoughtworks.xstream.security.ExplicitTypePermission)2 TypePermission (com.thoughtworks.xstream.security.TypePermission)2 WildcardTypePermission (com.thoughtworks.xstream.security.WildcardTypePermission)2