Path: blob/master/src/java.base/share/classes/java/nio/file/attribute/FileOwnerAttributeView.java
41161 views
/*1* Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.nio.file.attribute;2627import java.io.IOException;2829/**30* A file attribute view that supports reading or updating the owner of a file.31* This file attribute view is intended for file system implementations that32* support a file attribute that represents an identity that is the owner of33* the file. Often the owner of a file is the identity of the entity that34* created the file.35*36* <p> The {@link #getOwner getOwner} or {@link #setOwner setOwner} methods may37* be used to read or update the owner of the file.38*39* <p> The {@link java.nio.file.Files#getAttribute getAttribute} and40* {@link java.nio.file.Files#setAttribute setAttribute} methods may also be41* used to read or update the owner. In that case, the owner attribute is42* identified by the name {@code "owner"}, and the value of the attribute is43* a {@link UserPrincipal}.44*45* @since 1.746*/4748public interface FileOwnerAttributeView49extends FileAttributeView50{51/**52* Returns the name of the attribute view. Attribute views of this type53* have the name {@code "owner"}.54*/55@Override56String name();5758/**59* Read the file owner.60*61* <p> It is implementation specific if the file owner can be a {@link62* GroupPrincipal group}.63*64* @return the file owner65*66* @throws IOException67* if an I/O error occurs68* @throws SecurityException69* In the case of the default provider, a security manager is70* installed, and it denies {@link71* RuntimePermission}{@code ("accessUserInformation")} or its72* {@link SecurityManager#checkRead(String) checkRead} method73* denies read access to the file.74*/75UserPrincipal getOwner() throws IOException;7677/**78* Updates the file owner.79*80* <p> It is implementation specific if the file owner can be a {@link81* GroupPrincipal group}. To ensure consistent and correct behavior82* across platforms it is recommended that this method should only be used83* to set the file owner to a user principal that is not a group.84*85* @param owner86* the new file owner87*88* @throws IOException89* if an I/O error occurs, or the {@code owner} parameter is a90* group and this implementation does not support setting the owner91* to a group92* @throws SecurityException93* In the case of the default provider, a security manager is94* installed, and it denies {@link95* RuntimePermission}{@code ("accessUserInformation")} or its96* {@link SecurityManager#checkWrite(String) checkWrite} method97* denies write access to the file.98*/99void setOwner(UserPrincipal owner) throws IOException;100}101102103