org.apache.shiro.authz.permission.WildcardPermissionResolver类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(159)

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

WildcardPermissionResolver介绍

[英]PermissionResolver implementation that returns a new WildcardPermissionbased on the input string.
[中]PermissionResolver实现,基于输入字符串返回新的通配符Permission。

代码示例

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

@Test
public void testCaseInsensitive()
{
  WildcardPermissionResolver resolver = new WildcardPermissionResolver(false);
  assertFalse( "Sensitivity should be false", resolver.isCaseSensitive());
  /* this is a round-about test as permissions don't store case sensitivity just lower case 
  the string. */
  WildcardPermission permission = (WildcardPermission) resolver.resolvePermission( "Foo:*" );
  assertEquals( "string should be lowercase", "foo:*", permission.toString());
}

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

@Test
public void testCaseSensitiveToggle()
{
  WildcardPermissionResolver resolver = new WildcardPermissionResolver();
  assertFalse( "Default sensitivity should be false", resolver.isCaseSensitive());
  resolver.setCaseSensitive( true );
  assertTrue( "Sensitivity should be true", resolver.isCaseSensitive());
  resolver.setCaseSensitive( false );
  assertFalse( "Sensitivity should be false", resolver.isCaseSensitive());
}

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

public AuthorizingRealm(CacheManager cacheManager, CredentialsMatcher matcher) {
  super();
  if (cacheManager != null) setCacheManager(cacheManager);
  if (matcher != null) setCredentialsMatcher(matcher);
  this.authorizationCachingEnabled = true;
  this.permissionResolver = new WildcardPermissionResolver();
  int instanceNumber = INSTANCE_COUNT.getAndIncrement();
  this.authorizationCacheName = getClass().getName() + DEFAULT_AUTHORIZATION_CACHE_SUFFIX;
  if (instanceNumber > 0) {
    this.authorizationCacheName = this.authorizationCacheName + "." + instanceNumber;
  }
}

代码示例来源:origin: org.restcomm/restcomm-connect.http

WildcardPermissionResolver resolver = new WildcardPermissionResolver();
Permission neededPermission = resolver.resolvePermission(neededPermissionString);

代码示例来源:origin: be.c4j.ee.security.octopus/octopus-core

@Override
  public Permission resolvePermission(String permissionString) {
    Permission permission;
    if (permissionLookup == null && stringLookup == null) {
      if (permissionString.contains(":")) {
        permission = super.resolvePermission(permissionString);
      } else {
        permission = super.resolvePermission(permissionString + ":*:*");
      }
    } else {
      if (permissionLookup != null) {
        permission = permissionLookup.getPermission(permissionString);
      } else {
        permission = stringLookup.getPermission(permissionString);
      }
    }
    return permission;
  }
}

代码示例来源:origin: org.apache.shiro/shiro-core

public AuthorizingRealm(CacheManager cacheManager, CredentialsMatcher matcher) {
  super();
  if (cacheManager != null) setCacheManager(cacheManager);
  if (matcher != null) setCredentialsMatcher(matcher);
  this.authorizationCachingEnabled = true;
  this.permissionResolver = new WildcardPermissionResolver();
  int instanceNumber = INSTANCE_COUNT.getAndIncrement();
  this.authorizationCacheName = getClass().getName() + DEFAULT_AUTHORIZATION_CACHE_SUFFIX;
  if (instanceNumber > 0) {
    this.authorizationCacheName = this.authorizationCacheName + "." + instanceNumber;
  }
}

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

@Test
public void testDefaultIsNonCaseSensitive()
{
  WildcardPermissionResolver resolver = new WildcardPermissionResolver();
  assertFalse( "Default sensitivity should be false", resolver.isCaseSensitive());
  /* this is a round-about test as permissions don't store case sensitivity just lower case 
  the string. */
  WildcardPermission permission = (WildcardPermission) resolver.resolvePermission( "Foo:*" );
  assertEquals( "string should be lowercase", "foo:*", permission.toString());
}

代码示例来源:origin: stormpath/stormpath-shiro

/**
 * Creates a new instance, using the default {@link #getCustomDataFieldName() customDataFieldName} of
 * {@code apacheShiroPermissions} and a default {@link WildcardPermissionResolver}.
 */
public CustomDataPermissionResolver() {
  this.customDataFieldName = CustomDataPermissionsEditor.DEFAULT_CUSTOM_DATA_FIELD_NAME;
  this.permissionResolver = new WildcardPermissionResolver();
}

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

@Test
public void testCaseSensitive()
{
  WildcardPermissionResolver resolver = new WildcardPermissionResolver(true);
  assertTrue( "Sensitivity should be true", resolver.isCaseSensitive());
  /* this is a round-about test as permissions don't store case sensitivity just lower case 
  the string. */
  WildcardPermission permission = (WildcardPermission) resolver.resolvePermission( "Foo:*" );
  assertEquals( "string should be mixed case", "Foo:*", permission.toString());
}

代码示例来源:origin: stackoverflow.com

package org.apache.shiro.samples.web;

import org.apache.shiro.authz.Permission;
import org.apache.shiro.authz.permission.*;

import java.util.Collection;
import java.util.Collections;

public class SimpleRolePermissionResolver implements RolePermissionResolver, PermissionResolverAware {

  private PermissionResolver permissionResolver = new WildcardPermissionResolver();

  public void setPermissionResolver(PermissionResolver permissionResolver) {
    this.permissionResolver = permissionResolver;
  }

  public Collection<Permission> resolvePermissionsInRole(String roleString) {
    return Collections.<Permission>singleton(permissionResolver.resolvePermission(roleString));
  }
}

代码示例来源:origin: com.stormpath.shiro/stormpath-shiro-core

/**
 * Creates a new instance, using the default {@link #getCustomDataFieldName() customDataFieldName} of
 * {@code apacheShiroPermissions} and a default {@link WildcardPermissionResolver}.
 */
public CustomDataPermissionResolver() {
  this.customDataFieldName = CustomDataPermissionsEditor.DEFAULT_CUSTOM_DATA_FIELD_NAME;
  this.permissionResolver = new WildcardPermissionResolver();
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.shiro

public AuthorizingRealm() {
  this.authorizationCachingEnabled = true;
  this.permissionResolver = new WildcardPermissionResolver();
  int instanceNumber = INSTANCE_COUNT.getAndIncrement();
  this.authorizationCacheName = getClass().getName() + DEFAULT_AUTHORIZATION_CACHE_SUFFIX;
  if (instanceNumber > 0) {
    this.authorizationCacheName = this.authorizationCacheName + "." + instanceNumber;
  }
}

代码示例来源:origin: Rekoe/rk_svnadmin

public static void main(String[] args) {
    PermissionResolver permissionResolver = new WildcardPermissionResolver();

    System.out.println(permissionResolver.resolvePermission("*:*:*").implies(permissionResolver.resolvePermission("game.server")));
  }
}

相关文章