use of com.sun.identity.xacml.context.Attribute in project OpenAM by OpenRock.
the class SubjectImpl method processElement.
private void processElement(Element element) throws XACMLException {
if (element == null) {
XACMLSDKUtils.debug.error("SubjectImpl.processElement(): invalid root element");
throw new XACMLException(XACMLSDKUtils.xacmlResourceBundle.getString("invalid_element"));
}
String elemName = element.getLocalName();
if (elemName == null) {
XACMLSDKUtils.debug.error("SubjectImpl.processElement(): local name missing");
throw new XACMLException(XACMLSDKUtils.xacmlResourceBundle.getString("missing_local_name"));
}
if (!elemName.equals(XACMLConstants.SUBJECT)) {
XACMLSDKUtils.debug.error("SubjectImpl.processElement(): invalid local name " + elemName);
throw new XACMLException(XACMLSDKUtils.xacmlResourceBundle.getString("invalid_local_name"));
}
// starts processing subelements
NodeList nodes = element.getChildNodes();
int numOfNodes = nodes.getLength();
if (numOfNodes >= 1) {
ContextFactory factory = ContextFactory.getInstance();
for (int nextElem = 0; nextElem < numOfNodes; nextElem++) {
Node child = (Node) nodes.item(nextElem);
if ((child.getNodeType() == Node.ELEMENT_NODE) || (child.getNodeType() == Node.ATTRIBUTE_NODE)) {
// The child nodes should be <Attribute>
// or <SubjectCategory>
String attrChildName = child.getLocalName();
if (attrChildName.equals(XACMLConstants.ATTRIBUTE)) {
if (this.attributes == null) {
this.attributes = new ArrayList();
}
Attribute attribute = factory.getInstance().createAttribute((Element) child);
attributes.add(attribute);
} else if (attrChildName.equals(XACMLConstants.SUBJECT_CATEGORY)) {
try {
subjectCategory = new URI(child.getNodeValue());
} catch (Exception e) {
throw new XACMLException(XACMLSDKUtils.xacmlResourceBundle.getString("attribute_not_uri"));
}
} else {
XACMLSDKUtils.debug.error("RequestImpl." + "processElement(): Invalid element :" + attrChildName);
throw new XACMLException(XACMLSDKUtils.xacmlResourceBundle.getString("invalid_element"));
}
}
}
}
}
use of com.sun.identity.xacml.context.Attribute in project OpenAM by OpenRock.
the class ActionImpl method processElement.
private void processElement(Element element) throws XACMLException {
if (element == null) {
XACMLSDKUtils.debug.error("ActionImpl.processElement(): invalid root element");
throw new XACMLException(XACMLSDKUtils.xacmlResourceBundle.getString("invalid_element"));
}
String elemName = element.getLocalName();
if (elemName == null) {
XACMLSDKUtils.debug.error("ActionImpl.processElement(): local name missing");
throw new XACMLException(XACMLSDKUtils.xacmlResourceBundle.getString("missing_local_name"));
}
if (!elemName.equals(XACMLConstants.ACTION)) {
XACMLSDKUtils.debug.error("ActionImpl.processElement(): invalid local name " + elemName);
throw new XACMLException(XACMLSDKUtils.xacmlResourceBundle.getString("invalid_local_name"));
}
// starts processing subelements
NodeList nodes = element.getChildNodes();
int numOfNodes = nodes.getLength();
if (numOfNodes >= 1) {
ContextFactory factory = ContextFactory.getInstance();
for (int nextElem = 0; nextElem < numOfNodes; nextElem++) {
Node child = (Node) nodes.item(nextElem);
if (child.getNodeType() == Node.ELEMENT_NODE) {
// The child nodes should be <Attribute>
String attrChildName = child.getLocalName();
if (attrChildName.equals(XACMLConstants.ATTRIBUTE)) {
if (this.attributes == null) {
this.attributes = new ArrayList();
}
Attribute attribute = factory.getInstance().createAttribute((Element) child);
attributes.add(attribute);
} else {
XACMLSDKUtils.debug.error("ActionImpl." + "processElement(): Invalid element :" + attrChildName);
throw new XACMLException(XACMLSDKUtils.xacmlResourceBundle.getString("invalid_element"));
}
}
}
}
}
Aggregations