sunxacml-commit Mailing List for Sun's XACML Implementation (Page 8)
Brought to you by:
farrukh_najmi,
sethp
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(3) |
Jun
(3) |
Jul
(6) |
Aug
(37) |
Sep
(5) |
Oct
(6) |
Nov
(1) |
Dec
(3) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(3) |
Feb
(11) |
Mar
(26) |
Apr
(5) |
May
(27) |
Jun
(13) |
Jul
(7) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
2005 |
Jan
(12) |
Feb
(5) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(8) |
2006 |
Jan
(10) |
Feb
(6) |
Mar
|
Apr
(3) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
(1) |
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(6) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <se...@us...> - 2003-08-26 14:39:41
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr In directory sc8-pr-cvs1:/tmp/cvs-serv30238/com/sun/xacml/attr Modified Files: TimeAttribute.java Log Message: fixed a corner case bug with the mod code in init Index: TimeAttribute.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr/TimeAttribute.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TimeAttribute.java 25 Aug 2003 16:49:17 -0000 1.3 --- TimeAttribute.java 26 Aug 2003 14:39:33 -0000 1.4 *************** *** 235,240 **** // Check that the date is normalized to 1/1/70 ! if ((timeGMT >= DateAttribute.MILLIS_PER_DAY) || (timeGMT < 0)) timeGMT = timeGMT % DateAttribute.MILLIS_PER_DAY; } --- 235,245 ---- // Check that the date is normalized to 1/1/70 ! if ((timeGMT >= DateAttribute.MILLIS_PER_DAY) || (timeGMT < 0)) { timeGMT = timeGMT % DateAttribute.MILLIS_PER_DAY; + + // if we had a negative value then we need to shift by a day + if (timeGMT < 0) + timeGMT += DateAttribute.MILLIS_PER_DAY; + } } |
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine In directory sc8-pr-cvs1:/tmp/cvs-serv20965 Added Files: OrderedDenyOverridesPolicyAlg.java OrderedDenyOverridesRuleAlg.java OrderedPermitOverridesPolicyAlg.java OrderedPermitOverridesRuleAlg.java Log Message: Created new subclasses for the ordered version of the algs (for identity) --- NEW FILE: OrderedDenyOverridesPolicyAlg.java --- /* * OrderedDenyOverridesPolicyAlg.java * * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistribution of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistribution in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Sun Microsystems, Inc. or the names of contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * * You acknowledge that this software is not designed or intended for use in * the design, construction, operation or maintenance of any nuclear facility. */ package com.sun.xacml.combine; import java.net.URI; import java.net.URISyntaxException; /** * This is the standard Ordered Deny Overrides policy combining algorithm. It * allows a single evaluation of Deny to take precedence over any number * of permit, not applicable or indeterminate results. Note that this uses * the regular Deny Overrides implementation since it is also orderd. * * @author seth proctor */ public class OrderedDenyOverridesPolicyAlg extends DenyOverridesPolicyAlg { /** * The standard URN used to identify this algorithm */ public static final String algId = "urn:oasis:names:tc:xacml:1.0:policy-combining-algorithm:" + "ordered-deny-overrides"; // a URI form of the identifier private static URI identifierURI; // exception if the URI was invalid, which should never be a problem private static RuntimeException earlyException; static { try { identifierURI = new URI(algId); } catch (URISyntaxException se) { earlyException = new IllegalArgumentException(); earlyException.initCause(se); } } /** * Standard constructor. */ public OrderedDenyOverridesPolicyAlg() { super(identifierURI); if (earlyException != null) throw earlyException; } } --- NEW FILE: OrderedDenyOverridesRuleAlg.java --- /* * @(#)OrderedDenyOverridesRuleAlg.java * * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistribution of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistribution in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Sun Microsystems, Inc. or the names of contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * * You acknowledge that this software is not designed or intended for use in * the design, construction, operation or maintenance of any nuclear facility. */ package com.sun.xacml.combine; import java.net.URI; import java.net.URISyntaxException; /** * This is the standard Ordered Deny Overrides rule combining algorithm. It * allows a single evaluation of Deny to take precedence over any number * of permit, not applicable or indeterminate results. Note that this uses * the regular Deny Overrides implementation since it is also orderd. * * @author seth proctor */ public class OrderedDenyOverridesRuleAlg extends DenyOverridesRuleAlg { /** * The standard URN used to identify this algorithm */ public static final String algId = "urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:" + "ordered-deny-overrides"; // a URI form of the identifier private static URI identifierURI; // exception if the URI was invalid, which should never be a problem private static RuntimeException earlyException; static { try { identifierURI = new URI(algId); } catch (URISyntaxException se) { earlyException = new IllegalArgumentException(); earlyException.initCause(se); } } /** * Standard constructor. */ public OrderedDenyOverridesRuleAlg() { super(identifierURI); if (earlyException != null) throw earlyException; } } --- NEW FILE: OrderedPermitOverridesPolicyAlg.java --- /* * @(#)OrderedPermitOverridesPolicyAlg.java * * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistribution of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistribution in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Sun Microsystems, Inc. or the names of contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * * You acknowledge that this software is not designed or intended for use in * the design, construction, operation or maintenance of any nuclear facility. */ package com.sun.xacml.combine; import java.net.URI; import java.net.URISyntaxException; /** * This is the standard Ordered Permit Overrides policy combining algorithm. * It allows a single evaluation of Permit to take precedence over any number * of deny, not applicable or indeterminate results. Note that this uses * the regular Permit Overrides implementation since it is also orderd. * * @author seth proctor */ public class OrderedPermitOverridesPolicyAlg extends PermitOverridesPolicyAlg { /** * The standard URN used to identify this algorithm */ public static final String algId = "urn:oasis:names:tc:xacml:1.0:policy-combining-algorithm:" + "ordered-permit-overrides"; // a URI form of the identifier private static URI identifierURI; // exception if the URI was invalid, which should never be a problem private static RuntimeException earlyException; static { try { identifierURI = new URI(algId); } catch (URISyntaxException se) { earlyException = new IllegalArgumentException(); earlyException.initCause(se); } } /** * Standard constructor. */ public OrderedPermitOverridesPolicyAlg() { super(identifierURI); if (earlyException != null) throw earlyException; } } --- NEW FILE: OrderedPermitOverridesRuleAlg.java --- /* * @(#)OrderedPermitOverridesRuleAlg.java * * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistribution of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistribution in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Sun Microsystems, Inc. or the names of contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * * You acknowledge that this software is not designed or intended for use in * the design, construction, operation or maintenance of any nuclear facility. */ package com.sun.xacml.combine; import java.net.URI; import java.net.URISyntaxException; /** * This is the standard Ordered Permit Overrides rule combining algorithm. It * allows a single evaluation of Permit to take precedence over any number * of deny, not applicable or indeterminate results. Note that this uses * the regular Permit Overrides implementation since it is also orderd. * * @author seth proctor */ public class OrderedPermitOverridesRuleAlg extends PermitOverridesRuleAlg { /** * The standard URN used to identify this algorithm */ public static final String algId = "urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:" + "ordered-permit-overrides"; // a URI form of the identifier private static URI identifierURI; // exception if the URI was invalid, which should never be a problem private static RuntimeException earlyException; static { try { identifierURI = new URI(algId); } catch (URISyntaxException se) { earlyException = new IllegalArgumentException(); earlyException.initCause(se); } } /** * Standard constructor. */ public OrderedPermitOverridesRuleAlg() { super(identifierURI); if (earlyException != null) throw earlyException; } } |
From: <se...@us...> - 2003-08-26 13:11:35
|
Update of /cvsroot/sunxacml/sunxacml In directory sc8-pr-cvs1:/tmp/cvs-serv22455 Modified Files: overview.html Log Message: added note about encoding Index: overview.html =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/overview.html,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** overview.html 13 Feb 2003 22:19:10 -0000 1.1.1.1 --- overview.html 25 Aug 2003 16:53:47 -0000 1.2 *************** *** 1,8 **** <body> ! This is an implementation of the OASIS XACML 1.0 standard. It supports the full specification including parsing policies, managing requests and responses, processing policies against requests, adding new attribute types and functions, and providing modules for hooking into external services. This is an OpenSource project started by Sun Microsystems. </body> --- 1,18 ---- <body> ! This is an implementation of the OASIS XACML 1.1 standard. It supports the full specification including parsing policies, managing requests and responses, processing policies against requests, adding new attribute types and functions, and providing modules for hooking into external services. This is an OpenSource project started by Sun Microsystems. + <p> + NOTE: The classes in this project support parsing all the XACML types + and support being encoded back into their XML form. At present, this + is being done by hand, and with limited functionality. These routines + will be useful for people who want to parse policies and requests, or + for those who want to build tools that create XACML structures, but + they are only being provided as a temporary measure until a more + robust system can be introduced. As such, consider all the + <code>getInstance</code> and <code>encode</code> methods to be in a + state of flux. </body> |
From: <se...@us...> - 2003-08-26 10:53:21
|
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 + "\"/>"); |
From: <se...@us...> - 2003-08-26 10:53:00
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml In directory sc8-pr-cvs1:/tmp/cvs-serv22245 Modified Files: AbstractPolicy.java Indenter.java Obligation.java PDP.java Policy.java PolicyReference.java PolicySet.java PolicyTreeElement.java Rule.java Target.java TargetMatch.java Log Message: updated all existing encoding and added new encoding routines for all policy related elements Index: AbstractPolicy.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/AbstractPolicy.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AbstractPolicy.java 14 Aug 2003 22:56:48 -0000 1.4 --- AbstractPolicy.java 25 Aug 2003 16:53:10 -0000 1.5 *************** *** 44,47 **** --- 44,49 ---- import com.sun.xacml.ctx.Result; + import java.io.OutputStream; + import java.net.URI; *************** *** 391,394 **** --- 393,417 ---- // finally, return the result return result; + } + + /** + * Routine used by <code>Policy</code> and <code>PolicySet</code> to + * encode some common elements. + * + * @param output a stream into which the XML-encoded data is written + * @param indenter an object that creates indentation strings + */ + protected void encodeCommonElements(OutputStream out, Indenter indenter) { + target.encode(out, indenter); + + Iterator it = children.iterator(); + while (it.hasNext()) { + ((PolicyTreeElement)(it.next())).encode(out, indenter); + } + + it = obligations.iterator(); + while (it.hasNext()) { + ((Obligation)(it.next())).encode(out, indenter); + } } Index: Indenter.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/Indenter.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Indenter.java 13 Feb 2003 22:19:10 -0000 1.1.1.1 --- Indenter.java 25 Aug 2003 16:53:10 -0000 1.2 *************** *** 51,60 **** { // The width of one indentation level private int width; ! // Default width ! private final int defaultWidth = 2; ! /** --- 51,64 ---- { + /** + * The default indentation width + */ + public static final int DEFAULT_WIDTH = 2; + // The width of one indentation level private int width; ! // the current depth ! private int depth; /** *************** *** 63,67 **** */ public Indenter() { ! width = defaultWidth; } --- 67,71 ---- */ public Indenter() { ! this(DEFAULT_WIDTH); } *************** *** 74,90 **** public Indenter(int userWidth) { width = userWidth; } /** ! * Create a <code>String</code> of spaces for indentation. Uses ! * width setting and depth parameter to generate string of correct ! * length. ! * ! * @param depth the current depth of the XML nesting * * @return an indent string to prepend to lines of XML */ ! public String makeString(int depth) { // Return quickly if no indenting if (width <= 0) { --- 78,105 ---- public Indenter(int userWidth) { width = userWidth; + depth = 0; + } + + /** + * Move in one width. + */ + public void in() { + depth += width; } + /** + * Move out one width. + */ + public void out() { + depth -= width; + } /** ! * Create a <code>String</code> of spaces for indentation based on the ! * current depth. * * @return an indent string to prepend to lines of XML */ ! public String makeString() { // Return quickly if no indenting if (width <= 0) { *************** *** 93,97 **** // Make a char array and fill it with spaces ! char[] array = new char[depth * width]; Arrays.fill(array, ' '); --- 108,112 ---- // Make a char array and fill it with spaces ! char[] array = new char[depth]; Arrays.fill(array, ' '); *************** *** 99,103 **** return new String(array); } - } --- 114,117 ---- Index: Obligation.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/Obligation.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Obligation.java 13 Feb 2003 22:19:10 -0000 1.1.1.1 --- Obligation.java 25 Aug 2003 16:53:10 -0000 1.2 *************** *** 190,210 **** /** * Encodes this <code>Obligation</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); out.println(indent + "<Obligation ObligationId=\"" + id.toString() + "\" FulfillOn=\"" + Result.DECISIONS[fulfillOn] + "\">"); Iterator it = assignments.iterator(); while (it.hasNext()) { Attribute attr = (Attribute)(it.next()); ! out.println(indenter.makeString(depth+1) + "<AttributeAssignment AttributeId=\"" + attr.getId().toString() + "\" DataType=\"" + --- 190,222 ---- /** * Encodes this <code>Obligation</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>Obligation</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(); out.println(indent + "<Obligation ObligationId=\"" + id.toString() + "\" FulfillOn=\"" + Result.DECISIONS[fulfillOn] + "\">"); + + indenter.in(); Iterator it = assignments.iterator(); + while (it.hasNext()) { Attribute attr = (Attribute)(it.next()); ! out.println(indenter.makeString() + "<AttributeAssignment AttributeId=\"" + attr.getId().toString() + "\" DataType=\"" + *************** *** 213,216 **** --- 225,230 ---- "</AttributeAssignment>"); } + + indenter.out(); out.println(indent + "</Obligation>"); Index: PDP.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/PDP.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** PDP.java 13 Feb 2003 22:19:10 -0000 1.1.1.1 --- PDP.java 25 Aug 2003 16:53:10 -0000 1.2 *************** *** 252,256 **** ByteArrayOutputStream out = new ByteArrayOutputStream(); ! response.encode(out, 0, new Indenter()); return out; --- 252,256 ---- ByteArrayOutputStream out = new ByteArrayOutputStream(); ! response.encode(out, new Indenter()); return out; Index: Policy.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/Policy.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Policy.java 14 Aug 2003 22:56:48 -0000 1.3 --- Policy.java 25 Aug 2003 16:53:10 -0000 1.4 *************** *** 41,45 **** import com.sun.xacml.ctx.Result; ! import java.io.InputStream; import java.net.URI; --- 41,46 ---- import com.sun.xacml.ctx.Result; ! import java.io.OutputStream; ! import java.io.PrintStream; import java.net.URI; *************** *** 233,236 **** --- 234,284 ---- return new Policy(root); + } + + /** + * Encodes this <code>Policy</code> 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 <code>Policy</code> 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(); + + out.println(indent + "<Policy PolicyId=\"" + getId().toString() + + "\" RuleCombiningAlgId=\"" + + getCombiningAlg().getIdentifier().toString() + + "\">"); + + indenter.in(); + String nextIndent = indenter.makeString(); + + String description = getDescription(); + if (description != null) + out.println(nextIndent + "<Description>" + description + + "</Description>"); + + String version = getDefaultVersion(); + if (version != null) + out.println("<PolicyDefaults><XPathVersion>" + version + + "</XPathVersion></PolicyDefaults>"); + + encodeCommonElements(output, indenter); + + indenter.out(); + out.println(indent + "</Policy>"); } Index: PolicyReference.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/PolicyReference.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PolicyReference.java 17 Jun 2003 18:23:52 -0000 1.2 --- PolicyReference.java 25 Aug 2003 16:53:10 -0000 1.3 *************** *** 45,48 **** --- 45,51 ---- import com.sun.xacml.finder.PolicyFinderResult; + import java.io.OutputStream; + import java.io.PrintStream; + import java.net.URI; *************** *** 311,314 **** --- 314,349 ---- // we must have found a policy return pfr.getPolicy().evaluate(context); + } + + /** + * Encodes this <code>PolicyReference</code> 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 <code>PolicyReference</code> 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 encoded = indenter.makeString(); + + if (policyType == POLICY_REFERENCE) { + out.println(encoded + "<PolicyIdReference>" + + reference.toString() + "</PolicyIdReference"); + } else { + out.println(encoded + "<PolicySetIdReference>" + + reference.toString() + "</PolicySetIdReference>"); + } } Index: PolicySet.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/PolicySet.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PolicySet.java 14 Aug 2003 22:56:48 -0000 1.3 --- PolicySet.java 25 Aug 2003 16:53:10 -0000 1.4 *************** *** 43,47 **** import com.sun.xacml.finder.PolicyFinder; ! import java.io.InputStream; import java.net.URI; --- 43,48 ---- import com.sun.xacml.finder.PolicyFinder; ! import java.io.OutputStream; ! import java.io.PrintStream; import java.net.URI; *************** *** 264,267 **** --- 265,315 ---- return new PolicySet(root, finder); + } + + /** + * Encodes this <code>PolicySet</code> 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 <code>PolicySet</code> 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(); + + out.println(indent + "<PolicySet PolicySetId=\"" + getId().toString() + + "\" PolicyCombiningAlgId=\"" + + getCombiningAlg().getIdentifier().toString() + + "\">"); + + indenter.in(); + String nextIndent = indenter.makeString(); + + String description = getDescription(); + if (description != null) + out.println(nextIndent + "<Description>" + description + + "</Description>"); + + String version = getDefaultVersion(); + if (version != null) + out.println("<PolicySetDefaults><XPathVersion>" + version + + "</XPathVersion></PolicySetDefaults>"); + + encodeCommonElements(output, indenter); + + indenter.out(); + out.println(indent + "</PolicySet>"); } Index: PolicyTreeElement.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/PolicyTreeElement.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PolicyTreeElement.java 17 Jun 2003 18:23:52 -0000 1.1 --- PolicyTreeElement.java 25 Aug 2003 16:53:10 -0000 1.2 *************** *** 39,42 **** --- 39,44 ---- import com.sun.xacml.ctx.Result; + import java.io.OutputStream; + import java.net.URI; *************** *** 110,113 **** --- 112,134 ---- */ public Result evaluate(EvaluationCtx context); + + /** + * Encodes this element 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); + + /** + * Encodes this element 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); } Index: Rule.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/Rule.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Rule.java 17 Jun 2003 18:23:52 -0000 1.2 --- Rule.java 25 Aug 2003 16:53:10 -0000 1.3 *************** *** 45,48 **** --- 45,51 ---- import com.sun.xacml.ctx.Status; + import java.io.OutputStream; + import java.io.PrintStream; + import java.net.URI; import java.net.URISyntaxException; *************** *** 80,84 **** * * @param id the rule's identifier ! * @param effect the effect to return if the rule applies * @param description a textual description, or null * @param target the rule's target, or null if the target is to be --- 83,88 ---- * * @param id the rule's identifier ! * @param effect the effect to return if the rule applies (either ! * Pemit or Deny) as specified in <code>Result</code> * @param description a textual description, or null * @param target the rule's target, or null if the target is to be *************** *** 151,155 **** /** * Returns the effect that this <code>Rule</code> will return from ! * the evaluate method if the request applies. * * @return a decision effect, as defined in <code>Result</code> --- 155,159 ---- /** * Returns the effect that this <code>Rule</code> will return from ! * the evaluate method (Permit or Deny) if the request applies. * * @return a decision effect, as defined in <code>Result</code> *************** *** 287,290 **** --- 291,345 ---- else return new Result(Result.DECISION_NOT_APPLICABLE); + } + } + + /** + * Encodes this <code>Rule</code> 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 <code>Rule</code> 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(); + + out.print(indent + "<Rule RuleId=\"" + idAttr.toString() + + "\" Effect=\"" + Result.DECISIONS[effectAttr] + "\""); + + if ((description != null) || (target != null) || (condition != null)) { + // there is some content in the Rule + out.println(">"); + + indenter.in(); + String nextIndent = indenter.makeString(); + + if (description != null) + out.println(nextIndent + "<Description>" + description + + "</Description>"); + + if (target != null) + target.encode(output, indenter); + + if (condition != null) + condition.encode(output, indenter); + + indenter.out(); + out.println(indent + "</Rule>"); + } else { + // the Rule is empty, so close the tag and we're done + out.println("/>"); } } Index: Target.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/Target.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Target.java 29 Jul 2003 22:01:46 -0000 1.2 --- Target.java 25 Aug 2003 16:53:10 -0000 1.3 *************** *** 39,42 **** --- 39,45 ---- import com.sun.xacml.ctx.Status; + import java.io.OutputStream; + import java.io.PrintStream; + import java.util.ArrayList; import java.util.Collections; *************** *** 305,308 **** --- 308,386 ---- return new MatchResult(MatchResult.INDETERMINATE, firstIndeterminateStatus); + } + + /** + * Encodes this <code>Target</code> 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 <code>Target</code> 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(); + + out.println(indent + "<Target>"); + indenter.in(); + + encodeSection(out, indenter, "Subject", subjects); + encodeSection(out, indenter, "Resource", resources); + encodeSection(out, indenter, "Action", actions); + + indenter.out(); + out.println(indent + "</Target>"); + } + + /** + * Helper function that encodes a section of the target. + */ + private void encodeSection(PrintStream output, Indenter indenter, + String name, List list) { + String indent = indenter.makeString(); + + output.println(indent + "<" + name + "s>"); + + indenter.in(); + String indentNext = indenter.makeString(); + + if (list == null) { + // the match is any + output.println(indentNext + "<Any" + name + "/>"); + } else { + String nextIndent = indenter.makeString(); + + Iterator it = list.iterator(); + indenter.in(); + + while (it.hasNext()) { + List items = (List)(it.next()); + output.println(indentNext + "<" + name + ">"); + + Iterator matchIterator = items.iterator(); + while (matchIterator.hasNext()) { + TargetMatch tm = (TargetMatch)(matchIterator.next()); + tm.encode(output, indenter); + } + + output.println(indentNext + "</" + name + ">"); + } + + indenter.out(); + } + + indenter.out(); + output.println(indent + "</" + name + "s>"); } Index: TargetMatch.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/TargetMatch.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TargetMatch.java 29 Jul 2003 22:01:46 -0000 1.2 --- TargetMatch.java 25 Aug 2003 16:53:10 -0000 1.3 *************** *** 54,57 **** --- 54,60 ---- import com.sun.xacml.ctx.Status; + import java.io.OutputStream; + import java.io.PrintStream; + import java.net.URI; import java.net.URISyntaxException; *************** *** 339,342 **** --- 342,389 ---- else return new MatchResult(MatchResult.NO_MATCH); + } + + /** + * Encodes this <code>TargetMatch</code> 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 <code>TargetMatch</code> 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 tagName = null; + + switch (type) { + case SUBJECT: tagName = "SubjectMatch"; + break; + case RESOURCE: tagName = "ResourceMatch"; + break; + case ACTION: tagName = "ActionMatch"; + break; + } + + out.println(indent + "<" + tagName + " MatchId=\"" + + function.getIdentifier().toString()+ "\">"); + indenter.in(); + + attrValue.encode(output, indenter); + eval.encode(output, indenter); + + indenter.out(); + out.println(indent + "</" + tagName + ">"); } |
From: <se...@us...> - 2003-08-26 10:51:30
|
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 |
From: <se...@us...> - 2003-08-26 08:53:15
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr In directory sc8-pr-cvs1:/tmp/cvs-serv21612 Modified Files: TimeAttribute.java Log Message: fixed the encoding and removed some now no longer needed code Index: TimeAttribute.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr/TimeAttribute.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TimeAttribute.java 11 Aug 2003 20:48:45 -0000 1.2 --- TimeAttribute.java 25 Aug 2003 16:49:17 -0000 1.3 *************** *** 38,48 **** import com.sun.xacml.ParsingException; import java.net.URI; - import java.text.DateFormat; - import java.text.FieldPosition; import java.text.ParseException; - import java.text.SimpleDateFormat; import java.util.ArrayList; --- 38,46 ---- import com.sun.xacml.ParsingException; + import com.sun.xacml.ProcessingException; import java.net.URI; import java.text.ParseException; import java.util.ArrayList; *************** *** 108,125 **** /** - * Parser for dates with no time zones - * <p> - * This field is only initialized if needed (by initParsers()). - * <p> - * NOTE: This object should only be accessed from code that - * has synchronized on it, since SimpleDateFormat objects are not - * thread-safe. If this is causing performance problems, we could - * easily make this a method variable in methods that use it - * instead of a class field. But that would mean we'd need to - * spend a lot more time creating these objects. - */ - private static DateFormat simpleParser; - - /** * Time zone value that indicates that the time zone was not * specified. --- 106,109 ---- *************** *** 194,199 **** * offset to GMT, in minutes. * @param defaultedTimeZone the time zone actually used for this ! * object (if it was originally unspecified, ! * the default time zone used). * The offset to GMT, in minutes. */ --- 178,182 ---- * offset to GMT, in minutes. * @param defaultedTimeZone the time zone actually used for this ! * object, which must be specified. * The offset to GMT, in minutes. */ *************** *** 202,205 **** --- 185,194 ---- super(identifierURI); + // if the timezone is unspecified, it's illegal for the defaulted + // timezone to also be unspecified + if ((timeZone == TZ_UNSPECIFIED) && + (defaultedTimeZone == TZ_UNSPECIFIED)) + throw new ProcessingException("default timezone must be specified"); + init(date, nanoseconds, timeZone, defaultedTimeZone); } *************** *** 246,250 **** // Check that the date is normalized to 1/1/70 ! if ((timeGMT > DateAttribute.MILLIS_PER_DAY) || (timeGMT < 0)) timeGMT = timeGMT % DateAttribute.MILLIS_PER_DAY; } --- 235,239 ---- // Check that the date is normalized to 1/1/70 ! if ((timeGMT >= DateAttribute.MILLIS_PER_DAY) || (timeGMT < 0)) timeGMT = timeGMT % DateAttribute.MILLIS_PER_DAY; } *************** *** 306,330 **** /** - * Initialize the parser objects. - */ - private static void initParsers() { - // If simpleParser is already set, we're done. - if (simpleParser != null) - return; - - // Make sure that identifierURI is not null - if (earlyException != null) - throw earlyException; - - // Synchronize on identifierURI while initializing parsers - // so we don't end up using a half-way initialized parser - synchronized (identifierURI) { - // This simple parser has no time zone - simpleParser = new SimpleDateFormat("HH:mm:ss"); - simpleParser.setLenient(false); - } - } - - /** * Gets the time represented by this object. The return * value is a <code>Date</code> object representing the --- 295,298 ---- *************** *** 450,454 **** /** * Encodes the value in a form suitable for including in XML data like ! * a request or an obligation. This must return a value that could in * turn be used by the factory to create a new instance with the same * value. --- 418,422 ---- /** * Encodes the value in a form suitable for including in XML data like ! * a request or an obligation. This returns a time value that could in * turn be used by the factory to create a new instance with the same * value. *************** *** 460,497 **** return encodedValue; - if (timeZone == TZ_UNSPECIFIED) { - // If no time zone was specified, format Date value in - // local time with no time zone string. - initParsers(); - synchronized (simpleParser) { - encodedValue = simpleParser.format(new Date(timeGMT)); - } - if (nanoseconds != 0) { - encodedValue = encodedValue + "." + - DateAttribute.zeroPadInt(nanoseconds, 9); - } - } else { - // If a time zone was specified, don't use SimpleParser - // because it can only format dates in the local (default) - // time zone. And the offset between that time zone and the - // time zone we need to display can vary in complicated ways. - - // Instead, do it ourselves using our formatDateWithTZ method. - encodedValue = formatTimeWithTZ(); - } - return encodedValue; - } - - /** - * Encodes the value of this object as an xsi:time. - * Only for use when the time zone is specified. - * - * @return a <code>String</code> form of the value - */ - private String formatTimeWithTZ() { // "hh:mm:ss.sssssssss+hh:mm".length() = 27 StringBuffer buf = new StringBuffer(27); int millis = (int)timeGMT; int hour = millis / DateAttribute.MILLIS_PER_HOUR; millis = millis % DateAttribute.MILLIS_PER_HOUR; --- 428,448 ---- return encodedValue; // "hh:mm:ss.sssssssss+hh:mm".length() = 27 StringBuffer buf = new StringBuffer(27); + // get the correct time for the timezone being used int millis = (int)timeGMT; + if (timeZone == TZ_UNSPECIFIED) + millis += (defaultedTimeZone * DateAttribute.MILLIS_PER_MINUTE); + else + millis += (timeZone * DateAttribute.MILLIS_PER_MINUTE); + + if (millis < 0) { + millis += DateAttribute.MILLIS_PER_DAY; + } else if (millis >= DateAttribute.MILLIS_PER_DAY) { + millis -= DateAttribute.MILLIS_PER_DAY; + } + + // now generate the time string int hour = millis / DateAttribute.MILLIS_PER_HOUR; millis = millis % DateAttribute.MILLIS_PER_HOUR; *************** *** 505,508 **** --- 456,460 ---- buf.append(DateAttribute.zeroPadInt(second, 2)); + // add any nanoseconds if (nanoseconds != 0) { buf.append('.'); *************** *** 510,526 **** } ! int tzNoSign = timeZone; ! if (timeZone < 0) { ! tzNoSign = -tzNoSign; ! buf.append('-'); ! } else ! buf.append('+'); ! int tzHours = tzNoSign / 60; ! buf.append(DateAttribute.zeroPadInt(tzHours, 2)); ! buf.append(':'); ! int tzMinutes = tzNoSign % 60; ! buf.append(DateAttribute.zeroPadInt(tzMinutes, 2)); ! return buf.toString(); } } --- 462,485 ---- } ! // if there is a specified timezone, then include that in the encoding ! if (timeZone != TZ_UNSPECIFIED) { ! int tzNoSign = timeZone; ! if (timeZone < 0) { ! tzNoSign = -tzNoSign; ! buf.append('-'); ! } else ! buf.append('+'); ! int tzHours = tzNoSign / 60; ! buf.append(DateAttribute.zeroPadInt(tzHours, 2)); ! buf.append(':'); ! int tzMinutes = tzNoSign % 60; ! buf.append(DateAttribute.zeroPadInt(tzMinutes, 2)); ! } ! // remember the encoding for later ! encodedValue = buf.toString(); ! ! return encodedValue; } + } |
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine In directory sc8-pr-cvs1:/tmp/cvs-serv21267 Modified Files: CombiningAlgFactory.java CombiningAlgorithm.java DenyOverridesPolicyAlg.java DenyOverridesRuleAlg.java FirstApplicablePolicyAlg.java FirstApplicableRuleAlg.java OnlyOneApplicablePolicyAlg.java PermitOverridesPolicyAlg.java PermitOverridesRuleAlg.java PolicyCombiningAlgorithm.java RuleCombiningAlgorithm.java Log Message: updated to use new ordered sub-classes and to support identity Index: CombiningAlgFactory.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine/CombiningAlgFactory.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CombiningAlgFactory.java 14 Aug 2003 22:56:48 -0000 1.3 --- CombiningAlgFactory.java 25 Aug 2003 16:46:33 -0000 1.4 *************** *** 75,82 **** new DenyOverridesPolicyAlg()); ! algMap.put(DenyOverridesRuleAlg.orderedAlgId, ! new DenyOverridesRuleAlg()); ! algMap.put(DenyOverridesPolicyAlg.orderedAlgId, ! new DenyOverridesPolicyAlg()); algMap.put(PermitOverridesRuleAlg.algId, --- 75,82 ---- new DenyOverridesPolicyAlg()); ! algMap.put(OrderedDenyOverridesRuleAlg.algId, ! new OrderedDenyOverridesRuleAlg()); ! algMap.put(OrderedDenyOverridesPolicyAlg.algId, ! new OrderedDenyOverridesPolicyAlg()); algMap.put(PermitOverridesRuleAlg.algId, *************** *** 85,92 **** new PermitOverridesPolicyAlg()); ! algMap.put(PermitOverridesRuleAlg.orderedAlgId, ! new PermitOverridesRuleAlg()); ! algMap.put(PermitOverridesPolicyAlg.orderedAlgId, ! new PermitOverridesPolicyAlg()); algMap.put(FirstApplicableRuleAlg.algId, --- 85,92 ---- new PermitOverridesPolicyAlg()); ! algMap.put(OrderedPermitOverridesRuleAlg.algId, ! new OrderedPermitOverridesRuleAlg()); ! algMap.put(OrderedPermitOverridesPolicyAlg.algId, ! new OrderedPermitOverridesPolicyAlg()); algMap.put(FirstApplicableRuleAlg.algId, Index: CombiningAlgorithm.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine/CombiningAlgorithm.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** CombiningAlgorithm.java 13 Feb 2003 22:19:10 -0000 1.1.1.1 --- CombiningAlgorithm.java 25 Aug 2003 16:46:33 -0000 1.2 *************** *** 41,44 **** --- 41,46 ---- import com.sun.xacml.ctx.Result; + import java.net.URI; + import java.util.List; *************** *** 53,56 **** --- 55,70 ---- { + // the identifier for the algorithm + private URI identifier; + + /** + * Constructor that takes the algorithm's identifier. + * + * @param identifier the algorithm's identifier + */ + public CombiningAlgorithm(URI identifier) { + this.identifier = identifier; + } + /** * Combines the inputs based on the context to produce some unified *************** *** 63,66 **** --- 77,89 ---- */ public abstract Result combine(EvaluationCtx context, List inputs); + + /** + * Returns the identifier for this algorithm. + * + * @return the algorithm's identifier + */ + public URI getIdentifier() { + return identifier; + } } Index: DenyOverridesPolicyAlg.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine/DenyOverridesPolicyAlg.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DenyOverridesPolicyAlg.java 14 Aug 2003 22:56:48 -0000 1.2 --- DenyOverridesPolicyAlg.java 25 Aug 2003 16:46:33 -0000 1.3 *************** *** 45,48 **** --- 45,49 ---- import java.net.URI; + import java.net.URISyntaxException; import java.util.HashSet; *************** *** 71,80 **** "deny-overrides"; /** ! * The standard URN used to identify the ordered version of this algorithm */ ! public static final String orderedAlgId = ! "urn:oasis:names:tc:xacml:1.0:policy-combining-algorithm:" + ! "ordered-deny-overrides"; /** --- 72,107 ---- "deny-overrides"; + // a URI form of the identifier + private static URI identifierURI; + // exception if the URI was invalid, which should never be a problem + private static RuntimeException earlyException; + + static { + try { + identifierURI = new URI(algId); + } catch (URISyntaxException se) { + earlyException = new IllegalArgumentException(); + earlyException.initCause(se); + } + } + /** ! * Standard constructor. */ ! public DenyOverridesPolicyAlg() { ! super(identifierURI); ! ! if (earlyException != null) ! throw earlyException; ! } ! ! /** ! * Protected constructor used by the ordered version of this algorithm. ! * ! * @param identifier the algorithm's identifier ! */ ! protected DenyOverridesPolicyAlg(URI identifier) { ! super(identifier); ! } /** Index: DenyOverridesRuleAlg.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine/DenyOverridesRuleAlg.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DenyOverridesRuleAlg.java 14 Aug 2003 22:56:48 -0000 1.2 --- DenyOverridesRuleAlg.java 25 Aug 2003 16:46:33 -0000 1.3 *************** *** 44,47 **** --- 44,48 ---- import java.net.URI; + import java.net.URISyntaxException; import java.util.Iterator; *************** *** 68,77 **** "deny-overrides"; /** ! * The standard URN used to identify the ordered version of this algorithm */ ! public static final String orderedAlgId = ! "urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:" + ! "ordered-deny-overrides"; /** --- 69,104 ---- "deny-overrides"; + // a URI form of the identifier + private static URI identifierURI; + // exception if the URI was invalid, which should never be a problem + private static RuntimeException earlyException; + + static { + try { + identifierURI = new URI(algId); + } catch (URISyntaxException se) { + earlyException = new IllegalArgumentException(); + earlyException.initCause(se); + } + } + /** ! * Standard constructor. */ ! public DenyOverridesRuleAlg() { ! super(identifierURI); ! ! if (earlyException != null) ! throw earlyException; ! } ! ! /** ! * Protected constructor used by the ordered version of this algorithm. ! * ! * @param identifier the algorithm's identifier ! */ ! protected DenyOverridesRuleAlg(URI identifier) { ! super(identifier); ! } /** Index: FirstApplicablePolicyAlg.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine/FirstApplicablePolicyAlg.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** FirstApplicablePolicyAlg.java 13 Feb 2003 22:19:10 -0000 1.1.1.1 --- FirstApplicablePolicyAlg.java 25 Aug 2003 16:46:33 -0000 1.2 *************** *** 45,48 **** --- 45,49 ---- import java.net.URI; + import java.net.URISyntaxException; import java.util.Iterator; *************** *** 66,69 **** --- 67,94 ---- "urn:oasis:names:tc:xacml:1.0:policy-combining-algorithm:" + "first-applicable"; + + // a URI form of the identifier + private static URI identifierURI; + // exception if the URI was invalid, which should never be a problem + private static RuntimeException earlyException; + + static { + try { + identifierURI = new URI(algId); + } catch (URISyntaxException se) { + earlyException = new IllegalArgumentException(); + earlyException.initCause(se); + } + } + + /** + * Standard constructor. + */ + public FirstApplicablePolicyAlg() { + super(identifierURI); + + if (earlyException != null) + throw earlyException; + } /** Index: FirstApplicableRuleAlg.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine/FirstApplicableRuleAlg.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** FirstApplicableRuleAlg.java 13 Feb 2003 22:19:10 -0000 1.1.1.1 --- FirstApplicableRuleAlg.java 25 Aug 2003 16:46:33 -0000 1.2 *************** *** 44,47 **** --- 44,48 ---- import java.net.URI; + import java.net.URISyntaxException; import java.util.Iterator; *************** *** 65,68 **** --- 66,93 ---- "urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:" + "first-applicable"; + + // a URI form of the identifier + private static URI identifierURI; + // exception if the URI was invalid, which should never be a problem + private static RuntimeException earlyException; + + static { + try { + identifierURI = new URI(algId); + } catch (URISyntaxException se) { + earlyException = new IllegalArgumentException(); + earlyException.initCause(se); + } + } + + /** + * Standard constructor. + */ + public FirstApplicableRuleAlg() { + super(identifierURI); + + if (earlyException != null) + throw earlyException; + } /** Index: OnlyOneApplicablePolicyAlg.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine/OnlyOneApplicablePolicyAlg.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** OnlyOneApplicablePolicyAlg.java 13 Feb 2003 22:19:10 -0000 1.1.1.1 --- OnlyOneApplicablePolicyAlg.java 25 Aug 2003 16:46:33 -0000 1.2 *************** *** 44,47 **** --- 44,50 ---- import com.sun.xacml.ctx.Status; + import java.net.URI; + import java.net.URISyntaxException; + import java.util.ArrayList; import java.util.Iterator; *************** *** 65,68 **** --- 68,95 ---- "urn:oasis:names:tc:xacml:1.0:policy-combining-algorithm:" + "only-one-applicable"; + + // a URI form of the identifier + private static URI identifierURI; + // exception if the URI was invalid, which should never be a problem + private static RuntimeException earlyException; + + static { + try { + identifierURI = new URI(algId); + } catch (URISyntaxException se) { + earlyException = new IllegalArgumentException(); + earlyException.initCause(se); + } + } + + /** + * Standard constructor. + */ + public OnlyOneApplicablePolicyAlg() { + super(identifierURI); + + if (earlyException != null) + throw earlyException; + } /** Index: PermitOverridesPolicyAlg.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine/PermitOverridesPolicyAlg.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PermitOverridesPolicyAlg.java 14 Aug 2003 22:56:48 -0000 1.2 --- PermitOverridesPolicyAlg.java 25 Aug 2003 16:46:33 -0000 1.3 *************** *** 45,48 **** --- 45,49 ---- import java.net.URI; + import java.net.URISyntaxException; import java.util.HashSet; *************** *** 71,80 **** "permit-overrides"; /** ! * The standard URN used to identify the ordered version of this algorithm */ ! public static final String orderedAlgId = ! "urn:oasis:names:tc:xacml:1.0:policy-combining-algorithm:" + ! "ordered-permit-overrides"; /** --- 72,107 ---- "permit-overrides"; + // a URI form of the identifier + private static URI identifierURI; + // exception if the URI was invalid, which should never be a problem + private static RuntimeException earlyException; + + static { + try { + identifierURI = new URI(algId); + } catch (URISyntaxException se) { + earlyException = new IllegalArgumentException(); + earlyException.initCause(se); + } + } + /** ! * Standard constructor. */ ! public PermitOverridesPolicyAlg() { ! super(identifierURI); ! ! if (earlyException != null) ! throw earlyException; ! } ! ! /** ! * Protected constructor used by the ordered version of this algorithm. ! * ! * @param identifier the algorithm's identifier ! */ ! protected PermitOverridesPolicyAlg(URI identifier) { ! super(identifier); ! } /** Index: PermitOverridesRuleAlg.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine/PermitOverridesRuleAlg.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PermitOverridesRuleAlg.java 14 Aug 2003 22:56:48 -0000 1.2 --- PermitOverridesRuleAlg.java 25 Aug 2003 16:46:33 -0000 1.3 *************** *** 44,47 **** --- 44,48 ---- import java.net.URI; + import java.net.URISyntaxException; import java.util.Iterator; *************** *** 68,77 **** "permit-overrides"; /** ! * The standard URN used to identify the ordered version of this algorithm */ ! public static final String orderedAlgId = ! "urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:" + ! "ordered-permit-overrides"; /** --- 69,104 ---- "permit-overrides"; + // a URI form of the identifier + private static URI identifierURI; + // exception if the URI was invalid, which should never be a problem + private static RuntimeException earlyException; + + static { + try { + identifierURI = new URI(algId); + } catch (URISyntaxException se) { + earlyException = new IllegalArgumentException(); + earlyException.initCause(se); + } + } + /** ! * Standard constructor. */ ! public PermitOverridesRuleAlg() { ! super(identifierURI); ! ! if (earlyException != null) ! throw earlyException; ! } ! ! /** ! * Protected constructor used by the ordered version of this algorithm. ! * ! * @param identifier the algorithm's identifier ! */ ! protected PermitOverridesRuleAlg(URI identifier) { ! super(identifier); ! } /** Index: PolicyCombiningAlgorithm.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine/PolicyCombiningAlgorithm.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** PolicyCombiningAlgorithm.java 13 Feb 2003 22:19:10 -0000 1.1.1.1 --- PolicyCombiningAlgorithm.java 25 Aug 2003 16:46:33 -0000 1.2 *************** *** 41,44 **** --- 41,46 ---- import com.sun.xacml.ctx.Result; + import java.net.URI; + import java.util.List; *************** *** 60,63 **** --- 62,74 ---- public abstract class PolicyCombiningAlgorithm extends CombiningAlgorithm { + + /** + * Constructor that takes the algorithm's identifier. + * + * @param identifier the algorithm's identifier + */ + public PolicyCombiningAlgorithm(URI identifier) { + super(identifier); + } /** Index: RuleCombiningAlgorithm.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine/RuleCombiningAlgorithm.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RuleCombiningAlgorithm.java 14 Aug 2003 22:56:48 -0000 1.2 --- RuleCombiningAlgorithm.java 25 Aug 2003 16:46:33 -0000 1.3 *************** *** 41,44 **** --- 41,46 ---- import com.sun.xacml.ctx.Result; + import java.net.URI; + import java.util.List; *************** *** 52,55 **** --- 54,66 ---- public abstract class RuleCombiningAlgorithm extends CombiningAlgorithm { + + /** + * Constructor that takes the algorithm's identifier. + * + * @param identifier the algorithm's identifier + */ + public RuleCombiningAlgorithm(URI identifier) { + super(identifier); + } /** |
From: <se...@us...> - 2003-08-18 21:28:32
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/finder In directory sc8-pr-cvs1:/tmp/cvs-serv23260/com/sun/xacml/finder Removed Files: Makefile Log Message: removed all makefiles since ant is the correct way to bulid this project --- Makefile DELETED --- |
From: <se...@us...> - 2003-08-18 21:28:32
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/finder/impl In directory sc8-pr-cvs1:/tmp/cvs-serv23260/com/sun/xacml/finder/impl Removed Files: Makefile Log Message: removed all makefiles since ant is the correct way to bulid this project --- Makefile DELETED --- |
From: <se...@us...> - 2003-08-18 21:28:32
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/ctx In directory sc8-pr-cvs1:/tmp/cvs-serv23260/com/sun/xacml/ctx Removed Files: Makefile Log Message: removed all makefiles since ant is the correct way to bulid this project --- Makefile DELETED --- |
From: <se...@us...> - 2003-08-18 21:28:32
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond In directory sc8-pr-cvs1:/tmp/cvs-serv23260/com/sun/xacml/cond Removed Files: Makefile Log Message: removed all makefiles since ant is the correct way to bulid this project --- Makefile DELETED --- |
From: <se...@us...> - 2003-08-18 21:28:31
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine In directory sc8-pr-cvs1:/tmp/cvs-serv23260/com/sun/xacml/combine Removed Files: Makefile Log Message: removed all makefiles since ant is the correct way to bulid this project --- Makefile DELETED --- |
From: <se...@us...> - 2003-08-18 21:28:31
|
Update of /cvsroot/sunxacml/sunxacml/com In directory sc8-pr-cvs1:/tmp/cvs-serv23260/com Removed Files: Makefile Log Message: removed all makefiles since ant is the correct way to bulid this project --- Makefile DELETED --- |
From: <se...@us...> - 2003-08-18 21:28:31
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr In directory sc8-pr-cvs1:/tmp/cvs-serv23260/com/sun/xacml/attr Removed Files: Makefile Log Message: removed all makefiles since ant is the correct way to bulid this project --- Makefile DELETED --- |
From: <se...@us...> - 2003-08-18 21:28:31
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml In directory sc8-pr-cvs1:/tmp/cvs-serv23260/com/sun/xacml Removed Files: Makefile Log Message: removed all makefiles since ant is the correct way to bulid this project --- Makefile DELETED --- |
From: <se...@us...> - 2003-08-18 21:28:31
|
Update of /cvsroot/sunxacml/sunxacml/com/sun In directory sc8-pr-cvs1:/tmp/cvs-serv23260/com/sun Removed Files: Makefile Log Message: removed all makefiles since ant is the correct way to bulid this project --- Makefile DELETED --- |
From: <se...@us...> - 2003-08-18 21:28:31
|
Update of /cvsroot/sunxacml/sunxacml In directory sc8-pr-cvs1:/tmp/cvs-serv23260 Removed Files: Makefile make.javadoc make.vars Log Message: removed all makefiles since ant is the correct way to bulid this project --- Makefile DELETED --- --- make.javadoc DELETED --- --- make.vars DELETED --- |
From: <se...@us...> - 2003-08-14 23:26:17
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml In directory sc8-pr-cvs1:/tmp/cvs-serv25166/com/sun/xacml Modified Files: AbstractPolicy.java Policy.java PolicySet.java Log Message: Added support for the new ordered combining algs from 1.1 and added enforcement code to make sure that Policy/PolicySet instances use the right kind of algs Index: AbstractPolicy.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/AbstractPolicy.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AbstractPolicy.java 17 Jun 2003 18:23:52 -0000 1.3 --- AbstractPolicy.java 14 Aug 2003 22:56:48 -0000 1.4 *************** *** 39,42 **** --- 39,44 ---- import com.sun.xacml.combine.CombiningAlgorithm; import com.sun.xacml.combine.CombiningAlgFactory; + import com.sun.xacml.combine.PolicyCombiningAlgorithm; + import com.sun.xacml.combine.RuleCombiningAlgorithm; import com.sun.xacml.ctx.Result; *************** *** 154,158 **** * * @param root the DOM root of the policy ! * @param policyPrefix typically "Policy" or "PolicySet" * @param combiningName name of the field naming the combining alg * --- 156,160 ---- * * @param root the DOM root of the policy ! * @param policyPrefix either "Policy" or "PolicySet" * @param combiningName name of the field naming the combining alg * *************** *** 173,178 **** } try { - // now get the combining algorithm URI algId = new URI(attrs.getNamedItem(combiningName). getNodeValue()); --- 175,180 ---- } + // now get the combining algorithm... try { URI algId = new URI(attrs.getNamedItem(combiningName). getNodeValue()); *************** *** 181,184 **** --- 183,197 ---- throw new ParsingException("Error parsing combining algorithm" + " in " + policyPrefix, e); + } + + // ...and make sure it's the right kind + if (policyPrefix.equals("Policy")) { + if (! (combiningAlg instanceof RuleCombiningAlgorithm)) + throw new ParsingException("Policy must use a Rule " + + "Combining Algorithm"); + } else { + if (! (combiningAlg instanceof PolicyCombiningAlgorithm)) + throw new ParsingException("PolicySet must use a Policy " + + "Combining Algorithm"); } Index: Policy.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/Policy.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Policy.java 17 Jun 2003 18:23:52 -0000 1.2 --- Policy.java 14 Aug 2003 22:56:48 -0000 1.3 *************** *** 37,41 **** package com.sun.xacml; ! import com.sun.xacml.combine.CombiningAlgorithm; import com.sun.xacml.ctx.Result; --- 37,41 ---- package com.sun.xacml; ! import com.sun.xacml.combine.RuleCombiningAlgorithm; import com.sun.xacml.ctx.Result; *************** *** 73,77 **** * @param target the <code>Target</code> for this policy */ ! public Policy(URI id, CombiningAlgorithm combiningAlg, Target target) { this(id, combiningAlg, null, target, null, null, null); } --- 73,77 ---- * @param target the <code>Target</code> for this policy */ ! public Policy(URI id, RuleCombiningAlgorithm combiningAlg, Target target) { this(id, combiningAlg, null, target, null, null, null); } *************** *** 91,95 **** * <code>Rule</code> */ ! public Policy(URI id, CombiningAlgorithm combiningAlg, Target target, List rules) { this(id, combiningAlg, null, target, null, rules, null); --- 91,95 ---- * <code>Rule</code> */ ! public Policy(URI id, RuleCombiningAlgorithm combiningAlg, Target target, List rules) { this(id, combiningAlg, null, target, null, rules, null); *************** *** 111,115 **** * <code>Rule</code> */ ! public Policy(URI id, CombiningAlgorithm combiningAlg, Target target, String defaultVersion, List rules) { this(id, combiningAlg, null, target, defaultVersion, rules, null); --- 111,115 ---- * <code>Rule</code> */ ! public Policy(URI id, RuleCombiningAlgorithm combiningAlg, Target target, String defaultVersion, List rules) { this(id, combiningAlg, null, target, defaultVersion, rules, null); *************** *** 131,136 **** * <code>Rule</code> */ ! public Policy(URI id, CombiningAlgorithm combiningAlg, String description, ! Target target, List rules) { this(id, combiningAlg, description, target, null, rules, null); } --- 131,136 ---- * <code>Rule</code> */ ! public Policy(URI id, RuleCombiningAlgorithm combiningAlg, ! String description, Target target, List rules) { this(id, combiningAlg, description, target, null, rules, null); } *************** *** 152,157 **** * <code>Rule</code> */ ! public Policy(URI id, CombiningAlgorithm combiningAlg, String description, ! Target target, String defaultVersion, List rules) { this(id, combiningAlg, description, target, defaultVersion, rules, null); --- 152,158 ---- * <code>Rule</code> */ ! public Policy(URI id, RuleCombiningAlgorithm combiningAlg, ! String description, Target target, String defaultVersion, ! List rules) { this(id, combiningAlg, description, target, defaultVersion, rules, null); *************** *** 175,181 **** * <code>Rule</code> */ ! public Policy(URI id, CombiningAlgorithm combiningAlg, String description, ! Target target, String defaultVersion, List rules, ! Set obligations) { super(id, combiningAlg, description, target, defaultVersion, obligations); --- 176,182 ---- * <code>Rule</code> */ ! public Policy(URI id, RuleCombiningAlgorithm combiningAlg, ! String description, Target target, String defaultVersion, ! List rules, Set obligations) { super(id, combiningAlg, description, target, defaultVersion, obligations); Index: PolicySet.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/PolicySet.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PolicySet.java 17 Jun 2003 18:23:52 -0000 1.2 --- PolicySet.java 14 Aug 2003 22:56:48 -0000 1.3 *************** *** 37,41 **** package com.sun.xacml; ! import com.sun.xacml.combine.CombiningAlgorithm; import com.sun.xacml.ctx.Result; --- 37,41 ---- package com.sun.xacml; ! import com.sun.xacml.combine.PolicyCombiningAlgorithm; import com.sun.xacml.ctx.Result; *************** *** 75,79 **** * @param target the <code>Target</code> for this set */ ! public PolicySet(URI id, CombiningAlgorithm combiningAlg, Target target) { this(id, combiningAlg, null, target, null, null, null); } --- 75,80 ---- * @param target the <code>Target</code> for this set */ ! public PolicySet(URI id, PolicyCombiningAlgorithm combiningAlg, ! Target target) { this(id, combiningAlg, null, target, null, null, null); } *************** *** 93,98 **** * <code>AbstractPolicy</code> */ ! public PolicySet(URI id, CombiningAlgorithm combiningAlg, Target target, ! List policies) { this(id, combiningAlg, null, target, policies, null, null); } --- 94,99 ---- * <code>AbstractPolicy</code> */ ! public PolicySet(URI id, PolicyCombiningAlgorithm combiningAlg, ! Target target, List policies) { this(id, combiningAlg, null, target, policies, null, null); } *************** *** 113,118 **** * <code>AbstractPolicy</code> */ ! public PolicySet(URI id, CombiningAlgorithm combiningAlg, Target target, ! List policies, String defaultVersion) { this(id, combiningAlg, null, target, policies, defaultVersion, null); } --- 114,119 ---- * <code>AbstractPolicy</code> */ ! public PolicySet(URI id, PolicyCombiningAlgorithm combiningAlg, ! Target target, List policies, String defaultVersion) { this(id, combiningAlg, null, target, policies, defaultVersion, null); } *************** *** 133,137 **** * <code>AbstractPolicy</code> */ ! public PolicySet(URI id, CombiningAlgorithm combiningAlg, String description, Target target, List policies) { this(id, combiningAlg, description, target, policies, null, null); --- 134,138 ---- * <code>AbstractPolicy</code> */ ! public PolicySet(URI id, PolicyCombiningAlgorithm combiningAlg, String description, Target target, List policies) { this(id, combiningAlg, description, target, policies, null, null); *************** *** 154,158 **** * <code>AbstractPolicy</code> */ ! public PolicySet(URI id, CombiningAlgorithm combiningAlg, String description, Target target, List policies, String defaultVersion) { --- 155,159 ---- * <code>AbstractPolicy</code> */ ! public PolicySet(URI id, PolicyCombiningAlgorithm combiningAlg, String description, Target target, List policies, String defaultVersion) { *************** *** 178,182 **** * <code>AbstractPolicy</code> */ ! public PolicySet(URI id, CombiningAlgorithm combiningAlg, String description, Target target, List policies, String defaultVersion, Set obligations) { --- 179,183 ---- * <code>AbstractPolicy</code> */ ! public PolicySet(URI id, PolicyCombiningAlgorithm combiningAlg, String description, Target target, List policies, String defaultVersion, Set obligations) { |
From: <se...@us...> - 2003-08-14 23:02:00
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine In directory sc8-pr-cvs1:/tmp/cvs-serv25166/com/sun/xacml/combine Modified Files: CombiningAlgFactory.java DenyOverridesPolicyAlg.java DenyOverridesRuleAlg.java PermitOverridesPolicyAlg.java PermitOverridesRuleAlg.java RuleCombiningAlgorithm.java Log Message: Added support for the new ordered combining algs from 1.1 and added enforcement code to make sure that Policy/PolicySet instances use the right kind of algs Index: CombiningAlgFactory.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine/CombiningAlgFactory.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CombiningAlgFactory.java 9 May 2003 20:50:23 -0000 1.2 --- CombiningAlgFactory.java 14 Aug 2003 22:56:48 -0000 1.3 *************** *** 75,81 **** --- 75,91 ---- new DenyOverridesPolicyAlg()); + algMap.put(DenyOverridesRuleAlg.orderedAlgId, + new DenyOverridesRuleAlg()); + algMap.put(DenyOverridesPolicyAlg.orderedAlgId, + new DenyOverridesPolicyAlg()); + algMap.put(PermitOverridesRuleAlg.algId, new PermitOverridesRuleAlg()); algMap.put(PermitOverridesPolicyAlg.algId, + new PermitOverridesPolicyAlg()); + + algMap.put(PermitOverridesRuleAlg.orderedAlgId, + new PermitOverridesRuleAlg()); + algMap.put(PermitOverridesPolicyAlg.orderedAlgId, new PermitOverridesPolicyAlg()); Index: DenyOverridesPolicyAlg.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine/DenyOverridesPolicyAlg.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** DenyOverridesPolicyAlg.java 13 Feb 2003 22:19:10 -0000 1.1.1.1 --- DenyOverridesPolicyAlg.java 14 Aug 2003 22:56:48 -0000 1.2 *************** *** 55,59 **** * This is the standard Deny Overrides policy combining algorithm. It * allows a single evaluation of Deny to take precedence over any number ! * of permit, not applicable or indeterminate results. * * @author Seth Proctor --- 55,61 ---- * This is the standard Deny Overrides policy combining algorithm. It * allows a single evaluation of Deny to take precedence over any number ! * of permit, not applicable or indeterminate results. Note that since ! * this implementation does an ordered evaluation, this class also ! * supports the Ordered Deny Overrides algorithm. * * @author Seth Proctor *************** *** 68,71 **** --- 70,80 ---- "urn:oasis:names:tc:xacml:1.0:policy-combining-algorithm:" + "deny-overrides"; + + /** + * The standard URN used to identify the ordered version of this algorithm + */ + public static final String orderedAlgId = + "urn:oasis:names:tc:xacml:1.0:policy-combining-algorithm:" + + "ordered-deny-overrides"; /** Index: DenyOverridesRuleAlg.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine/DenyOverridesRuleAlg.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** DenyOverridesRuleAlg.java 13 Feb 2003 22:19:10 -0000 1.1.1.1 --- DenyOverridesRuleAlg.java 14 Aug 2003 22:56:48 -0000 1.2 *************** *** 52,56 **** * This is the standard Deny Overrides rule combining algorithm. It * allows a single evaluation of Deny to take precedence over any number ! * of permit, not applicable or indeterminate results. * * @author Seth Proctor --- 52,58 ---- * This is the standard Deny Overrides rule combining algorithm. It * allows a single evaluation of Deny to take precedence over any number ! * of permit, not applicable or indeterminate results. Note that since ! * this implementation does an ordered evaluation, this class also ! * supports the Ordered Deny Overrides algorithm. * * @author Seth Proctor *************** *** 65,68 **** --- 67,77 ---- "urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:" + "deny-overrides"; + + /** + * The standard URN used to identify the ordered version of this algorithm + */ + public static final String orderedAlgId = + "urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:" + + "ordered-deny-overrides"; /** Index: PermitOverridesPolicyAlg.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine/PermitOverridesPolicyAlg.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** PermitOverridesPolicyAlg.java 13 Feb 2003 22:19:10 -0000 1.1.1.1 --- PermitOverridesPolicyAlg.java 14 Aug 2003 22:56:48 -0000 1.2 *************** *** 55,59 **** * This is the standard Permit Overrides policy combining algorithm. It * allows a single evaluation of Permit to take precedence over any number ! * of deny, not applicable or indeterminate results. * * @author Seth Proctor --- 55,61 ---- * This is the standard Permit Overrides policy combining algorithm. It * allows a single evaluation of Permit to take precedence over any number ! * of deny, not applicable or indeterminate results. Note that since ! * this implementation does an ordered evaluation, this class also ! * supports the Ordered Permit Overrides algorithm. * * @author Seth Proctor *************** *** 68,71 **** --- 70,80 ---- "urn:oasis:names:tc:xacml:1.0:policy-combining-algorithm:" + "permit-overrides"; + + /** + * The standard URN used to identify the ordered version of this algorithm + */ + public static final String orderedAlgId = + "urn:oasis:names:tc:xacml:1.0:policy-combining-algorithm:" + + "ordered-permit-overrides"; /** Index: PermitOverridesRuleAlg.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine/PermitOverridesRuleAlg.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** PermitOverridesRuleAlg.java 13 Feb 2003 22:19:10 -0000 1.1.1.1 --- PermitOverridesRuleAlg.java 14 Aug 2003 22:56:48 -0000 1.2 *************** *** 52,56 **** * This is the standard Permit Overrides rule combining algorithm. It * allows a single evaluation of Permit to take precedence over any number ! * of deny, not applicable or indeterminate results. * * @author Seth Proctor --- 52,58 ---- * This is the standard Permit Overrides rule combining algorithm. It * allows a single evaluation of Permit to take precedence over any number ! * of deny, not applicable or indeterminate results. Note that since ! * this implementation does an ordered evaluation, this class also ! * supports the Ordered Permit Overrides algorithm. * * @author Seth Proctor *************** *** 65,68 **** --- 67,77 ---- "urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:" + "permit-overrides"; + + /** + * The standard URN used to identify the ordered version of this algorithm + */ + public static final String orderedAlgId = + "urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:" + + "ordered-permit-overrides"; /** Index: RuleCombiningAlgorithm.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine/RuleCombiningAlgorithm.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** RuleCombiningAlgorithm.java 13 Feb 2003 22:19:10 -0000 1.1.1.1 --- RuleCombiningAlgorithm.java 14 Aug 2003 22:56:48 -0000 1.2 *************** *** 54,58 **** /** ! * Combines the policies based on the context to produce some unified * result. This is the one function of a combining algorithm. * --- 54,58 ---- /** ! * Combines the rules based on the context to produce some unified * result. This is the one function of a combining algorithm. * |
From: <se...@us...> - 2003-08-14 22:25:24
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/finder/impl In directory sc8-pr-cvs1:/tmp/cvs-serv13599/com/sun/xacml/finder/impl Modified Files: FilePolicyModule.java Log Message: Fixed the identifier URIs Index: FilePolicyModule.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/finder/impl/FilePolicyModule.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** FilePolicyModule.java 13 Feb 2003 22:19:13 -0000 1.1.1.1 --- FilePolicyModule.java 14 Aug 2003 21:35:45 -0000 1.2 *************** *** 75,78 **** --- 75,84 ---- * each of which will be searched through when trying to find a * policy that is applicable to a specific request. + * <p> + * Note: this module is provided only as an example and for testing + * purposes. It is not part of the standard, and it should not be + * relied upon for production systems. In the future, this will likely + * be moved into a package with other similar example and testing + * code. * * @author Seth Proctor |
From: <se...@us...> - 2003-08-14 22:25:24
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr In directory sc8-pr-cvs1:/tmp/cvs-serv13599/com/sun/xacml/attr Modified Files: DayTimeDurationAttribute.java YearMonthDurationAttribute.java Log Message: Fixed the identifier URIs Index: DayTimeDurationAttribute.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr/DayTimeDurationAttribute.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** DayTimeDurationAttribute.java 13 Feb 2003 22:19:10 -0000 1.1.1.1 --- DayTimeDurationAttribute.java 14 Aug 2003 21:35:45 -0000 1.2 *************** *** 64,68 **** */ public static final String identifier = ! "http://www.w3.org/TR/xquery-operators#dayTimeDuration"; /** --- 64,69 ---- */ public static final String identifier = ! "http://www.w3.org/TR/2002/WD-xquery-operators-20020816#" + ! "dayTimeDuration"; /** Index: YearMonthDurationAttribute.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr/YearMonthDurationAttribute.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** YearMonthDurationAttribute.java 13 Feb 2003 22:19:10 -0000 1.1.1.1 --- YearMonthDurationAttribute.java 14 Aug 2003 21:35:45 -0000 1.2 *************** *** 64,68 **** */ public static final String identifier = ! "http://www.w3.org/TR/xquery-operators#yearMonthDuration"; /** --- 64,69 ---- */ public static final String identifier = ! "http://www.w3.org/TR/2002/WD-xquery-operators-20020816#" + ! "yearMonthDuration"; /** |
From: <se...@us...> - 2003-08-11 21:01:06
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml In directory sc8-pr-cvs1:/tmp/cvs-serv21844/com/sun/xacml Modified Files: EvaluationCtx.java Log Message: TimeAttribute fix for DST and new Time & current env features plus some small fixes and cleanups Index: EvaluationCtx.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/EvaluationCtx.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** EvaluationCtx.java 22 Jul 2003 15:05:45 -0000 1.3 --- EvaluationCtx.java 11 Aug 2003 20:48:44 -0000 1.4 *************** *** 40,44 **** --- 40,47 ---- import com.sun.xacml.attr.AttributeValue; import com.sun.xacml.attr.BagAttribute; + import com.sun.xacml.attr.DateAttribute; + import com.sun.xacml.attr.DateTimeAttribute; import com.sun.xacml.attr.StringAttribute; + import com.sun.xacml.attr.TimeAttribute; import com.sun.xacml.cond.EvaluationResult; *************** *** 69,72 **** --- 72,85 ---- * class is typically instantiated whenever the PDP gets a request and * needs to perform an evaluation as a result. + * <p> + * Note that this class does some optional caching for current date, time, + * and dateTime values (defined by a boolean flag to the constructors). The + * XACML specification requires that these values always be available, but it + * does not specify whether or not they must remain constant over the course + * of an evaluation if the values are being generated by the PDP (if the + * values are provided in the Request, then obviously they will remain + * constant). The default behavior is for these environment values to be cached, + * so that (for example) the current time remains constant over the course + * of an evaluation. * * @author Seth Proctor *************** *** 120,126 **** private int scope; /** * Constructs a new <code>EvaluationCtx</code> based on the given ! * request. * * @param request the request --- 133,147 ---- private int scope; + // the cached current date, time, and datetime, which we may or may + // not be using depending on how this object was constructed + private DateAttribute currentDate; + private TimeAttribute currentTime; + private DateTimeAttribute currentDateTime; + private boolean useCachedEnvValues; + /** * Constructs a new <code>EvaluationCtx</code> based on the given ! * request. The resulting context will cache current date, time, and ! * dateTime values so they remain constant for this evaluation. * * @param request the request *************** *** 130,134 **** */ public EvaluationCtx(RequestCtx request) throws ParsingException { ! this(request, null); } --- 151,173 ---- */ public EvaluationCtx(RequestCtx request) throws ParsingException { ! this(request, null, true); ! } ! ! /** ! * Constructs a new <code>EvaluationCtx</code> based on the given ! * request. ! * ! * @param request the request ! * @param cacheEnvValues whether or not to cache the current time, date, ! * and dateTime so they are constant for the scope ! * of this evaluation ! * ! * @throws ParsingException if a required attribute is missing, or if there ! * are any problems dealing with the request data ! */ ! public EvaluationCtx(RequestCtx request, boolean cacheEnvValues) ! throws ParsingException ! { ! this(request, null, cacheEnvValues); } *************** *** 136,140 **** * Constructs a new <code>EvaluationCtx</code> based on the given * request, and supports looking outside the original request for attribute ! * values using the <code>AttributeFinder</code>. * * @param request the request --- 175,181 ---- * Constructs a new <code>EvaluationCtx</code> based on the given * request, and supports looking outside the original request for attribute ! * values using the <code>AttributeFinder</code>. The resulting context ! * will cache current date, time, and dateTime values so they remain ! * constant for this evaluation. * * @param request the request *************** *** 148,151 **** --- 189,212 ---- throws ParsingException { + this(request, finder, true); + } + + /** + * Constructs a new <code>EvaluationCtx</code> based on the given + * request, and supports looking outside the original request for attribute + * values using the <code>AttributeFinder</code>. + * + * @param request the request + * @param finder an <code>AttributeFinder</code> to use in looking for + * attributes that aren't in the request + * @param cacheEnvValues whether or not to cache the current time, date, + * and dateTime so they are constant for the scope + * of this evaluation + * + * @throws ParsingException if a required attribute is missing, or if there + * are any problems dealing with the request data + */ + public EvaluationCtx(RequestCtx request, AttributeFinder finder, + boolean cacheEnvValues) throws ParsingException { // keep track of the finder this.finder = finder; *************** *** 154,157 **** --- 215,225 ---- requestRoot = request.getDocumentRoot(); + // initialize the cached date/time values so it's clear we haven't + // retrieved them yet + this.useCachedEnvValues = cacheEnvValues; + currentDate = null; + currentTime = null; + currentDateTime = null; + // get the subjects, make sure they're correct, and setup tables subjectMap = new HashMap(); *************** *** 366,369 **** --- 434,509 ---- attr.getIssuer(), attr.getIssueInstant(), resourceId)); + } + + /** + * Returns the cached value for the current time. If The value has never + * been set by a call to <code>setCurrentTime</code>, or if caching is + * not enabled in this instance, then this will return null. Note that this + * only applies to dynamically resolved values, not those supplied in the + * Request. + * + * @return the current time or null + */ + public TimeAttribute getCurrentTime() { + return currentTime; + } + + /** + * Sets the current time for this evaluation. If caching is not enabled + * for this instance then the value is ignored. + * + * @param currentTime the dynamically resolved current time + */ + public void setCurrentTime(TimeAttribute currentTime) { + if (useCachedEnvValues) + this.currentTime = currentTime; + } + + /** + * Returns the cached value for the current date. If The value has never + * been set by a call to <code>setCurrentDate</code>, or if caching is + * not enabled in this instance, then this will return null. Note that this + * only applies to dynamically resolved values, not those supplied in the + * Request. + * + * @return the current date or null + */ + public DateAttribute getCurrentDate() { + return currentDate; + } + + /** + * Sets the current date for this evaluation. If caching is not enabled + * for this instance then the value is ignored. + * + * @param currentDate the dynamically resolved current date + */ + public void setCurrentDate(DateAttribute currentDate) { + if (useCachedEnvValues) + this.currentDate = currentDate; + } + + /** + * Returns the cached value for the current dateTime. If The value has never + * been set by a call to <code>setCurrentDateTime</code>, or if caching is + * not enabled in this instance, then this will return null. Note that this + * only applies to dynamically resolved values, not those supplied in the + * Request. + * + * @return the current date or null + */ + public DateTimeAttribute getCurrentDateTime() { + return currentDateTime; + } + + /** + * Sets the current dateTime for this evaluation. If caching is not enabled + * for this instance then the value is ignored. + * + * @param currentDateTime the dynamically resolved current dateTime + */ + public void setCurrentDateTime(DateTimeAttribute currentDateTime) { + if (useCachedEnvValues) + this.currentDateTime = currentDateTime; } |
From: <se...@us...> - 2003-08-11 21:01:06
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr In directory sc8-pr-cvs1:/tmp/cvs-serv21844/com/sun/xacml/attr Modified Files: AttributeFactory.java AttributeSelector.java TimeAttribute.java Log Message: TimeAttribute fix for DST and new Time & current env features plus some small fixes and cleanups Index: AttributeFactory.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr/AttributeFactory.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** AttributeFactory.java 13 Feb 2003 22:19:10 -0000 1.1.1.1 --- AttributeFactory.java 11 Aug 2003 20:48:44 -0000 1.2 *************** *** 266,271 **** * @return a new <code>AttributeValue</code> * ! * @throws UnknownIdentifierException if the type in the node isn't ! * known to the factory * @throws ParsingException if the node is invalid or can't be parsed * by the appropriate proxy --- 266,271 ---- * @return a new <code>AttributeValue</code> * ! * @throws UnknownIdentifierException if the data type isn't known to ! * the factory * @throws ParsingException if the node is invalid or can't be parsed * by the appropriate proxy *************** *** 285,290 **** * @return a new <code>AttributeValue</code> * ! * @throws UnknownIdentifierException if the type in the node isn't ! * known to the factory * @throws ParsingException if the node is invalid or can't be parsed * by the appropriate proxy --- 285,290 ---- * @return a new <code>AttributeValue</code> * ! * @throws UnknownIdentifierException if the type isn't known to ! * the factory * @throws ParsingException if the node is invalid or can't be parsed * by the appropriate proxy *************** *** 319,324 **** * @return a new <code>AttributeValue</code> * ! * @throws UnknownIdentifierException if the type in the node isn't ! * known to the factory * @throws ParsingException if the text is invalid or can't be parsed * by the appropriate proxy --- 319,324 ---- * @return a new <code>AttributeValue</code> * ! * @throws UnknownIdentifierException if the data type isn't known to ! * the factory * @throws ParsingException if the text is invalid or can't be parsed * by the appropriate proxy Index: AttributeSelector.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr/AttributeSelector.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AttributeSelector.java 29 Jul 2003 22:01:47 -0000 1.2 --- AttributeSelector.java 11 Aug 2003 20:48:45 -0000 1.3 *************** *** 93,97 **** * of the XML type. * ! * @param node the root of the DOM tree for the XML AttributeSelectorType * XML type * --- 93,97 ---- * of the XML type. * ! * @param root the root of the DOM tree for the XML AttributeSelectorType * XML type * Index: TimeAttribute.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr/TimeAttribute.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** TimeAttribute.java 13 Feb 2003 22:19:10 -0000 1.1.1.1 --- TimeAttribute.java 11 Aug 2003 20:48:45 -0000 1.2 *************** *** 50,53 **** --- 50,54 ---- import java.util.Iterator; import java.util.List; + import java.util.TimeZone; import org.w3c.dom.Node; *************** *** 127,143 **** /** ! * The actual time that this object represents, in GMT, with the ! * date set to January 1, 1970. If no time zone was specified, the local ! * time zone is used to convert to seconds relative to GMT. ! * <p> ! * This Date does not include fractions of a second. Those are ! * handled by the separate nanoseconds field, since Date only ! * provides millisecond accuracy and the XML Query spec requires ! * at least 100 nanosecond accuracy. */ ! private Date value; /** ! * The number of nanoseconds beyond the Date given by the value * field. The XML Query document says that fractional seconds * must be supported down to at least 100 nanosecond resolution. --- 128,140 ---- /** ! * The time that this object represents in second resolution, in ! * milliseconds GMT, with zero being midnight. If no time zone was ! * specified, the local time zone is used to convert to milliseconds ! * relative to GMT. */ ! private long timeGMT; /** ! * The number of nanoseconds beyond the time given by the timeGMT * field. The XML Query document says that fractional seconds * must be supported down to at least 100 nanosecond resolution. *************** *** 147,150 **** --- 144,151 ---- private int nanoseconds; + // NOTE: now that we're not using a Date object, the above two variables + // could be condensed, and the interface could be changed so we don't + // need to worry about tracking the time values separately + /** * The time zone specified for this object (or TZ_UNSPECIFIED if *************** *** 167,171 **** /** * Creates a new <code>TimeAttribute</code> that represents ! * the current time in the default time zone. */ public TimeAttribute() { --- 168,172 ---- /** * Creates a new <code>TimeAttribute</code> that represents ! * the current time in the current time zone. */ public TimeAttribute() { *************** *** 224,228 **** */ private void init(Date date, int nanoseconds, int timeZone, ! int defaultedTimeZone) { // Shouldn't happen, but just in case... --- 225,229 ---- */ private void init(Date date, int nanoseconds, int timeZone, ! int defaultedTimeZone) { // Shouldn't happen, but just in case... *************** *** 230,247 **** throw earlyException; ! // Make a new Date object ! this.value = (Date) date.clone(); // Combine the nanoseconds so they are between 0 and 999,999,999 this.nanoseconds = ! DateTimeAttribute.combineNanos(this.value, nanoseconds); this.timeZone = timeZone; this.defaultedTimeZone = defaultedTimeZone; ! // Check that the date is normalized to 1/1/70, and adjust as needed ! long millis = value.getTime(); ! if ((millis > DateAttribute.MILLIS_PER_DAY) || (millis < 0)) { ! millis = millis % DateAttribute.MILLIS_PER_DAY; ! value.setTime(millis); ! } } --- 231,251 ---- throw earlyException; ! // get a temporary copy of the date ! Date tmpDate = (Date)(date.clone()); ! // Combine the nanoseconds so they are between 0 and 999,999,999 this.nanoseconds = ! DateTimeAttribute.combineNanos(tmpDate, nanoseconds); ! ! // now that the date has been (potentially) updated, store the time ! this.timeGMT = tmpDate.getTime(); ! ! // keep track of the timezone values this.timeZone = timeZone; this.defaultedTimeZone = defaultedTimeZone; ! // Check that the date is normalized to 1/1/70 ! if ((timeGMT > DateAttribute.MILLIS_PER_DAY) || (timeGMT < 0)) ! timeGMT = timeGMT % DateAttribute.MILLIS_PER_DAY; } *************** *** 279,286 **** DateTimeAttribute dateTime = DateTimeAttribute.getInstance(value); ! return new TimeAttribute(dateTime.getValue(), dateTime.getNanoseconds(), dateTime.getTimeZone(), ! dateTime.getDefaultedTimeZone()); } --- 283,306 ---- DateTimeAttribute dateTime = DateTimeAttribute.getInstance(value); ! // if there was no explicit TZ provided, then we want to make sure ! // the that the defaulting is done correctly, especially since 1/1/70 ! // is always out of daylight savings time ! ! Date dateValue = dateTime.getValue(); ! int defaultedTimeZone = dateTime.getDefaultedTimeZone(); ! if (dateTime.getTimeZone() == TZ_UNSPECIFIED) { ! TimeZone localTZ = TimeZone.getDefault(); ! int newDefTimeZone = ! DateTimeAttribute.getDefaultTZOffset(new Date()); ! dateValue = new Date(dateValue.getTime() - ! (newDefTimeZone - defaultedTimeZone) * ! DateAttribute.MILLIS_PER_MINUTE); ! defaultedTimeZone = newDefTimeZone; ! } ! ! return new TimeAttribute(dateValue, dateTime.getNanoseconds(), dateTime.getTimeZone(), ! defaultedTimeZone); } *************** *** 312,318 **** * of January 1, 1970. Subsecond values are handled by the * {@link #getNanoseconds getNanoseconds} method. - * <p> - * <b>NOTE:</b> The <code>Date</code> object is cloned before it - * is returned to avoid unauthorized changes. * * @return a <code>Date</code> object representing the --- 332,335 ---- *************** *** 320,324 **** */ public Date getValue() { ! return (Date) value.clone(); } --- 337,353 ---- */ public Date getValue() { ! return new Date(timeGMT); ! } ! ! /** ! * Gets the number of milliseconds since midnight GMT that this attribute ! * value represents. This is the same time returned by ! * <code>getValue</code>, and likewise the milliseconds are provided ! * with second resolution. ! * ! * @return milliseconds since midnight GMT ! */ ! public long getMilliseconds() { ! return timeGMT; } *************** *** 366,370 **** TimeAttribute other = (TimeAttribute)o; ! return (value.equals(other.value) && (nanoseconds == other.nanoseconds)); } --- 395,399 ---- TimeAttribute other = (TimeAttribute)o; ! return (timeGMT == other.timeGMT && (nanoseconds == other.nanoseconds)); } *************** *** 378,386 **** */ public int hashCode() { ! // Both the value field and the nanoseconds field are considered // by the equals method, so it's best if the hashCode is derived // from both of those fields. ! int hashCode = value.hashCode(); ! hashCode = 31*hashCode + nanoseconds; return hashCode; } --- 407,418 ---- */ public int hashCode() { ! // the standard Date hashcode is used here... ! int hashCode = (int)(timeGMT ^ (timeGMT >>> 32)); ! ! // ...but both the timeGMT and the nanoseconds fields are considered // by the equals method, so it's best if the hashCode is derived // from both of those fields. ! hashCode = (31 * hashCode) + nanoseconds; ! return hashCode; } *************** *** 392,404 **** */ public String toString() { ! StringBuffer sb = new StringBuffer(); ! sb.append("TimeAttribute: [\n"); ! sb.append(" Date: " + value + " local time"); sb.append(" Nanoseconds: " + nanoseconds); sb.append(" TimeZone: " + timeZone); sb.append(" Defaulted TimeZone: " + defaultedTimeZone); ! sb.append("]"); ! return sb.toString(); } --- 424,449 ---- */ public String toString() { ! StringBuffer sb = new StringBuffer(); ! sb.append("TimeAttribute: [\n"); ! ! // calculate the GMT value of this time ! long secsGMT = timeGMT / 1000; ! long minsGMT = secsGMT / 60; ! secsGMT = secsGMT % 60; ! long hoursGMT = minsGMT / 60; ! minsGMT = minsGMT % 60; ! // put the right number of zeros in place ! String hoursStr = (hoursGMT < 10) ? "0" + hoursGMT : "" + hoursGMT; ! String minsStr = (minsGMT < 10) ? "0" + minsGMT : "" + minsGMT; ! String secsStr = (secsGMT < 10) ? "0" + secsGMT : "" + secsGMT; ! ! sb.append(" Time GMT: " + hoursStr + ":" + minsStr + ":" + secsStr); sb.append(" Nanoseconds: " + nanoseconds); sb.append(" TimeZone: " + timeZone); sb.append(" Defaulted TimeZone: " + defaultedTimeZone); ! sb.append("]"); ! ! return sb.toString(); } *************** *** 420,424 **** initParsers(); synchronized (simpleParser) { ! encodedValue = simpleParser.format(value); } if (nanoseconds != 0) { --- 465,469 ---- initParsers(); synchronized (simpleParser) { ! encodedValue = simpleParser.format(new Date(timeGMT)); } if (nanoseconds != 0) { *************** *** 448,452 **** StringBuffer buf = new StringBuffer(27); ! int millis = (int) value.getTime(); int hour = millis / DateAttribute.MILLIS_PER_HOUR; millis = millis % DateAttribute.MILLIS_PER_HOUR; --- 493,497 ---- StringBuffer buf = new StringBuffer(27); ! int millis = (int)timeGMT; int hour = millis / DateAttribute.MILLIS_PER_HOUR; millis = millis % DateAttribute.MILLIS_PER_HOUR; |
From: <se...@us...> - 2003-08-11 21:01:05
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/finder/impl In directory sc8-pr-cvs1:/tmp/cvs-serv21844/com/sun/xacml/finder/impl Modified Files: CurrentEnvModule.java SelectorModule.java Log Message: TimeAttribute fix for DST and new Time & current env features plus some small fixes and cleanups Index: CurrentEnvModule.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/finder/impl/CurrentEnvModule.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** CurrentEnvModule.java 13 Feb 2003 22:19:13 -0000 1.1.1.1 --- CurrentEnvModule.java 11 Aug 2003 20:48:45 -0000 1.2 *************** *** 67,70 **** --- 67,74 ---- * The module provides support for this feature by generating real-time * values as known at the host where this module is running. + * <p> + * This class uses the caching functions of <code>EvaluationCtx</code> to + * make sure that values are constant within an evaluation, if that is the + * desired behavior. * * @author Seth Proctor *************** *** 149,157 **** if (attrName.equals(ENVIRONMENT_CURRENT_TIME)) { ! return handleTime(attributeType, issuer); } else if (attrName.equals(ENVIRONMENT_CURRENT_DATE)) { ! return handleDate(attributeType, issuer); } else if (attrName.equals(ENVIRONMENT_CURRENT_DATETIME)) { ! return handleDateTime(attributeType, issuer); } --- 153,161 ---- if (attrName.equals(ENVIRONMENT_CURRENT_TIME)) { ! return handleTime(attributeType, issuer, context); } else if (attrName.equals(ENVIRONMENT_CURRENT_DATE)) { ! return handleDate(attributeType, issuer, context); } else if (attrName.equals(ENVIRONMENT_CURRENT_DATETIME)) { ! return handleDateTime(attributeType, issuer, context); } *************** *** 164,168 **** * Handles requests for the current Time. */ ! private EvaluationResult handleTime(URI type, URI issuer) { // make sure they're asking for a time attribute if (! type.toString().equals(TimeAttribute.identifier)) --- 168,173 ---- * Handles requests for the current Time. */ ! private EvaluationResult handleTime(URI type, URI issuer, ! EvaluationCtx context) { // make sure they're asking for a time attribute if (! type.toString().equals(TimeAttribute.identifier)) *************** *** 170,175 **** createEmptyBag(type)); ! // create the time data and send it back ! TimeAttribute attr = new TimeAttribute(); return makeBag(attr); } --- 175,187 ---- createEmptyBag(type)); ! // see if there's a value already cached that we should use ! TimeAttribute attr = context.getCurrentTime(); ! ! if (attr == null) { ! // create the current time data ! attr = new TimeAttribute(); ! context.setCurrentTime(attr); ! } ! return makeBag(attr); } *************** *** 178,182 **** * Handles requests for the current Date. */ ! private EvaluationResult handleDate(URI type, URI issuer) { // make sure they're asking for a date attribute if (! type.toString().equals(DateAttribute.identifier)) --- 190,195 ---- * Handles requests for the current Date. */ ! private EvaluationResult handleDate(URI type, URI issuer, ! EvaluationCtx context) { // make sure they're asking for a date attribute if (! type.toString().equals(DateAttribute.identifier)) *************** *** 184,189 **** createEmptyBag(type)); ! // create the date data and send it back ! DateAttribute attr = new DateAttribute(); return makeBag(attr); } --- 197,209 ---- createEmptyBag(type)); ! // see if there's a value already cached that we should use ! DateAttribute attr = context.getCurrentDate(); ! ! if (attr == null) { ! // create the current date data ! attr = new DateAttribute(); ! context.setCurrentDate(attr); ! } ! return makeBag(attr); } *************** *** 192,196 **** * Handles requests for the current DateTime. */ ! private EvaluationResult handleDateTime(URI type, URI issuer) { // make sure they're asking for a dateTime attribute if (! type.toString().equals(DateTimeAttribute.identifier)) --- 212,217 ---- * Handles requests for the current DateTime. */ ! private EvaluationResult handleDateTime(URI type, URI issuer, ! EvaluationCtx context) { // make sure they're asking for a dateTime attribute if (! type.toString().equals(DateTimeAttribute.identifier)) *************** *** 198,203 **** createEmptyBag(type)); ! // create the dateTime data and send it back ! DateTimeAttribute attr = new DateTimeAttribute(); return makeBag(attr); } --- 219,231 ---- createEmptyBag(type)); ! // see if there's a value already cached that we should use ! DateTimeAttribute attr = context.getCurrentDateTime(); ! ! if (attr == null) { ! // create the current dateTime data ! attr = new DateTimeAttribute(); ! context.setCurrentDateTime(attr); ! } ! return makeBag(attr); } Index: SelectorModule.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/finder/impl/SelectorModule.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** SelectorModule.java 13 Feb 2003 22:19:13 -0000 1.1.1.1 --- SelectorModule.java 11 Aug 2003 20:48:45 -0000 1.2 *************** *** 104,109 **** * error occurred, an empty bag is returned. * ! * @param contextPath the XPath expression to search against ! * @param attributeType the datatype of the attributes to find * @param context the representation of the request data * --- 104,109 ---- * error occurred, an empty bag is returned. * ! * @param path the XPath expression to search against ! * @param type the datatype of the attributes to find * @param context the representation of the request data * |