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