org.osgi.framework.Bundle.hasPermission()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(119)

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

Bundle.hasPermission介绍

[英]Determines if this bundle has the specified permissions.

If the Java Runtime Environment does not support permissions, this method always returns true.

permission is of type Object to avoid referencing the java.security.Permission class directly. This is to allow the Framework to be implemented in Java environments which do not support permissions.

If the Java Runtime Environment does support permissions, this bundle and all its resources including embedded JAR files, belong to the same java.security.ProtectionDomain; that is, they must share the same set of permissions.
[中]确定此捆绑包是否具有指定的权限。
如果Java运行时环境不支持权限,则此方法始终返回true。
权限类型为Object,以避免引用java。安全直接访问权限类。这是为了允许框架在不支持权限的Java环境中实现。
如果Java运行时环境确实支持权限,那么这个包及其所有资源(包括嵌入的JAR文件)都属于同一个Java。安全保护域;也就是说,它们必须共享同一组权限。

代码示例

代码示例来源:origin: org.apache.felix/org.apache.felix.scr

@Override
  public boolean implies(final Permission permission) {
    try {
      return bundle.hasPermission(permission);
    } catch (IllegalStateException e) {
      return false;
    }
  }
}

代码示例来源:origin: org.apache.felix/org.apache.felix.configadmin

@Override
  public boolean implies(Permission permission) {
    try {
      return bundle.hasPermission(permission);
    } catch (IllegalStateException e) {
      return false;
    }
  }
}

代码示例来源:origin: org.apache.aries.blueprint/org.apache.aries.blueprint.core

public boolean implies(Permission permission) {
    try {
      return bundle.hasPermission(permission);
    } catch (IllegalStateException e) {
      return false;
    }
  }
}

代码示例来源:origin: apache/felix

@Override
  public boolean implies(final Permission permission) {
    try {
      return bundle.hasPermission(permission);
    } catch (IllegalStateException e) {
      return false;
    }
  }
}

代码示例来源:origin: apache/felix

@Override
  public boolean implies(Permission permission) {
    try {
      return bundle.hasPermission(permission);
    } catch (IllegalStateException e) {
      return false;
    }
  }
}

代码示例来源:origin: org.eclipse.gemini.blueprint/gemini-blueprint-core

@Override
  public boolean implies(Permission permission) {
    return bundle.hasPermission(permission);
  }
}

代码示例来源:origin: org.eclipse/org.eclipse.osgi

public boolean hasPermission(Object permission) {
  Bundle current = systemBundle;
  if (current == null)
    return false;
  return current.hasPermission(permission);
}

代码示例来源:origin: apache/aries

public boolean implies(Permission permission) {
    try {
      return bundle.hasPermission(permission);
    } catch (IllegalStateException e) {
      return false;
    }
  }
}

代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.osgi

public boolean hasPermission(Object permission) {
  Bundle current = systemBundle;
  if (current == null)
    return false;
  return current.hasPermission(permission);
}

代码示例来源:origin: org.eclipse/osgi

public static void filterCapabilityPermissions(Collection<? extends BundleCapability> capabilities) {
  if (System.getSecurityManager() == null) {
    return;
  }
  for (Iterator<? extends BundleCapability> iCapabilities = capabilities.iterator(); iCapabilities.hasNext();) {
    BundleCapability capability = iCapabilities.next();
    Permission permission = getProvidePermission(capability);
    Bundle provider = capability.getRevision().getBundle();
    if (provider != null && !provider.hasPermission(permission)) {
      iCapabilities.remove();
    }
  }
}

代码示例来源:origin: org.eclipse.tycho/org.eclipse.osgi

public static void filterCapabilityPermissions(Collection<? extends BundleCapability> capabilities) {
  if (System.getSecurityManager() == null) {
    return;
  }
  for (Iterator<? extends BundleCapability> iCapabilities = capabilities.iterator(); iCapabilities.hasNext();) {
    BundleCapability capability = iCapabilities.next();
    Permission permission = getProvidePermission(capability);
    Bundle provider = capability.getRevision().getBundle();
    if (provider != null && !provider.hasPermission(permission)) {
      iCapabilities.remove();
    }
  }
}

代码示例来源:origin: org.osgi/org.amdatu.remote.admin.http

private void emitRemoteServiceAdminEvent(RemoteServiceAdminEvent event, EndpointDescription endpoint) {
  EndpointPermission permission =
    new EndpointPermission(endpoint, ServiceUtil.getFrameworkUUID(getBundleContext()), EndpointPermission.READ);
  for (Entry<ServiceReference<?>, RemoteServiceAdminListener> entry : m_listeners.entrySet()) {
    if (entry.getKey().getBundle().hasPermission(permission)) {
      logDebug("Calling RSA listener %s - %s", entry.getKey(), entry.getValue());
      entry.getValue().remoteAdminEvent(event);
    }
  }
}

代码示例来源:origin: com.github.veithen.cosmos.bootstrap/org.eclipse.osgi.compatibility.state

boolean checkCapabilityPermission(GenericDescription capability) {
    if (!checkPermissions)
      return true;
    Bundle bundle = capability.getSupplier().getBundle();
    return bundle == null ? false : bundle.hasPermission(new CapabilityPermission(capability.getType(), CapabilityPermission.PROVIDE));
  }
}

代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.osgi

boolean checkCapabilityPermission(GenericDescription capability) {
    if (!checkPermissions)
      return true;
    Bundle bundle = capability.getSupplier().getBundle();
    return bundle == null ? false : bundle.hasPermission(new CapabilityPermission(capability.getType(), CapabilityPermission.PROVIDE));
  }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.osgi.compatibility.state

boolean checkCapabilityPermission(GenericDescription capability) {
    if (!checkPermissions)
      return true;
    Bundle bundle = capability.getSupplier().getBundle();
    return bundle == null ? false : bundle.hasPermission(new CapabilityPermission(capability.getType(), CapabilityPermission.PROVIDE));
  }
}

代码示例来源:origin: org.eclipse/org.eclipse.osgi

boolean checkCapabilityPermission(GenericDescription capability) {
    if (!checkPermissions)
      return true;
    Bundle bundle = capability.getSupplier().getBundle();
    return bundle == null ? false : bundle.hasPermission(new CapabilityPermission(capability.getType(), CapabilityPermission.PROVIDE));
  }
}

代码示例来源:origin: org.eclipse/org.eclipse.osgi

boolean checkPackagePermission(ExportPackageDescription export) {
  if (!checkPermissions)
    return true;
  export.getSupplier().getBundle();
  Bundle bundle = export.getSupplier().getBundle();
  return bundle == null ? false : bundle.hasPermission(new PackagePermission(export.getName(), PackagePermission.EXPORTONLY));
}

代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.osgi

boolean checkPackagePermission(ExportPackageDescription export) {
  if (!checkPermissions)
    return true;
  export.getSupplier().getBundle();
  Bundle bundle = export.getSupplier().getBundle();
  return bundle == null ? false : bundle.hasPermission(new PackagePermission(export.getName(), PackagePermission.EXPORTONLY));
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.osgi.compatibility.state

boolean checkPackagePermission(ExportPackageDescription export) {
  if (!checkPermissions)
    return true;
  export.getSupplier().getBundle();
  Bundle bundle = export.getSupplier().getBundle();
  return bundle == null ? false : bundle.hasPermission(new PackagePermission(export.getName(), PackagePermission.EXPORTONLY));
}

代码示例来源:origin: com.github.veithen.cosmos.bootstrap/org.eclipse.osgi.compatibility.state

boolean checkPackagePermission(ExportPackageDescription export) {
  if (!checkPermissions)
    return true;
  export.getSupplier().getBundle();
  Bundle bundle = export.getSupplier().getBundle();
  return bundle == null ? false : bundle.hasPermission(new PackagePermission(export.getName(), PackagePermission.EXPORTONLY));
}

相关文章