@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]); }
@Override public boolean isPermitted(PrincipalCollection subjectPrincipal, String permission) { for (Realm realm : getRealms()) { if (!(realm instanceof Authorizer)) { continue; } try { if (((Authorizer) realm).isPermitted(subjectPrincipal, permission)) { if (logger.isTraceEnabled()) { logger.trace("Realm: " + realm.getName() + " user: " + subjectPrincipal.iterator().next() + " has permission: " + permission); } return true; } else { if (logger.isTraceEnabled()) { logger.trace("Realm: " + realm.getName() + " user: " + subjectPrincipal.iterator().next() + " does NOT have permission: " + permission); } } } catch (AuthorizationException e) { logAndIgnore(realm, e); } catch (RuntimeException e) { logAndIgnore(realm, e); } } return false; }
ExceptionCatchingModularRealmAuthorizer extends ModularRealmAuthorizer { @Override public boolean isPermitted(PrincipalCollection subjectPrincipal, String permission) { for (Realm realm : getRealms()) { if (!(realm instanceof Authorizer)) { continue; } try { if (((Authorizer) realm).isPermitted(subjectPrincipal, permission)) { if (logger.isTraceEnabled()) { logger.trace("Realm: " + realm.getName() + " user: " + subjectPrincipal.iterator().next() + " has permission: " + permission); } return true; } else { if (logger.isTraceEnabled()) { logger.trace("Realm: " + realm.getName() + " user: " + subjectPrincipal.iterator().next() + " does NOT have permission: " + permission); } } } catch (AuthorizationException e) { logAndIgnore(realm, e); } catch (RuntimeException e) { logAndIgnore(realm, e); } } return false; } }
ExceptionCatchingModularRealmAuthorizer extends ModularRealmAuthorizer { @Override public boolean isPermitted(PrincipalCollection subjectPrincipal, String permission) { for (Realm realm : getRealms()) { if (!(realm instanceof Authorizer)) { continue; } try { if (((Authorizer) realm).isPermitted(subjectPrincipal, permission)) { if (logger.isTraceEnabled()) { logger.trace("Realm: " + realm.getName() + " user: " + subjectPrincipal.iterator().next() + " has permission: " + permission); } return true; } else { if (logger.isTraceEnabled()) { logger.trace("Realm: " + realm.getName() + " user: " + subjectPrincipal.iterator().next() + " does NOT have permission: " + permission); } } } catch (AuthorizationException e) { logAndIgnore(realm, e); } catch (RuntimeException e) { logAndIgnore(realm, e); } } return false; } ExceptionCatchingModularRealmAuthorizer(Collection<Realm> realms); @Inject  ExceptionCatchingModularRealmAuthorizer(final Collection<Realm> realms, 
                                                 final Provider<RolePermissionResolver> rolePermissionResolverProvider); }
ExceptionCatchingModularRealmAuthorizer extends ModularRealmAuthorizer { @Override public boolean isPermitted(PrincipalCollection subjectPrincipal, String permission) { for (Realm realm : getRealms()) { if (!(realm instanceof Authorizer)) { continue; } try { if (((Authorizer) realm).isPermitted(subjectPrincipal, permission)) { if (logger.isTraceEnabled()) { logger.trace("Realm: " + realm.getName() + " user: " + subjectPrincipal.iterator().next() + " has permission: " + permission); } return true; } else { if (logger.isTraceEnabled()) { logger.trace("Realm: " + realm.getName() + " user: " + subjectPrincipal.iterator().next() + " does NOT have permission: " + permission); } } } catch (AuthorizationException e) { logAndIgnore(realm, e); } catch (RuntimeException e) { logAndIgnore(realm, e); } } return false; } ExceptionCatchingModularRealmAuthorizer(Collection<Realm> realms); @Inject  ExceptionCatchingModularRealmAuthorizer(final Collection<Realm> realms, 
                                                 final Provider<RolePermissionResolver> rolePermissionResolverProvider); @Override RolePermissionResolver getRolePermissionResolver(); @Override void checkPermission(PrincipalCollection subjectPrincipal, String permission); @Override void checkPermission(PrincipalCollection subjectPrincipal, Permission permission); @Override void checkPermissions(PrincipalCollection subjectPrincipal, String... permissions); @Override void checkPermissions(PrincipalCollection subjectPrincipal, Collection<Permission> permissions); @Override void checkRole(PrincipalCollection subjectPrincipal, String roleIdentifier); @Override void checkRoles(PrincipalCollection subjectPrincipal, Collection<String> roleIdentifiers); @Override boolean hasAllRoles(PrincipalCollection subjectPrincipal, Collection<String> roleIdentifiers); @Override boolean hasRole(PrincipalCollection subjectPrincipal, String roleIdentifier); @Override boolean[] hasRoles(PrincipalCollection subjectPrincipal, List<String> roleIdentifiers); @Override boolean isPermitted(PrincipalCollection subjectPrincipal, String permission); @Override boolean isPermitted(PrincipalCollection subjectPrincipal, Permission permission); @Override boolean[] isPermitted(PrincipalCollection subjectPrincipal, String... permissions); @Override boolean[] isPermitted(PrincipalCollection subjectPrincipal, List<Permission> permissions); @Override boolean isPermittedAll(PrincipalCollection subjectPrincipal, String... permissions); @Override boolean isPermittedAll(PrincipalCollection subjectPrincipal, Collection<Permission> permissions); }
ExceptionCatchingModularRealmAuthorizer extends ModularRealmAuthorizer { @Override public boolean isPermitted(PrincipalCollection subjectPrincipal, String permission) { for (Realm realm : getRealms()) { if (!(realm instanceof Authorizer)) { continue; } try { if (((Authorizer) realm).isPermitted(subjectPrincipal, permission)) { if (logger.isTraceEnabled()) { logger.trace("Realm: " + realm.getName() + " user: " + subjectPrincipal.iterator().next() + " has permission: " + permission); } return true; } else { if (logger.isTraceEnabled()) { logger.trace("Realm: " + realm.getName() + " user: " + subjectPrincipal.iterator().next() + " does NOT have permission: " + permission); } } } catch (AuthorizationException e) { logAndIgnore(realm, e); } catch (RuntimeException e) { logAndIgnore(realm, e); } } return false; } ExceptionCatchingModularRealmAuthorizer(Collection<Realm> realms); @Inject  ExceptionCatchingModularRealmAuthorizer(final Collection<Realm> realms, 
                                                 final Provider<RolePermissionResolver> rolePermissionResolverProvider); @Override RolePermissionResolver getRolePermissionResolver(); @Override void checkPermission(PrincipalCollection subjectPrincipal, String permission); @Override void checkPermission(PrincipalCollection subjectPrincipal, Permission permission); @Override void checkPermissions(PrincipalCollection subjectPrincipal, String... permissions); @Override void checkPermissions(PrincipalCollection subjectPrincipal, Collection<Permission> permissions); @Override void checkRole(PrincipalCollection subjectPrincipal, String roleIdentifier); @Override void checkRoles(PrincipalCollection subjectPrincipal, Collection<String> roleIdentifiers); @Override boolean hasAllRoles(PrincipalCollection subjectPrincipal, Collection<String> roleIdentifiers); @Override boolean hasRole(PrincipalCollection subjectPrincipal, String roleIdentifier); @Override boolean[] hasRoles(PrincipalCollection subjectPrincipal, List<String> roleIdentifiers); @Override boolean isPermitted(PrincipalCollection subjectPrincipal, String permission); @Override boolean isPermitted(PrincipalCollection subjectPrincipal, Permission permission); @Override boolean[] isPermitted(PrincipalCollection subjectPrincipal, String... permissions); @Override boolean[] isPermitted(PrincipalCollection subjectPrincipal, List<Permission> permissions); @Override boolean isPermittedAll(PrincipalCollection subjectPrincipal, String... permissions); @Override boolean isPermittedAll(PrincipalCollection subjectPrincipal, Collection<Permission> permissions);  }