List of usage examples for org.apache.shiro.authz.permission AllPermission AllPermission
AllPermission
From source file:com.bennavetta.appsite.security.ObjectifyRealm.java
License:Apache License
@Override protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { log.trace("Loading authorization info for {}", principals); Set<String> roles = new HashSet<>(); Set<Permission> permissions = new HashSet<>(); for (Object principal : principals.fromRealm(REALM_NAME)) // they're each strings {/*from ww w . j av a 2 s . c om*/ User user = ofy().load().type(User.class).id(principal.toString()).get(); log.trace("Found user {}", user); roles.addAll(user.getRoles()); for (String permStr : user.getPermissions()) { if (permStr.equals("all")) { permissions.add(new AllPermission()); } else { permissions.add(new WildcardPermission(permStr)); } } } SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); info.setRoles(roles); info.setObjectPermissions(permissions); log.trace("Authorization info loaded: {}", info); return info; }
From source file:org.atteo.moonshine.shiro.simple.AdminSimpleAccountRealm.java
License:Apache License
public void addAccount(String username, String password, boolean isAdmin, String... roles) { Set<String> roleNames = CollectionUtils.asSet(roles); Set<Permission> permissions = null; if (isAdmin) { permissions = Sets.<Permission>newHashSet(new AllPermission()); }/* w w w. ja v a2s. c o m*/ SimpleAccount account = new SimpleAccount(username, password, getName(), roleNames, permissions); add(account); }
From source file:org.graylog2.security.realm.GraylogSimpleAccountRealm.java
License:Open Source License
public void addRootAccount(String username, String password) { LOG.debug("Adding root account named {}, having all permissions", username); add(new SimpleAccount(username, password, getName(), CollectionUtils.asSet("root"), CollectionUtils.<Permission>asSet(new AllPermission()))); }
From source file:org.graylog2.security.realm.RootAccountRealm.java
License:Open Source License
private void addRootAccount(String username, String password) { LOG.debug("Adding root account named {}, having all permissions", username); add(new SimpleAccount(username, password, getName(), CollectionUtils.asSet("root"), CollectionUtils.<Permission>asSet(new AllPermission()))); }
From source file:org.sonatype.nexus.security.authz.ExceptionCatchingModularRealmAuthorizerTest.java
License:Open Source License
@Test public void ignoreRuntimeException() throws Exception { ExceptionCatchingModularRealmAuthorizer subject = new ExceptionCatchingModularRealmAuthorizer( Collections.<Realm>singleton(BROKEN_REALM)); Permission permission = new AllPermission(); Assert.assertFalse(subject.isPermitted(null, "")); Assert.assertFalse(subject.isPermitted(null, permission)); Assert.assertFalse(subject.isPermitted(null, new String[] { "" })[0]); Assert.assertFalse(subject.isPermitted(null, Collections.singletonList(permission))[0]); }