Path: blob/master/src/java.base/share/classes/java/nio/file/attribute/UserPrincipalLookupService.java
41161 views
/*1* Copyright (c) 2007, 2009, 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* An object to lookup user and group principals by name. A {@link UserPrincipal}31* represents an identity that may be used to determine access rights to objects32* in a file system. A {@link GroupPrincipal} represents a <em>group identity</em>.33* A {@code UserPrincipalLookupService} defines methods to lookup identities by34* name or group name (which are typically user or account names). Whether names35* and group names are case sensitive or not depends on the implementation.36* The exact definition of a group is implementation specific but typically a37* group represents an identity created for administrative purposes so as to38* determine the access rights for the members of the group. In particular it is39* implementation specific if the <em>namespace</em> for names and groups is the40* same or is distinct. To ensure consistent and correct behavior across41* platforms it is recommended that this API be used as if the namespaces are42* distinct. In other words, the {@link #lookupPrincipalByName43* lookupPrincipalByName} should be used to lookup users, and {@link44* #lookupPrincipalByGroupName lookupPrincipalByGroupName} should be used to45* lookup groups.46*47* @since 1.748*49* @see java.nio.file.FileSystem#getUserPrincipalLookupService50*/5152public abstract class UserPrincipalLookupService {5354/**55* Initializes a new instance of this class.56*/57protected UserPrincipalLookupService() {58}5960/**61* Lookup a user principal by name.62*63* @param name64* the string representation of the user principal to lookup65*66* @return a user principal67*68* @throws UserPrincipalNotFoundException69* the principal does not exist70* @throws IOException71* if an I/O error occurs72* @throws SecurityException73* In the case of the default provider, and a security manager is74* installed, it checks75* {@link RuntimePermission}{@code ("lookupUserInformation")}76*/77public abstract UserPrincipal lookupPrincipalByName(String name)78throws IOException;7980/**81* Lookup a group principal by group name.82*83* <p> Where an implementation does not support any notion of group then84* this method always throws {@link UserPrincipalNotFoundException}. Where85* the namespace for user accounts and groups is the same, then this method86* is identical to invoking {@link #lookupPrincipalByName87* lookupPrincipalByName}.88*89* @param group90* the string representation of the group to lookup91*92* @return a group principal93*94* @throws UserPrincipalNotFoundException95* the principal does not exist or is not a group96* @throws IOException97* if an I/O error occurs98* @throws SecurityException99* In the case of the default provider, and a security manager is100* installed, it checks101* {@link RuntimePermission}{@code ("lookupUserInformation")}102*/103public abstract GroupPrincipal lookupPrincipalByGroupName(String group)104throws IOException;105}106107108