java.security.Permissions.add()方法的使用及代码示例

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

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

Permissions.add介绍

[英]Adds a permission object to the PermissionCollection for the class the permission belongs to. For example, if permission is a FilePermission, it is added to the FilePermissionCollection stored in this Permissions object. This method creates a new PermissionCollection object (and adds the permission to it) if an appropriate collection does not yet exist.
[中]将权限对象添加到该权限所属类的PermissionCollection中。例如,如果权限是FilePermission,则会将其添加到存储在此Permissions对象中的FilePermissionCollection中。如果适当的集合尚不存在,此方法将创建一个新的PermissionCollection对象(并向其添加权限)。

代码示例

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

  1. void addPermission(Permission perm) {
  2. perms.add(perm);
  3. }

代码示例来源:origin: google/guava

  1. void addPermission(Permission perm) {
  2. perms.add(perm);
  3. }

代码示例来源:origin: google/guava

  1. AdjustablePolicy(Permission... permissions) {
  2. for (Permission permission : permissions) perms.add(permission);
  3. }

代码示例来源:origin: ben-manes/caffeine

  1. AdjustablePolicy(Permission... permissions) {
  2. for (Permission permission : permissions) {
  3. perms.add(permission);
  4. }
  5. }
  6. void addPermission(Permission perm) { perms.add(perm); }

代码示例来源:origin: jankotek/mapdb

  1. AdjustablePolicy(Permission... permissions) {
  2. for (Permission permission : permissions)
  3. perms.add(permission);
  4. }
  5. void addPermission(Permission perm) { perms.add(perm); }

代码示例来源:origin: ben-manes/caffeine

  1. void addPermission(Permission perm) { perms.add(perm); }
  2. void clearPermissions() { perms = new Permissions(); }

代码示例来源:origin: jankotek/mapdb

  1. void addPermission(Permission perm) { perms.add(perm); }
  2. void clearPermissions() { perms = new Permissions(); }

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

  1. @Override
  2. public void addToExcludedPolicy(Permission permission) throws PolicyContextException {
  3. checkNotNullParam("permission", permission);
  4. synchronized (this) { // prevents state change while adding
  5. checkIfInOpenState();
  6. this.excludedPermissions.add(permission);
  7. }
  8. }

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

  1. @Override
  2. public void addToUncheckedPolicy(Permission permission) throws PolicyContextException {
  3. checkNotNullParam("permission", permission);
  4. synchronized (this) { // prevents state change while adding
  5. checkIfInOpenState();
  6. this.uncheckedPermissions.add(permission);
  7. }
  8. }

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

  1. } else {
  2. final java.security.Permission perm = createPermission(p);
  3. granted.add(perm);
  4. granted.add(new SocketPermission("localhost:1024-", "listen"));
  5. granted.add(new PropertyPermission("java.version", "read"));
  6. granted.add(new PropertyPermission("java.vendor", "read"));
  7. granted.add(new PropertyPermission("java.vendor.url", "read"));
  8. granted.add(new PropertyPermission("java.class.version", "read"));
  9. granted.add(new PropertyPermission("os.name", "read"));
  10. granted.add(new PropertyPermission("os.version", "read"));
  11. granted.add(new PropertyPermission("os.arch", "read"));
  12. granted.add(new PropertyPermission("file.encoding", "read"));
  13. granted.add(new PropertyPermission("file.separator", "read"));
  14. granted.add(new PropertyPermission("path.separator", "read"));
  15. granted.add(new PropertyPermission("line.separator", "read"));
  16. granted.add(new PropertyPermission("java.specification.version", "read"));
  17. granted.add(new PropertyPermission("java.specification.vendor", "read"));
  18. granted.add(new PropertyPermission("java.specification.name", "read"));
  19. granted.add(new PropertyPermission("java.vm.specification.version", "read"));
  20. granted.add(new PropertyPermission("java.vm.specification.vendor", "read"));
  21. granted.add(new PropertyPermission("java.vm.specification.name", "read"));
  22. granted.add(new PropertyPermission("java.vm.version", "read"));
  23. granted.add(new PropertyPermission("java.vm.vendor", "read"));
  24. granted.add(new PropertyPermission("java.vm.name", "read"));

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

  1. @Override
  2. public void addToRole(String roleName, Permission permission) throws PolicyContextException {
  3. checkNotNullParam("roleName", roleName);
  4. checkNotNullParam("permission", permission);
  5. synchronized (this) { // prevents state change while adding
  6. checkIfInOpenState();
  7. this.rolePermissions.computeIfAbsent(roleName, s -> new Permissions()).add(permission);
  8. }
  9. }

代码示例来源:origin: dlew/joda-time-android

  1. public PermissionCollection getPermissions(CodeSource codesource) {
  2. Permissions p = new Permissions();
  3. p.add(new AllPermission()); // enable everything
  4. return p;
  5. }
  6. public void refresh() {

代码示例来源:origin: dlew/joda-time-android

  1. public PermissionCollection getPermissions(CodeSource codesource) {
  2. Permissions p = new Permissions();
  3. p.add(new AllPermission()); // enable everything
  4. return p;
  5. }
  6. public void refresh() {

代码示例来源:origin: spring-projects/spring-framework

  1. perms.add(new AuthPermission("getSubject"));
  2. ProtectionDomain pd = new ProtectionDomain(null, perms);

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

  1. /**
  2. * Add dynamic {@link SocketPermission} for the specified port range.
  3. *
  4. * @param policy the {@link Permissions} instance to apply the dynamic {@link SocketPermission} to.
  5. * @param portRange the port range
  6. */
  7. private static void addSocketPermissionForPortRange(final Permissions policy, final String portRange) {
  8. // listen is always called with 'localhost' but use wildcard to be sure, no name service is consulted.
  9. // see SocketPermission implies() code
  10. policy.add(new SocketPermission("*:" + portRange, "listen,resolve"));
  11. }

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

  1. /**
  2. * Add access to single file path
  3. * @param policy current policy to add permissions to
  4. * @param path the path itself
  5. * @param permissions set of file permissions to grant to the path
  6. */
  7. @SuppressForbidden(reason = "only place where creating Java-9 compatible FilePermission objects is possible")
  8. public static void addSingleFilePath(Permissions policy, Path path, String permissions) throws IOException {
  9. policy.add(new FilePermission(path.toString(), permissions));
  10. if (VERSION_IS_AT_LEAST_JAVA_9 && Files.exists(path)) {
  11. // Java 9 FilePermission model requires this due to the removal of pathname canonicalization,
  12. // see also https://github.com/elastic/elasticsearch/issues/21534
  13. Path realPath = path.toRealPath();
  14. if (path.toString().equals(realPath.toString()) == false) {
  15. policy.add(new FilePermission(realPath.toString(), permissions));
  16. }
  17. }
  18. }

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

  1. policy.add(new FilePermission(path.toString(), permissions));
  2. policy.add(new FilePermission(path.toString() + path.getFileSystem().getSeparator() + "-", permissions));
  3. if (VERSION_IS_AT_LEAST_JAVA_9) {
  4. policy.add(new FilePermission(realPath.toString(), permissions));
  5. policy.add(new FilePermission(realPath.toString() + realPath.getFileSystem().getSeparator() + "-", permissions));

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

  1. void addToExcludedPolicy(Permission permission)
  2. throws PolicyContextException
  3. {
  4. excludedPermissions.add(permission);
  5. }

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

  1. void addToRole(String roleName, Permission permission)
  2. throws PolicyContextException
  3. {
  4. Permissions perms = rolePermissions.get(roleName);
  5. if( perms == null )
  6. {
  7. perms = new Permissions();
  8. rolePermissions.put(roleName, perms);
  9. }
  10. perms.add(permission);
  11. }

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

  1. private static PermissionCollection copyPermissions(PermissionCollection permissionCollection) {
  2. final Permissions permissions = new Permissions();
  3. final Enumeration<Permission> elements = permissionCollection.elements();
  4. while (elements.hasMoreElements()) {
  5. permissions.add(elements.nextElement());
  6. }
  7. permissions.setReadOnly();
  8. return permissions;
  9. }

相关文章