import java.util.Iterator;
import java.util.Set;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.log4j.Logger;
import org.apache.xerces.parsers.DOMParser;
import org.w3c.dom.CharacterData;
import org.w3c.dom.Document;
private Set rules = new HashSet();
private String description;
private boolean sitePolicy = false;
+ private static Logger log = Logger.getLogger(Arp.class.getName());
/**
* Creates an Arp for the specified <code>Principal</code>.
* @return the xml <code>Element</code>
*/
- Element unmarshall() {
+ Element unmarshall() throws ArpMarshallingException {
- DOMParser parser = new DOMParser();
- Document placeHolder = parser.getDocument();
- Element policyNode = placeHolder.createElement("AttributeReleasePolicy");
+ try {
+ Document placeHolder = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+ Element policyNode = placeHolder.createElement("AttributeReleasePolicy");
+ if (description != null) {
+ Element descriptionNode = placeHolder.createElement("Description");
+ descriptionNode.appendChild(placeHolder.createTextNode(description));
+ policyNode.appendChild(descriptionNode);
+ }
- if (description != null) {
- Element descriptionNode = placeHolder.createElement("Description");
- descriptionNode.appendChild(placeHolder.createTextNode(description));
- policyNode.appendChild(descriptionNode);
- }
+ Rule[] rules = getAllRules();
+ for (int i = 0; rules.length > i; i++) {
+ policyNode.appendChild(placeHolder.importNode(rules[i].unmarshall(), true));
+ }
+
+ return policyNode;
- Rule[] rules = getAllRules();
- for (int i = 0; rules.length > i; i++) {
- policyNode.appendChild(rules[i].unmarshall());
+ } catch (ParserConfigurationException e) {
+ log.error("Encountered a problem unmarshalling an ARP: " + e);
+ throw new ArpMarshallingException("Encountered a problem unmarshalling an ARP.");
}
- return policyNode;
}
/**
package edu.internet2.middleware.shibboleth.aa.arp;
+import java.io.IOException;
+import java.io.StringWriter;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Set;
import org.apache.log4j.Logger;
+import org.apache.xml.serialize.OutputFormat;
+import org.apache.xml.serialize.XMLSerializer;
/**
* Defines a processing engine for Attribute Release Policies.
effectiveArp.setDescription("Effective ARP.");
Arp[] userPolicies = repository.getAllPolicies(principal);
- log.debug("Creating effective ARP from (" + userPolicies.length + ") polic(y|ies).");
+
+ if (log.isDebugEnabled()) {
+ log.debug("Creating effective ARP from (" + userPolicies.length + ") polic(y|ies).");
+ try {
+ for (int i = 0; userPolicies.length > i; i++) {
+ StringWriter writer = new StringWriter();
+ OutputFormat format = new OutputFormat();
+ format.setIndent(4);
+ XMLSerializer serializer = new XMLSerializer(writer, format);
+ serializer.serialize(userPolicies[i].unmarshall());
+ log.debug(
+ "Dumping ARP from:" + System.getProperty("line.separator") + writer.toString());
+ }
+ } catch (ArpMarshallingException ame) {
+ } catch (IOException ioe) {
+ }
+ }
+
for (int i = 0; userPolicies.length > i; i++) {
Rule[] rules = userPolicies[i].getMatchingRules(requester, resource);
throws ArpProcessingException {
Set releaseSet = new HashSet();
+
+ log.info("Applying Attribute Release Policies.");
+ if (log.isDebugEnabled()) {
+ log.debug("Processing the following attributes:");
+ for (int i = 0;attributes.length > i; i++) {
+ log.debug("Attribute: (" + attributes[i].getName() + ")");
+ }
+ }
//Gather all applicable ARP attribute specifiers
Set attributeNames = new HashSet();
import java.util.Iterator;
import java.util.Set;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
import org.apache.log4j.Logger;
-import org.apache.xerces.parsers.DOMParser;
import org.w3c.dom.CharacterData;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
* @return the xml <code>Element</code>
*/
- public Element unmarshall() {
+ public Element unmarshall() throws ArpMarshallingException {
- DOMParser parser = new DOMParser();
- Document placeHolder = parser.getDocument();
- Element ruleNode = placeHolder.createElement("Rule");
+ try {
+ Document placeHolder = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+ Element ruleNode = placeHolder.createElement("Rule");
- if (description != null) {
- Element descriptionNode = placeHolder.createElement("Description");
- descriptionNode.appendChild(placeHolder.createTextNode(description));
- ruleNode.appendChild(descriptionNode);
- }
+ if (description != null) {
+ Element descriptionNode = placeHolder.createElement("Description");
+ descriptionNode.appendChild(placeHolder.createTextNode(description));
+ ruleNode.appendChild(descriptionNode);
+ }
- return ruleNode;
+ return ruleNode;
+ } catch (ParserConfigurationException e) {
+ log.error("Encountered a problem unmarshalling an ARP Rule: " + e);
+ throw new ArpMarshallingException("Encountered a problem unmarshalling an ARP Rule.");
+ }
}
/**