rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
public NotBoundException(String s)
public NotBoundException()
public NotBoundException(String s) { super(s); }
super(s);
public NotBoundException(String s) { super(s); }
className = "gnu.xml.aelfred2.SAXDriver";
public static XMLReader createXMLReader () throws SAXException { String className = null; ClassLoader loader = NewInstance.getClassLoader (); // 1. try the JVM-instance-wide system property try { className = System.getProperty (property); } catch (RuntimeException e) { /* normally fails for applets */ } // 2. if that fails, try META-INF/services/ if (className == null) { try { String service = "META-INF/services/" + property; InputStream in; BufferedReader reader; if (loader == null) in = ClassLoader.getSystemResourceAsStream (service); else in = loader.getResourceAsStream (service); if (in != null) { reader = new BufferedReader ( new InputStreamReader (in, "UTF8")); className = reader.readLine (); in.close (); } } catch (Exception e) { } } // 3. Distro-specific fallback if (className == null) {// BEGIN DISTRIBUTION-SPECIFIC // use the non-validating one className = "gnu.xml.aelfred2.SAXDriver";// END DISTRIBUTION-SPECIFIC } // do we know the XMLReader implementation class yet? if (className != null) return loadClass (loader, className); // 4. panic -- adapt any SAX1 parser try { return new ParserAdapter (ParserFactory.makeParser ()); } catch (Exception e) { throw new SAXException ("Can't create default XMLReader; " + "is system property org.xml.sax.driver set?"); } }
public Throwable getCause() { return containedException; }
public Throwable getCause() { return cause; }
public Throwable getCause() { return containedException; }
public abstract Templates newTemplates (Source stylesheet) throws TransformerConfigurationException;
public abstract Templates newTemplates(Source source) throws TransformerConfigurationException;
public abstract Templates newTemplates (Source stylesheet) throws TransformerConfigurationException;
public TransformerConfigurationException(String msg) { super(msg); }
public TransformerConfigurationException() { this(null, null, null); }
public TransformerConfigurationException(String msg) { super(msg); } // TransformerConfigurationException()
public abstract Transformer newTransformer()
public abstract Transformer newTransformer(Source source)
public abstract Transformer newTransformer() throws TransformerConfigurationException;
public abstract TransformerHandler newTransformerHandler()
public abstract TransformerHandler newTransformerHandler(Source src)
public abstract TransformerHandler newTransformerHandler() throws TransformerConfigurationException;
public abstract XMLFilter newXMLFilter (Source stylesheet)
public abstract XMLFilter newXMLFilter(Source src)
public abstract XMLFilter newXMLFilter (Source stylesheet) throws TransformerConfigurationException;
public final Class getCategory()
public Class getCategory()
public final Class getCategory() { return QueuedJobCount.class; }
public final String getName()
public String getName()
public final String getName() { return "queued-job-count"; }
public final void set(int year, int month, int date, int hour, int minute)
public void set(int field, int value)
public final void set(int year, int month, int date, int hour, int minute) { set(year, month, date); fields[HOUR_OF_DAY] = hour; fields[MINUTE] = minute; isSet[HOUR_OF_DAY] = isSet[MINUTE] = true; isSet[AM_PM] = false; isSet[HOUR] = false; }
set(year, month, date); fields[HOUR_OF_DAY] = hour; fields[MINUTE] = minute; isSet[HOUR_OF_DAY] = isSet[MINUTE] = true; isSet[AM_PM] = false; isSet[HOUR] = false;
if (isTimeSet) for (int i = 0; i < FIELD_COUNT; i++) isSet[i] = false; isTimeSet = false; fields[field] = value; isSet[field] = true; switch (field) { case MONTH: isSet[DAY_OF_YEAR] = false; isSet[WEEK_OF_YEAR] = false; break; case DAY_OF_MONTH: isSet[YEAR] = true; isSet[MONTH] = true; isSet[WEEK_OF_MONTH] = true; isSet[DAY_OF_WEEK] = false; isSet[DAY_OF_WEEK_IN_MONTH] = false; isSet[DAY_OF_YEAR] = false; isSet[WEEK_OF_YEAR] = false; break; case WEEK_OF_MONTH: if (! isSet[DAY_OF_WEEK]) fields[DAY_OF_WEEK] = getFirstDayOfWeek(); isSet[YEAR] = true; isSet[MONTH] = true; isSet[DAY_OF_WEEK] = true; isSet[DAY_OF_MONTH] = false; isSet[DAY_OF_WEEK_IN_MONTH] = false; isSet[DAY_OF_YEAR] = false; isSet[WEEK_OF_YEAR] = false; break; case DAY_OF_WEEK_IN_MONTH: if (! isSet[DAY_OF_WEEK]) fields[DAY_OF_WEEK] = getFirstDayOfWeek(); isSet[YEAR] = true; isSet[MONTH] = true; isSet[DAY_OF_WEEK] = true; isSet[DAY_OF_YEAR] = false; isSet[DAY_OF_MONTH] = false; isSet[WEEK_OF_MONTH] = false; isSet[WEEK_OF_YEAR] = false; break; case DAY_OF_YEAR: isSet[YEAR] = true; isSet[MONTH] = false; isSet[WEEK_OF_MONTH] = false; isSet[DAY_OF_MONTH] = false; isSet[DAY_OF_WEEK] = false; isSet[WEEK_OF_YEAR] = false; isSet[DAY_OF_WEEK_IN_MONTH] = false; break; case WEEK_OF_YEAR: if (! isSet[DAY_OF_WEEK]) fields[DAY_OF_WEEK] = getFirstDayOfWeek(); isSet[YEAR] = true; isSet[DAY_OF_WEEK] = true; isSet[MONTH] = false; isSet[DAY_OF_MONTH] = false; isSet[WEEK_OF_MONTH] = false; isSet[DAY_OF_YEAR] = false; isSet[DAY_OF_WEEK_IN_MONTH] = false; break; case AM_PM: isSet[HOUR] = true; isSet[HOUR_OF_DAY] = false; break; case HOUR_OF_DAY: isSet[AM_PM] = false; isSet[HOUR] = false; break; case HOUR: isSet[AM_PM] = true; isSet[HOUR_OF_DAY] = false; break; case DST_OFFSET: explicitDSTOffset = true; } if (! explicitDSTOffset && (field != DST_OFFSET && field != ZONE_OFFSET)) isSet[DST_OFFSET] = false;
public final void set(int year, int month, int date, int hour, int minute) { set(year, month, date); fields[HOUR_OF_DAY] = hour; fields[MINUTE] = minute; isSet[HOUR_OF_DAY] = isSet[MINUTE] = true; isSet[AM_PM] = false; isSet[HOUR] = false; }
UIDefaults defaults = UIManager.getLookAndFeelDefaults(); splitPane.setBackground(defaults.getColor("SplitPane.background")); splitPane.setBorder(defaults.getBorder("SplitPane.border")); splitPane.setDividerSize(defaults.getInt("SplitPane.dividerSize"));
splitPane.setDividerSize(UIManager.getInt("SplitPane.dividerSize"));
protected void installDefaults() { divider = createDefaultDivider(); resetLayoutManager(); nonContinuousLayoutDivider = createDefaultNonContinuousLayoutDivider(); splitPane.add(divider, JSplitPane.DIVIDER); // There is no need to add the nonContinuousLayoutDivider UIDefaults defaults = UIManager.getLookAndFeelDefaults(); splitPane.setBackground(defaults.getColor("SplitPane.background")); splitPane.setBorder(defaults.getBorder("SplitPane.border")); splitPane.setDividerSize(defaults.getInt("SplitPane.dividerSize")); splitPane.setOpaque(true); }
manager = createFocusManager();
manager = new DefaultKeyboardFocusManager();
public static void setCurrentKeyboardFocusManager (KeyboardFocusManager m) { SecurityManager sm = System.getSecurityManager (); if (sm != null) sm.checkPermission (new AWTPermission ("replaceKeyboardFocusManager")); ThreadGroup currentGroup = Thread.currentThread ().getThreadGroup (); KeyboardFocusManager manager; if (m == null) manager = createFocusManager(); else manager = m; currentKeyboardFocusManagers.put (currentGroup, manager); }
public static AWTKeyStroke getAWTKeyStroke(int keyCode, int modifiers)
public static AWTKeyStroke getAWTKeyStroke(char keyChar)
public static AWTKeyStroke getAWTKeyStroke(int keyCode, int modifiers) { return getAWTKeyStroke(KeyEvent.CHAR_UNDEFINED, keyCode, extend(modifiers), false); }
return getAWTKeyStroke(KeyEvent.CHAR_UNDEFINED, keyCode, extend(modifiers), false);
return getAWTKeyStroke(keyChar, KeyEvent.VK_UNDEFINED, 0, false);
public static AWTKeyStroke getAWTKeyStroke(int keyCode, int modifiers) { return getAWTKeyStroke(KeyEvent.CHAR_UNDEFINED, keyCode, extend(modifiers), false); }
public FocusEvent(Component source, int id, boolean temporary)
public FocusEvent(Component source, int id, boolean temporary, Component opposite)
public FocusEvent(Component source, int id, boolean temporary) { this(source, id, temporary, null); }
this(source, id, temporary, null);
super(source, id); this.temporary = temporary; this.opposite = opposite;
public FocusEvent(Component source, int id, boolean temporary) { this(source, id, temporary, null); }
public String toString()
public String toString(boolean objectInfo)
public String toString() { return toString(false); }
return toString(false);
StringBuffer sb = new StringBuffer(super.toString()); Throwable cause = getRootCause(); if (cause != null) { sb.append(" caused by "); sb.append(cause); } Name remaining = getRemainingName(); if (remaining != null) { sb.append(" [remainingName: "); sb.append(remaining); } Object resolved = getResolvedObj(); if (objectInfo && resolved != null) { if (remainingName == null) sb.append(" ["); else sb.append(", "); sb.append("resolvedObj: "); sb.append(resolved); } if ((remaining != null) || (objectInfo && resolved != null)) sb.append(']'); return sb.toString();
public String toString() { return toString(false); }
public void addCertificate(java.security.Certificate certificate)
public void addCertificate(Certificate certificate)
public void addCertificate(java.security.Certificate certificate) throws KeyManagementException { SecurityManager sm = System.getSecurityManager(); if (sm != null) sm.checkSecurityAccess("addIdentityCertificate"); //Check public key of this certificate against the first one //in the vector if (certificates.size() > 0) { if (((Certificate) certificates.firstElement()).getPublicKey() != publicKey) throw new KeyManagementException("Public key does not match"); } certificates.addElement(certificate); }
public KeyManagementException(String msg)
public KeyManagementException()
public KeyManagementException(String msg) { super(msg); }
super(msg);
public KeyManagementException(String msg) { super(msg); }
public ZipEntry(String name) { if (name == null) throw new NullPointerException();
public ZipEntry(String name) { int length = name.length(); if (length > 65535) throw new IllegalArgumentException("name length is " + length);
public ZipEntry(String name) { if (name == null) throw new NullPointerException(); this.name = name; }
public int getColumnCount();
int getColumnCount();
public int getColumnCount();
public TableColumn getColumn(int columnIndex);
TableColumn getColumn(int columnIndex);
public TableColumn getColumn(int columnIndex);
public Component getTableCellRendererComponent(JTable table,
Component getTableCellRendererComponent(JTable table,
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column);
public int getTotalColumnWidth();
int getTotalColumnWidth();
public int getTotalColumnWidth();
public SocketException(String message)
public SocketException()
public SocketException(String message) { super(message); }
super(message);
public SocketException(String message) { super(message); }
/*
ClassLoader getCallingClassLoader() { Class[] stack = getClassContext(); /* for (int i = 0; i < stack.length; i++) { if (stack[i] != Security.class && stack[i] != ResourceBundle.class) return stack[i].getClassLoader(); } return null; */ return stack[3].getClassLoader(); }
return null; */ return stack[3].getClassLoader();
ClassLoader getCallingClassLoader() { Class[] stack = getClassContext(); /* for (int i = 0; i < stack.length; i++) { if (stack[i] != Security.class && stack[i] != ResourceBundle.class) return stack[i].getClassLoader(); } return null; */ return stack[3].getClassLoader(); }
return null;
ClassLoader getCallingClassLoader() { Class[] stack = getClassContext(); /* for (int i = 0; i < stack.length; i++) { if (stack[i] != Security.class && stack[i] != ResourceBundle.class) return stack[i].getClassLoader(); } return null; */ return stack[3].getClassLoader(); }
private static final ResourceBundle tryBundle(String localizedName, Locale locale,
private static ResourceBundle tryBundle(String localizedName, Locale locale,
private static final ResourceBundle tryBundle(String localizedName, Locale locale, ClassLoader classloader, ResourceBundle bundle, HashMap cache) { // First look into the cache. if (cache.containsKey(localizedName)) { Reference ref = (Reference) cache.get(localizedName); // If REF is null, that means that we added a `null' value to // the hash map. That means we failed to find the bundle // previously, and we cached that fact. The JDK does this, so // it must be ok. if (ref == null) return null; else { ResourceBundle rb = (ResourceBundle) ref.get(); if (rb != null) { // RB should already have the right parent, except if // something very strange happened. return rb; } // If RB is null, then we previously found it but it was // collected. So we try again. } } // foundBundle holds exact matches for the localizedName resource // bundle, which may later be cached. ResourceBundle foundBundle = null; try { Class rbClass; if (classloader == null) rbClass = Class.forName(localizedName); else rbClass = classloader.loadClass(localizedName); foundBundle = (ResourceBundle) rbClass.newInstance(); foundBundle.parent = bundle; foundBundle.locale = locale; } catch (Exception ex) { // ignore them all foundBundle = null; } if (foundBundle == null) { try { InputStream is; final String resourceName = localizedName.replace('.', '/') + ".properties"; if (classloader == null) is = ClassLoader.getSystemResourceAsStream(resourceName); else is = classloader.getResourceAsStream(resourceName); if (is != null) { foundBundle = new PropertyResourceBundle(is); foundBundle.parent = bundle; foundBundle.locale = locale; } } catch (IOException ex) { } } // Put the result into the hash table. If we didn't find anything // here, we record our parent bundle. If we record `null' that means // nothing, not even the base, was found. if (foundBundle == null) foundBundle = bundle; if (foundBundle == null) cache.put(localizedName, null); else cache.put(localizedName, new SoftReference(foundBundle)); return foundBundle; }
private static final ResourceBundle tryLocalBundle(String baseName, Locale locale,
private static ResourceBundle tryLocalBundle(String baseName, Locale locale,
private static final ResourceBundle tryLocalBundle(String baseName, Locale locale, ClassLoader classloader, ResourceBundle bundle, HashMap cache) { final String language = locale.getLanguage(); final String country = locale.getCountry(); final String variant = locale.getVariant(); StringBuffer sb = new StringBuffer(60); sb.append(baseName); sb.append('_'); if (language.length() > 0) { sb.append(language); bundle = tryBundle(sb.toString(), new Locale(language), classloader, bundle, cache); } // If LANGUAGE was empty, we still need to try the other // components, and the `_' is required. sb.append('_'); if (country.length() > 0) { sb.append(country); bundle = tryBundle(sb.toString(), new Locale(language, country), classloader, bundle, cache); } sb.append('_'); if (variant.length() > 0) { sb.append(variant); bundle = tryBundle(sb.toString(), locale, classloader, bundle, cache); } return bundle; }
public Locale(String language)
public Locale(String language, String country, String variant)
public Locale(String language) { this(language, "", ""); }
this(language, "", "");
if (defaultLocale != null) { language = convertLanguage(language).intern(); country = country.toUpperCase().intern(); variant = variant.intern(); } this.language = language; this.country = country; this.variant = variant; hashcode = language.hashCode() ^ country.hashCode() ^ variant.hashCode();
public Locale(String language) { this(language, "", ""); }
return null;
if (value!=null) super.setText(value.toString()); return this;
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { return null; }
public void setSelected(boolean b) { getModel().setSelected(b); }
public void setSelected(boolean s) { getModel().setSelected(s); }
public void setSelected(boolean b) { getModel().setSelected(b); }
public DefaultTableModel(int numRows, int numColumns) { int columnIndex; Vector defaultNames; defaultNames = new Vector(); for (columnIndex = 0; columnIndex < numColumns; columnIndex++) { defaultNames.addElement(super.getColumnName(columnIndex)); }
public DefaultTableModel() { this(0, 0);
public DefaultTableModel(int numRows, int numColumns) { // Variables int columnIndex; Vector defaultNames; // Create Column Names defaultNames = new Vector(); for (columnIndex = 0; columnIndex < numColumns; columnIndex++) { defaultNames.addElement(super.getColumnName(columnIndex)); } // for // Setup Data// setDataVector(defaultNames, numRows); } // DefaultTableModel()
public ListSelectionModel getSelectionModel();
ListSelectionModel getSelectionModel();
public ListSelectionModel getSelectionModel();
public String getColumnName(int columnIndex);
String getColumnName(int columnIndex);
public String getColumnName(int columnIndex);
public void addColumn(TableColumn column);
void addColumn(TableColumn column);
public void addColumn(TableColumn column);
public TableColumn(int modelIndex) { this(modelIndex, 75, null, null);
public TableColumn() { this(0, 75, null, null);
public TableColumn(int modelIndex) { this(modelIndex, 75, null, null); } // TableColumn()
public void removeColumn(TableColumn column);
void removeColumn(TableColumn column);
public void removeColumn(TableColumn column);
public Class getColumnClass(int columnIndex);
Class getColumnClass(int columnIndex);
public Class getColumnClass(int columnIndex);
public int getColumnMargin();
int getColumnMargin();
public int getColumnMargin();
public int getColumnIndex(Object columnIdentifier);
int getColumnIndex(Object columnIdentifier);
public int getColumnIndex(Object columnIdentifier);
public boolean getColumnSelectionAllowed();
boolean getColumnSelectionAllowed();
public boolean getColumnSelectionAllowed();
super(); this.noFocusBorder = new EmptyBorder(0, 0, 0, 0);
public DefaultTableCellRenderer() { }
public int getRowCount();
int getRowCount();
public int getRowCount();
public Object getValueAt(int rowIndex, int columnIndex);
Object getValueAt(int rowIndex, int columnIndex);
public Object getValueAt(int rowIndex, int columnIndex);
public void addColumnModelListener(TableColumnModelListener listener);
void addColumnModelListener(TableColumnModelListener listener);
public void addColumnModelListener(TableColumnModelListener listener);
public boolean isCellEditable(int rowIndex, int columnIndex);
boolean isCellEditable(int rowIndex, int columnIndex);
public boolean isCellEditable(int rowIndex, int columnIndex);
public void moveColumn(int columnIndex, int newIndex);
void moveColumn(int columnIndex, int newIndex);
public void moveColumn(int columnIndex, int newIndex);
public void addCellEditorListener(CellEditorListener listener);
void addCellEditorListener(CellEditorListener listener);
public void addCellEditorListener(CellEditorListener listener);
public void removeColumnModelListener(TableColumnModelListener listener);
void removeColumnModelListener(TableColumnModelListener listener);
public void removeColumnModelListener(TableColumnModelListener listener);
public void setColumnSelectionAllowed(boolean value);
void setColumnSelectionAllowed(boolean value);
public void setColumnSelectionAllowed(boolean value);
public void setColumnMargin(int margin);
void setColumnMargin(int margin);
public void setColumnMargin(int margin);
public void removeTableModelListener(TableModelListener listener);
void removeTableModelListener(TableModelListener listener);
public void removeTableModelListener(TableModelListener listener);
public void addTableModelListener(TableModelListener listener);
void addTableModelListener(TableModelListener listener);
public void addTableModelListener(TableModelListener listener);
public void setValueAt(Object aValue, int rowIndex, int columnIndex);
void setValueAt(Object aValue, int rowIndex, int columnIndex);
public void setValueAt(Object aValue, int rowIndex, int columnIndex);
public MultipleComponentProfileHolder(TaggedComponent[] initialValue)
public MultipleComponentProfileHolder()
public MultipleComponentProfileHolder(TaggedComponent[] initialValue) { value = initialValue; }
value = initialValue;
public MultipleComponentProfileHolder(TaggedComponent[] initialValue) { value = initialValue; }
optionPane.setOpaque(true);
protected void installDefaults() { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); optionPane.setFont(defaults.getFont("OptionPane.font")); optionPane.setBackground(defaults.getColor("OptionPane.background")); optionPane.setForeground(defaults.getColor("OptionPane.foreground")); optionPane.setBorder(defaults.getBorder("OptionPane.border")); messageBorder = defaults.getBorder("OptionPane.messageAreaBorder"); messageForeground = defaults.getColor("OptionPane.messageForeground"); buttonBorder = defaults.getBorder("OptionPane.buttonAreaBorder"); minimumSize = defaults.getDimension("OptionPane.minimumSize"); minimumWidth = minimumSize.width; minimumHeight = minimumSize.height; // FIXME: Image icons don't seem to work properly right now. // Once they do, replace the synthetic icons with these ones. /* warningIcon = (IconUIResource) defaults.getIcon("OptionPane.warningIcon"); infoIcon = (IconUIResource) defaults.getIcon("OptionPane.informationIcon"); errorIcon = (IconUIResource) defaults.getIcon("OptionPane.errorIcon"); questionIcon = (IconUIResource) defaults.getIcon("OptionPane.questionIcon"); */ }
Box(int a) { setLayout(new BoxLayout(this, a)); }
public Box(int a) { setLayout(new BoxLayout(this, a)); }
Box(int a) { setLayout(new BoxLayout(this, a)); }
public static Border createEmptyBorder( int top, int left, int bottom, int right) { return null; }
public static Border createEmptyBorder () { return new EmptyBorder (0, 0, 0, 0); }
public static Border createEmptyBorder( int top, int left, int bottom, int right) { /* Creates an empty border that takes up no space but which does no drawing, specifying the width of the top, left, bottom, and right sides. Parameters: top - an int specifying the width of the top in pixelsleft - an int specifying the width of the left side in pixelsbottom - an int specifying the width of the right side in pixelsright - an int specifying the width of the bottom in pixelsReturns: the Border object createCompoundBorder */ return null; }
public JComboBox(Object[] value0) {
public JComboBox(ComboBoxModel value0) {
public JComboBox(Object[] value0) { // TODO } // JComboBox()
ByteArrayResponseBodyReader reader = new ByteArrayResponseBodyReader(); request.setResponseBodyReader(reader);
public void connect() throws IOException { if (connected) { return; } String protocol = url.getProtocol(); boolean secure = "https".equals(protocol); String host = url.getHost(); int port = url.getPort(); if (port < 0) { port = secure ? HTTPConnection.HTTPS_PORT : HTTPConnection.HTTP_PORT; } String file = url.getFile(); String username = url.getUserInfo(); String password = null; if (username != null) { int ci = username.indexOf(':'); if (ci != -1) { password = username.substring(ci + 1); username = username.substring(0, ci); } } final Credentials creds = (username == null) ? null : new Credentials (username, password); boolean retry; do { retry = false; if (connection == null) { connection = getConnection(host, port, secure); if (secure) { SSLSocketFactory factory = getSSLSocketFactory(); HostnameVerifier verifier = getHostnameVerifier(); if (factory != null) { connection.setSSLSocketFactory(factory); } connection.addHandshakeCompletedListener(this); // TODO verifier } } if (proxyHostname != null) { if (proxyPort < 0) { proxyPort = secure ? HTTPConnection.HTTPS_PORT : HTTPConnection.HTTP_PORT; } connection.setProxy(proxyHostname, proxyPort); } request = connection.newRequest(method, file); if (!keepAlive) { request.setHeader("Connection", "close"); } if (agent != null) { request.setHeader("User-Agent", agent); } request.getHeaders().putAll(requestHeaders); if (requestSink != null) { byte[] content = requestSink.toByteArray(); RequestBodyWriter writer = new ByteArrayRequestBodyWriter(content); request.setRequestBodyWriter(writer); } ByteArrayResponseBodyReader reader = new ByteArrayResponseBodyReader(); request.setResponseBodyReader(reader); if (creds != null) { request.setAuthenticator(new Authenticator() { public Credentials getCredentials(String realm, int attempts) { return (attempts < 2) ? creds : null; } }); } response = request.dispatch(); if (response.getCodeClass() == 3 && getInstanceFollowRedirects()) { // Follow redirect String location = response.getHeader("Location"); if (location != null) { String connectionUri = connection.getURI(); int start = connectionUri.length(); if (location.startsWith(connectionUri) && location.charAt(start) == '/') { file = location.substring(start); retry = true; } else if (location.startsWith("http:")) { connection.close(); connection = null; secure = false; start = 7; int end = location.indexOf('/', start); host = location.substring(start, end); int ci = host.lastIndexOf(':'); if (ci != -1) { port = Integer.parseInt(host.substring (ci + 1)); host = host.substring(0, ci); } else { port = HTTPConnection.HTTP_PORT; } file = location.substring(end); retry = true; } else if (location.startsWith("https:")) { connection.close(); connection = null; secure = true; start = 8; int end = location.indexOf('/', start); host = location.substring(start, end); int ci = host.lastIndexOf(':'); if (ci != -1) { port = Integer.parseInt(host.substring (ci + 1)); host = host.substring(0, ci); } else { port = HTTPConnection.HTTPS_PORT; } file = location.substring(end); retry = true; } else if (location.length() > 0) { // Malformed absolute URI, treat as file part of URI if (location.charAt(0) == '/') { // Absolute path file = location; } else { // Relative path int lsi = file.lastIndexOf('/'); file = (lsi == -1) ? "/" : file.substring(0, lsi + 1); file += location; } retry = true; } } } else { responseSink = new ByteArrayInputStream(reader.toByteArray ()); if (response.getCode() == 404) { errorSink = responseSink; throw new FileNotFoundException(url.toString()); } } } while (retry); connected = true; }
responseSink = new ByteArrayInputStream(reader.toByteArray ());
responseSink = response.getBody();
public void connect() throws IOException { if (connected) { return; } String protocol = url.getProtocol(); boolean secure = "https".equals(protocol); String host = url.getHost(); int port = url.getPort(); if (port < 0) { port = secure ? HTTPConnection.HTTPS_PORT : HTTPConnection.HTTP_PORT; } String file = url.getFile(); String username = url.getUserInfo(); String password = null; if (username != null) { int ci = username.indexOf(':'); if (ci != -1) { password = username.substring(ci + 1); username = username.substring(0, ci); } } final Credentials creds = (username == null) ? null : new Credentials (username, password); boolean retry; do { retry = false; if (connection == null) { connection = getConnection(host, port, secure); if (secure) { SSLSocketFactory factory = getSSLSocketFactory(); HostnameVerifier verifier = getHostnameVerifier(); if (factory != null) { connection.setSSLSocketFactory(factory); } connection.addHandshakeCompletedListener(this); // TODO verifier } } if (proxyHostname != null) { if (proxyPort < 0) { proxyPort = secure ? HTTPConnection.HTTPS_PORT : HTTPConnection.HTTP_PORT; } connection.setProxy(proxyHostname, proxyPort); } request = connection.newRequest(method, file); if (!keepAlive) { request.setHeader("Connection", "close"); } if (agent != null) { request.setHeader("User-Agent", agent); } request.getHeaders().putAll(requestHeaders); if (requestSink != null) { byte[] content = requestSink.toByteArray(); RequestBodyWriter writer = new ByteArrayRequestBodyWriter(content); request.setRequestBodyWriter(writer); } ByteArrayResponseBodyReader reader = new ByteArrayResponseBodyReader(); request.setResponseBodyReader(reader); if (creds != null) { request.setAuthenticator(new Authenticator() { public Credentials getCredentials(String realm, int attempts) { return (attempts < 2) ? creds : null; } }); } response = request.dispatch(); if (response.getCodeClass() == 3 && getInstanceFollowRedirects()) { // Follow redirect String location = response.getHeader("Location"); if (location != null) { String connectionUri = connection.getURI(); int start = connectionUri.length(); if (location.startsWith(connectionUri) && location.charAt(start) == '/') { file = location.substring(start); retry = true; } else if (location.startsWith("http:")) { connection.close(); connection = null; secure = false; start = 7; int end = location.indexOf('/', start); host = location.substring(start, end); int ci = host.lastIndexOf(':'); if (ci != -1) { port = Integer.parseInt(host.substring (ci + 1)); host = host.substring(0, ci); } else { port = HTTPConnection.HTTP_PORT; } file = location.substring(end); retry = true; } else if (location.startsWith("https:")) { connection.close(); connection = null; secure = true; start = 8; int end = location.indexOf('/', start); host = location.substring(start, end); int ci = host.lastIndexOf(':'); if (ci != -1) { port = Integer.parseInt(host.substring (ci + 1)); host = host.substring(0, ci); } else { port = HTTPConnection.HTTPS_PORT; } file = location.substring(end); retry = true; } else if (location.length() > 0) { // Malformed absolute URI, treat as file part of URI if (location.charAt(0) == '/') { // Absolute path file = location; } else { // Relative path int lsi = file.lastIndexOf('/'); file = (lsi == -1) ? "/" : file.substring(0, lsi + 1); file += location; } retry = true; } } } else { responseSink = new ByteArrayInputStream(reader.toByteArray ()); if (response.getCode() == 404) { errorSink = responseSink; throw new FileNotFoundException(url.toString()); } } } while (retry); connected = true; }
StringBuffer buf = new StringBuffer(secure ? "https: buf.append(Thread.currentThread().hashCode()); buf.append('@'); buf.append(host); buf.append(':'); buf.append(port); String key = buf.toString();
Object key = HTTPConnection.getPoolKey(host, port, secure);
HTTPConnection getConnection(String host, int port, boolean secure) throws IOException { HTTPConnection connection; if (keepAlive) { StringBuffer buf = new StringBuffer(secure ? "https://" : "http://"); buf.append(Thread.currentThread().hashCode()); buf.append('@'); buf.append(host); buf.append(':'); buf.append(port); String key = buf.toString(); synchronized (connectionPool) { connection = (HTTPConnection) connectionPool.get(key); if (connection == null) { connection = new HTTPConnection(host, port, secure); // Good housekeeping if (connectionPool.size() == maxConnections) { // maxConnections must always be >= 1 Object lru = connectionPool.keySet().iterator().next(); connectionPool.remove(lru); } connectionPool.put(key, connection); } } } else { connection = new HTTPConnection(host, port, secure); } return connection; }
connection = (HTTPConnection) connectionPool.get(key);
connection = (HTTPConnection) connectionPool.remove(key);
HTTPConnection getConnection(String host, int port, boolean secure) throws IOException { HTTPConnection connection; if (keepAlive) { StringBuffer buf = new StringBuffer(secure ? "https://" : "http://"); buf.append(Thread.currentThread().hashCode()); buf.append('@'); buf.append(host); buf.append(':'); buf.append(port); String key = buf.toString(); synchronized (connectionPool) { connection = (HTTPConnection) connectionPool.get(key); if (connection == null) { connection = new HTTPConnection(host, port, secure); // Good housekeeping if (connectionPool.size() == maxConnections) { // maxConnections must always be >= 1 Object lru = connectionPool.keySet().iterator().next(); connectionPool.remove(lru); } connectionPool.put(key, connection); } } } else { connection = new HTTPConnection(host, port, secure); } return connection; }
if (connectionPool.size() == maxConnections) { Object lru = connectionPool.keySet().iterator().next(); connectionPool.remove(lru); } connectionPool.put(key, connection);
connection.setPool(connectionPool);
HTTPConnection getConnection(String host, int port, boolean secure) throws IOException { HTTPConnection connection; if (keepAlive) { StringBuffer buf = new StringBuffer(secure ? "https://" : "http://"); buf.append(Thread.currentThread().hashCode()); buf.append('@'); buf.append(host); buf.append(':'); buf.append(port); String key = buf.toString(); synchronized (connectionPool) { connection = (HTTPConnection) connectionPool.get(key); if (connection == null) { connection = new HTTPConnection(host, port, secure); // Good housekeeping if (connectionPool.size() == maxConnections) { // maxConnections must always be >= 1 Object lru = connectionPool.keySet().iterator().next(); connectionPool.remove(lru); } connectionPool.put(key, connection); } } } else { connection = new HTTPConnection(host, port, secure); } return connection; }
Map headers = response.getHeaders(); Map ret = new LinkedHashMap(); ret.put("", Collections.singletonList(getStatusLine(response)));
Headers headers = response.getHeaders(); LinkedHashMap ret = new LinkedHashMap(); ret.put(null, Collections.singletonList(getStatusLine(response)));
public Map getHeaderFields() { if (!connected) { try { connect(); } catch (IOException e) { return null; } } Map headers = response.getHeaders(); Map ret = new LinkedHashMap(); ret.put("", Collections.singletonList(getStatusLine(response))); for (Iterator i = headers.entrySet().iterator(); i.hasNext(); ) { Map.Entry entry = (Map.Entry) i.next(); String key = (String) entry.getKey(); String value = (String) entry.getValue(); ret.put(key, Collections.singletonList(value)); } return ret; }
return ret;
return Collections.unmodifiableMap(ret);
public Map getHeaderFields() { if (!connected) { try { connect(); } catch (IOException e) { return null; } } Map headers = response.getHeaders(); Map ret = new LinkedHashMap(); ret.put("", Collections.singletonList(getStatusLine(response))); for (Iterator i = headers.entrySet().iterator(); i.hasNext(); ) { Map.Entry entry = (Map.Entry) i.next(); String key = (String) entry.getKey(); String value = (String) entry.getValue(); ret.put(key, Collections.singletonList(value)); } return ret; }
return codeClass;
return code / 100;
public int getCodeClass() { return codeClass; }
public void clearSelection();
void clearSelection();
public void clearSelection();
public int write(ByteBuffer src) throws IOException;
int write(ByteBuffer src) throws IOException;
public int write(ByteBuffer src) throws IOException;
public Component getComponent();
Component getComponent();
public Component getComponent();
public void setValue(Object value, boolean selected);
void setValue(Object value, boolean selected);
public void setValue(Object value, boolean selected);
log.info("Using PointerDevice " + pointerDevice.getId());
log.debug("Using PointerDevice " + pointerDevice.getId());
public MouseHandler(Device fbDevice, Dimension screenSize) { HardwareCursorAPI hwCursor = null; Device pointerDevice = null; PointerAPI pointerAPI = null; try { hwCursor = (HardwareCursorAPI) fbDevice.getAPI(HardwareCursorAPI.class); } catch (ApiNotFoundException ex) { log.info("No hardware-cursor found on device " + fbDevice.getId()); } if (hwCursor != null) { try { final Collection pointers = DeviceUtils.getDevicesByAPI(PointerAPI.class); if (!pointers.isEmpty()) { pointerDevice = (Device) pointers.iterator().next(); pointerAPI = (PointerAPI) pointerDevice.getAPI(PointerAPI.class); } } catch (ApiNotFoundException ex) { log.error("Strange...", ex); } } this.hwCursor = hwCursor; this.pointerAPI = pointerAPI; this.screenSize = screenSize; if (pointerAPI != null) { log.info("Using PointerDevice " + pointerDevice.getId()); hwCursor.setCursorImage(JNodeCursors.ARROW); hwCursor.setCursorVisible(true); hwCursor.setCursorPosition(x, y); pointerAPI.addPointerListener(this); } }
public abstract Image createImage(byte[] data, int offset, int len);
public abstract Image createImage(String filename);
public abstract Image createImage(byte[] data, int offset, int len);
if (certs != null && (cs.certs == null || !certs.containsAll(cs.certs))) { return false; }
if (certs != null && (cs.certs == null || ! certs.containsAll(cs.certs))) return false;
public boolean implies(CodeSource cs) { if (cs == null) return false; // First check the certificate list. if (certs != null && (cs.certs == null || !certs.containsAll(cs.certs))) { return false; } // Next check the location. if (location == null) { return true; } if (cs.location == null) { return false; } if (!location.getProtocol().equals(cs.location.getProtocol())) { return false; } final int ourPort = location.getPort(); if ((ourPort != -1) && (ourPort != cs.location.getPort())) { return false; } final String ourRef = location.getRef(); if ((ourRef != null) && !ourRef.equals(cs.location.getRef())) { return false; } final String ourHost = location.getHost(); if (ourHost != null) { final String their_host = cs.location.getHost(); if (their_host == null) { return false; } final SocketPermission our_sockperm = new SocketPermission(ourHost, "accept"); final SocketPermission their_sockperm = new SocketPermission( their_host, "accept"); if (!our_sockperm.implies(their_sockperm)) { return false; } } String our_file = location.getFile(); if (our_file != null) { if (!our_file.endsWith("/")) { our_file += "/"; } final String their_file = cs.location.getFile(); if (their_file == null || !their_file.startsWith(our_file)) return false; } return true; }
if (location == null) { return true; } if (cs.location == null) { return false; } if (!location.getProtocol().equals(cs.location.getProtocol())) { return false; } final int ourPort = location.getPort(); if ((ourPort != -1) && (ourPort != cs.location.getPort())) { return false; } final String ourRef = location.getRef(); if ((ourRef != null) && !ourRef.equals(cs.location.getRef())) { return false; } final String ourHost = location.getHost(); if (ourHost != null) { final String their_host = cs.location.getHost(); if (their_host == null) { return false; } final SocketPermission our_sockperm = new SocketPermission(ourHost, "accept"); final SocketPermission their_sockperm = new SocketPermission( their_host, "accept"); if (!our_sockperm.implies(their_sockperm)) { return false; }
if (location == null) return true; if (cs.location == null || ! location.getProtocol().equals(cs.location.getProtocol()) || (location.getPort() != -1 && location.getPort() != cs.location.getPort()) || (location.getRef() != null && ! location.getRef().equals(cs.location.getRef()))) return false; if (location.getHost() != null) { String their_host = cs.location.getHost(); if (their_host == null) return false; SocketPermission our_sockperm = new SocketPermission(location.getHost(), "accept"); SocketPermission their_sockperm = new SocketPermission(their_host, "accept"); if (! our_sockperm.implies(their_sockperm)) return false;
public boolean implies(CodeSource cs) { if (cs == null) return false; // First check the certificate list. if (certs != null && (cs.certs == null || !certs.containsAll(cs.certs))) { return false; } // Next check the location. if (location == null) { return true; } if (cs.location == null) { return false; } if (!location.getProtocol().equals(cs.location.getProtocol())) { return false; } final int ourPort = location.getPort(); if ((ourPort != -1) && (ourPort != cs.location.getPort())) { return false; } final String ourRef = location.getRef(); if ((ourRef != null) && !ourRef.equals(cs.location.getRef())) { return false; } final String ourHost = location.getHost(); if (ourHost != null) { final String their_host = cs.location.getHost(); if (their_host == null) { return false; } final SocketPermission our_sockperm = new SocketPermission(ourHost, "accept"); final SocketPermission their_sockperm = new SocketPermission( their_host, "accept"); if (!our_sockperm.implies(their_sockperm)) { return false; } } String our_file = location.getFile(); if (our_file != null) { if (!our_file.endsWith("/")) { our_file += "/"; } final String their_file = cs.location.getFile(); if (their_file == null || !their_file.startsWith(our_file)) return false; } return true; }
if (our_file != null) { if (!our_file.endsWith("/")) {
if (our_file != null) { if (! our_file.endsWith("/"))
public boolean implies(CodeSource cs) { if (cs == null) return false; // First check the certificate list. if (certs != null && (cs.certs == null || !certs.containsAll(cs.certs))) { return false; } // Next check the location. if (location == null) { return true; } if (cs.location == null) { return false; } if (!location.getProtocol().equals(cs.location.getProtocol())) { return false; } final int ourPort = location.getPort(); if ((ourPort != -1) && (ourPort != cs.location.getPort())) { return false; } final String ourRef = location.getRef(); if ((ourRef != null) && !ourRef.equals(cs.location.getRef())) { return false; } final String ourHost = location.getHost(); if (ourHost != null) { final String their_host = cs.location.getHost(); if (their_host == null) { return false; } final SocketPermission our_sockperm = new SocketPermission(ourHost, "accept"); final SocketPermission their_sockperm = new SocketPermission( their_host, "accept"); if (!our_sockperm.implies(their_sockperm)) { return false; } } String our_file = location.getFile(); if (our_file != null) { if (!our_file.endsWith("/")) { our_file += "/"; } final String their_file = cs.location.getFile(); if (their_file == null || !their_file.startsWith(our_file)) return false; } return true; }
} final String their_file = cs.location.getFile(); if (their_file == null || !their_file.startsWith(our_file))
String their_file = cs.location.getFile(); if (their_file == null || ! their_file.startsWith(our_file))
public boolean implies(CodeSource cs) { if (cs == null) return false; // First check the certificate list. if (certs != null && (cs.certs == null || !certs.containsAll(cs.certs))) { return false; } // Next check the location. if (location == null) { return true; } if (cs.location == null) { return false; } if (!location.getProtocol().equals(cs.location.getProtocol())) { return false; } final int ourPort = location.getPort(); if ((ourPort != -1) && (ourPort != cs.location.getPort())) { return false; } final String ourRef = location.getRef(); if ((ourRef != null) && !ourRef.equals(cs.location.getRef())) { return false; } final String ourHost = location.getHost(); if (ourHost != null) { final String their_host = cs.location.getHost(); if (their_host == null) { return false; } final SocketPermission our_sockperm = new SocketPermission(ourHost, "accept"); final SocketPermission their_sockperm = new SocketPermission( their_host, "accept"); if (!our_sockperm.implies(their_sockperm)) { return false; } } String our_file = location.getFile(); if (our_file != null) { if (!our_file.endsWith("/")) { our_file += "/"; } final String their_file = cs.location.getFile(); if (their_file == null || !their_file.startsWith(our_file)) return false; } return true; }
public boolean equals(Object obj) { if (obj == null || !(obj instanceof URL)) return false;
public boolean equals(Object obj) { if (! (obj instanceof URL)) return false;
public boolean equals(Object obj) { if (obj == null || !(obj instanceof URL)) return false; URL uObj = (URL) obj; return handler.equals(this, uObj); }
URL uObj = (URL) obj; return handler.equals(this, uObj);
return ph.equals(this, (URL) obj);
public boolean equals(Object obj) { if (obj == null || !(obj instanceof URL)) return false; URL uObj = (URL) obj; return handler.equals(this, uObj); }
return handler.hashCode(this);
return ph.hashCode(this);
public int hashCode() { if (hashCode != 0) return hashCode; // Use cached value if available. else return handler.hashCode(this); }
if (! ourlist.startsWith(theirlist)) return false;
if (ourlist.indexOf(theirlist) == -1) return false;
public boolean implies(Permission perm) { SocketPermission p; // First make sure we are the right object type if (perm instanceof SocketPermission) p = (SocketPermission) perm; else return false; // Next check the actions String ourlist = getActions(); String theirlist = p.getActions(); if (! ourlist.startsWith(theirlist)) return false; // Now check ports int ourfirstport = 0; // Now check ports int ourlastport = 0; // Now check ports int theirfirstport = 0; // Now check ports int theirlastport = 0; // Get ours if (hostport.indexOf(":") == -1) { ourfirstport = 0; ourlastport = 65535; } else { // FIXME: Needs bulletproofing. // This will dump if hostport if all sorts of bad data was passed to // the constructor String range = hostport.substring(hostport.indexOf(":") + 1); if (range.startsWith("-")) ourfirstport = 0; else if (range.indexOf("-") == -1) ourfirstport = Integer.parseInt(range); else ourfirstport = Integer.parseInt(range.substring(0, range.indexOf("-"))); if (range.endsWith("-")) ourlastport = 65535; else if (range.indexOf("-") == -1) ourlastport = Integer.parseInt(range); else ourlastport = Integer.parseInt(range.substring(range.indexOf("-") + 1, range.length())); } // Get theirs if (p.hostport.indexOf(":") == -1) { theirfirstport = 0; ourlastport = 65535; } else { // This will dump if hostport if all sorts of bad data was passed to // the constructor// @classpath-bugfix 18/10/2005 Martin Husted Hartvig ([email protected]) :// Wrong usage of hostport and not p.hostport in call to indexOf String range = p.hostport.substring(p.hostport.indexOf(":") + 1);// @classpath-bugfix-end if (range.startsWith("-")) theirfirstport = 0; else if (range.indexOf("-") == -1) theirfirstport = Integer.parseInt(range); else theirfirstport = Integer.parseInt(range.substring(0, range.indexOf("-"))); if (range.endsWith("-")) theirlastport = 65535; else if (range.indexOf("-") == -1) theirlastport = Integer.parseInt(range); else theirlastport = Integer.parseInt(range.substring(range.indexOf("-") + 1, range.length())); } // Now check them if ((theirfirstport < ourfirstport) || (theirlastport > ourlastport)) return false; // Finally we can check the hosts String ourhost; // Finally we can check the hosts String theirhost; // Get ours if (hostport.indexOf(":") == -1) ourhost = hostport; else ourhost = hostport.substring(0, hostport.indexOf(":")); // Get theirs if (p.hostport.indexOf(":") == -1) theirhost = p.hostport; else theirhost = p.hostport.substring(0, p.hostport.indexOf(":")); // Are they equal? if (ourhost.equals(theirhost)) return true; // Try the canonical names String ourcanonical = null; // Try the canonical names String theircanonical = null; try { ourcanonical = InetAddress.getByName(ourhost).getHostName(); theircanonical = InetAddress.getByName(theirhost).getHostName(); } catch (UnknownHostException e) { // Who didn't resolve? Just assume current address is canonical enough // Is this ok to do? if (ourcanonical == null) ourcanonical = ourhost; if (theircanonical == null) theircanonical = theirhost; } if (ourcanonical.equals(theircanonical)) return true; // Well, last chance. Try for a wildcard if (ourhost.indexOf("*.") != -1) { String wild_domain = ourhost.substring(ourhost.indexOf("*" + 1)); if (theircanonical.endsWith(wild_domain)) return true; }// @classpath-bugfix 18/10/2005 Martin Husted Hartvig ([email protected]) :// Missed wildcard as host address if (ourhost.equals("*")) return true;// @classpath-bugfix-end // Didn't make it return false; }
int ourfirstport = 0;
if (hostport.equals(empty) && p.hostport.equals(empty)) return true;
public boolean implies(Permission perm) { SocketPermission p; // First make sure we are the right object type if (perm instanceof SocketPermission) p = (SocketPermission) perm; else return false; // Next check the actions String ourlist = getActions(); String theirlist = p.getActions(); if (! ourlist.startsWith(theirlist)) return false; // Now check ports int ourfirstport = 0; // Now check ports int ourlastport = 0; // Now check ports int theirfirstport = 0; // Now check ports int theirlastport = 0; // Get ours if (hostport.indexOf(":") == -1) { ourfirstport = 0; ourlastport = 65535; } else { // FIXME: Needs bulletproofing. // This will dump if hostport if all sorts of bad data was passed to // the constructor String range = hostport.substring(hostport.indexOf(":") + 1); if (range.startsWith("-")) ourfirstport = 0; else if (range.indexOf("-") == -1) ourfirstport = Integer.parseInt(range); else ourfirstport = Integer.parseInt(range.substring(0, range.indexOf("-"))); if (range.endsWith("-")) ourlastport = 65535; else if (range.indexOf("-") == -1) ourlastport = Integer.parseInt(range); else ourlastport = Integer.parseInt(range.substring(range.indexOf("-") + 1, range.length())); } // Get theirs if (p.hostport.indexOf(":") == -1) { theirfirstport = 0; ourlastport = 65535; } else { // This will dump if hostport if all sorts of bad data was passed to // the constructor// @classpath-bugfix 18/10/2005 Martin Husted Hartvig ([email protected]) :// Wrong usage of hostport and not p.hostport in call to indexOf String range = p.hostport.substring(p.hostport.indexOf(":") + 1);// @classpath-bugfix-end if (range.startsWith("-")) theirfirstport = 0; else if (range.indexOf("-") == -1) theirfirstport = Integer.parseInt(range); else theirfirstport = Integer.parseInt(range.substring(0, range.indexOf("-"))); if (range.endsWith("-")) theirlastport = 65535; else if (range.indexOf("-") == -1) theirlastport = Integer.parseInt(range); else theirlastport = Integer.parseInt(range.substring(range.indexOf("-") + 1, range.length())); } // Now check them if ((theirfirstport < ourfirstport) || (theirlastport > ourlastport)) return false; // Finally we can check the hosts String ourhost; // Finally we can check the hosts String theirhost; // Get ours if (hostport.indexOf(":") == -1) ourhost = hostport; else ourhost = hostport.substring(0, hostport.indexOf(":")); // Get theirs if (p.hostport.indexOf(":") == -1) theirhost = p.hostport; else theirhost = p.hostport.substring(0, p.hostport.indexOf(":")); // Are they equal? if (ourhost.equals(theirhost)) return true; // Try the canonical names String ourcanonical = null; // Try the canonical names String theircanonical = null; try { ourcanonical = InetAddress.getByName(ourhost).getHostName(); theircanonical = InetAddress.getByName(theirhost).getHostName(); } catch (UnknownHostException e) { // Who didn't resolve? Just assume current address is canonical enough // Is this ok to do? if (ourcanonical == null) ourcanonical = ourhost; if (theircanonical == null) theircanonical = theirhost; } if (ourcanonical.equals(theircanonical)) return true; // Well, last chance. Try for a wildcard if (ourhost.indexOf("*.") != -1) { String wild_domain = ourhost.substring(ourhost.indexOf("*" + 1)); if (theircanonical.endsWith(wild_domain)) return true; }// @classpath-bugfix 18/10/2005 Martin Husted Hartvig ([email protected]) :// Missed wildcard as host address if (ourhost.equals("*")) return true;// @classpath-bugfix-end // Didn't make it return false; }
int ourlastport = 0;
int ourfirstport = 0;
public boolean implies(Permission perm) { SocketPermission p; // First make sure we are the right object type if (perm instanceof SocketPermission) p = (SocketPermission) perm; else return false; // Next check the actions String ourlist = getActions(); String theirlist = p.getActions(); if (! ourlist.startsWith(theirlist)) return false; // Now check ports int ourfirstport = 0; // Now check ports int ourlastport = 0; // Now check ports int theirfirstport = 0; // Now check ports int theirlastport = 0; // Get ours if (hostport.indexOf(":") == -1) { ourfirstport = 0; ourlastport = 65535; } else { // FIXME: Needs bulletproofing. // This will dump if hostport if all sorts of bad data was passed to // the constructor String range = hostport.substring(hostport.indexOf(":") + 1); if (range.startsWith("-")) ourfirstport = 0; else if (range.indexOf("-") == -1) ourfirstport = Integer.parseInt(range); else ourfirstport = Integer.parseInt(range.substring(0, range.indexOf("-"))); if (range.endsWith("-")) ourlastport = 65535; else if (range.indexOf("-") == -1) ourlastport = Integer.parseInt(range); else ourlastport = Integer.parseInt(range.substring(range.indexOf("-") + 1, range.length())); } // Get theirs if (p.hostport.indexOf(":") == -1) { theirfirstport = 0; ourlastport = 65535; } else { // This will dump if hostport if all sorts of bad data was passed to // the constructor// @classpath-bugfix 18/10/2005 Martin Husted Hartvig ([email protected]) :// Wrong usage of hostport and not p.hostport in call to indexOf String range = p.hostport.substring(p.hostport.indexOf(":") + 1);// @classpath-bugfix-end if (range.startsWith("-")) theirfirstport = 0; else if (range.indexOf("-") == -1) theirfirstport = Integer.parseInt(range); else theirfirstport = Integer.parseInt(range.substring(0, range.indexOf("-"))); if (range.endsWith("-")) theirlastport = 65535; else if (range.indexOf("-") == -1) theirlastport = Integer.parseInt(range); else theirlastport = Integer.parseInt(range.substring(range.indexOf("-") + 1, range.length())); } // Now check them if ((theirfirstport < ourfirstport) || (theirlastport > ourlastport)) return false; // Finally we can check the hosts String ourhost; // Finally we can check the hosts String theirhost; // Get ours if (hostport.indexOf(":") == -1) ourhost = hostport; else ourhost = hostport.substring(0, hostport.indexOf(":")); // Get theirs if (p.hostport.indexOf(":") == -1) theirhost = p.hostport; else theirhost = p.hostport.substring(0, p.hostport.indexOf(":")); // Are they equal? if (ourhost.equals(theirhost)) return true; // Try the canonical names String ourcanonical = null; // Try the canonical names String theircanonical = null; try { ourcanonical = InetAddress.getByName(ourhost).getHostName(); theircanonical = InetAddress.getByName(theirhost).getHostName(); } catch (UnknownHostException e) { // Who didn't resolve? Just assume current address is canonical enough // Is this ok to do? if (ourcanonical == null) ourcanonical = ourhost; if (theircanonical == null) theircanonical = theirhost; } if (ourcanonical.equals(theircanonical)) return true; // Well, last chance. Try for a wildcard if (ourhost.indexOf("*.") != -1) { String wild_domain = ourhost.substring(ourhost.indexOf("*" + 1)); if (theircanonical.endsWith(wild_domain)) return true; }// @classpath-bugfix 18/10/2005 Martin Husted Hartvig ([email protected]) :// Missed wildcard as host address if (ourhost.equals("*")) return true;// @classpath-bugfix-end // Didn't make it return false; }
int theirfirstport = 0;
int ourlastport = 0;
public boolean implies(Permission perm) { SocketPermission p; // First make sure we are the right object type if (perm instanceof SocketPermission) p = (SocketPermission) perm; else return false; // Next check the actions String ourlist = getActions(); String theirlist = p.getActions(); if (! ourlist.startsWith(theirlist)) return false; // Now check ports int ourfirstport = 0; // Now check ports int ourlastport = 0; // Now check ports int theirfirstport = 0; // Now check ports int theirlastport = 0; // Get ours if (hostport.indexOf(":") == -1) { ourfirstport = 0; ourlastport = 65535; } else { // FIXME: Needs bulletproofing. // This will dump if hostport if all sorts of bad data was passed to // the constructor String range = hostport.substring(hostport.indexOf(":") + 1); if (range.startsWith("-")) ourfirstport = 0; else if (range.indexOf("-") == -1) ourfirstport = Integer.parseInt(range); else ourfirstport = Integer.parseInt(range.substring(0, range.indexOf("-"))); if (range.endsWith("-")) ourlastport = 65535; else if (range.indexOf("-") == -1) ourlastport = Integer.parseInt(range); else ourlastport = Integer.parseInt(range.substring(range.indexOf("-") + 1, range.length())); } // Get theirs if (p.hostport.indexOf(":") == -1) { theirfirstport = 0; ourlastport = 65535; } else { // This will dump if hostport if all sorts of bad data was passed to // the constructor// @classpath-bugfix 18/10/2005 Martin Husted Hartvig ([email protected]) :// Wrong usage of hostport and not p.hostport in call to indexOf String range = p.hostport.substring(p.hostport.indexOf(":") + 1);// @classpath-bugfix-end if (range.startsWith("-")) theirfirstport = 0; else if (range.indexOf("-") == -1) theirfirstport = Integer.parseInt(range); else theirfirstport = Integer.parseInt(range.substring(0, range.indexOf("-"))); if (range.endsWith("-")) theirlastport = 65535; else if (range.indexOf("-") == -1) theirlastport = Integer.parseInt(range); else theirlastport = Integer.parseInt(range.substring(range.indexOf("-") + 1, range.length())); } // Now check them if ((theirfirstport < ourfirstport) || (theirlastport > ourlastport)) return false; // Finally we can check the hosts String ourhost; // Finally we can check the hosts String theirhost; // Get ours if (hostport.indexOf(":") == -1) ourhost = hostport; else ourhost = hostport.substring(0, hostport.indexOf(":")); // Get theirs if (p.hostport.indexOf(":") == -1) theirhost = p.hostport; else theirhost = p.hostport.substring(0, p.hostport.indexOf(":")); // Are they equal? if (ourhost.equals(theirhost)) return true; // Try the canonical names String ourcanonical = null; // Try the canonical names String theircanonical = null; try { ourcanonical = InetAddress.getByName(ourhost).getHostName(); theircanonical = InetAddress.getByName(theirhost).getHostName(); } catch (UnknownHostException e) { // Who didn't resolve? Just assume current address is canonical enough // Is this ok to do? if (ourcanonical == null) ourcanonical = ourhost; if (theircanonical == null) theircanonical = theirhost; } if (ourcanonical.equals(theircanonical)) return true; // Well, last chance. Try for a wildcard if (ourhost.indexOf("*.") != -1) { String wild_domain = ourhost.substring(ourhost.indexOf("*" + 1)); if (theircanonical.endsWith(wild_domain)) return true; }// @classpath-bugfix 18/10/2005 Martin Husted Hartvig ([email protected]) :// Missed wildcard as host address if (ourhost.equals("*")) return true;// @classpath-bugfix-end // Didn't make it return false; }
int theirlastport = 0;
int theirfirstport = 0;
public boolean implies(Permission perm) { SocketPermission p; // First make sure we are the right object type if (perm instanceof SocketPermission) p = (SocketPermission) perm; else return false; // Next check the actions String ourlist = getActions(); String theirlist = p.getActions(); if (! ourlist.startsWith(theirlist)) return false; // Now check ports int ourfirstport = 0; // Now check ports int ourlastport = 0; // Now check ports int theirfirstport = 0; // Now check ports int theirlastport = 0; // Get ours if (hostport.indexOf(":") == -1) { ourfirstport = 0; ourlastport = 65535; } else { // FIXME: Needs bulletproofing. // This will dump if hostport if all sorts of bad data was passed to // the constructor String range = hostport.substring(hostport.indexOf(":") + 1); if (range.startsWith("-")) ourfirstport = 0; else if (range.indexOf("-") == -1) ourfirstport = Integer.parseInt(range); else ourfirstport = Integer.parseInt(range.substring(0, range.indexOf("-"))); if (range.endsWith("-")) ourlastport = 65535; else if (range.indexOf("-") == -1) ourlastport = Integer.parseInt(range); else ourlastport = Integer.parseInt(range.substring(range.indexOf("-") + 1, range.length())); } // Get theirs if (p.hostport.indexOf(":") == -1) { theirfirstport = 0; ourlastport = 65535; } else { // This will dump if hostport if all sorts of bad data was passed to // the constructor// @classpath-bugfix 18/10/2005 Martin Husted Hartvig ([email protected]) :// Wrong usage of hostport and not p.hostport in call to indexOf String range = p.hostport.substring(p.hostport.indexOf(":") + 1);// @classpath-bugfix-end if (range.startsWith("-")) theirfirstport = 0; else if (range.indexOf("-") == -1) theirfirstport = Integer.parseInt(range); else theirfirstport = Integer.parseInt(range.substring(0, range.indexOf("-"))); if (range.endsWith("-")) theirlastport = 65535; else if (range.indexOf("-") == -1) theirlastport = Integer.parseInt(range); else theirlastport = Integer.parseInt(range.substring(range.indexOf("-") + 1, range.length())); } // Now check them if ((theirfirstport < ourfirstport) || (theirlastport > ourlastport)) return false; // Finally we can check the hosts String ourhost; // Finally we can check the hosts String theirhost; // Get ours if (hostport.indexOf(":") == -1) ourhost = hostport; else ourhost = hostport.substring(0, hostport.indexOf(":")); // Get theirs if (p.hostport.indexOf(":") == -1) theirhost = p.hostport; else theirhost = p.hostport.substring(0, p.hostport.indexOf(":")); // Are they equal? if (ourhost.equals(theirhost)) return true; // Try the canonical names String ourcanonical = null; // Try the canonical names String theircanonical = null; try { ourcanonical = InetAddress.getByName(ourhost).getHostName(); theircanonical = InetAddress.getByName(theirhost).getHostName(); } catch (UnknownHostException e) { // Who didn't resolve? Just assume current address is canonical enough // Is this ok to do? if (ourcanonical == null) ourcanonical = ourhost; if (theircanonical == null) theircanonical = theirhost; } if (ourcanonical.equals(theircanonical)) return true; // Well, last chance. Try for a wildcard if (ourhost.indexOf("*.") != -1) { String wild_domain = ourhost.substring(ourhost.indexOf("*" + 1)); if (theircanonical.endsWith(wild_domain)) return true; }// @classpath-bugfix 18/10/2005 Martin Husted Hartvig ([email protected]) :// Missed wildcard as host address if (ourhost.equals("*")) return true;// @classpath-bugfix-end // Didn't make it return false; }
if (hostport.indexOf(":") == -1)
int theirlastport = 0; String ourhost; String theirhost; String range; int portsIndex; int portDelimitorIndex; portsIndex = hostport.indexOf(ports); if (portsIndex == -1)
public boolean implies(Permission perm) { SocketPermission p; // First make sure we are the right object type if (perm instanceof SocketPermission) p = (SocketPermission) perm; else return false; // Next check the actions String ourlist = getActions(); String theirlist = p.getActions(); if (! ourlist.startsWith(theirlist)) return false; // Now check ports int ourfirstport = 0; // Now check ports int ourlastport = 0; // Now check ports int theirfirstport = 0; // Now check ports int theirlastport = 0; // Get ours if (hostport.indexOf(":") == -1) { ourfirstport = 0; ourlastport = 65535; } else { // FIXME: Needs bulletproofing. // This will dump if hostport if all sorts of bad data was passed to // the constructor String range = hostport.substring(hostport.indexOf(":") + 1); if (range.startsWith("-")) ourfirstport = 0; else if (range.indexOf("-") == -1) ourfirstport = Integer.parseInt(range); else ourfirstport = Integer.parseInt(range.substring(0, range.indexOf("-"))); if (range.endsWith("-")) ourlastport = 65535; else if (range.indexOf("-") == -1) ourlastport = Integer.parseInt(range); else ourlastport = Integer.parseInt(range.substring(range.indexOf("-") + 1, range.length())); } // Get theirs if (p.hostport.indexOf(":") == -1) { theirfirstport = 0; ourlastport = 65535; } else { // This will dump if hostport if all sorts of bad data was passed to // the constructor// @classpath-bugfix 18/10/2005 Martin Husted Hartvig ([email protected]) :// Wrong usage of hostport and not p.hostport in call to indexOf String range = p.hostport.substring(p.hostport.indexOf(":") + 1);// @classpath-bugfix-end if (range.startsWith("-")) theirfirstport = 0; else if (range.indexOf("-") == -1) theirfirstport = Integer.parseInt(range); else theirfirstport = Integer.parseInt(range.substring(0, range.indexOf("-"))); if (range.endsWith("-")) theirlastport = 65535; else if (range.indexOf("-") == -1) theirlastport = Integer.parseInt(range); else theirlastport = Integer.parseInt(range.substring(range.indexOf("-") + 1, range.length())); } // Now check them if ((theirfirstport < ourfirstport) || (theirlastport > ourlastport)) return false; // Finally we can check the hosts String ourhost; // Finally we can check the hosts String theirhost; // Get ours if (hostport.indexOf(":") == -1) ourhost = hostport; else ourhost = hostport.substring(0, hostport.indexOf(":")); // Get theirs if (p.hostport.indexOf(":") == -1) theirhost = p.hostport; else theirhost = p.hostport.substring(0, p.hostport.indexOf(":")); // Are they equal? if (ourhost.equals(theirhost)) return true; // Try the canonical names String ourcanonical = null; // Try the canonical names String theircanonical = null; try { ourcanonical = InetAddress.getByName(ourhost).getHostName(); theircanonical = InetAddress.getByName(theirhost).getHostName(); } catch (UnknownHostException e) { // Who didn't resolve? Just assume current address is canonical enough // Is this ok to do? if (ourcanonical == null) ourcanonical = ourhost; if (theircanonical == null) theircanonical = theirhost; } if (ourcanonical.equals(theircanonical)) return true; // Well, last chance. Try for a wildcard if (ourhost.indexOf("*.") != -1) { String wild_domain = ourhost.substring(ourhost.indexOf("*" + 1)); if (theircanonical.endsWith(wild_domain)) return true; }// @classpath-bugfix 18/10/2005 Martin Husted Hartvig ([email protected]) :// Missed wildcard as host address if (ourhost.equals("*")) return true;// @classpath-bugfix-end // Didn't make it return false; }
ourfirstport = 0; ourlastport = 65535;
ourlastport = 65535; ourhost = hostport;
public boolean implies(Permission perm) { SocketPermission p; // First make sure we are the right object type if (perm instanceof SocketPermission) p = (SocketPermission) perm; else return false; // Next check the actions String ourlist = getActions(); String theirlist = p.getActions(); if (! ourlist.startsWith(theirlist)) return false; // Now check ports int ourfirstport = 0; // Now check ports int ourlastport = 0; // Now check ports int theirfirstport = 0; // Now check ports int theirlastport = 0; // Get ours if (hostport.indexOf(":") == -1) { ourfirstport = 0; ourlastport = 65535; } else { // FIXME: Needs bulletproofing. // This will dump if hostport if all sorts of bad data was passed to // the constructor String range = hostport.substring(hostport.indexOf(":") + 1); if (range.startsWith("-")) ourfirstport = 0; else if (range.indexOf("-") == -1) ourfirstport = Integer.parseInt(range); else ourfirstport = Integer.parseInt(range.substring(0, range.indexOf("-"))); if (range.endsWith("-")) ourlastport = 65535; else if (range.indexOf("-") == -1) ourlastport = Integer.parseInt(range); else ourlastport = Integer.parseInt(range.substring(range.indexOf("-") + 1, range.length())); } // Get theirs if (p.hostport.indexOf(":") == -1) { theirfirstport = 0; ourlastport = 65535; } else { // This will dump if hostport if all sorts of bad data was passed to // the constructor// @classpath-bugfix 18/10/2005 Martin Husted Hartvig ([email protected]) :// Wrong usage of hostport and not p.hostport in call to indexOf String range = p.hostport.substring(p.hostport.indexOf(":") + 1);// @classpath-bugfix-end if (range.startsWith("-")) theirfirstport = 0; else if (range.indexOf("-") == -1) theirfirstport = Integer.parseInt(range); else theirfirstport = Integer.parseInt(range.substring(0, range.indexOf("-"))); if (range.endsWith("-")) theirlastport = 65535; else if (range.indexOf("-") == -1) theirlastport = Integer.parseInt(range); else theirlastport = Integer.parseInt(range.substring(range.indexOf("-") + 1, range.length())); } // Now check them if ((theirfirstport < ourfirstport) || (theirlastport > ourlastport)) return false; // Finally we can check the hosts String ourhost; // Finally we can check the hosts String theirhost; // Get ours if (hostport.indexOf(":") == -1) ourhost = hostport; else ourhost = hostport.substring(0, hostport.indexOf(":")); // Get theirs if (p.hostport.indexOf(":") == -1) theirhost = p.hostport; else theirhost = p.hostport.substring(0, p.hostport.indexOf(":")); // Are they equal? if (ourhost.equals(theirhost)) return true; // Try the canonical names String ourcanonical = null; // Try the canonical names String theircanonical = null; try { ourcanonical = InetAddress.getByName(ourhost).getHostName(); theircanonical = InetAddress.getByName(theirhost).getHostName(); } catch (UnknownHostException e) { // Who didn't resolve? Just assume current address is canonical enough // Is this ok to do? if (ourcanonical == null) ourcanonical = ourhost; if (theircanonical == null) theircanonical = theirhost; } if (ourcanonical.equals(theircanonical)) return true; // Well, last chance. Try for a wildcard if (ourhost.indexOf("*.") != -1) { String wild_domain = ourhost.substring(ourhost.indexOf("*" + 1)); if (theircanonical.endsWith(wild_domain)) return true; }// @classpath-bugfix 18/10/2005 Martin Husted Hartvig ([email protected]) :// Missed wildcard as host address if (ourhost.equals("*")) return true;// @classpath-bugfix-end // Didn't make it return false; }
String range = hostport.substring(hostport.indexOf(":") + 1); if (range.startsWith("-")) ourfirstport = 0; else if (range.indexOf("-") == -1) ourfirstport = Integer.parseInt(range); else ourfirstport = Integer.parseInt(range.substring(0, range.indexOf("-")));
range = hostport.substring(portsIndex + 1); portDelimitorIndex = range.indexOf(portDelimitor);
public boolean implies(Permission perm) { SocketPermission p; // First make sure we are the right object type if (perm instanceof SocketPermission) p = (SocketPermission) perm; else return false; // Next check the actions String ourlist = getActions(); String theirlist = p.getActions(); if (! ourlist.startsWith(theirlist)) return false; // Now check ports int ourfirstport = 0; // Now check ports int ourlastport = 0; // Now check ports int theirfirstport = 0; // Now check ports int theirlastport = 0; // Get ours if (hostport.indexOf(":") == -1) { ourfirstport = 0; ourlastport = 65535; } else { // FIXME: Needs bulletproofing. // This will dump if hostport if all sorts of bad data was passed to // the constructor String range = hostport.substring(hostport.indexOf(":") + 1); if (range.startsWith("-")) ourfirstport = 0; else if (range.indexOf("-") == -1) ourfirstport = Integer.parseInt(range); else ourfirstport = Integer.parseInt(range.substring(0, range.indexOf("-"))); if (range.endsWith("-")) ourlastport = 65535; else if (range.indexOf("-") == -1) ourlastport = Integer.parseInt(range); else ourlastport = Integer.parseInt(range.substring(range.indexOf("-") + 1, range.length())); } // Get theirs if (p.hostport.indexOf(":") == -1) { theirfirstport = 0; ourlastport = 65535; } else { // This will dump if hostport if all sorts of bad data was passed to // the constructor// @classpath-bugfix 18/10/2005 Martin Husted Hartvig ([email protected]) :// Wrong usage of hostport and not p.hostport in call to indexOf String range = p.hostport.substring(p.hostport.indexOf(":") + 1);// @classpath-bugfix-end if (range.startsWith("-")) theirfirstport = 0; else if (range.indexOf("-") == -1) theirfirstport = Integer.parseInt(range); else theirfirstport = Integer.parseInt(range.substring(0, range.indexOf("-"))); if (range.endsWith("-")) theirlastport = 65535; else if (range.indexOf("-") == -1) theirlastport = Integer.parseInt(range); else theirlastport = Integer.parseInt(range.substring(range.indexOf("-") + 1, range.length())); } // Now check them if ((theirfirstport < ourfirstport) || (theirlastport > ourlastport)) return false; // Finally we can check the hosts String ourhost; // Finally we can check the hosts String theirhost; // Get ours if (hostport.indexOf(":") == -1) ourhost = hostport; else ourhost = hostport.substring(0, hostport.indexOf(":")); // Get theirs if (p.hostport.indexOf(":") == -1) theirhost = p.hostport; else theirhost = p.hostport.substring(0, p.hostport.indexOf(":")); // Are they equal? if (ourhost.equals(theirhost)) return true; // Try the canonical names String ourcanonical = null; // Try the canonical names String theircanonical = null; try { ourcanonical = InetAddress.getByName(ourhost).getHostName(); theircanonical = InetAddress.getByName(theirhost).getHostName(); } catch (UnknownHostException e) { // Who didn't resolve? Just assume current address is canonical enough // Is this ok to do? if (ourcanonical == null) ourcanonical = ourhost; if (theircanonical == null) theircanonical = theirhost; } if (ourcanonical.equals(theircanonical)) return true; // Well, last chance. Try for a wildcard if (ourhost.indexOf("*.") != -1) { String wild_domain = ourhost.substring(ourhost.indexOf("*" + 1)); if (theircanonical.endsWith(wild_domain)) return true; }// @classpath-bugfix 18/10/2005 Martin Husted Hartvig ([email protected]) :// Missed wildcard as host address if (ourhost.equals("*")) return true;// @classpath-bugfix-end // Didn't make it return false; }
if (range.endsWith("-")) ourlastport = 65535; else if (range.indexOf("-") == -1) ourlastport = Integer.parseInt(range); else ourlastport = Integer.parseInt(range.substring(range.indexOf("-") + 1, range.length()));
if (portDelimitorIndex == 0) { ourfirstport = 0; } else if (portDelimitorIndex == -1) { ourfirstport = Integer.parseInt(range); ourlastport = ourfirstport; } else ourfirstport = Integer.parseInt(range.substring(0, portDelimitorIndex)); if (range.endsWith(portDelimitor)) ourlastport = 65535; else ourlastport = Integer.parseInt(range.substring(portDelimitorIndex + 1, range.length())); ourhost = hostport.substring(0, portsIndex);
public boolean implies(Permission perm) { SocketPermission p; // First make sure we are the right object type if (perm instanceof SocketPermission) p = (SocketPermission) perm; else return false; // Next check the actions String ourlist = getActions(); String theirlist = p.getActions(); if (! ourlist.startsWith(theirlist)) return false; // Now check ports int ourfirstport = 0; // Now check ports int ourlastport = 0; // Now check ports int theirfirstport = 0; // Now check ports int theirlastport = 0; // Get ours if (hostport.indexOf(":") == -1) { ourfirstport = 0; ourlastport = 65535; } else { // FIXME: Needs bulletproofing. // This will dump if hostport if all sorts of bad data was passed to // the constructor String range = hostport.substring(hostport.indexOf(":") + 1); if (range.startsWith("-")) ourfirstport = 0; else if (range.indexOf("-") == -1) ourfirstport = Integer.parseInt(range); else ourfirstport = Integer.parseInt(range.substring(0, range.indexOf("-"))); if (range.endsWith("-")) ourlastport = 65535; else if (range.indexOf("-") == -1) ourlastport = Integer.parseInt(range); else ourlastport = Integer.parseInt(range.substring(range.indexOf("-") + 1, range.length())); } // Get theirs if (p.hostport.indexOf(":") == -1) { theirfirstport = 0; ourlastport = 65535; } else { // This will dump if hostport if all sorts of bad data was passed to // the constructor// @classpath-bugfix 18/10/2005 Martin Husted Hartvig ([email protected]) :// Wrong usage of hostport and not p.hostport in call to indexOf String range = p.hostport.substring(p.hostport.indexOf(":") + 1);// @classpath-bugfix-end if (range.startsWith("-")) theirfirstport = 0; else if (range.indexOf("-") == -1) theirfirstport = Integer.parseInt(range); else theirfirstport = Integer.parseInt(range.substring(0, range.indexOf("-"))); if (range.endsWith("-")) theirlastport = 65535; else if (range.indexOf("-") == -1) theirlastport = Integer.parseInt(range); else theirlastport = Integer.parseInt(range.substring(range.indexOf("-") + 1, range.length())); } // Now check them if ((theirfirstport < ourfirstport) || (theirlastport > ourlastport)) return false; // Finally we can check the hosts String ourhost; // Finally we can check the hosts String theirhost; // Get ours if (hostport.indexOf(":") == -1) ourhost = hostport; else ourhost = hostport.substring(0, hostport.indexOf(":")); // Get theirs if (p.hostport.indexOf(":") == -1) theirhost = p.hostport; else theirhost = p.hostport.substring(0, p.hostport.indexOf(":")); // Are they equal? if (ourhost.equals(theirhost)) return true; // Try the canonical names String ourcanonical = null; // Try the canonical names String theircanonical = null; try { ourcanonical = InetAddress.getByName(ourhost).getHostName(); theircanonical = InetAddress.getByName(theirhost).getHostName(); } catch (UnknownHostException e) { // Who didn't resolve? Just assume current address is canonical enough // Is this ok to do? if (ourcanonical == null) ourcanonical = ourhost; if (theircanonical == null) theircanonical = theirhost; } if (ourcanonical.equals(theircanonical)) return true; // Well, last chance. Try for a wildcard if (ourhost.indexOf("*.") != -1) { String wild_domain = ourhost.substring(ourhost.indexOf("*" + 1)); if (theircanonical.endsWith(wild_domain)) return true; }// @classpath-bugfix 18/10/2005 Martin Husted Hartvig ([email protected]) :// Missed wildcard as host address if (ourhost.equals("*")) return true;// @classpath-bugfix-end // Didn't make it return false; }
if (p.hostport.indexOf(":") == -1)
portsIndex = p.hostport.indexOf(ports); if (portsIndex == -1)
public boolean implies(Permission perm) { SocketPermission p; // First make sure we are the right object type if (perm instanceof SocketPermission) p = (SocketPermission) perm; else return false; // Next check the actions String ourlist = getActions(); String theirlist = p.getActions(); if (! ourlist.startsWith(theirlist)) return false; // Now check ports int ourfirstport = 0; // Now check ports int ourlastport = 0; // Now check ports int theirfirstport = 0; // Now check ports int theirlastport = 0; // Get ours if (hostport.indexOf(":") == -1) { ourfirstport = 0; ourlastport = 65535; } else { // FIXME: Needs bulletproofing. // This will dump if hostport if all sorts of bad data was passed to // the constructor String range = hostport.substring(hostport.indexOf(":") + 1); if (range.startsWith("-")) ourfirstport = 0; else if (range.indexOf("-") == -1) ourfirstport = Integer.parseInt(range); else ourfirstport = Integer.parseInt(range.substring(0, range.indexOf("-"))); if (range.endsWith("-")) ourlastport = 65535; else if (range.indexOf("-") == -1) ourlastport = Integer.parseInt(range); else ourlastport = Integer.parseInt(range.substring(range.indexOf("-") + 1, range.length())); } // Get theirs if (p.hostport.indexOf(":") == -1) { theirfirstport = 0; ourlastport = 65535; } else { // This will dump if hostport if all sorts of bad data was passed to // the constructor// @classpath-bugfix 18/10/2005 Martin Husted Hartvig ([email protected]) :// Wrong usage of hostport and not p.hostport in call to indexOf String range = p.hostport.substring(p.hostport.indexOf(":") + 1);// @classpath-bugfix-end if (range.startsWith("-")) theirfirstport = 0; else if (range.indexOf("-") == -1) theirfirstport = Integer.parseInt(range); else theirfirstport = Integer.parseInt(range.substring(0, range.indexOf("-"))); if (range.endsWith("-")) theirlastport = 65535; else if (range.indexOf("-") == -1) theirlastport = Integer.parseInt(range); else theirlastport = Integer.parseInt(range.substring(range.indexOf("-") + 1, range.length())); } // Now check them if ((theirfirstport < ourfirstport) || (theirlastport > ourlastport)) return false; // Finally we can check the hosts String ourhost; // Finally we can check the hosts String theirhost; // Get ours if (hostport.indexOf(":") == -1) ourhost = hostport; else ourhost = hostport.substring(0, hostport.indexOf(":")); // Get theirs if (p.hostport.indexOf(":") == -1) theirhost = p.hostport; else theirhost = p.hostport.substring(0, p.hostport.indexOf(":")); // Are they equal? if (ourhost.equals(theirhost)) return true; // Try the canonical names String ourcanonical = null; // Try the canonical names String theircanonical = null; try { ourcanonical = InetAddress.getByName(ourhost).getHostName(); theircanonical = InetAddress.getByName(theirhost).getHostName(); } catch (UnknownHostException e) { // Who didn't resolve? Just assume current address is canonical enough // Is this ok to do? if (ourcanonical == null) ourcanonical = ourhost; if (theircanonical == null) theircanonical = theirhost; } if (ourcanonical.equals(theircanonical)) return true; // Well, last chance. Try for a wildcard if (ourhost.indexOf("*.") != -1) { String wild_domain = ourhost.substring(ourhost.indexOf("*" + 1)); if (theircanonical.endsWith(wild_domain)) return true; }// @classpath-bugfix 18/10/2005 Martin Husted Hartvig ([email protected]) :// Missed wildcard as host address if (ourhost.equals("*")) return true;// @classpath-bugfix-end // Didn't make it return false; }