/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* This class is used to represent a subnet mask (a group of hosts matching the same
* IP mask).
*
* @see java.security.acl.Group
*/
/**
* Constructs an empty group.
* @exception UnknownHostException Not implemented
*/
}
private byte[] extractSubNet(byte[] b) {
int addrLength = b.length;
"extractSubNet", "BINARY ARRAY :");
for(int i =0; i < addrLength; i++) {
}
}
// 8 is a byte size. Common to any InetAddress (V4 or V6).
if(fullyCoveredByte == addrLength) {
"The mask is the complete address, strange..." + addrLength);
}
subnet = b;
return subnet;
}
if(fullyCoveredByte > addrLength) {
"The number of covered byte is longer than the address. BUG");
}
throw new IllegalArgumentException("The number of covered byte is longer than the address.");
}
"Partially covered index : " + partialyCoveredIndex);
}
byte toDeal = b[partialyCoveredIndex];
"Partially covered byte : " + toDeal);
}
// 8 is a byte size. Common to any InetAddress (V4 or V6).
int subnetSize = 0;
if(nbbits == 0)
else
"Remains : " + nbbits);
}
byte mask = 0;
for(int i = 0; i < nbbits; i++) {
}
}
}
subnet = new byte[subnetSize];
"Resulting subnet : ");
}
for(int i = 0; i < partialyCoveredIndex; i++) {
subnet[i] = b[i];
}
}
if(nbbits != 0) {
}
}
return subnet;
}
/**
* Constructs a group using the specified subnet mask.
* THIS ALGORITHM IS V4 and V6 compatible.
*
* @exception UnknownHostException if the subnet mask cann't be built.
*/
super(a);
}
/**
* Adds the specified member to the group.
*
* @param p the principal to add to this group.
* @return true if the member was successfully added, false if the
* principal was already a member.
*/
// we don't need to add members because the ip address is a subnet mask
return true;
}
public int hashCode() {
return super.hashCode();
}
/**
* Compares this group to the specified object. Returns true if the object
* passed in matches the group represented.
*
* @param p the object to compare with.
* @return true if the object passed in matches the subnet mask,
* false otherwise.
*/
if (p instanceof PrincipalImpl || p instanceof NetMaskImpl){
"Received Address : " + addr);
}
"(recAddr[i] & subnet[i]) : " +
}
"FALSE");
}
return false;
}
}
"TRUE");
}
return true;
} else
return false;
}
/**
* Returns true if the passed principal is a member of the group.
*
* @param p the principal whose membership is to be checked.
* @return true if the principal is a member of this group, false otherwise.
*/
else return false;
}
/**
* Returns an enumeration which contains the subnet mask.
*
* @return an enumeration which contains the subnet mask.
*/
v.addElement(this);
return v.elements();
}
/**
* Removes the specified member from the group. (Not implemented)
*
* @param p the principal to remove from this group.
* @return allways return true.
*/
return true;
}
/**
* Prints a string representation of this group.
*
* @return a string representation of this group.
*/
}
}