@Test(expected = IllegalArgumentException.class) public void testCannotGrantPermissionForServiceUser() { ByteBuffer username = service.tokens .identify(service.tokens.serviceIssue()); service.grant(username, Permission.READ, Random.getSimpleString()); }
public void grant(ByteBuffer username, Permission permission, String environment) { lock.writeLock().lock(); try { Verify.thatArgument(getRole(username) != Role.SERVICE, "Cannot grant a permission to a service user"); User user = getUserStrict(username); user.grant(permission, environment); } finally { lock.writeLock().unlock(); } }
UserService { public void grant(ByteBuffer username, Permission permission, String environment) { lock.writeLock().lock(); try { Verify.thatArgument(getRole(username) != Role.SERVICE, "Cannot grant a permission to a service user"); User user = getUserStrict(username); user.grant(permission, environment); } finally { lock.writeLock().unlock(); } } }
UserService { public void grant(ByteBuffer username, Permission permission, String environment) { lock.writeLock().lock(); try { Verify.thatArgument(getRole(username) != Role.SERVICE, "Cannot grant a permission to a service user"); User user = getUserStrict(username); user.grant(permission, environment); } finally { lock.writeLock().unlock(); } } @SuppressWarnings("unchecked") private  UserService(String backingStore, int accessTokenTtl,
            TimeUnit accessTokenTtlUnit); }
UserService { public void grant(ByteBuffer username, Permission permission, String environment) { lock.writeLock().lock(); try { Verify.thatArgument(getRole(username) != Role.SERVICE, "Cannot grant a permission to a service user"); User user = getUserStrict(username); user.grant(permission, environment); } finally { lock.writeLock().unlock(); } } @SuppressWarnings("unchecked") private  UserService(String backingStore, int accessTokenTtl,
            TimeUnit accessTokenTtlUnit); static UserService create(String backingStore); boolean authenticate(ByteBuffer username, ByteBuffer password); boolean can(ByteBuffer username, Permission permission,
            String environment); void create(ByteBuffer username, ByteBuffer password, Role role); void delete(ByteBuffer username); void disable(ByteBuffer username); void enable(ByteBuffer username); boolean exists(ByteBuffer username); void forEachUser(Consumer<ByteBuffer> consumer); Role getRole(ByteBuffer username); void grant(ByteBuffer username, Permission permission,
            String environment); boolean isEnabled(ByteBuffer username); void revoke(ByteBuffer username, String environment); void setPassword(ByteBuffer username, ByteBuffer password); void setRole(ByteBuffer username, Role role); }
UserService { public void grant(ByteBuffer username, Permission permission, String environment) { lock.writeLock().lock(); try { Verify.thatArgument(getRole(username) != Role.SERVICE, "Cannot grant a permission to a service user"); User user = getUserStrict(username); user.grant(permission, environment); } finally { lock.writeLock().unlock(); } } @SuppressWarnings("unchecked") private  UserService(String backingStore, int accessTokenTtl,
            TimeUnit accessTokenTtlUnit); static UserService create(String backingStore); boolean authenticate(ByteBuffer username, ByteBuffer password); boolean can(ByteBuffer username, Permission permission,
            String environment); void create(ByteBuffer username, ByteBuffer password, Role role); void delete(ByteBuffer username); void disable(ByteBuffer username); void enable(ByteBuffer username); boolean exists(ByteBuffer username); void forEachUser(Consumer<ByteBuffer> consumer); Role getRole(ByteBuffer username); void grant(ByteBuffer username, Permission permission,
            String environment); boolean isEnabled(ByteBuffer username); void revoke(ByteBuffer username, String environment); void setPassword(ByteBuffer username, ByteBuffer password); void setRole(ByteBuffer username, Role role); final AccessTokenManager tokens; }