List of usage examples for org.apache.shiro.authz.permission WildcardPermission WildcardPermission
public WildcardPermission(String wildcardString, boolean caseSensitive)
From source file:com.gemstone.gemfire.internal.security.shiro.GeodePermissionResolver.java
License:Apache License
@Override public Permission resolvePermission(final String permissionString) { return new WildcardPermission(permissionString, true); }
From source file:com.gemstone.gemfire.management.internal.security.GfshCommandsSecurityTest.java
License:Apache License
private void runCommandsWithAndWithout(String permission) throws Exception { List<TestCommand> allPermitted = TestCommand.getPermittedCommands(new WildcardPermission(permission, true)); for (TestCommand permitted : allPermitted) { LogService.getLogger().info("Processing authorized command: " + permitted.getCommand()); gfsh.executeCommand(permitted.getCommand()); CommandResult result = (CommandResult) gfsh.getResult(); assertNotNull(result);//from ww w . j a va 2 s . c o m if (result.getResultData() instanceof ErrorResultData) { assertNotEquals(ResultBuilder.ERRORCODE_UNAUTHORIZED, ((ErrorResultData) result.getResultData()).getErrorCode()); } else { assertEquals(Result.Status.OK, result.getStatus()); } } List<TestCommand> others = TestCommand.getCommands(); others.removeAll(allPermitted); for (TestCommand other : others) { // skip no permission commands if (other.getPermission() == null) continue; LogService.getLogger().info("Processing unauthorized command: " + other.getCommand()); gfsh.executeCommand(other.getCommand()); CommandResult result = (CommandResult) gfsh.getResult(); int errorCode = ((ErrorResultData) result.getResultData()).getErrorCode(); // for some commands there are pre execution checks to check for user input error, will skip those commands if (errorCode == ResultBuilder.ERRORCODE_USER_ERROR) { LogService.getLogger().info("Skip user error: " + result.getContent()); continue; } assertEquals(ResultBuilder.ERRORCODE_UNAUTHORIZED, ((ErrorResultData) result.getResultData()).getErrorCode()); String resultMessage = result.getContent().toString(); String permString = other.getPermission().toString(); assertTrue(resultMessage + " does not contain " + permString, resultMessage.contains(permString)); } }
From source file:org.apache.activemq.shiro.authz.ActiveMQWildcardPermissionTest.java
License:Apache License
protected static boolean matches(String pattern, String value) { ActiveMQWildcardPermission patternPerm = new ActiveMQWildcardPermission(pattern); WildcardPermission valuePerm = new WildcardPermission(value, true); return patternPerm.implies(valuePerm); }
From source file:org.apache.geode.management.internal.security.GfshCommandsSecurityTest.java
License:Apache License
private void runCommandsWithAndWithout(String permission) throws Exception { List<TestCommand> allPermitted = TestCommand.getPermittedCommands(new WildcardPermission(permission, true)); for (TestCommand permitted : allPermitted) { LogService.getLogger().info("Processing authorized command: " + permitted.getCommand()); gfsh.executeCommand(permitted.getCommand()); CommandResult result = (CommandResult) gfsh.getResult(); assertNotNull(result);//www .j av a 2 s. c om if (result.getResultData() instanceof ErrorResultData) { assertNotEquals(ResultBuilder.ERRORCODE_UNAUTHORIZED, ((ErrorResultData) result.getResultData()).getErrorCode()); } else { assertEquals(Result.Status.OK, result.getStatus()); } } List<TestCommand> others = TestCommand.getCommands(); others.removeAll(allPermitted); for (TestCommand other : others) { // skip no permission commands if (other.getPermission() == null) continue; LogService.getLogger().info("Processing unauthorized command: " + other.getCommand()); gfsh.executeCommand(other.getCommand()); CommandResult result = (CommandResult) gfsh.getResult(); int errorCode = ((ErrorResultData) result.getResultData()).getErrorCode(); // for some commands there are pre execution checks to check for user input error, will skip // those commands if (errorCode == ResultBuilder.ERRORCODE_USER_ERROR) { LogService.getLogger().info("Skip user error: " + result.getContent()); continue; } assertEquals(ResultBuilder.ERRORCODE_UNAUTHORIZED, ((ErrorResultData) result.getResultData()).getErrorCode()); String resultMessage = result.getContent().toString(); String permString = other.getPermission().toString(); assertTrue(resultMessage + " does not contain " + permString, resultMessage.contains(permString)); } }