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

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

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

Permission.getActions介绍

[英]Returns the actions as a String. This is abstract so subclasses can defer creating a String representation until one is needed. Subclasses should always return actions in what they consider to be their canonical form. For example, two FilePermission objects created via the following:

perm1 = new FilePermission(p1,"read,write"); 
perm2 = new FilePermission(p2,"write,read");

both return "read,write" when the getActions method is invoked.
[中]以字符串形式返回操作。这是抽象的,所以子类可以推迟创建字符串表示,直到需要为止。子类应该总是以他们认为是规范的形式返回动作。例如,通过以下方式创建的两个FilePermission对象:

perm1 = new FilePermission(p1,"read,write"); 
perm2 = new FilePermission(p2,"write,read");

调用getActions方法时,这两个对象都返回“读、写”。

代码示例

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

/**
 * Returns the String representation of the action list.
 * 
 * @return Action list of this permission instance. It is always
 *         "privatearea".
 * @see java.security.Permission#getActions()
 */
public String getActions() {
  return delegate.getActions();
}

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

/**
 * Returns the String representation of the action list.
 * <p>
 * The method always gives back the actions in the following (alphabetical)
 * order:
 * {@code cancel, install, list, metadata, uninstall, uninstall_forced}
 * 
 * @return Action list of this permission instance. This is a
 *         comma-separated list that reflects the action parameter of the
 *         constructor.
 * @see java.security.Permission#getActions()
 */
public String getActions() {
  return delegate.getActions();
}

代码示例来源:origin: javaee-samples/javaee7-samples

private Set<String> filterRoles(HttpServletRequest request, PermissionCollection permissionCollection) {
  Set<String> roles = new HashSet<>();
  for (Permission permission : list(permissionCollection.elements())) {
    if (permission instanceof WebRoleRefPermission) {
      String role = permission.getActions();
      // Note that the WebRoleRefPermission is given for every Servlet in the application, even when
      // no role refs are used anywhere. This will also include Servlets like the default servlet and the
      // implicit JSP servlet. So if there are 2 application roles, and 3 application servlets, then 
      // at least 6 WebRoleRefPermission elements will be present in the collection.
      if (!roles.contains(role) && request.isUserInRole(role)) {
        roles.add(role);
      }
    }
  }
  return roles;
}

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

private void handlePermissionCheckEvent(SecurityPermissionCheckEvent event, StringBuilder stringBuilder) {
  handleDefiniteOutcomeEvent(event, stringBuilder);
  Permission permission = event.getPermission();
  stringBuilder.append(",permission=[type=").append(permission.getClass().getName());
  stringBuilder.append(",actions=").append(permission.getActions());
  stringBuilder.append(",name=").append(permission.getName()).append(']');
}

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

private void handlePermissionCheckEvent(SecurityPermissionCheckEvent event, JsonObjectBuilder objectBuilder) {
  handleDefiniteOutcomeEvent(event, objectBuilder);
  Permission permission = event.getPermission();
  JsonObjectBuilder permissionBuilder = Json.createObjectBuilder();
  permissionBuilder.add("type", permission.getClass().getName());
  permissionBuilder.add("actions", permission.getActions());
  permissionBuilder.add("name", permission.getName());
  objectBuilder.add("permission", permissionBuilder);
}

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

/**
 * Learn whether the permission matches in case of a revoked permission.
 * @param perm The permission to check against.
 */
boolean matches(final java.security.Permission perm) {
  if (!className.equals(perm.getClass().getName())) { //NOSONAR
    return false;
  }
  if (name != null) {
    if (name.endsWith("*")) {
      if (!perm.getName().startsWith(name.substring(0, name.length() - 1))) {
        return false;
      }
    } else if (!name.equals(perm.getName())) {
      return false;
    }
  }
  if (actions != null) {
    final Set<String> as = parseActions(perm.getActions());
    final int size = as.size();
    as.removeAll(actions);
    // If no actions removed, then all allowed
    return as.size() != size;
  }
  return true;
}

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

/**
 * Returns the String representation of the action list.<p>
 * The method always gives back the actions in the following (alphabetical) order: 
 * <code>cancel, install, list, metadata, uninstall, uninstall_forced</code>
 * 
 * @return Action list of this permission instance. This is a comma-separated 
 *         list that reflects the action parameter of the constructor.
 * @see java.security.Permission#getActions()
 */
public String getActions() {
  return delegate.getActions();
}

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

/**
 * Returns the String representation of the action list.
 * 
 * @return Action list of this permission instance. It is always "privatearea".
 * @see java.security.Permission#getActions()
 */
public String getActions() {
  return delegate.getActions();
}

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

@Override
public String getActions() {
  return badDefaultPermission.getActions();
}

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

actions = ((UnresolvedPermission) permission).getUnresolvedActions();
} else {
  actions = permission.getActions();

代码示例来源:origin: camunda/camunda-bpm-platform

if (log != null) {
  Permission perm = ace.getPermission();
  if (perm instanceof FilePermission && perm.getActions().equals("read")) {
    log.warning("Reading " + perm.getName() + " is not permitted. See \"per context logging\" in the default catalina.policy file.");

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

/**
 * Returns the String representation of the action list.
 * 
 * @return Action list of this permission instance. It is always
 *         "privatearea".
 * @see java.security.Permission#getActions()
 */
@Override
public String getActions() {
  return delegate.getActions();
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

/**
 * Returns the String representation of the action list.<p>
 * The method always gives back the actions in the following (alphabetical) order: 
 * {@code cancel, install, list, metadata, uninstall, uninstall_forced}
 * 
 * @return Action list of this permission instance. This is a comma-separated 
 *         list that reflects the action parameter of the constructor.
 * @see java.security.Permission#getActions()
 */
public String getActions() {
  return delegate.getActions();
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

/**
 * Returns the String representation of the action list.
 * 
 * @return Action list of this permission instance. It is always "privatearea".
 * @see java.security.Permission#getActions()
 */
public String getActions() {
  return delegate.getActions();
}

代码示例来源:origin: resteasy/Resteasy

permissionElement.appendChild(nameElement);
final String actions = permission.getActions();
if (actions != null && ! actions.isEmpty()) {
 final Element actionsElement = new Element("actions");

代码示例来源:origin: EvoSuite/evosuite

private String getPermissionType(Permission permission) {
  String name = permission.getName();
  String actions = permission.getActions();
  String type = "";
  if (actions != null && !actions.isEmpty()) {
    type += actions + " ";
  }
  if (name != null && !name.isEmpty()) {
    type += name;
  }
  return type;
}

代码示例来源:origin: org.mobicents.servers.jainslee.core/components

private void doPermDump(PermissionCollection pc, String string) {
  Enumeration<Permission> en = pc.elements();
  while (en.hasMoreElements()) {
    Permission p = en.nextElement();
    logger.info(string + "===>P:" + p.getClass() + " N:" + p.getName() + " A:" + p.getActions());
  }
}

代码示例来源:origin: com.intel.icecp/icecp-core

/**
 * @param permission the {@link Permission} to check against
 * @return true if the actions match, or this permission implies any set of
 * actions (e.g. *)
 */
private boolean hasMatchingActions(Permission permission) {
  return getActions().equals("*") || actionList.containsAll(parseActions(permission.getActions()));
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core

public boolean implies(Permission permission) {
  //TODO!
  return ( "*".equals( getName() ) || getName().equals( permission.getName() ) ) &&
    ( "*".equals(actions) || actions.indexOf( permission.getActions() ) >= 0 );
}

代码示例来源:origin: org.wildfly.security/wildfly-elytron-audit

private void handlePermissionCheckEvent(SecurityPermissionCheckEvent event, JsonObjectBuilder objectBuilder) {
  handleDefiniteOutcomeEvent(event, objectBuilder);
  Permission permission = event.getPermission();
  JsonObjectBuilder permissionBuilder = Json.createObjectBuilder();
  permissionBuilder.add("type", permission.getClass().getName());
  permissionBuilder.add("actions", permission.getActions());
  permissionBuilder.add("name", permission.getName());
  objectBuilder.add("permission", permissionBuilder);
}

相关文章