001/*
002 * (C) Copyright 2006-2007 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Nuxeo - initial API and implementation
016 *
017 * $Id$
018 */
019
020package org.nuxeo.ecm.webapp.security;
021
022import java.util.List;
023import java.util.Map;
024
025import javax.faces.model.SelectItem;
026
027import org.nuxeo.ecm.platform.query.api.PageSelections;
028
029/**
030 * Provides security related operations on the current document.
031 *
032 * @author Razvan Caraghin
033 */
034public interface SecurityActions {
035
036    /**
037     * Submits the security changes to the backend.
038     *
039     * @return the page that will be displayed next
040     */
041    String updateSecurityOnDocument();
042
043    /**
044     * Adds a permission to the list of permissions for the current document. After all client side changes are made,
045     * then the list of permissions need to be submitted on backend using <code>updateSecurityOnDocument()></code>.
046     *
047     * @return the page that needs to be displayed next
048     */
049    String addPermission();
050
051    /**
052     * Adds a list of permission to the list of permissions for the current document. After all client side changes are
053     * made, then the list of permissions need to be submitted on backend using <code>updateSecurityOnDocument()></code>
054     * .
055     *
056     * @return the page that needs to be displayed next
057     */
058    String addPermissions();
059
060    String addPermission(String principalName, String permissionName, boolean grant);
061
062    /**
063     * Removes a permission from the list of permissions for the current document. After all client side changes are
064     * made, then the list of permissions need to be submitted on backend using <code>updateSecurityOnDocument()></code>
065     * .
066     *
067     * @return the page that needs to be displayed next
068     */
069    String removePermission();
070
071    /**
072     * Adds a permission to the list of permissions for the current document and automatically update the backend with
073     * <code>updateSecurityOnDocument()></code>.
074     *
075     * @return the page that needs to be displayed next
076     */
077    String addPermissionAndUpdate();
078
079    /**
080     * Adds a list of permissions to the list of permissions for the current document and automatically update the
081     * backend with <code>updateSecurityOnDocument()></code>.
082     *
083     * @return the page that needs to be displayed next
084     */
085    String addPermissionsAndUpdate();
086
087    /**
088     * Removes a permission from the list of permissions for the current document and automatically update the backend
089     * with <code>updateSecurityOnDocument()></code>.
090     *
091     * @return the page that needs to be displayed next
092     */
093    String removePermissionAndUpdate();
094
095    String removePermissionsAndUpdate();
096
097    /**
098     * Marks the current security data info as obsolete so that it gets lazily recomputed from the backend the next time
099     * it is accessed.
100     */
101    void resetSecurityData();
102
103    /**
104     * Rebuilds the security displayable data from the current selected document.
105     */
106    void rebuildSecurityData();
107
108    /**
109     * @return a PageSelections used to build a checkboxable listing of managed permissions
110     */
111    PageSelections<String> getDataTableModel();
112
113    /**
114     * @return the SecurityData object that manages a stateful representation of the permissions mapping that apply to
115     *         the current document (inherited or not)
116     */
117    SecurityData getSecurityData();
118
119    /**
120     * Returns true if the implementator if the principal has the permission to add new security rules on currentItem.
121     */
122    boolean getCanAddSecurityRules();
123
124    /**
125     * Returns true if the implementator can provide a list of permissions delete now and the principal has
126     * WriteSecurity permission on the currentItem.
127     */
128    boolean getCanRemoveSecurityRules();
129
130    /**
131     * @return the list of permissions the users can set through the rights management tab
132     */
133    List<SelectItem> getSettablePermissions();
134
135    /**
136     * Maps the principal type to the icon path.
137     */
138    Map<String, String> getIconPathMap();
139
140    /**
141     * Maps the principal type to the icon alt text.
142     */
143    Map<String, String> getIconAltMap();
144
145    Boolean getBlockRightInheritance();
146
147    void setBlockRightInheritance(Boolean blockRightInheritance);
148
149    /**
150     * @deprecated use {@link #getDisplayInheritedPermissions()}
151     */
152    @Deprecated
153    Boolean displayInheritedPermissions();
154
155    /**
156     * Returns true if inherited permissions have to be displayed (depending on rights blocking)
157     */
158    boolean getDisplayInheritedPermissions();
159
160    List<String> getCurrentDocumentUsers();
161
162    List<String> getParentDocumentsUsers();
163
164    String removePermissions();
165
166    String saveSecurityUpdates();
167
168    /**
169     * Returns selected entry used in add/remove methods
170     */
171    String getSelectedEntry();
172
173    /**
174     * Sets selected entry used in add/remove methods
175     */
176    void setSelectedEntry(String selectedEntry);
177
178    /**
179     * Returns selected entries used in add/remove methods
180     */
181    List<String> getSelectedEntries();
182
183    /**
184     * Sets selected entries used in add/remove methods
185     */
186    void setSelectedEntries(List<String> selectedEntries);
187
188}