use of com.mindbright.security.x509.Attribute in project PGM by PGMDev.
the class RegionParser method parseTranslate.
@MethodParser("translate")
public TranslatedRegion parseTranslate(Element el) throws InvalidXMLException {
Attribute offsetAttribute = el.getAttribute("offset");
if (offsetAttribute == null) {
throw new InvalidXMLException("Translate region must have an offset", el);
}
Vector offset = XMLUtils.parseVector(offsetAttribute);
return new TranslatedRegion(this.parseChildren(el), offset);
}
use of com.mindbright.security.x509.Attribute in project PGM by PGMDev.
the class RegionParser method parseRegionProperty.
@Nullable
public Region parseRegionProperty(Element rootElement, @Nullable FeatureValidation<RegionDefinition> validation, Region def, String... names) throws InvalidXMLException {
Attribute propertyAttribute = null;
Element propertyElement = null;
for (String name : names) {
if (rootElement.getAttribute(name) != null && rootElement.getChild(name) != null) {
throw new InvalidXMLException("Multiple defined region properties for " + name, rootElement);
}
if ((rootElement.getAttribute(name) != null || rootElement.getChild(name) != null) && (propertyAttribute != null || propertyElement != null)) {
throw new InvalidXMLException("Multiple defined region properties for " + Arrays.toString(names), rootElement);
}
if (rootElement.getAttribute(name) != null) {
propertyAttribute = rootElement.getAttribute(name);
} else if (rootElement.getChild(name) != null) {
propertyElement = rootElement.getChild(name);
}
}
Region region = def;
Node node = null;
if (propertyAttribute != null) {
region = this.parseReference(propertyAttribute);
node = new Node(propertyAttribute);
} else if (propertyElement != null) {
region = this.parseChildren(propertyElement);
node = new Node(propertyElement);
}
if (region != null && validation != null) {
validate(region, validation, node);
}
return region;
}
use of com.mindbright.security.x509.Attribute in project PGM by PGMDev.
the class RegionFilterApplicationParser method parse.
public void parse(Element el) throws InvalidXMLException {
Region region = parseRegion(el);
Component message = XMLUtils.parseFormattedText(el, "message");
boolean earlyWarning = XMLUtils.parseBoolean(el.getAttribute("early-warning"), false);
Filter effectFilter = filterParser.parseFilterProperty(el, "filter");
Kit kit = factory.getKits().parseKitProperty(el, "kit");
if (kit != null) {
add(el, new RegionFilterApplication(RFAScope.EFFECT, region, effectFilter, kit, false));
}
kit = factory.getKits().parseKitProperty(el, "lend-kit");
if (kit != null) {
add(el, new RegionFilterApplication(RFAScope.EFFECT, region, effectFilter, kit, true));
}
Attribute attrVelocity = el.getAttribute("velocity");
if (attrVelocity != null) {
// Legacy support
String velocityText = attrVelocity.getValue();
if (velocityText.charAt(0) == '@')
velocityText = velocityText.substring(1);
Vector velocity = XMLUtils.parseVector(attrVelocity, velocityText);
add(el, new RegionFilterApplication(RFAScope.EFFECT, region, effectFilter, velocity));
}
for (String tag : RFAScope.byTag.keySet()) {
Filter filter;
if (useId()) {
filter = filterParser.parseFilterProperty(el, tag);
} else {
// Legacy syntax allows a list of filter names in the attribute
Node node = Node.fromAttr(el, tag);
if (node == null) {
filter = null;
} else {
List<Filter> filters = new ArrayList<>();
for (String name : Splitter.on(" ").split(node.getValue())) {
filters.add(filterParser.parseReference(node, name));
}
switch(filters.size()) {
case 0:
filter = null;
break;
case 1:
filter = filters.get(0);
break;
default:
filter = new FilterNode(filters, Collections.<Filter>emptyList(), Collections.<Filter>emptyList());
}
}
}
if (filter != null) {
for (RFAScope scope : RFAScope.byTag.get(tag)) {
add(el, new RegionFilterApplication(scope, region, filter, message, earlyWarning));
}
}
}
}
use of com.mindbright.security.x509.Attribute in project rascal by usethesource.
the class DOM method nodeToAttribute.
private Attribute nodeToAttribute(IConstructor n) {
IConstructor ns = (IConstructor) n.get(0);
IString name = (IString) n.get(1);
IString data = (IString) n.get(2);
return new Attribute(name.getValue(), data.getValue(), namespaceToNamespace(ns));
}
use of com.mindbright.security.x509.Attribute in project rascal by usethesource.
the class DOM method convertElement.
private IConstructor convertElement(Element e, boolean trim) {
IListWriter kids = vf.listWriter();
for (Object o : e.getAttributes()) {
Attribute attr = (Attribute) o;
IString key = vf.string(attr.getName());
IString val = vf.string(attr.getValue());
kids.insert(vf.constructor(Factory.Node_attribute, convertNamespace(attr.getNamespace()), key, val));
}
int len = e.getContentSize();
for (int i = 0; i < len; i++) {
try {
kids.append(convertContent(e.getContent(i), trim));
} catch (Skip c) {
// Ugh, terrible, but I'm in hurry
continue;
}
}
IString name = vf.string(e.getName());
return vf.constructor(Factory.Node_element, convertNamespace(e.getNamespace()), name, kids.done());
}
Aggregations