本文整理汇总了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());
}
}
示例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();
}
}
示例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);
}
示例4: testNonConstantInitialScopeRejected
import org.apache.shiro.authz.permission.InvalidPermissionStringException; //导入依赖的package包/类
@Test (expectedExceptions = InvalidPermissionStringException.class)
public void testNonConstantInitialScopeRejected() {
_resolver.resolvePermission("s*");
}
示例5: testNarrowedWildcardScopeRejected
import org.apache.shiro.authz.permission.InvalidPermissionStringException; //导入依赖的package包/类
@Test (expectedExceptions = InvalidPermissionStringException.class)
public void testNarrowedWildcardScopeRejected() {
_resolver.resolvePermission("*|update");
}
示例6: testInvalidActionCondition
import org.apache.shiro.authz.permission.InvalidPermissionStringException; //导入依赖的package包/类
@Test (expectedExceptions = InvalidPermissionStringException.class)
public void testInvalidActionCondition() {
_resolver.resolvePermission("sor|if(intrinsic(\"~table\":\"foo\"))");
}
示例7: testInvalidTableCondition
import org.apache.shiro.authz.permission.InvalidPermissionStringException; //导入依赖的package包/类
@Test (expectedExceptions = InvalidPermissionStringException.class)
public void testInvalidTableCondition() {
_resolver.resolvePermission("sor|*|if(intrinsic(\"~id\":~))");
}
示例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;
}
示例9: test_of_null
import org.apache.shiro.authz.permission.InvalidPermissionStringException; //导入依赖的package包/类
@Test(expectedExceptions = InvalidPermissionStringException.class)
public void test_of_null() {
ShiroWildcardPermission.of(null);
}
示例10: test_of_empty
import org.apache.shiro.authz.permission.InvalidPermissionStringException; //导入依赖的package包/类
@Test(expectedExceptions = InvalidPermissionStringException.class)
public void test_of_empty() {
ShiroWildcardPermission.of("");
}
示例11: test_of_blank
import org.apache.shiro.authz.permission.InvalidPermissionStringException; //导入依赖的package包/类
@Test(expectedExceptions = InvalidPermissionStringException.class)
public void test_of_blank() {
ShiroWildcardPermission.of(" ");
}
示例12: test_of_onlyColons
import org.apache.shiro.authz.permission.InvalidPermissionStringException; //导入依赖的package包/类
@Test(expectedExceptions = InvalidPermissionStringException.class)
public void test_of_onlyColons() {
ShiroWildcardPermission.of("::");
}
示例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");
}
示例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*");
}
示例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)));
}