151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski/*
250a925ba9f077dd128507215954bdfe21be5cf87Sergio Giro * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *
551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * This code is free software; you can redistribute it and/or modify it
651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * under the terms of the GNU General Public License version 2 only, as
751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * published by the Free Software Foundation.  Oracle designates this
851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * particular file as subject to the "Classpath" exception as provided
951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * by Oracle in the LICENSE file that accompanied this code.
1051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *
1151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * This code is distributed in the hope that it will be useful, but WITHOUT
1251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * version 2 for more details (a copy is included in the LICENSE file that
1551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * accompanied this code).
1651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *
1751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * You should have received a copy of the GNU General Public License version
1851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * 2 along with this work; if not, write to the Free Software Foundation,
1951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *
2151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * or visit www.oracle.com if you need additional information or have any
2351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * questions.
2451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */
2551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski
2651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebskipackage java.security.acl;
2751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski
2851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebskiimport java.util.Enumeration;
2951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebskiimport java.security.Principal;
3051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski
3151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski/**
3251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * This interface is used to represent a group of principals. (A principal
3351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * represents an entity such as an individual user or a company). <p>
3451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *
3551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Note that Group extends Principal. Thus, either a Principal or a Group can
3651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * be passed as an argument to methods containing a Principal parameter. For
3751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * example, you can add either a Principal or a Group to a Group object by
3850a925ba9f077dd128507215954bdfe21be5cf87Sergio Giro * calling the object's {@code addMember} method, passing it the
3951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * Principal or Group.
4051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski *
4151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski * @author      Satish Dharmaraj
4251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski */
4351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebskipublic interface Group extends Principal {
4451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski
4551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski    /**
4651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * Adds the specified member to the group.
4751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     *
4851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * @param user the principal to add to this group.
4951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     *
5051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * @return true if the member was successfully added,
5151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * false if the principal was already a member.
5251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     */
5351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski    public boolean addMember(Principal user);
5451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski
5551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski    /**
5651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * Removes the specified member from the group.
5751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     *
5851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * @param user the principal to remove from this group.
5951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     *
6051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * @return true if the principal was removed, or
6151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * false if the principal was not a member.
6251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     */
6351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski    public boolean removeMember(Principal user);
6451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski
6551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski    /**
6651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * Returns true if the passed principal is a member of the group.
6751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * This method does a recursive search, so if a principal belongs to a
6851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * group which is a member of this group, true is returned.
6951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     *
7051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * @param member the principal whose membership is to be checked.
7151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     *
7251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * @return true if the principal is a member of this group,
7351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * false otherwise.
7451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     */
7551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski    public boolean isMember(Principal member);
7651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski
7751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski
7851b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski    /**
7951b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * Returns an enumeration of the members in the group.
8051b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * The returned objects can be instances of either Principal
8151b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * or Group (which is a subclass of Principal).
8251b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     *
8351b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     * @return an enumeration of the group members.
8451b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski     */
8551b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski    public Enumeration<? extends Principal> members();
8651b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski
8751b1b6997fd3f980076b8081f7f1165ccc2a4008Piotr Jastrzebski}
88