src/share/classes/java/net/SocketPermission.java

Print this page




 939 
 940                 return (this.cname.equalsIgnoreCase(that.cname));
 941             }
 942 
 943         } catch (UnknownHostException uhe) {
 944             return compareHostnames(that);
 945         }
 946 
 947         // make sure the first thing that is done here is to return
 948         // false. If not, uncomment the return false in the above catch.
 949 
 950         return false;
 951     }
 952 
 953     private boolean compareHostnames(SocketPermission that) {
 954         // we see if the original names/IPs passed in were equal.
 955 
 956         String thisHost = hostname;
 957         String thatHost = that.hostname;
 958 
 959         if (thisHost == null)
 960             return false;
 961         else





 962             return thisHost.equalsIgnoreCase(thatHost);
 963     }

 964 
 965     /**
 966      * Checks two SocketPermission objects for equality.
 967      * <P>
 968      * @param obj the object to test for equality with this object.
 969      *
 970      * @return true if <i>obj</i> is a SocketPermission, and has the
 971      *  same hostname, port range, and actions as this
 972      *  SocketPermission object. However, port range will be ignored
 973      *  in the comparison if <i>obj</i> only contains the action, 'resolve'.
 974      */
 975     public boolean equals(Object obj) {
 976         if (obj == this)
 977             return true;
 978 
 979         if (! (obj instanceof SocketPermission))
 980             return false;
 981 
 982         SocketPermission that = (SocketPermission) obj;
 983 




 939 
 940                 return (this.cname.equalsIgnoreCase(that.cname));
 941             }
 942 
 943         } catch (UnknownHostException uhe) {
 944             return compareHostnames(that);
 945         }
 946 
 947         // make sure the first thing that is done here is to return
 948         // false. If not, uncomment the return false in the above catch.
 949 
 950         return false;
 951     }
 952 
 953     private boolean compareHostnames(SocketPermission that) {
 954         // we see if the original names/IPs passed in were equal.
 955 
 956         String thisHost = hostname;
 957         String thatHost = that.hostname;
 958 
 959         if (thisHost == null) {
 960             return false;
 961         } else if (this.wildcard) {
 962             final int cnameLength = this.cname.length();
 963             return thatHost.regionMatches(true,
 964                                           (thatHost.length() - cnameLength),
 965                                           this.cname, 0, cnameLength);
 966         } else {
 967             return thisHost.equalsIgnoreCase(thatHost);
 968         }
 969     }
 970 
 971     /**
 972      * Checks two SocketPermission objects for equality.
 973      * <P>
 974      * @param obj the object to test for equality with this object.
 975      *
 976      * @return true if <i>obj</i> is a SocketPermission, and has the
 977      *  same hostname, port range, and actions as this
 978      *  SocketPermission object. However, port range will be ignored
 979      *  in the comparison if <i>obj</i> only contains the action, 'resolve'.
 980      */
 981     public boolean equals(Object obj) {
 982         if (obj == this)
 983             return true;
 984 
 985         if (! (obj instanceof SocketPermission))
 986             return false;
 987 
 988         SocketPermission that = (SocketPermission) obj;
 989