* Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2003-2004 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:
* 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.
* 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
* 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.
* 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
* 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.
* 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
* 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
* 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
* 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
* 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
* 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.
* 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.
* You acknowledge that this software is not designed or intended for use in the design, construction, operation or maintenance of any nuclear facility.
* A class that implements the not function. This function takes one boolean argument and returns the logical negation of that value. If the argument evaluates
* A class that implements the not function. This function takes one boolean argument and returns the logical negation of that value. If the argument evaluates
* to indeterminate, an indeterminate result is returned.
* to indeterminate, an indeterminate result is returned.
* Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2003-2004 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:
* 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.
* 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
* 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.
* 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
* 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.
* 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
* 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
* 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
* 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
* 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
* 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.
* 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.
* You acknowledge that this software is not designed or intended for use in the design, construction, operation or maintenance of any nuclear facility.
*/
*/
packagecom.sun.xacml;
packagecom.sun.xacml;
importjava.util.Objects;
importjava.util.Objects;
/**
/**
* This class represents a port range as specified in the <code>dnsName</code> and <code>ipAddress</code> datatypes. The range may have upper and lower bounds,
* This class represents a port range as specified in the <code>dnsName</code> and <code>ipAddress</code> datatypes. The range may have upper and lower bounds,
* be specified by a single port number, or may be unbound.
* be specified by a single port number, or may be unbound.
*/
*
publicfinalclassPortRange
* @author cdangerv
{
* @version $Id: $
*/
/**
publicfinalclassPortRange
* Constant used to specify that the range is unbound on one side.
{
*/
privatestaticfinalintUNBOUND=-1;
/**
* Constant used to specify that the range is unbound on one side.
// the port bound values
*/
privatefinalintlowerBound;
privatestaticfinalintUNBOUND=-1;
privatefinalintupperBound;
// the port bound values
/**
privatefinalintlowerBound;
* Default constructor used to represent an unbound range. This is typically used when an address has no port information.
privatefinalintupperBound;
*/
publicPortRange()
/**
{
* Default constructor used to represent an unbound range. This is typically used when an address has no port information.
this(UNBOUND,UNBOUND);
*/
}
publicPortRange()
{
/**
this(UNBOUND,UNBOUND);
* Creates a <code>PortRange</code> with upper and lower bounds. Either of the parameters may have the value <code>UNBOUND</code> meaning that there is no
}
* bound at the respective end.
*
/**
* @param lowerBound
* Creates a <code>PortRange</code> with upper and lower bounds. Either of the parameters may have the value <code>UNBOUND</code> meaning that there is no
* the lower-bound port number or <code>UNBOUND</code>
* bound at the respective end.
* @param upperBound
*
* the upper-bound port number or <code>UNBOUND</code>
* @param lowerBound
*/
* the lower-bound port number or <code>UNBOUND</code>
privatePortRange(intlowerBound,intupperBound)
* @param upperBound
{
* the upper-bound port number or <code>UNBOUND</code>
this.lowerBound=lowerBound;
*/
this.upperBound=upperBound;
privatePortRange(intlowerBound,intupperBound)
}
{
this.lowerBound=lowerBound;
/**
this.upperBound=upperBound;
* Creates an instance of <code>PortRange</code> based on the given value.
}
*
* @param value
/**
* a <code>String</code> representing the range
* Creates an instance of <code>PortRange</code> based on the given value.
*
*
* @return a new <code>PortRange</code>
* @param value
*
* a <code>String</code> representing the range
* @throws NumberFormatException
* @return a new <code>PortRange</code>
* if a port value isn't an integer
* @throws java.lang.NumberFormatException
*/
* if a port value isn't an integer
publicstaticPortRangegetInstance(Stringvalue)
*/
{
publicstaticPortRangegetInstance(Stringvalue)
intlowerBound=UNBOUND;
{
intupperBound=UNBOUND;
intlowerBound=UNBOUND;
intupperBound=UNBOUND;
// first off, make sure there's actually content here
if(value.length()==0||value.equals("-"))
// first off, make sure there's actually content here
{
if(value.length()==0||value.equals("-"))
returnnewPortRange();
{
}
returnnewPortRange();
}
// there's content, so figure where the '-' is, if at all
intdashPos=value.indexOf('-');
// there's content, so figure where the '-' is, if at all
intdashPos=value.indexOf('-');
if(dashPos==-1)
{
if(dashPos==-1)
// there's no dash, so it's just a single number
{
lowerBound=upperBound=Integer.parseInt(value);
// there's no dash, so it's just a single number
}elseif(dashPos==0)
lowerBound=upperBound=Integer.parseInt(value);
{
}elseif(dashPos==0)
// it starts with a dash, so it's just upper-range bound
{
upperBound=Integer.parseInt(value.substring(1));
// it starts with a dash, so it's just upper-range bound
}else
upperBound=Integer.parseInt(value.substring(1));
{
}else
// it's a number followed by a dash, so get the lower-bound...
* Returns whether the range is unbound, which means that it specifies no port number or range. This is typically used with addresses that include no port
/**
* information.
* Returns whether the range is unbound, which means that it specifies no port number or range. This is typically used with addresses that include no port
*
* information.
* @return true if the range is unbound, false otherwise
*
*/
* @return true if the range is unbound, false otherwise