java.security.Permission.implies()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(10.2k)|赞(0)|评价(0)|浏览(111)

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

Permission.implies介绍

[英]Checks if the specified permission's actions are "implied by" this object's actions.

This must be implemented by subclasses of Permission, as they are the only ones that can impose semantics on a Permission object.

The implies method is used by the AccessController to determine whether or not a requested permission is implied by another permission that is known to be valid in the current execution context.
[中]检查指定权限的操作是否由该对象的操作“暗示”。
这必须由权限的子类实现,因为它们是唯一可以对权限对象施加语义的子类。
AccessController使用implies方法来确定请求的权限是否由另一个已知在当前执行上下文中有效的权限暗示。

代码示例

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

public boolean implies(final Permission permission) {
  for (Permission test : permissionsRef.get()) {
    if (test.implies(permission)) {
      return true;
    }
  }
  return false;
}

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

public boolean implies(final Permission permission) {
  for (Permission test : permissionsRef.get()) {
    if (test.implies(permission)) {
      return true;
    }
  }
  return false;
}

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

/**
 * Checks if this DeploymentCustomizerPermission would imply the parameter
 * permission. This permission implies another
 * DeploymentCustomizerPermission permission if:
 * 
 * <ul>
 * <li>both of them has the "privatearea" action (other actions are not
 * allowed) and</li>
 * <li>their filters (only name attribute is allowed in the filters) match
 * similarly to {@link DeploymentAdminPermission}.</li>
 * </ul>
 * 
 * The value of the name attribute means Bundle Symbolic Name and not
 * Deployment Package Symbolic Name here!
 * <p>
 * 
 * @param permission Permission to check.
 * @return true if this DeploymentCustomizerPermission object implies the
 *         specified permission.
 * @see java.security.Permission#implies(java.security.Permission)
 */
public boolean implies(Permission permission) {
  if (!(permission instanceof DeploymentCustomizerPermission))
    return false;
  DeploymentCustomizerPermission dcp = (DeploymentCustomizerPermission) permission;
  return delegate.implies(dcp.delegate);
}

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

return delegate.implies(dap.delegate);

代码示例来源:origin: languagetool-org/languagetool

@Override
public boolean implies(Permission p) {
 for (Permission perm : perms) {
  if (perm.implies(p)) {
   return true;
  }
 }
 return false;
}
@Override

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

public boolean implies(final Permission permission) {
    if (permission == null || getSourcePermission().getClass() != permission.getClass()) {
      return false;
    }
    final Permission all = this.all;
    if (all != null) {
      return all.implies(permission);
    }
    final Permission ourPermission = byName.get(permission.getName());
    return ourPermission != null && ourPermission.implies(permission);
  }
}

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

/**
   * Indicates whether the argument permission is implied by the permissions
   * contained in the receiver.
   *
   * @return boolean <code>true</code> if the argument permission is implied
   *         by the permissions in the receiver, and <code>false</code> if
   *         it is not.
   * @param permission
   *            java.security.Permission the permission to check
   */
  public boolean implies(Permission permission) {
    for (Enumeration elements = elements(); elements.hasMoreElements();) {
      if (((Permission)elements.nextElement()).implies(permission)) {
        return true;
      }
    }
    return false;
  }
}

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

/**
 * Try a permission check.  Any violations will be logged to the {@code org.wildfly.security.access} category
 * at a {@code DEBUG} level.
 *
 * @param permission the permission to check
 * @param domains the protection domains to try
 * @return {@code true} if the access check succeeded, {@code false} otherwise
 */
public static boolean tryCheckPermission(final Permission permission, final ProtectionDomain... domains) {
  if (permission.implies(SECURITY_MANAGER_PERMISSION)) {
    return false;
  }
  final Context ctx = CTX.get();
  if (ctx.checking) {
    if (ctx.entered) {
      return true;
    }
    ctx.entered = true;
    try {
      final ProtectionDomain deniedDomain = findAccessDenial(permission, domains);
      if (deniedDomain != null) {
        return false;
      }
    } finally {
      ctx.entered = false;
    }
  }
  return true;
}

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

/**
 * Adds a permission to the DmtPrincipalPermissionCollection.
 * 
 * @param permission the Permission object to add
 * @exception IllegalArgumentException if the permission is not a
 *            DmtPrincipalPermission
 * @exception SecurityException if this DmtPrincipalPermissionCollection
 *            object has been marked readonly
 */
public void add(Permission permission) {
  if (!(permission instanceof DmtPrincipalPermission))
    throw new IllegalArgumentException("Cannot add permission, invalid permission type: " + permission);
  if (isReadOnly())
    throw new SecurityException("Cannot add permission, collection is marked read-only.");
  // only add new permission if it is not already implied by the
  // permissions in the collection
  if (!implies(permission)) {
    // remove all permissions that are implied by the new one
    Iterator i = perms.iterator();
    while (i.hasNext())
      if (permission.implies((DmtPrincipalPermission) i.next()))
        i.remove();
    // no need to synchronize because all adds are done sequentially
    // before any implies() calls
    perms.add(permission);
  }
}

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

/**
 * Adds a permission to the DmtAlertPermissionCollection.
 * 
 * @param permission the Permission object to add
 * @exception IllegalArgumentException if the permission is not a
 *            AlertPermission
 * @exception SecurityException if this DmtAlertPermissionCollection object
 *            has been marked readonly
 */
public void add(Permission permission) {
  if (!(permission instanceof AlertPermission))
    throw new IllegalArgumentException("Cannot add permission, invalid permission type: " + permission);
  if (isReadOnly())
    throw new SecurityException("Cannot add permission, collection is marked read-only.");
  // only add new permission if it is not already implied by the
  // permissions in the collection
  if (!implies(permission)) {
    // remove all permissions that are implied by the new one
    Iterator i = perms.iterator();
    while (i.hasNext())
      if (permission.implies((AlertPermission) i.next()))
        i.remove();
    // no need to synchronize because all adds are done sequentially
    // before any implies() calls
    perms.add(permission);
  }
}

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

public boolean implies(Permission p) {
 for (Iterator<Permission> i = perms.iterator(); i.hasNext();) {
  if (((Permission) i.next()).implies(p)) {
   return true;
  }
 }
 return false;
}

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

oldVal = readVal;
for (Permission test : oldVal) {
  if (test.implies(permission)) {
    return;

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

if (perm.implies(SECURITY_MANAGER_PERMISSION)) {
  throw access.secMgrChange();

代码示例来源:origin: groovy/groovy-core

protected void executeScript(Class scriptClass, Permission missingPermission) {
  try {
    Script script = InvokerHelper.createScript(scriptClass, new Binding());
    script.run();
    //InvokerHelper.runScript(scriptClass, null);
  } catch (AccessControlException ace) {
    if (missingPermission != null && missingPermission.implies(ace.getPermission())) {
      return;
    } else {
      fail(ace.toString());
    }
  }
  if (missingPermission != null) {
    fail("Should catch an AccessControlException");
  }
}

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

/**
 * Checks if this DeploymentCustomizerPermission would imply the parameter permission.
 * This permission implies another DeploymentCustomizerPermission permission if:
 * 
 * <ul>
 *         <li>both of them has the "privatearea" action (other actions are not allowed) and</li>
 *         <li>their filters (only name attribute is allowed in the filters) match similarly to 
 *         {@link DeploymentAdminPermission}.</li>
 * </ul>
 * 
 * The value of the name attribute means Bundle Symbolic Name and not Deployment Package 
 * Symbolic Name here!<p>
 * 
 * @param permission Permission to check.
 * @return true if this DeploymentCustomizerPermission object implies the 
 * specified permission.
 * @see java.security.Permission#implies(java.security.Permission)
 */
public boolean implies(Permission permission) {
  if (!(permission instanceof DeploymentCustomizerPermission))
    return false;
      
  DeploymentCustomizerPermission dcp = (DeploymentCustomizerPermission) permission;
  
  return delegate.implies(dcp.delegate);
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
public final boolean implies(Permission permission) {
  return preImplies.test(permission) && badDefaultPermission.implies(permission);
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
  public boolean implies(ProtectionDomain domain, Permission permission) {
    if (BAD_DEFAULT_NUMBER_ONE.implies(permission) || BAD_DEFAULT_NUMBER_TWO.implies(permission)) {
      return false;
    }
    return delegate.implies(domain, permission);
  }
}

代码示例来源:origin: groovy/groovy-core

if (failure.thrownException() instanceof AccessControlException) {
  AccessControlException ace = (AccessControlException) failure.thrownException();
  if (missingPermission.implies(ace.getPermission())) {
    continue;

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

/**
 * Adds a permission to the DmtPrincipalPermissionCollection.
 * 
 * @param permission the Permission object to add
 * @exception IllegalArgumentException if the permission is not a
 *            DmtPrincipalPermission
 * @exception SecurityException if this DmtPrincipalPermissionCollection
 *            object has been marked readonly
 */
public void add(Permission permission) {
  if (!(permission instanceof DmtPrincipalPermission))
    throw new IllegalArgumentException(
        "Cannot add permission, invalid permission type: "
            + permission);
  if (isReadOnly())
    throw new SecurityException(
        "Cannot add permission, collection is marked read-only.");
  // only add new permission if it is not already implied by the
  // permissions in the collection
  if (!implies(permission)) {
    // remove all permissions that are implied by the new one
    Iterator i = perms.iterator();
    while (i.hasNext())
      if (permission.implies((DmtPrincipalPermission) i.next()))
        i.remove();
    // no need to synchronize because all adds are done sequentially
    // before any implies() calls
    perms.add(permission);
  }
}

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

/**
 * Adds a permission to the DmtAlertPermissionCollection.
 * 
 * @param permission the Permission object to add
 * @exception IllegalArgumentException if the permission is not a
 *            AlertPermission
 * @exception SecurityException if this DmtAlertPermissionCollection object
 *            has been marked readonly
 */
public void add(Permission permission) {
  if (!(permission instanceof AlertPermission))
    throw new IllegalArgumentException(
        "Cannot add permission, invalid permission type: "
            + permission);
  if (isReadOnly())
    throw new SecurityException(
        "Cannot add permission, collection is marked read-only.");
  // only add new permission if it is not already implied by the
  // permissions in the collection
  if (!implies(permission)) {
    // remove all permissions that are implied by the new one
    Iterator i = perms.iterator();
    while (i.hasNext())
      if (permission.implies((AlertPermission) i.next()))
        i.remove();
    // no need to synchronize because all adds are done sequentially
    // before any implies() calls
    perms.add(permission);
  }
}

相关文章