java.net.URLConnection.getPermission()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(178)

本文整理了Java中java.net.URLConnection.getPermission()方法的一些代码示例,展示了URLConnection.getPermission()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。URLConnection.getPermission()方法的具体详情如下:
包路径:java.net.URLConnection
类名称:URLConnection
方法名:getPermission

URLConnection.getPermission介绍

[英]Returns a Permission object representing all needed permissions to open this connection. The returned permission object depends on the state of the connection and will be null if no permissions are necessary. By default, this method returns AllPermission. Subclasses should overwrite this method to return an appropriate permission object.
[中]返回表示打开此连接所需的所有权限的权限对象。返回的权限对象取决于连接的状态,如果不需要权限,则返回的权限对象将为空。默认情况下,此方法返回AllPermission。子类应该覆盖此方法以返回适当的权限对象。

代码示例

代码示例来源:origin: robovm/robovm

/**
 * Returns the permission, in this case the subclass, FilePermission object
 * which represents the permission necessary for this URLConnection to
 * establish the connection.
 *
 * @return the permission required for this URLConnection.
 *
 * @throws IOException
 *             thrown when an IO exception occurs while creating the
 *             permission.
 */
@Override
public Permission getPermission() throws IOException {
  return jarFileURLConnection.getPermission();
}

代码示例来源:origin: igniterealtime/Openfire

String binaryPath = (new URL(Shaj.class.getProtectionDomain()
    .getCodeSource().getLocation(), ".")).openConnection()
    .getPermission().getName();
binaryPath = (new File(binaryPath)).getCanonicalPath();

代码示例来源:origin: org.mortbay.jetty/jetty-util

/**
 * Returns an File representing the given resource or NULL if this
 * is not possible.
 */
public File getFile()
  throws IOException
{
  // Try the permission hack
  if (checkConnection())
  {
    Permission perm = _connection.getPermission();
    if (perm instanceof java.io.FilePermission)
      return new File(perm.getName());
  }
  // Try the URL file arg
  try {return new File(_url.getFile());}
  catch(Exception e) {Log.ignore(e);}
  // Don't know the file
  return null;    
}

代码示例来源:origin: org.mortbay.jetty/jetty-util

Permission perm = _connection.getPermission();
_file = new File(perm==null?url.getFile():perm.getName());

代码示例来源:origin: org.eclipse.jetty/jetty-util

Permission perm = connection.getPermission();
file = new File(perm==null?url.getFile():perm.getName());

代码示例来源:origin: org.eclipse.jetty.osgi/jetty-osgi-boot-warurl

@Override
public Permission getPermission() throws IOException
{
  return _conn.getPermission();
}

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

@Override
public Permission getPermission() throws IOException {
  return wrappedJarUrlConnection.getPermission();
}

代码示例来源:origin: org.dihedron.commons/dihedron-commons

/**
 * Returns a {@code Permission} object representing the permissions needed 
 * to access the content.
 *  
 * @return
 *   a {@code Permission} object representing the permissions needed to access 
 *   the content.
 * @throws IOException
 */
public Permission getPermission() throws IOException {
  return connection.getPermission();
}

代码示例来源:origin: org.jboss/jboss-common-core

public Permission getPermission() throws IOException {
 return delegateConnection.getPermission();
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

@Override
public Permission getPermission() throws IOException {
  return wrappedJarUrlConnection.getPermission();
}

代码示例来源:origin: freeplane/freeplane

public Permission getPermission() throws IOException {
  return connection.getPermission();
}

代码示例来源:origin: ibinti/bugvm

/**
 * Returns the permission, in this case the subclass, FilePermission object
 * which represents the permission necessary for this URLConnection to
 * establish the connection.
 *
 * @return the permission required for this URLConnection.
 *
 * @throws IOException
 *             thrown when an IO exception occurs while creating the
 *             permission.
 */
@Override
public Permission getPermission() throws IOException {
  return jarFileURLConnection.getPermission();
}

代码示例来源:origin: MobiVM/robovm

/**
 * Returns the permission, in this case the subclass, FilePermission object
 * which represents the permission necessary for this URLConnection to
 * establish the connection.
 *
 * @return the permission required for this URLConnection.
 *
 * @throws IOException
 *             thrown when an IO exception occurs while creating the
 *             permission.
 */
@Override
public Permission getPermission() throws IOException {
  return jarFileURLConnection.getPermission();
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
 * Returns the permission, in this case the subclass, FilePermission object
 * which represents the permission necessary for this URLConnection to
 * establish the connection.
 *
 * @return the permission required for this URLConnection.
 *
 * @throws IOException
 *             thrown when an IO exception occurs while creating the
 *             permission.
 */
@Override
public Permission getPermission() throws IOException {
  return jarFileURLConnection.getPermission();
}

代码示例来源:origin: com.bugvm/bugvm-rt

/**
 * Returns the permission, in this case the subclass, FilePermission object
 * which represents the permission necessary for this URLConnection to
 * establish the connection.
 *
 * @return the permission required for this URLConnection.
 *
 * @throws IOException
 *             thrown when an IO exception occurs while creating the
 *             permission.
 */
@Override
public Permission getPermission() throws IOException {
  return jarFileURLConnection.getPermission();
}

代码示例来源:origin: com.gluonhq/robovm-rt

/**
 * Returns the permission, in this case the subclass, FilePermission object
 * which represents the permission necessary for this URLConnection to
 * establish the connection.
 *
 * @return the permission required for this URLConnection.
 *
 * @throws IOException
 *             thrown when an IO exception occurs while creating the
 *             permission.
 */
@Override
public Permission getPermission() throws IOException {
  return jarFileURLConnection.getPermission();
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-kernel

public Permission getPermission() throws IOException {
  URL jarFileUrl = new File(jarFile.getName()).toURL();
  return jarFileUrl.openConnection().getPermission();
}

代码示例来源:origin: jprante/elasticsearch-gatherer

@Override
public Permission getPermission() throws IOException {
  URL jarFileUrl = new File(jarFile.getName()).toURI().toURL();
  return jarFileUrl.openConnection().getPermission();
}

代码示例来源:origin: org.apache.xbean/xbean-classloader

public Permission getPermission() throws IOException {
  URL jarFileUrl = new File(jarFile.getName()).toURI().toURL();
  return jarFileUrl.openConnection().getPermission();
}

代码示例来源:origin: fr.opensagres.xdocreport.appengine-awt/appengine-awt

public URLDecodingImageSource(URL url){
  SecurityManager security = System.getSecurityManager();
  if (security != null) {
    security.checkConnect(url.getHost(), url.getPort());
    try {
      Permission p = url.openConnection().getPermission();
      security.checkPermission(p);
    } catch (IOException e) {
    }
  }
  this.url = url;
}

相关文章

URLConnection类方法