1/*2 * Copyright 2000-2001,2004 The Apache Software Foundation.3 * 4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */1617packageorg.apache.jetspeed.portal.security.portlets;
1819//jetspeed20import org.apache.jetspeed.portal.Portlet;
21import org.apache.jetspeed.portal.PortletState;
2223import org.apache.jetspeed.services.JetspeedSecurity;
2425//turbine26import org.apache.turbine.util.RunData;
27//import org.apache.turbine.util.TurbineRuntimeException;28293031/***32<p>33This object is used to wrap a Portlet, ensuring that access control rules are enforced.34</p>3536@author <A HREF="mailto:sgala@apache.org">Santiago Gala</A>37@author <A HREF="mailto:morciuch@apache.org">Mark Orciuch</A>38@version $Id: StatefulPortletWrapper.java,v 1.5 2004/02/23 03:27:46 jford Exp $39*/40publicclassStatefulPortletWrapperextendsPortletWrapper implements PortletState41 {
4243/*44 * The portletstate of our portlet45 */46privatePortletState wrappedState = null;
4748publicStatefulPortletWrapper( Portlet inner )
49 {
50super( inner );
51if( inner instanceof PortletState )
52 {
53 wrappedState = (PortletState) inner;
54 }
55else56 {
57//Report error or throw exception58 }
59 }
6061// PortletState Interface implementation6263/***64 * Implements the default close behavior: any authenticated user may65 * remove a portlet from his page66 *67 * @param rundata the RunData object for the current request68 */69publicfinalboolean allowClose( RunData rundata )
70 {
71return checkPermission(rundata,
72 JetspeedSecurity.PERMISSION_CLOSE );
73 }
7475/***76 * Returns true if this portlet is currently closed77 */78publicfinalboolean isClosed(RunData rundata)
79 {
80return wrappedState.isClosed( rundata );
81 }
8283/***84 * Toggles the portlet state between closed and normal85 *86 * @param minimized the new portlet state87 * @param data the RunData for this request88 */89publicfinalvoid setClosed(boolean close, RunData rundata)
90 {
91if( allowClose( rundata ) )
92 {
93 wrappedState.setClosed( close, rundata );
94 }
95 }
9697/***98 * Implements the default info behavior: any authenticated user may99 * get information on a portlet100 *101 * @param rundata the RunData object for the current request102 */103publicfinalboolean allowInfo( RunData rundata )
104 {
105return checkPermission(rundata,
106 JetspeedSecurity.PERMISSION_INFO );
107 }
108109/***110 * Implements the default customize behavior: any authenticated user may111 * customize a portlet112 *113 * @param rundata the RunData object for the current request114 */115publicfinalboolean allowCustomize( RunData rundata )
116 {
117return checkPermission(rundata,
118 JetspeedSecurity.PERMISSION_CUSTOMIZE );
119 }
120121/***122 * Implements the default maximize behavior: any authenticated user may123 * maximize a portlet124 *125 * @param rundata the RunData object for the current request126 */127publicboolean allowMaximize( RunData rundata )
128 {
129return checkPermission(rundata,
130 JetspeedSecurity.PERMISSION_MAXIMIZE );
131 }
132133/***134 * Implements the default info behavior: any authenticated user may135 * minimize a portlet136 *137 * @param rundata the RunData object for the current request138 */139publicboolean allowMinimize( RunData rundata )
140 {
141return checkPermission(rundata,
142 JetspeedSecurity.PERMISSION_MINIMIZE );
143 }
144145/***146 * Returns true if this portlet is currently minimized147 */148publicboolean isMinimized(RunData rundata)
149 {
150return wrappedState.isMinimized( rundata );
151 }
152153/***154 Change the portlet visibility state ( minimized <-> normal )155156 @param minimize True if the portlet change to minimized157 @param rundata A RunData object158 */159publicvoid setMinimized( boolean minimize, RunData rundata )
160 {
161if( allowMinimize( rundata ) )
162 {
163 wrappedState.setMinimized(minimize, rundata );
164 }
165 }
166167/***168 * Implements the default info behavior: any authenticated user may169 * view portlet in print friendly format170 *171 * @param rundata the RunData object for the current request172 */173publicboolean allowPrintFriendly( RunData rundata )
174 {
175return checkPermission(rundata,
176 JetspeedSecurity.PERMISSION_PRINT_FRIENDLY );
177 }
178179 }