Java Code Examples for java.net.URLConnection#getPermission()

The following examples show how to use java.net.URLConnection#getPermission() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
static void check(URL url) throws IOException {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        URLConnection urlConnection = url.openConnection();
        Permission perm = urlConnection.getPermission();
        if (perm != null) {
            try {
                security.checkPermission(perm);
            } catch (SecurityException se) {
                // fallback to checkRead/checkConnect for pre 1.2
                // security managers
                if ((perm instanceof java.io.FilePermission) &&
                    perm.getActions().indexOf("read") != -1) {
                    security.checkRead(perm.getName());
                } else if ((perm instanceof
                    java.net.SocketPermission) &&
                    perm.getActions().indexOf("connect") != -1) {
                    URL locUrl = url;
                    if (urlConnection instanceof JarURLConnection) {
                        locUrl = ((JarURLConnection)urlConnection).getJarFileURL();
                    }
                    security.checkConnect(locUrl.getHost(),
                                          locUrl.getPort());
                } else {
                    throw se;
                }
            }
        }
    }
}
 
Example 2
private Permission getPermission(JarFile jarFile) {
    try {
        URLConnection uc = getConnection(jarFile);
        if (uc != null)
            return uc.getPermission();
    } catch (IOException ioe) {
        // gulp
    }

    return null;
}
 
Example 3
private Permission getPermission(JarFile jarFile) {
    try {
        URLConnection uc = getConnection(jarFile);
        if (uc != null)
            return uc.getPermission();
    } catch (IOException ioe) {
        // gulp
    }

    return null;
}
 
Example 4
static void check(URL url) throws IOException {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        URLConnection urlConnection = url.openConnection();
        Permission perm = urlConnection.getPermission();
        if (perm != null) {
            try {
                security.checkPermission(perm);
            } catch (SecurityException se) {
                // fallback to checkRead/checkConnect for pre 1.2
                // security managers
                if ((perm instanceof java.io.FilePermission) &&
                    perm.getActions().indexOf("read") != -1) {
                    security.checkRead(perm.getName());
                } else if ((perm instanceof
                    java.net.SocketPermission) &&
                    perm.getActions().indexOf("connect") != -1) {
                    URL locUrl = url;
                    if (urlConnection instanceof JarURLConnection) {
                        locUrl = ((JarURLConnection)urlConnection).getJarFileURL();
                    }
                    security.checkConnect(locUrl.getHost(),
                                          locUrl.getPort());
                } else {
                    throw se;
                }
            }
        }
    }
}
 
Example 5
private Permission getPermission(JarFile jarFile) {
    try {
        URLConnection uc = getConnection(jarFile);
        if (uc != null)
            return uc.getPermission();
    } catch (IOException ioe) {
        // gulp
    }

    return null;
}
 
Example 6
private Permission getPermission(JarFile jarFile) {
    try {
        URLConnection uc = getConnection(jarFile);
        if (uc != null)
            return uc.getPermission();
    } catch (IOException ioe) {
        // gulp
    }

    return null;
}
 
Example 7
private Permission getPermission(JarFile jarFile) {
    try {
        URLConnection uc = getConnection(jarFile);
        if (uc != null)
            return uc.getPermission();
    } catch (IOException ioe) {
        // gulp
    }

    return null;
}
 
Example 8
private Permission getPermission(JarFile jarFile) {
    try {
        URLConnection uc = getConnection(jarFile);
        if (uc != null)
            return uc.getPermission();
    } catch (IOException ioe) {
        // gulp
    }

    return null;
}
 
Example 9
private Permission getPermission(JarFile jarFile) {
    try {
        URLConnection uc = getConnection(jarFile);
        if (uc != null)
            return uc.getPermission();
    } catch (IOException ioe) {
        // gulp
    }

    return null;
}
 
Example 10
static void check(URL url) throws IOException {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        URLConnection urlConnection = url.openConnection();
        Permission perm = urlConnection.getPermission();
        if (perm != null) {
            try {
                security.checkPermission(perm);
            } catch (SecurityException se) {
                // fallback to checkRead/checkConnect for pre 1.2
                // security managers
                if ((perm instanceof java.io.FilePermission) &&
                    perm.getActions().indexOf("read") != -1) {
                    security.checkRead(perm.getName());
                } else if ((perm instanceof
                    java.net.SocketPermission) &&
                    perm.getActions().indexOf("connect") != -1) {
                    URL locUrl = url;
                    if (urlConnection instanceof JarURLConnection) {
                        locUrl = ((JarURLConnection)urlConnection).getJarFileURL();
                    }
                    security.checkConnect(locUrl.getHost(),
                                          locUrl.getPort());
                } else {
                    throw se;
                }
            }
        }
    }
}
 
Example 11
private Permission getPermission(JarFile jarFile) {
    try {
        URLConnection uc = getConnection(jarFile);
        if (uc != null)
            return uc.getPermission();
    } catch (IOException ioe) {
        // gulp
    }

    return null;
}
 
Example 12
private Permission getPermission(JarFile jarFile) {
    try {
        URLConnection uc = getConnection(jarFile);
        if (uc != null)
            return uc.getPermission();
    } catch (IOException ioe) {
        // gulp
    }

    return null;
}
 
Example 13
static void check(URL url) throws IOException {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        URLConnection urlConnection = url.openConnection();
        Permission perm = urlConnection.getPermission();
        if (perm != null) {
            try {
                security.checkPermission(perm);
            } catch (SecurityException se) {
                // fallback to checkRead/checkConnect for pre 1.2
                // security managers
                if ((perm instanceof java.io.FilePermission) &&
                    perm.getActions().indexOf("read") != -1) {
                    security.checkRead(perm.getName());
                } else if ((perm instanceof
                    java.net.SocketPermission) &&
                    perm.getActions().indexOf("connect") != -1) {
                    URL locUrl = url;
                    if (urlConnection instanceof JarURLConnection) {
                        locUrl = ((JarURLConnection)urlConnection).getJarFileURL();
                    }
                    security.checkConnect(locUrl.getHost(),
                                          locUrl.getPort());
                } else {
                    throw se;
                }
            }
        }
    }
}
 
Example 14
static void check(URL url) throws IOException {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        URLConnection urlConnection = url.openConnection();
        Permission perm = urlConnection.getPermission();
        if (perm != null) {
            try {
                security.checkPermission(perm);
            } catch (SecurityException se) {
                // fallback to checkRead/checkConnect for pre 1.2
                // security managers
                if ((perm instanceof java.io.FilePermission) &&
                    perm.getActions().indexOf("read") != -1) {
                    security.checkRead(perm.getName());
                } else if ((perm instanceof
                    java.net.SocketPermission) &&
                    perm.getActions().indexOf("connect") != -1) {
                    URL locUrl = url;
                    if (urlConnection instanceof JarURLConnection) {
                        locUrl = ((JarURLConnection)urlConnection).getJarFileURL();
                    }
                    security.checkConnect(locUrl.getHost(),
                                          locUrl.getPort());
                } else {
                    throw se;
                }
            }
        }
    }
}
 
Example 15
private Permission getPermission(JarFile jarFile) {
    try {
        URLConnection uc = getConnection(jarFile);
        if (uc != null)
            return uc.getPermission();
    } catch (IOException ioe) {
        // gulp
    }

    return null;
}
 
Example 16
private Permission getPermission(JarFile jarFile) {
    try {
        URLConnection uc = getConnection(jarFile);
        if (uc != null)
            return uc.getPermission();
    } catch (IOException ioe) {
        // gulp
    }

    return null;
}
 
Example 17
private Permission getPermission(JarFile jarFile) {
    try {
        URLConnection uc = getConnection(jarFile);
        if (uc != null)
            return uc.getPermission();
    } catch (IOException ioe) {
        // gulp
    }

    return null;
}
 
Example 18
Source Project: Bytecoder   File: URLClassPath.java    License: Apache License 2.0 5 votes vote down vote up
public static void check(URL url) throws IOException {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        URLConnection urlConnection = url.openConnection();
        Permission perm = urlConnection.getPermission();
        if (perm != null) {
            try {
                security.checkPermission(perm);
            } catch (SecurityException se) {
                // fallback to checkRead/checkConnect for pre 1.2
                // security managers
                if ((perm instanceof java.io.FilePermission) &&
                    perm.getActions().indexOf("read") != -1) {
                    security.checkRead(perm.getName());
                } else if ((perm instanceof
                    java.net.SocketPermission) &&
                    perm.getActions().indexOf("connect") != -1) {
                    URL locUrl = url;
                    if (urlConnection instanceof JarURLConnection) {
                        locUrl = ((JarURLConnection)urlConnection).getJarFileURL();
                    }
                    security.checkConnect(locUrl.getHost(),
                                          locUrl.getPort());
                } else {
                    throw se;
                }
            }
        }
    }
}
 
Example 19
static void check(URL url) throws IOException {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        URLConnection urlConnection = url.openConnection();
        Permission perm = urlConnection.getPermission();
        if (perm != null) {
            try {
                security.checkPermission(perm);
            } catch (SecurityException se) {
                // fallback to checkRead/checkConnect for pre 1.2
                // security managers
                if ((perm instanceof java.io.FilePermission) &&
                    perm.getActions().indexOf("read") != -1) {
                    security.checkRead(perm.getName());
                } else if ((perm instanceof
                    java.net.SocketPermission) &&
                    perm.getActions().indexOf("connect") != -1) {
                    URL locUrl = url;
                    if (urlConnection instanceof JarURLConnection) {
                        locUrl = ((JarURLConnection)urlConnection).getJarFileURL();
                    }
                    security.checkConnect(locUrl.getHost(),
                                          locUrl.getPort());
                } else {
                    throw se;
                }
            }
        }
    }
}
 
Example 20
private Permission getPermission(JarFile jarFile) {
    try {
        URLConnection uc = getConnection(jarFile);
        if (uc != null)
            return uc.getPermission();
    } catch (IOException ioe) {
        // gulp
    }

    return null;
}