/** * Grants all actions to a user, without locking the instance. When using this method, one must * lock the instance before, and unlock it after. * * @param user User to grant all actions to. * @throws IOException on I/O error. */ private void grantAllWithoutLock(FijiUser user) throws IOException { LOG.debug("Granting all permissions to user {} on instance '{}'.", user.getName(), mInstanceUri.toOrderedString()); FijiPermissions newPermissions = getPermissions(user); for (FijiPermissions.Action action : FijiPermissions.Action.values()) { newPermissions = newPermissions.addAction(action); } grantInstancePermissions(user, newPermissions); }
/** {@inheritDoc} */ @Override public void grantInstanceCreator(FijiUser user) throws IOException { lock(); try { Set<FijiUser> currentGrantors = getUsersWithPermission(FijiPermissions.Action.GRANT); // This can only be called if there are no grantors, right when the instance is created. if (currentGrantors.size() != 0) { throw new FijiAccessException( "Cannot add user " + user + " to grantors as the instance creator for instance '" + mInstanceUri.toOrderedString() + "' because there are already grantors for this instance."); } Set<FijiUser> newGrantor = Collections.singleton(user); putUsersWithPermission(FijiPermissions.Action.GRANT, newGrantor); grantAllWithoutLock(user); } finally { unlock(); } LOG.info("Creator permissions on instance '{}' granted to user {}.", mInstanceUri, user.getName()); }
mInstanceUri.toOrderedString(), user);