java.nio.file.attribute.AclEntry Class in Java
Last Updated :
28 Mar, 2022
ACL entries are Examined by this class is validating on the ACL model declared in RFC 3530: Network File System i.e.(NFS) version of 4th Protocol and having four components within it as follows characteristics as follows:
- This type of component are determining if the entry grants or denies its accessing
- The principal component is generally known as the "who" component, is an end user-principal similar to identifying if entry grants or denies is accessing or not
- The permissions section components is a set of within its permissions
- The flags component is a set of flags to indicating that how every entry are inheriting and invoking
Syntax:
public final class java.nio.file.attribute.AclEntry
extends Object
This ACL entry is all are create to use an associated AclEntry.Builder object by generating its builder method i.e. ACL entries are verified and are safe for usage of multiple concurrents method threads.
It is having the builder of AclEntry objects, as this Builder objects are accessed during one of the newBuilder methods was defined by the AclEntry class on it. These Builder objects are prefetch and are not safe for usable by multiple sub-concurrent threadings working without validating type of synchronization
Nested Summary Present in Class
Modifier and Type | Class and Description |
---|
static class | AclEntry.Builder - A builder of AclEntry within the objects |
Method Summary Present in Class
Method | Description |
---|
equals(Object ob) | Comparing these similar objects within this ACL entry for checking they are equal or not |
flags() | Returns a merged copy of the flag's components. |
hashCode() | Returning the hash-code value declared for these ACL entries. |
newBuilder() | Constructing a new builder sets. |
newBuilder(AclEntry entry) | Sets a new builder with the components of prefetching ACL entries. |
permissions() | invoking a copy of the sets of permissions component of it. |
principal() | Returning the principal's components. |
toString() | Returning the string classification of these ACL entries |
type() | Returning these ACL types of entries. |
Method Details Present in Class
A. newBuilder(): Sets a new builder. That has the initial value of the type and whose components are null and it has the initial value of the permissions and flags components is in the empty set.
Syntax:
public static AclEntry.Builder newBuilder()
Return Type: A newly created builder
B. newBuilder(): Creating a new builder with the components of accessing that ACL entries.
Syntax:
public static AclEntry.Builder newBuilder(AclEntry entry)
Parameters: Entry, an ACL entry
Return Type: A newly created builder
C. toString(): This string representation is returning this ACL entries overrides overriding toString in this class Objects
Syntax:
public String toString()
Return Type: Sets the string classification of this entry
D. type(): Sets the ACL and their entry types
Syntax:
public AclEntryType type()
E. principal(): Creating the principal's component
Syntax:
public UserPrincipal principal()
F. permissions(): Returning a prefetch copy of entries as ACL permissions components having sets are modified copy of the permissions
Syntax:
public Set< AclEntryPermission > permissions()
G. flags(): Returning a prefetched copy of the flag's components and the returning sets are modified copy of the flags.
Syntax:
public Set<AclEntryFlag> flags()
Example:
Java
// Java Program to Illustrate Syntax and Usage of AclEntry
// Class present inside java.nio.file.attribute Package
// through its classes and methods
public void Myserver(AclEntryPermission mode)
throws AccessDeniedException
{
UserPrincipal currentUser
= this.attributes.getCurrentUser();
GroupPrincipal currentGroup
= this.attributes.getCurrentGroup();
for (AclEntry entry : this.acl) {
UserPrincipal principal = entry.principal();
if (principal.equals(currentUser)
|| principal.equals(currentGroup)) {
Set<AclEntryPermission> sets permissions
= entry.permissions();
boolean applies = permissions.contains(mode);
// type(); is used
AclEntryType type = entry.type();
if (applies) {
if (type == ALLOW) {
return system.out.println(
"message = Hello GFG Readers !");
}
if (type == DENY) {
// to.String() is used
throw new AccessDeniedException(
this.path.toString());
}
}
}
}
}
Output:
Similar Reads
java.nio.file.attribute.FileTime Class in Java
The java.nio.file.attribute.FileTime class is used to get a value representing this file's timestamp i.e, the time when this file was last modified, accessed, or created. Class Declaration: public final class FileTime extends Object implements Comparable<FileTime>Methods: MethodDescriptioncomp
2 min read
java.nio.charset.Charset Class in Java
In Java, Charset is a mapping technique used in Java to map the 16-bit Unicode sequence and sequences of bytes. It is also used to encode and decode the string data text into different character encoding. It comes under java.nio.charset.Charset package. The charset must begin with a number or letter
2 min read
java.nio.Buffer Class in Java
The Buffer class provides a buffer or a container for data chunks of specific primitive types. A finite sequence of elements is stored linearly in a buffer. Important properties of a buffer that make it convenient to perform read and write operations in the data are: Capacity: This property determin
4 min read
java.nio.file.Paths Class in Java
java.nio.file.Paths class contains static methods for converting path string or URI into Path. Class declaration : public final class Paths extends ObjectMethods: MethodDescriptionget(String first, String... more) This method converts a path string, or a sequence of strings that when joined form a p
2 min read
java.nio.charset.CharsetEncoder Class in Java
For the purpose of character encoding and decoding, java offers a number of classes in the 'java.nio.charset' package. The 'CharsetEncoder' class of this package performs the important task of encoding. In this article, let us understand this class, its syntax, different methods, and some examples o
6 min read
java.nio.charset.CoderResult Class in Java
The 'java.nio.charset' package in Java contains classes for character encoding and decoding. The CoderResult class is used for determining the outcome of an encoding or decoding operation. Before we get started, let's review the ideas behind character encoding and decoding in CoderResult. The proces
6 min read
java.nio.file.FileStore Class in Java
Java.nio.file is a package in java that consists of the FileStore class. FileStore class is a class that provides methods for the purpose of performing some operations on file store. FileStore is a class that extends Object from java.lang package. And few methods the FileStore class can inherit from
4 min read
java.nio.FloatBuffer Class in Java
A Buffer object can be termed as a container for a fixed amount of data. The buffer acts as a storing box, or temporary staging area, where data can be stored and later retrieved according to the usage. Java Buffer classes are the foundation or base upon which java.nio is built. Float buffers are cr
4 min read
java.nio.file.FileSystem class in java
java.nio.file.FileSystem class provides an interface to a file system. The file system acts as a factory for creating different objects like Path, PathMatcher, UserPrincipalLookupService, and WatchService. This object help to access the files and other objects in the file system. Syntax: Class decla
4 min read
java.nio.charset.CodingErrorAction Class in Java
In Java programming, Character encoding plays an important when we talk about handling data and information across different systems. The java.nio.charset package contains classes for managing character encoding and decoding. CodingErrorAction class is one of the package's core classes. This class d
2 min read