org.jboss.security.xacml.sunxacml
Class VersionConstraints

java.lang.Object
  extended by org.jboss.security.xacml.sunxacml.VersionConstraints

public class VersionConstraints
extends Object

Supports the three version constraints that can be included with a policy reference. This class also provides a simple set of comparison methods for matching against the constraints. Note that this feature was introduced in XACML 2.0, which means that constraints are never used in pre-2.0 policy references.

Since:
2.0
Author:
Seth Proctor

Constructor Summary
VersionConstraints(String version, String earliest, String latest)
          Creates a VersionConstraints with the three optional constraint strings.
 
Method Summary
 String getEarliestConstraint()
          Returns the lower-bound constraint string, which will be null if there is no lower-bound constraint on the version.
 String getLatestConstraint()
          Returns the upper-bound constraint string, which will be null if there is no upper-bound constraint on the version.
 String getVersionConstraint()
          Returns the matching constraint string, which will be null if there is no constraint on matching the version.
static boolean isEarlier(String version, String constraint)
          Checks if the given version string is less-than or equal-to the constraint string.
static boolean isLater(String version, String constraint)
          Checks if the given version string is greater-than or equal-to the constraint string.
static boolean matches(String version, String constraint)
          Checks if the given version string matches the constraint string.
 boolean meetsConstraint(String version)
          Checks if the given version string meets all three constraints.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VersionConstraints

public VersionConstraints(String version,
                          String earliest,
                          String latest)
Creates a VersionConstraints with the three optional constraint strings. Each of the three strings must conform to the VersionMatchType type defined in the XACML schema. Any of the strings may be null to specify that the given constraint is not used.

Parameters:
version - a matching constraint on the version or null
earliest - a lower-bound constraint on the version or null
latest - an upper-bound constraint on the version or null
Method Detail

getVersionConstraint

public String getVersionConstraint()
Returns the matching constraint string, which will be null if there is no constraint on matching the version.

Returns:
the version constraint

getEarliestConstraint

public String getEarliestConstraint()
Returns the lower-bound constraint string, which will be null if there is no lower-bound constraint on the version.

Returns:
the lower-bound constraint

getLatestConstraint

public String getLatestConstraint()
Returns the upper-bound constraint string, which will be null if there is no upper-bound constraint on the version.

Returns:
the upper-bound constraint

meetsConstraint

public boolean meetsConstraint(String version)
Checks if the given version string meets all three constraints.

Parameters:
version - the version to compare, which is formatted as a VersionType XACML type
Returns:
true if the given version meets all the constraints

matches

public static boolean matches(String version,
                              String constraint)
Checks if the given version string matches the constraint string.

Parameters:
version - the version string to check
constraint - a constraint string to use in matching
Returns:
true if the version string matches the constraint

isEarlier

public static boolean isEarlier(String version,
                                String constraint)
Checks if the given version string is less-than or equal-to the constraint string.

Parameters:
version - the version string to check
constraint - a constraint string to use in matching
Returns:
true if the version string is earlier than the constraint

isLater

public static boolean isLater(String version,
                              String constraint)
Checks if the given version string is greater-than or equal-to the constraint string.

Parameters:
version - the version string to check
constraint - a constraint string to use in matching
Returns:
true if the version string is later than the constraint


Copyright © 2009 JBoss, a division of Red Hat, Inc.. All Rights Reserved.