Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/ctx
In directory sc8-pr-cvs1:/tmp/cvs-serv22245/ctx
Modified Files:
Attribute.java RequestCtx.java ResponseCtx.java Result.java
Status.java
Log Message:
updated all existing encoding and added new encoding routines for all policy
related elements
Index: Attribute.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/ctx/Attribute.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Attribute.java 22 Jul 2003 15:05:45 -0000 1.2
--- Attribute.java 25 Aug 2003 16:53:10 -0000 1.3
***************
*** 214,227 ****
/**
* Encodes this attribute into its XML representation and writes
* this encoding to the given <code>OutputStream</code> with
* indentation.
*
* @param output a stream into which the XML-encoded data is written
- * @param depth the nesting depth for indenting XML
* @param indenter an object that creates indentation strings
*/
! public void encode(OutputStream output, int depth, Indenter indenter) {
// setup the formatting & outstream stuff
! String indent = indenter.makeString(depth);
PrintStream out = new PrintStream(output);
--- 214,237 ----
/**
* Encodes this attribute into its XML representation and writes
+ * this encoding to the given <code>OutputStream</code> with no
+ * indentation.
+ *
+ * @param output a stream into which the XML-encoded data is written
+ */
+ public void encode(OutputStream output) {
+ encode(output, new Indenter(0));
+ }
+
+ /**
+ * Encodes this attribute into its XML representation and writes
* this encoding to the given <code>OutputStream</code> with
* indentation.
*
* @param output a stream into which the XML-encoded data is written
* @param indenter an object that creates indentation strings
*/
! public void encode(OutputStream output, Indenter indenter) {
// setup the formatting & outstream stuff
! String indent = indenter.makeString();
PrintStream out = new PrintStream(output);
Index: RequestCtx.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/ctx/RequestCtx.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** RequestCtx.java 22 Jul 2003 15:05:45 -0000 1.4
--- RequestCtx.java 25 Aug 2003 16:53:10 -0000 1.5
***************
*** 372,376 ****
*/
public void encode(OutputStream output) {
! encode(output, 0, new Indenter(0));
}
--- 372,376 ----
*/
public void encode(OutputStream output) {
! encode(output, new Indenter(0));
}
***************
*** 381,388 ****
*
* @param output a stream into which the XML-encoded data is written
- * @param depth the nesting depth for indenting XML
* @param indenter an object that creates indentation strings
*/
! public void encode(OutputStream output, int depth, Indenter indenter) {
// Make a PrintStream for a nicer printing interface
--- 381,387 ----
*
* @param output a stream into which the XML-encoded data is written
* @param indenter an object that creates indentation strings
*/
! public void encode(OutputStream output, Indenter indenter) {
// Make a PrintStream for a nicer printing interface
***************
*** 390,398 ****
// Prepare the indentation string
! String topIndent = indenter.makeString(depth);
out.println(topIndent + "<Request>");
! // go in one more for all elements
! String indent = indenter.makeString(depth + 1);
// first off, go through all subjects
--- 389,401 ----
// Prepare the indentation string
! String topIndent = indenter.makeString();
out.println(topIndent + "<Request>");
! // go in one more for next-level elements...
! indenter.in();
! String indent = indenter.makeString();
!
! // ...and go in again for everything else
! indenter.in();
// first off, go through all subjects
***************
*** 401,432 ****
Subject subject = (Subject)(it.next());
! out.println(indent + "<Subject SubjectCategory=\"" +
! subject.getCategory().toString() + "\">");
! encodeAttributes(subject.getAttributes(), out, depth + 2,
! indenter);
! out.println(indent + "</Subject>");
}
// next do the resource
! out.println(indent + "<Resource>");
! if (resourceContent != null)
! out.println(indenter.makeString(depth + 2) + resourceContent);
! encodeAttributes(resource, out, depth + 2, indenter);
! out.println(indent + "</Resource>");
// now the action
! out.println(indent + "<Action>");
! encodeAttributes(action, out, depth + 2, indenter);
! out.println(indent + "</Action>");
// finally the environment, if there are any attrs
if (environment.size() != 0) {
out.println(indent + "<Environment>");
! encodeAttributes(environment, out, depth + 2, indenter);
out.println(indent + "</Environment>");
}
out.println(topIndent + "</Request>");
}
--- 404,456 ----
Subject subject = (Subject)(it.next());
! out.print(indent + "<Subject SubjectCategory=\"" +
! subject.getCategory().toString() + "\"");
!
! Set subjectAttrs = subject.getAttributes();
! if (subjectAttrs.size() == 0) {
! // there's nothing in this Subject, so just close the tag
! out.println("/>");
! } else {
! // there's content, so fill it in
! out.println(">");
!
! encodeAttributes(subjectAttrs, out, indenter);
! out.println(indent + "</Subject>");
! }
}
// next do the resource
! if (resource.size() != 0) {
! out.println(indent + "<Resource>");
! if (resourceContent != null)
! out.println(indenter.makeString() + resourceContent);
! encodeAttributes(resource, out, indenter);
! out.println(indent + "</Resource>");
! } else {
! out.println(indent + "<Resource/>");
! }
// now the action
! if (action.size() != 0) {
! out.println(indent + "<Action>");
! encodeAttributes(action, out, indenter);
! out.println(indent + "</Action>");
! } else {
! out.println(indent + "<Action/>");
! }
// finally the environment, if there are any attrs
if (environment.size() != 0) {
out.println(indent + "<Environment>");
! encodeAttributes(environment, out, indenter);
out.println(indent + "</Environment>");
}
+ // we're back to the top
+ indenter.out();
+ indenter.out();
+
out.println(topIndent + "</Request>");
}
***************
*** 435,444 ****
* Private helper function to encode the attribute sets
*/
! private void encodeAttributes(Set attributes, PrintStream out, int depth,
Indenter indenter) {
Iterator it = attributes.iterator();
while (it.hasNext()) {
Attribute attr = (Attribute)(it.next());
! attr.encode(out, depth, indenter);
}
}
--- 459,468 ----
* Private helper function to encode the attribute sets
*/
! private void encodeAttributes(Set attributes, PrintStream out,
Indenter indenter) {
Iterator it = attributes.iterator();
while (it.hasNext()) {
Attribute attr = (Attribute)(it.next());
! attr.encode(out, indenter);
}
}
Index: ResponseCtx.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/ctx/ResponseCtx.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** ResponseCtx.java 13 Feb 2003 22:19:10 -0000 1.1.1.1
--- ResponseCtx.java 25 Aug 2003 16:53:10 -0000 1.2
***************
*** 153,163 ****
/**
* Encodes this context into its XML representation and writes this
! * encoding to the given <code>OutputStream</code>. No
! * indentation is used.
*
* @param output a stream into which the XML-encoded data is written
*/
public void encode(OutputStream output) {
! encode(output, 0, new Indenter(0));
}
--- 153,163 ----
/**
* Encodes this context into its XML representation and writes this
! * encoding to the given <code>OutputStream</code> with no
! * indentation.
*
* @param output a stream into which the XML-encoded data is written
*/
public void encode(OutputStream output) {
! encode(output, new Indenter(0));
}
***************
*** 168,175 ****
*
* @param output a stream into which the XML-encoded data is written
- * @param depth the nesting depth for indenting XML
* @param indenter an object that creates indentation strings
*/
! public void encode(OutputStream output, int depth, Indenter indenter) {
// Make a PrintStream for a nicer printing interface
--- 168,174 ----
*
* @param output a stream into which the XML-encoded data is written
* @param indenter an object that creates indentation strings
*/
! public void encode(OutputStream output, Indenter indenter) {
// Make a PrintStream for a nicer printing interface
***************
*** 177,181 ****
// Prepare the indentation string
! String indent = indenter.makeString(depth);
// Now write the XML...
--- 176,180 ----
// Prepare the indentation string
! String indent = indenter.makeString();
// Now write the XML...
***************
*** 185,192 ****
// Go through all results
Iterator it = results.iterator();
while (it.hasNext()) {
Result result = (Result)(it.next());
! result.encode(out, depth + 1, indenter);
}
// Finish the XML for a response
--- 184,195 ----
// Go through all results
Iterator it = results.iterator();
+ indenter.in();
+
while (it.hasNext()) {
Result result = (Result)(it.next());
! result.encode(out, indenter);
}
+
+ indenter.out();
// Finish the XML for a response
Index: Result.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/ctx/Result.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Result.java 13 Feb 2003 22:19:10 -0000 1.1.1.1
--- Result.java 25 Aug 2003 16:53:10 -0000 1.2
***************
*** 392,405 ****
/**
* Encodes this <code>Result</code> into its XML form and writes this
* out to the provided <code>OutputStream<code> with indentation.
*
* @param output a stream into which the XML-encoded data is written
- * @param depth the nesting depth for indenting XML
* @param indenter an object that creates indentation strings
*/
! public void encode(OutputStream output, int depth, Indenter indenter) {
PrintStream out = new PrintStream(output);
! String indent = indenter.makeString(depth);
! String indentNext = indenter.makeString(depth + 1);
// encode the starting tag
--- 392,416 ----
/**
* Encodes this <code>Result</code> into its XML form and writes this
+ * out to the provided <code>OutputStream<code> with no indentation.
+ *
+ * @param output a stream into which the XML-encoded data is written
+ */
+ public void encode(OutputStream output) {
+ encode(output, new Indenter(0));
+ }
+
+ /**
+ * Encodes this <code>Result</code> into its XML form and writes this
* out to the provided <code>OutputStream<code> with indentation.
*
* @param output a stream into which the XML-encoded data is written
* @param indenter an object that creates indentation strings
*/
! public void encode(OutputStream output, Indenter indenter) {
PrintStream out = new PrintStream(output);
! String indent = indenter.makeString();
!
! indenter.in();
! String indentNext = indenter.makeString();
// encode the starting tag
***************
*** 415,419 ****
// encode the status
if (status != null)
! status.encode(output, depth + 1, indenter);
// encode the obligations
--- 426,430 ----
// encode the status
if (status != null)
! status.encode(output, indenter);
// encode the obligations
***************
*** 422,432 ****
Iterator it = obligations.iterator();
while (it.hasNext()) {
Obligation obligation = (Obligation)(it.next());
! obligation.encode(output, depth + 2, indenter);
}
out.println(indentNext + "</Obligations>");
}
// finish it off
--- 433,448 ----
Iterator it = obligations.iterator();
+ indenter.in();
+
while (it.hasNext()) {
Obligation obligation = (Obligation)(it.next());
! obligation.encode(output, indenter);
}
+ indenter.out();
out.println(indentNext + "</Obligations>");
}
+
+ indenter.out();
// finish it off
Index: Status.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/ctx/Status.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Status.java 13 Feb 2003 22:19:10 -0000 1.1.1.1
--- Status.java 25 Aug 2003 16:53:10 -0000 1.2
***************
*** 253,257 ****
for (int i = 0; i < list.getLength(); i++) {
Node node = list.item(i);
! code.add(node.getAttributes().getNamedItem("Value").getNodeValue());
}
--- 253,258 ----
for (int i = 0; i < list.getLength(); i++) {
Node node = list.item(i);
! code.add(node.getAttributes().getNamedItem("Value").
! getNodeValue());
}
***************
*** 259,262 ****
--- 260,273 ----
}
+ /**
+ * Encodes this status data into its XML representation and writes
+ * this encoding to the given <code>OutputStream</code> with no
+ * indentation.
+ *
+ * @param output a stream into which the XML-encoded data is written
+ */
+ public void encode(OutputStream output) {
+ encode(output, new Indenter(0));
+ }
/**
***************
*** 266,282 ****
*
* @param output a stream into which the XML-encoded data is written
- * @param depth the nesting depth for indenting XML
* @param indenter an object that creates indentation strings
*/
! public void encode(OutputStream output, int depth, Indenter indenter) {
PrintStream out = new PrintStream(output);
! String indent = indenter.makeString(depth);
out.println(indent + "<Status>");
! encodeStatusCode(out, depth + 1, indenter, code.iterator());
if (message != null)
! out.println(indenter.makeString(depth + 1) + "<StatusMessage>" +
message + "</StatusMessage>");
--- 277,294 ----
*
* @param output a stream into which the XML-encoded data is written
* @param indenter an object that creates indentation strings
*/
! public void encode(OutputStream output, Indenter indenter) {
PrintStream out = new PrintStream(output);
! String indent = indenter.makeString();
out.println(indent + "<Status>");
! indenter.in();
!
! encodeStatusCode(out, indenter, code.iterator());
if (message != null)
! out.println(indenter.makeString() + "<StatusMessage>" +
message + "</StatusMessage>");
***************
*** 284,287 ****
--- 296,301 ----
out.println(detail.getEncoded());
+ indenter.out();
+
out.println(indent + "</Status>");
}
***************
*** 290,302 ****
* Encodes the object in XML
*/
! private void encodeStatusCode(PrintStream out, int depth,
! Indenter indenter, Iterator iterator) {
! String in = indenter.makeString(depth);
String code = (String)(iterator.next());
if (iterator.hasNext()) {
out.println(in + "<StatusCode Value=\"" + code + "\">");
! encodeStatusCode(out, depth + 1, indenter, iterator);
out.println(in + "</StatusCode>");
} else {
out.println(in + "<StatusCode Value=\"" + code + "\"/>");
--- 304,318 ----
* Encodes the object in XML
*/
! private void encodeStatusCode(PrintStream out, Indenter indenter,
! Iterator iterator) {
! String in = indenter.makeString();
String code = (String)(iterator.next());
if (iterator.hasNext()) {
+ indenter.in();
out.println(in + "<StatusCode Value=\"" + code + "\">");
! encodeStatusCode(out, indenter, iterator);
out.println(in + "</StatusCode>");
+ indenter.out();
} else {
out.println(in + "<StatusCode Value=\"" + code + "\"/>");
|