/** * Constructs a default {@link CreateOptions}. */ private CreateOptions(String authUmask) { mAcl = null; mCreateParent = false; mEnsureAtomic = false; // default owner and group are null (unset) mOwner = null; mGroup = null; mMode = ModeUtils.applyFileUMask(Mode.defaults(), authUmask); }
private CompleteUfsFileOptions(AlluxioConfiguration alluxioConf) { mOwner = SecurityUtils.getOwnerFromLoginModule(alluxioConf); mGroup = SecurityUtils.getGroupFromLoginModule(alluxioConf); mMode = ModeUtils.applyFileUMask(Mode.defaults(), alluxioConf.get(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK)); // TODO(chaomin): set permission based on the alluxio file. Not needed for now since the // file is always created with default permission. } }
private CreateUfsFileOptions(AlluxioConfiguration alluxioConf) { mOwner = SecurityUtils.getOwnerFromLoginModule(alluxioConf); mGroup = SecurityUtils.getGroupFromLoginModule(alluxioConf); mMode = ModeUtils.applyFileUMask(Mode.defaults(), alluxioConf .get(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK)); // TODO(chaomin): set permission based on the alluxio file. Not needed for now since the // file is always created with default permission. } }
private OutStreamOptions(AlluxioConfiguration alluxioConf) { mBlockSizeBytes = alluxioConf.getBytes(PropertyKey.USER_BLOCK_SIZE_BYTES_DEFAULT); mTtl = Constants.NO_TTL; mTtlAction = TtlAction.DELETE; mLocationPolicy = CommonUtils.createNewClassInstance(alluxioConf.<FileWriteLocationPolicy>getClass( PropertyKey.USER_FILE_WRITE_LOCATION_POLICY), new Class[] {AlluxioConfiguration.class}, new Object[] {alluxioConf}); mWriteTier = alluxioConf.getInt(PropertyKey.USER_FILE_WRITE_TIER_DEFAULT); mWriteType = alluxioConf.getEnum(PropertyKey.USER_FILE_WRITE_TYPE_DEFAULT, WriteType.class); mOwner = SecurityUtils.getOwnerFromLoginModule(alluxioConf); mGroup = SecurityUtils.getGroupFromLoginModule(alluxioConf); mMode = ModeUtils.applyFileUMask(Mode.defaults(), alluxioConf .get(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK)); mMountId = IdUtils.INVALID_MOUNT_ID; mReplicationDurable = alluxioConf.getInt(PropertyKey.USER_FILE_REPLICATION_DURABLE); mReplicationMax = alluxioConf.getInt(PropertyKey.USER_FILE_REPLICATION_MAX); mReplicationMin = alluxioConf.getInt(PropertyKey.USER_FILE_REPLICATION_MIN); }
/** * Tests the {@link MutableInodeFile#getMode()} method. */ @Test public void permissionStatus() { MutableInodeFile inode1 = createInodeFile(1); assertEquals(TEST_OWNER, inode1.getOwner()); assertEquals(TEST_GROUP, inode1.getGroup()); assertEquals(ModeUtils.applyFileUMask(Mode.defaults(), ServerConfiguration.get(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK)).toShort(), inode1.getMode()); } }
/** * Tests for default {@link CreateOptions}. */ @Test public void defaults() throws IOException { CreateOptions options = CreateOptions.defaults(mConfiguration); assertFalse(options.getCreateParent()); assertFalse(options.isEnsureAtomic()); assertNull(options.getOwner()); assertNull(options.getGroup()); String umask = mConfiguration.get(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK); assertEquals(ModeUtils.applyFileUMask(Mode.defaults(), umask), options.getMode()); }
/** * @return Master side defaults for {@link CreateFilePOptions} */ public static CreateFilePOptions createFileDefaults() { return CreateFilePOptions.newBuilder() .setCommonOptions(commonDefaults()) .setRecursive(false) .setBlockSizeBytes(ServerConfiguration.getBytes(PropertyKey.USER_BLOCK_SIZE_BYTES_DEFAULT)) .setFileWriteLocationPolicy( ServerConfiguration.get(PropertyKey.USER_FILE_WRITE_LOCATION_POLICY)) .setWriteTier(ServerConfiguration.getInt(PropertyKey.USER_FILE_WRITE_TIER_DEFAULT)) .setWriteType(ServerConfiguration .getEnum(PropertyKey.USER_FILE_WRITE_TYPE_DEFAULT, WriteType.class).toProto()) .setMode(ModeUtils.applyFileUMask(Mode.defaults(), ServerConfiguration.get(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK)).toProto()) .setReplicationDurable(ServerConfiguration .getInt(PropertyKey.USER_FILE_REPLICATION_DURABLE)) .setReplicationMin(ServerConfiguration.getInt(PropertyKey.USER_FILE_REPLICATION_MIN)) .setReplicationMax(ServerConfiguration.getInt(PropertyKey.USER_FILE_REPLICATION_MAX)) .build(); }
/** * Tests for building an {@link CreateOptions} with a security enabled * configuration. */ @Test public void securityEnabled() throws IOException { mConfiguration.set(PropertyKey.SECURITY_AUTHENTICATION_TYPE, AuthType.SIMPLE.getAuthName()); mConfiguration.set(PropertyKey.SECURITY_LOGIN_USERNAME, "foo"); // Use IdentityUserGroupMapping to map user "foo" to group "foo". mConfiguration.set(PropertyKey.SECURITY_GROUP_MAPPING_CLASS, IdentityUserGroupsMapping.class.getName()); CreateOptions options = CreateOptions.defaults(mConfiguration); assertFalse(options.getCreateParent()); assertFalse(options.isEnsureAtomic()); assertNull(options.getOwner()); assertNull(options.getGroup()); String umask = mConfiguration.get(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK); assertEquals(ModeUtils.applyFileUMask(Mode.defaults(), umask), options.getMode()); }
/** * Tests that building an {@link OutStreamOptions} with the defaults works. */ @Test public void defaults() throws IOException { AlluxioStorageType alluxioType = AlluxioStorageType.STORE; UnderStorageType ufsType = UnderStorageType.SYNC_PERSIST; mConf.set(PropertyKey.USER_BLOCK_SIZE_BYTES_DEFAULT, "64MB"); mConf.set(PropertyKey.USER_FILE_WRITE_TYPE_DEFAULT, WriteType.CACHE_THROUGH.toString()); mConf.set(PropertyKey.USER_FILE_WRITE_TIER_DEFAULT, Constants.LAST_TIER); OutStreamOptions options = OutStreamOptions.defaults(mConf); assertEquals(alluxioType, options.getAlluxioStorageType()); assertEquals(64 * Constants.MB, options.getBlockSizeBytes()); assertTrue(options.getLocationPolicy() instanceof LocalFirstPolicy); assertEquals("test_user", options.getOwner()); assertEquals("test_group", options.getGroup()); assertEquals(ModeUtils.applyFileUMask(Mode.defaults(), mConf.get(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK)), options.getMode()); assertEquals(Constants.NO_TTL, options.getTtl()); assertEquals(TtlAction.DELETE, options.getTtlAction()); assertEquals(ufsType, options.getUnderStorageType()); assertEquals(WriteType.CACHE_THROUGH, options.getWriteType()); assertEquals(Constants.LAST_TIER, options.getWriteTier()); }