当前位置: 首页>>代码示例>>Java>>正文


Java InvalidPermissionStringException类代码示例

本文整理汇总了Java中org.apache.shiro.authz.permission.InvalidPermissionStringException的典型用法代码示例。如果您正苦于以下问题:Java InvalidPermissionStringException类的具体用法?Java InvalidPermissionStringException怎么用?Java InvalidPermissionStringException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


InvalidPermissionStringException类属于org.apache.shiro.authz.permission包,在下文中一共展示了InvalidPermissionStringException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolvePermission

import org.apache.shiro.authz.permission.InvalidPermissionStringException; //导入依赖的package包/类
private EmoPermission resolvePermission(String permission) {
    try {
        // All permissions returned by the resolver are EmoPermissions
        return (EmoPermission) _permissionResolver.resolvePermission(permission);
    } catch (InvalidPermissionStringException e) {
        // Permission string was invalid; convert to the API exception
        throw new InvalidEmoPermissionException(e.getMessage(), e.getPermissionString());
    }
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:10,代码来源:LocalSubjectUserAccessControl.java

示例2: MatchingPermission

import org.apache.shiro.authz.permission.InvalidPermissionStringException; //导入依赖的package包/类
protected MatchingPermission(String permission, boolean initializePermission) {
    _permission = checkNotNull(permission, "permission");
    if ("".equals(permission.trim())) {
        throw new InvalidPermissionStringException("Permission must be a non-null, non-empty string", permission);
    }

    if (initializePermission) {
        initializePermission();
    }
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:11,代码来源:MatchingPermission.java

示例3: ShiroWildcardPermission

import org.apache.shiro.authz.permission.InvalidPermissionStringException; //导入依赖的package包/类
/**
 * Creates an instance.
 * 
 * @param permissionString  the permission string, not null
 * @throws InvalidPermissionStringException if the permission string is invalid
 */
private ShiroWildcardPermission(final String permissionString) {
  String permStr = StringUtils.stripToNull(permissionString);
  if (permStr == null) {
    throw new InvalidPermissionStringException("Permission string must not be blank: " + permissionString, permissionString);
  }
  // case insensitive
  permStr = permStr.toLowerCase(Locale.ROOT);
  // split once
  List<Set<String>> wildcardSegments = new ArrayList<>();
  String[] segmentStrs = StringUtils.splitPreserveAllTokens(permStr, ':');
  for (String segmentStr : segmentStrs) {
    String[] partStrs = StringUtils.splitPreserveAllTokens(segmentStr, ',');
    if (partStrs.length == 0) {
      throw new InvalidPermissionStringException("Permission string must not contain an empty segment: " + permissionString, permissionString);
    }
    Set<String> parts = new LinkedHashSet<>();
    for (String partStr : partStrs) {
      partStr = partStr.trim();
      if (partStr.isEmpty()) {
        throw new InvalidPermissionStringException("Permission string must not contain an empty part: " + permissionString, permissionString);
      }
      if (partStr.contains("*") && partStr.equals("*") == false) {
        throw new InvalidPermissionStringException("Permission string wildcard can only be applied to whole segment: " + permissionString, permissionString);
      }
      parts.add(partStr);
    }
    // simplify
    if (parts.contains("*")) {
      wildcardSegments.add(WILDCARD_SEGMENT);
    } else {
      _segments.addAll(wildcardSegments);
      wildcardSegments.clear();
      _segments.add(parts);
    }
  }
  _hashCode = _segments.hashCode();
  _toString = createToString(_segments);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:45,代码来源:ShiroWildcardPermission.java

示例4: testNonConstantInitialScopeRejected

import org.apache.shiro.authz.permission.InvalidPermissionStringException; //导入依赖的package包/类
@Test (expectedExceptions = InvalidPermissionStringException.class)
public void testNonConstantInitialScopeRejected() {
    _resolver.resolvePermission("s*");
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:5,代码来源:EmoPermissionTest.java

示例5: testNarrowedWildcardScopeRejected

import org.apache.shiro.authz.permission.InvalidPermissionStringException; //导入依赖的package包/类
@Test (expectedExceptions = InvalidPermissionStringException.class)
public void testNarrowedWildcardScopeRejected() {
    _resolver.resolvePermission("*|update");
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:5,代码来源:EmoPermissionTest.java

示例6: testInvalidActionCondition

import org.apache.shiro.authz.permission.InvalidPermissionStringException; //导入依赖的package包/类
@Test (expectedExceptions = InvalidPermissionStringException.class)
public void testInvalidActionCondition() {
    _resolver.resolvePermission("sor|if(intrinsic(\"~table\":\"foo\"))");
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:5,代码来源:EmoPermissionTest.java

示例7: testInvalidTableCondition

import org.apache.shiro.authz.permission.InvalidPermissionStringException; //导入依赖的package包/类
@Test (expectedExceptions = InvalidPermissionStringException.class)
public void testInvalidTableCondition() {
    _resolver.resolvePermission("sor|*|if(intrinsic(\"~id\":~))");
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:5,代码来源:EmoPermissionTest.java

示例8: validated

import org.apache.shiro.authz.permission.InvalidPermissionStringException; //导入依赖的package包/类
/**
 * Validates that a permission string can be resolved.
 */
private String validated(String permissionString)
        throws InvalidPermissionStringException {
    _permissionResolver.resolvePermission(permissionString);
    return permissionString;
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:9,代码来源:TablePermissionManagerDAO.java

示例9: test_of_null

import org.apache.shiro.authz.permission.InvalidPermissionStringException; //导入依赖的package包/类
@Test(expectedExceptions = InvalidPermissionStringException.class)
public void test_of_null() {
  ShiroWildcardPermission.of(null);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:5,代码来源:ShiroWildcardPermissionTest.java

示例10: test_of_empty

import org.apache.shiro.authz.permission.InvalidPermissionStringException; //导入依赖的package包/类
@Test(expectedExceptions = InvalidPermissionStringException.class)
public void test_of_empty() {
  ShiroWildcardPermission.of("");
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:5,代码来源:ShiroWildcardPermissionTest.java

示例11: test_of_blank

import org.apache.shiro.authz.permission.InvalidPermissionStringException; //导入依赖的package包/类
@Test(expectedExceptions = InvalidPermissionStringException.class)
public void test_of_blank() {
  ShiroWildcardPermission.of("   ");
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:5,代码来源:ShiroWildcardPermissionTest.java

示例12: test_of_onlyColons

import org.apache.shiro.authz.permission.InvalidPermissionStringException; //导入依赖的package包/类
@Test(expectedExceptions = InvalidPermissionStringException.class)
public void test_of_onlyColons() {
  ShiroWildcardPermission.of("::");
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:5,代码来源:ShiroWildcardPermissionTest.java

示例13: test_of_onlyCommas

import org.apache.shiro.authz.permission.InvalidPermissionStringException; //导入依赖的package包/类
@Test(expectedExceptions = InvalidPermissionStringException.class)
public void test_of_onlyCommas() {
  ShiroWildcardPermission.of("a:,:b");
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:5,代码来源:ShiroWildcardPermissionTest.java

示例14: test_of_invalidWildcard

import org.apache.shiro.authz.permission.InvalidPermissionStringException; //导入依赖的package包/类
@Test(expectedExceptions = InvalidPermissionStringException.class)
public void test_of_invalidWildcard() {
  ShiroWildcardPermission.of("a:beta*");
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:5,代码来源:ShiroWildcardPermissionTest.java

示例15: setParts

import org.apache.shiro.authz.permission.InvalidPermissionStringException; //导入依赖的package包/类
protected void setParts(String wildcardString) {
    if (Objects.isNull( wildcardString) || wildcardString.trim().isEmpty()) {
        throw new InvalidPermissionStringException("string cannot be null or empty.", wildcardString);
    }


    wildcardString = wildcardString.trim();

    int indexOfColon = wildcardString.indexOf(":");

    if (indexOfColon < 0) {
        throw new IllegalArgumentException("Client permission must be prefixed with the permission type.");
    }

    setType(wildcardString.substring(0, indexOfColon));

    wildcardString = wildcardString.substring(indexOfColon + 1);

    if ( wildcardString.trim().isEmpty()) {
        throw new InvalidPermissionStringException("string cannot be null or empty.", wildcardString);
    }

    if(wildcardString.contains(PART_DIVIDER_TOKEN+PART_DIVIDER_TOKEN) || wildcardString.endsWith(PART_DIVIDER_TOKEN)){
        throw new InvalidPermissionStringException("permission string cannot" +
                " contain parts with only dividers. Make sure permission strings" +
                " are properly formatted ", wildcardString);

    }

    if (wildcardString.isEmpty()) {
        throw new IllegalArgumentException("Client permission string cannot contain only dividers. Make sure permission strings are properly formatted.");
    }

    this.parts = Arrays.asList(wildcardString.split(Pattern.quote(PART_DIVIDER_TOKEN)));


}
 
开发者ID:caricah,项目名称:iotracah,代码行数:38,代码来源:IOTPermission.java


注:本文中的org.apache.shiro.authz.permission.InvalidPermissionStringException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。