本文整理了Java中alluxio.security.authorization.Mode.defaults()
方法的一些代码示例,展示了Mode.defaults()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mode.defaults()
方法的具体详情如下:
包路径:alluxio.security.authorization.Mode
类名称:Mode
方法名:defaults
[英]Gets the default mode.
[中]获取默认模式。
代码示例来源:origin: Alluxio/alluxio
/**
* Constructs a default {@link MkdirsOptions}.
*/
private MkdirsOptions(String authUmask) {
// By default create parent is true.
mCreateParent = true;
// default owner and group are null (unset)
mOwner = null;
mGroup = null;
mMode = ModeUtils.applyDirectoryUMask(Mode.defaults(), authUmask);
}
代码示例来源:origin: Alluxio/alluxio
/**
* 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);
}
代码示例来源:origin: Alluxio/alluxio
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.
}
}
代码示例来源:origin: Alluxio/alluxio
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.
}
}
代码示例来源:origin: Alluxio/alluxio
@Test
public void defaults() {
Mode mode = Mode.defaults();
assertEquals(Constants.DEFAULT_FILE_SYSTEM_MODE, mode.toShort());
}
代码示例来源:origin: Alluxio/alluxio
/**
* Tests the {@link Mode#getUMask()} method to thrown an exception when it is not an integer.
*/
@Test
public void umaskNotInteger() {
String umask = "NotInteger";
mThrown.expect(IllegalArgumentException.class);
mThrown.expectMessage(ExceptionMessage.INVALID_CONFIGURATION_VALUE.getMessage(umask,
PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK));
ModeUtils.applyDirectoryUMask(Mode.defaults(), umask);
}
代码示例来源:origin: Alluxio/alluxio
/**
* @return Master side defaults for {@link CreateDirectoryPOptions}
*/
public static CreateDirectoryPOptions createDirectoryDefaults() {
return CreateDirectoryPOptions.newBuilder()
.setCommonOptions(commonDefaults())
.setMode(ModeUtils.applyDirectoryUMask(Mode.defaults(),
ServerConfiguration.get(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK)).toProto())
.setRecursive(false)
.setWriteType(ServerConfiguration
.getEnum(PropertyKey.USER_FILE_WRITE_TYPE_DEFAULT, WriteType.class).toProto())
.setAllowExists(false).build();
}
代码示例来源:origin: Alluxio/alluxio
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);
}
代码示例来源:origin: Alluxio/alluxio
/**
* Tests the {@link Mode#getUMask()} method to thrown an exception when it exceeds the length.
*/
@Test
public void umaskExceedLength() {
String umask = "00022";
mConfiguration.set(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK, umask);
mThrown.expect(IllegalArgumentException.class);
mThrown.expectMessage(ExceptionMessage.INVALID_CONFIGURATION_VALUE.getMessage(umask,
PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK));
ModeUtils.applyDirectoryUMask(Mode.defaults(), mConfiguration
.get(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK));
}
代码示例来源:origin: Alluxio/alluxio
/**
* Tests the {@link Mode#toShort()} method.
*/
@Test
public void toShort() {
Mode mode = new Mode(Mode.Bits.ALL, Mode.Bits.READ_EXECUTE, Mode.Bits.READ_EXECUTE);
assertEquals(0755, mode.toShort());
mode = Mode.defaults();
assertEquals(0777, mode.toShort());
mode = new Mode(Mode.Bits.READ_WRITE, Mode.Bits.READ, Mode.Bits.READ);
assertEquals(0644, mode.toShort());
}
代码示例来源:origin: Alluxio/alluxio
/**
* Tests the {@link Mode#Mode(Mode)} constructor.
*/
@Test
public void copyConstructor() {
Mode mode = new Mode(Mode.defaults());
assertEquals(Mode.Bits.ALL, mode.getOwnerBits());
assertEquals(Mode.Bits.ALL, mode.getGroupBits());
assertEquals(Mode.Bits.ALL, mode.getOtherBits());
assertEquals(0777, mode.toShort());
}
代码示例来源:origin: Alluxio/alluxio
/**
* Tests the {@link Mode#equals(Object)} method.
*/
@Test
public void equals() {
Mode allAccess = new Mode((short) 0777);
assertTrue(allAccess.equals(Mode.defaults()));
Mode noAccess = new Mode((short) 0000);
assertTrue(noAccess.equals(Mode.createNoAccess()));
assertFalse(allAccess.equals(noAccess));
}
代码示例来源:origin: Alluxio/alluxio
/**
* Tests the {@link MutableInodeDirectory#getMode()} method.
*/
@Test
public void permissionStatus() {
MutableInodeDirectory inode2 = createInodeDirectory();
Assert.assertEquals(TEST_OWNER, inode2.getOwner());
Assert.assertEquals(TEST_GROUP, inode2.getGroup());
Assert.assertEquals(ModeUtils.applyDirectoryUMask(Mode.defaults(),
ServerConfiguration.get(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK)).toShort(),
inode2.getMode());
}
代码示例来源:origin: Alluxio/alluxio
/**
* Tests the {@link Mode#getUMask()} and
* {@link Mode#applyUMask(Mode)} methods.
*/
@Test
public void umask() {
String umask = "0022";
Mode mode = ModeUtils.applyDirectoryUMask(Mode.defaults(), umask);
assertEquals(Mode.Bits.ALL, mode.getOwnerBits());
assertEquals(Mode.Bits.READ_EXECUTE, mode.getGroupBits());
assertEquals(Mode.Bits.READ_EXECUTE, mode.getOtherBits());
assertEquals(0755, mode.toShort());
}
代码示例来源:origin: Alluxio/alluxio
/**
* 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());
}
}
代码示例来源:origin: Alluxio/alluxio
/**
* Tests for default {@link MkdirsOptions}.
*/
@Test
public void defaults() throws IOException {
MkdirsOptions options = MkdirsOptions.defaults(mConfiguration);
// Verify the default createParent is true.
assertTrue(options.getCreateParent());
// Verify that the owner and group are not set.
assertNull(options.getOwner());
assertNull(options.getGroup());
String umask = mConfiguration.get(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK);
assertEquals(ModeUtils.applyDirectoryUMask(Mode.defaults(), umask), options.getMode());
}
代码示例来源:origin: Alluxio/alluxio
/**
* 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());
}
代码示例来源:origin: Alluxio/alluxio
/**
* @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();
}
代码示例来源:origin: Alluxio/alluxio
/**
* 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());
}
代码示例来源:origin: Alluxio/alluxio
/**
* Tests for building an {@link MkdirsOptions} with a security enabled
* configuration.
*/
@Test
public void securityEnabled() throws IOException {
InstancedConfiguration conf = new InstancedConfiguration(ConfigurationUtils.defaults());
conf.set(PropertyKey.SECURITY_AUTHENTICATION_TYPE, AuthType.SIMPLE.getAuthName());
conf.set(PropertyKey.SECURITY_LOGIN_USERNAME, "foo");
// Use IdentityUserGroupMapping to map user "foo" to group "foo".
conf.set(PropertyKey.SECURITY_GROUP_MAPPING_CLASS,
IdentityUserGroupsMapping.class.getName());
MkdirsOptions options = MkdirsOptions.defaults(mConfiguration);
// Verify the default createParent is true.
assertTrue(options.getCreateParent());
// Verify that the owner and group are not set.
assertNull(options.getOwner());
assertNull(options.getGroup());
String umask = mConfiguration.get(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK);
assertEquals(ModeUtils.applyDirectoryUMask(Mode.defaults(), umask), options.getMode());
}
内容来源于网络,如有侵权,请联系作者删除!