@Test public void testAllowsNonExistingUser() { assertFalse(impersonation.allows(createSubject(new PrincipalImpl("nonExisting")))); }
@Override public boolean allows(@NotNull Subject subject) { if (subject == null) { return false; } Set<String> principalNames = new HashSet<>(); for (Principal principal : subject.getPrincipals()) { principalNames.add(principal.getName()); } boolean allows = getImpersonatorNames().removeAll(principalNames); if (!allows) { for (Principal principal : subject.getPrincipals()) { if (isAdmin(principal)) { allows = true; break; } } } return allows; }
ImpersonationImpl implements Impersonation, UserConstants { @Override public boolean allows(@NotNull Subject subject) { if (subject == null) { return false; } Set<String> principalNames = new HashSet<>(); for (Principal principal : subject.getPrincipals()) { principalNames.add(principal.getName()); } boolean allows = getImpersonatorNames().removeAll(principalNames); if (!allows) { for (Principal principal : subject.getPrincipals()) { if (isAdmin(principal)) { allows = true; break; } } } return allows; } }
ImpersonationImpl implements Impersonation, UserConstants { @Override public boolean allows(@NotNull Subject subject) { if (subject == null) { return false; } Set<String> principalNames = new HashSet<>(); for (Principal principal : subject.getPrincipals()) { principalNames.add(principal.getName()); } boolean allows = getImpersonatorNames().removeAll(principalNames); if (!allows) { for (Principal principal : subject.getPrincipals()) { if (isAdmin(principal)) { allows = true; break; } } } return allows; } ImpersonationImpl(@NotNull UserImpl user); }
ImpersonationImpl implements Impersonation, UserConstants { @Override public boolean allows(@NotNull Subject subject) { if (subject == null) { return false; } Set<String> principalNames = new HashSet<>(); for (Principal principal : subject.getPrincipals()) { principalNames.add(principal.getName()); } boolean allows = getImpersonatorNames().removeAll(principalNames); if (!allows) { for (Principal principal : subject.getPrincipals()) { if (isAdmin(principal)) { allows = true; break; } } } return allows; } ImpersonationImpl(@NotNull UserImpl user); @NotNull @Override PrincipalIterator getImpersonators(); @Override boolean grantImpersonation(@NotNull Principal principal); @Override boolean revokeImpersonation(@NotNull Principal principal); @Override boolean allows(@NotNull Subject subject); }
ImpersonationImpl implements Impersonation, UserConstants { @Override public boolean allows(@NotNull Subject subject) { if (subject == null) { return false; } Set<String> principalNames = new HashSet<>(); for (Principal principal : subject.getPrincipals()) { principalNames.add(principal.getName()); } boolean allows = getImpersonatorNames().removeAll(principalNames); if (!allows) { for (Principal principal : subject.getPrincipals()) { if (isAdmin(principal)) { allows = true; break; } } } return allows; } ImpersonationImpl(@NotNull UserImpl user); @NotNull @Override PrincipalIterator getImpersonators(); @Override boolean grantImpersonation(@NotNull Principal principal); @Override boolean revokeImpersonation(@NotNull Principal principal); @Override boolean allows(@NotNull Subject subject);  }