Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr
In directory sc8-pr-cvs1:/tmp/cvs-serv22245/attr
Modified Files:
AttributeDesignator.java AttributeSelector.java
AttributeValue.java
Log Message:
updated all existing encoding and added new encoding routines for all policy
related elements
Index: AttributeDesignator.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr/AttributeDesignator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** AttributeDesignator.java 29 Jul 2003 22:01:47 -0000 1.2
--- AttributeDesignator.java 25 Aug 2003 16:53:10 -0000 1.3
***************
*** 38,41 ****
--- 38,42 ----
import com.sun.xacml.EvaluationCtx;
+ import com.sun.xacml.Indenter;
import com.sun.xacml.MatchResult;
import com.sun.xacml.ParsingException;
***************
*** 49,52 ****
--- 50,56 ----
import com.sun.xacml.ctx.StatusDetail;
+ import java.io.OutputStream;
+ import java.io.PrintStream;
+
import java.net.URI;
***************
*** 138,142 ****
* @param id the attribute id looked for by this designator
* @param mustBePresent whether resolution must find a value
! * @param issuer the issuer of the values to search for
*
* @throws IllegalArgumentException if the input target isn't a valid value
--- 142,147 ----
* @param id the attribute id looked for by this designator
* @param mustBePresent whether resolution must find a value
! * @param issuer the issuer of the values to search for or null if no
! * issuer is specified
*
* @throws IllegalArgumentException if the input target isn't a valid value
***************
*** 375,378 ****
--- 380,425 ----
// so we just return the result
return result;
+ }
+
+ /**
+ * Encodes this designator 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 designator 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) {
+ PrintStream out = new PrintStream(output);
+ String indent = indenter.makeString();
+
+ String tag = "<" + targetTypes[target] + "AttributeDesignator";
+
+ if ((target == SUBJECT_TARGET) && (subjectCategory != null))
+ tag += " SubjectCategory=\"" + subjectCategory.toString() + "\"";
+
+ tag += " AttributeId=\"" + id.toString() + "\"";
+ tag += " DataType=\"" + type.toString() + "\"";
+
+ if (issuer != null)
+ tag += " Issuer=\"" + issuer.toString() + "\"";
+
+ if (mustBePresent)
+ tag += " MustBePresent=\"true\"";
+
+ tag += "/>";
+
+ out.println(indent + tag);
}
Index: AttributeSelector.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr/AttributeSelector.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** AttributeSelector.java 11 Aug 2003 20:48:45 -0000 1.3
--- AttributeSelector.java 25 Aug 2003 16:53:10 -0000 1.4
***************
*** 38,41 ****
--- 38,42 ----
import com.sun.xacml.EvaluationCtx;
+ import com.sun.xacml.Indenter;
import com.sun.xacml.ParsingException;
***************
*** 47,50 ****
--- 48,54 ----
import com.sun.xacml.finder.AttributeFinder;
+ import java.io.OutputStream;
+ import java.io.PrintStream;
+
import java.net.URI;
***************
*** 237,239 ****
--- 241,277 ----
}
+ /**
+ * Encodes this selector 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 selector 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) {
+ PrintStream out = new PrintStream(output);
+ String indent = indenter.makeString();
+
+ String tag = "<AttributeSelector RequestContextPath=\"" + contextPath +
+ "\" DataType=\"" + type.toString() + "\"";
+
+ if (mustBePresent)
+ tag += " MustBePresent=\"true\"";
+
+ tag += "/>";
+
+ out.println(indent + tag);
+ }
+
}
Index: AttributeValue.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr/AttributeValue.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** AttributeValue.java 22 Jul 2003 15:05:45 -0000 1.2
--- AttributeValue.java 25 Aug 2003 16:53:10 -0000 1.3
***************
*** 38,45 ****
--- 38,49 ----
import com.sun.xacml.EvaluationCtx;
+ import com.sun.xacml.Indenter;
import com.sun.xacml.cond.Evaluatable;
import com.sun.xacml.cond.EvaluationResult;
+ import java.io.OutputStream;
+ import java.io.PrintStream;
+
import java.net.URI;
***************
*** 130,133 ****
--- 134,167 ----
public abstract String encode();
+ /**
+ * Encodes this <code>AttributeValue</code> into its XML representation
+ * and writes this encoding to the given <code>OutputStream</code> with
+ * no indentation. This will always produce the version used in a
+ * policy rather than that used in a request, so this is equivalent
+ * to calling <code>encodeWithTags(true)</code> and then stuffing that
+ * into a stream.
+ *
+ * @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>AttributeValue</code> into its XML representation
+ * and writes this encoding to the given <code>OutputStream</code> with
+ * indentation. This will always produce the version used in a
+ * policy rather than that used in a request, so this is equivalent
+ * to calling <code>encodeWithTags(true)</code> and then stuffing that
+ * into a stream.
+ *
+ * @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);
+ out.println(indenter.makeString() + encodeWithTags(true));
+ }
+
/**
* Encodes the value and includes the AttributeValue XML tags so that
|