001: /*
002: * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/auth/MVNForumPermissionImpl.java,v 1.43 2007/12/20 06:55:43 minhnn Exp $
003: * $Author: minhnn $
004: * $Revision: 1.43 $
005: * $Date: 2007/12/20 06:55:43 $
006: *
007: * ====================================================================
008: *
009: * Copyright (C) 2002-2007 by MyVietnam.net
010: *
011: * All copyright notices regarding mvnForum MUST remain
012: * intact in the scripts and in the outputted HTML.
013: * The "powered by" text/logo with a link back to
014: * http://www.mvnForum.com and http://www.MyVietnam.net in
015: * the footer of the pages MUST remain visible when the pages
016: * are viewed on the internet or intranet.
017: *
018: * This program is free software; you can redistribute it and/or modify
019: * it under the terms of the GNU General Public License as published by
020: * the Free Software Foundation; either version 2 of the License, or
021: * any later version.
022: *
023: * This program is distributed in the hope that it will be useful,
024: * but WITHOUT ANY WARRANTY; without even the implied warranty of
025: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
026: * GNU General Public License for more details.
027: *
028: * You should have received a copy of the GNU General Public License
029: * along with this program; if not, write to the Free Software
030: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
031: *
032: * Support can be obtained from support forums at:
033: * http://www.mvnForum.com/mvnforum/index
034: *
035: * Correspondence and Marketing Questions can be sent to:
036: * info at MyVietnam net
037: *
038: * @author: Minh Nguyen
039: * @author: Mai Nguyen
040: */
041: package com.mvnforum.auth;
042:
043: import java.util.*;
044:
045: import net.myvietnam.mvncore.exception.NotLoginException;
046: import net.myvietnam.mvncore.util.AssertionUtil;
047:
048: import com.mvnforum.db.GroupsBean;
049:
050: /**
051: * This class is private in the package
052: */
053: class MVNForumPermissionImpl extends AbstractPermission implements
054: MVNForumPermission {
055:
056: private Collection groupsContainMember = new ArrayList();
057:
058: MVNForumPermissionImpl() {
059: }
060:
061: public Collection getGroupsContainMember() {
062: return groupsContainMember;
063: }
064:
065: public void setGroupsContainMember(Collection groupsContainMember) {
066: this .groupsContainMember = groupsContainMember;
067: }
068:
069: private void setBypassPrivateForum(boolean bypass) {
070:
071: editForum.setBypassPrivateForum(bypass);
072: deleteForum.setBypassPrivateForum(bypass);
073: assignToForum.setBypassPrivateForum(bypass);
074:
075: readPost.setBypassPrivateForum(bypass);
076: addThread.setBypassPrivateForum(bypass);
077: addPost.setBypassPrivateForum(bypass);
078: editPost.setBypassPrivateForum(bypass);
079: editOwnPost.setBypassPrivateForum(bypass);
080: deletePost.setBypassPrivateForum(bypass);
081: addPoll.setBypassPrivateForum(bypass);
082: editPoll.setBypassPrivateForum(bypass);
083: editOwnPoll.setBypassPrivateForum(bypass);
084: deletePoll.setBypassPrivateForum(bypass);
085: addAttachment.setBypassPrivateForum(bypass);
086: getAttachment.setBypassPrivateForum(bypass);
087: moderateThread.setBypassPrivateForum(bypass);
088: }
089:
090: private void setBypassPrivateChannel(boolean bypass) {
091:
092: writeContent.setBypassPrivateChannel(bypass);
093: writeContentInStepWithChannel.setBypassPrivateChannel(bypass);
094: editContent.setBypassPrivateChannel(bypass);
095: editContentInStepWithChannel.setBypassPrivateChannel(bypass);
096: approveContent.setBypassPrivateChannel(bypass);
097: publishContent.setBypassPrivateChannel(bypass);
098: deleteContent.setBypassPrivateChannel(bypass);
099: deleteContentInStepWithChannel.setBypassPrivateChannel(bypass);
100: viewContentInStepWithChannel.setBypassPrivateChannel(bypass);
101: viewContentStepWithChannel.setBypassPrivateChannel(bypass);
102: goToContentStepWithChannel.setBypassPrivateChannel(bypass);
103: deployContentInStepWithChannel.setBypassPrivateChannel(bypass);
104: }
105:
106: /**
107: * The ONLY way to set permission, so this MUST have default package access
108: */
109: void setPermission(int permission) {
110: switch (permission) {
111: case PERMISSION_AUTHENTICATED:
112: authenticated = true;
113: break;
114:
115: case PERMISSION_ACTIVATED:
116: activated = true;
117: break;
118: /**************************************************************************
119: * Combined permissions, range from 100 to 199
120: * A permission in this range is the combination of other permissions
121: **************************************************************************/
122: case PERMISSION_SYSTEM_ADMIN:
123: adminSystem = true;
124: addForum = true;
125: editForum.setAllForumsPermission(true);
126: deleteForum.setAllForumsPermission(true);
127: assignToForum.setAllForumsPermission(true);
128: addCategory = true;
129: editCategory = true;
130: deleteCategory = true;
131: sendMail = true;
132: moderateUser = true;
133: useAvatar = true;
134: useMessage = true;
135: addMessageAttachment = true;
136: useAlbum = true;
137: manageOrphanPoll = true;
138: manageAlbumItemPoll = true;
139: setPollToAnonymousType = true;
140: haveRoleEditor = true;
141: haveRoleChiefEditor = true;
142: manageInfoInDay = true;
143: editCDSLayout = true;
144:
145: readPost.setAllForumsPermission(true);
146: addThread.setAllForumsPermission(true);
147: addPost.setAllForumsPermission(true);
148: editPost.setAllForumsPermission(true);
149: editOwnPost.setAllForumsPermission(true);
150: deletePost.setAllForumsPermission(true);
151: addPoll.setAllForumsPermission(true);
152: editPoll.setAllForumsPermission(true);
153: editOwnPoll.setAllForumsPermission(true);
154: deletePoll.setAllForumsPermission(true);
155: addAttachment.setAllForumsPermission(true);
156: getAttachment.setAllForumsPermission(true);
157: moderateThread.setAllForumsPermission(true);
158:
159: setBypassPrivateForum(true);
160:
161: // CMS permissions
162: addChannel = true;
163: editChannel = true;
164: deleteChannel = true;
165:
166: writeContent.setAllChannelsPermission(true);
167: writeContentInStepWithChannel
168: .setAllStepAndChannelsPermission(true);
169: editContent.setAllChannelsPermission(true);
170: editContentInStepWithChannel
171: .setAllStepAndChannelsPermission(true);
172: approveContent.setAllChannelsPermission(true);
173: publishContent.setAllChannelsPermission(true);
174: deleteContent.setAllChannelsPermission(true);
175: deleteContentInStepWithChannel
176: .setAllStepAndChannelsPermission(true);
177: viewContentInStepWithChannel
178: .setAllStepAndChannelsPermission(true);
179: viewContentStepWithChannel
180: .setAllStepAndChannelsPermission(true);
181: goToContentStepWithChannel
182: .setAllStepAndChannelsPermission(true);
183: deployContentInStepWithChannel
184: .setAllStepAndChannelsPermission(true);
185:
186: setBypassPrivateChannel(true);
187:
188: manageAds = true;
189: addZone = true;
190: editZone = true;
191: deleteZone = true;
192: addBanner = true;
193: editBanner = true;
194: deleteBanner = true;
195: viewZone = true;
196: viewBanner = true;
197: uploadMedia = true;
198: break;
199:
200: case PERMISSION_FORUM_ADMIN:
201: addForum = true;
202: editForum.setAllForumsPermission(true);
203: deleteForum.setAllForumsPermission(true);
204: assignToForum.setAllForumsPermission(true);
205: addCategory = true;
206: editCategory = true;
207: deleteCategory = true;
208:
209: moderateThread.setAllForumsPermission(true);
210:
211: readPost.setAllForumsPermission(true);
212: addThread.setAllForumsPermission(true);
213: addPost.setAllForumsPermission(true);
214: editPost.setAllForumsPermission(true);
215: editOwnPost.setAllForumsPermission(true);
216: deletePost.setAllForumsPermission(true);
217: addPoll.setAllForumsPermission(true);
218: editPoll.setAllForumsPermission(true);
219: editOwnPoll.setAllForumsPermission(true);
220: deletePoll.setAllForumsPermission(true);
221: addAttachment.setAllForumsPermission(true);
222: getAttachment.setAllForumsPermission(true);
223: break;
224:
225: case PERMISSION_FORUM_MODERATOR:
226: editForum.setAllForumsPermission(true);
227: editCategory = true;
228:
229: moderateThread.setAllForumsPermission(true);
230:
231: readPost.setAllForumsPermission(true);
232: addThread.setAllForumsPermission(true);
233: addPost.setAllForumsPermission(true);
234: editPost.setAllForumsPermission(true);
235: editOwnPost.setAllForumsPermission(true);
236: deletePost.setAllForumsPermission(true);
237: addPoll.setAllForumsPermission(true);
238: editPoll.setAllForumsPermission(true);
239: editOwnPoll.setAllForumsPermission(true);
240: deletePoll.setAllForumsPermission(true);
241: addAttachment.setAllForumsPermission(true);
242: getAttachment.setAllForumsPermission(true);
243: break;
244:
245: case PERMISSION_LIMITED_USER:
246: readPost.setAllForumsPermission(true);
247: /** @todo at the 1.0.0 beta2/beta3/RC1/RC2 release, add post is disable*/
248: // addPost = true;
249: break;
250:
251: case PERMISSION_NORMAL_USER:
252: useAvatar = true;
253: useMessage = true;
254:
255: readPost.setAllForumsPermission(true);
256: addThread.setAllForumsPermission(true);
257: addPost.setAllForumsPermission(true);
258: getAttachment.setAllForumsPermission(true);
259: break;
260:
261: /**
262: * Can:
263: * - login, read thread and post, reply to a thread
264: * - add thread, use avatar, use private message, get attachment
265: * - use attachment, create poll
266: */
267: case PERMISSION_POWER_USER:
268: useAvatar = true;
269: useMessage = true;
270: addMessageAttachment = true;
271: useAlbum = true;
272:
273: readPost.setAllForumsPermission(true);
274: addThread.setAllForumsPermission(true);
275: addPost.setAllForumsPermission(true);
276: editOwnPost.setAllForumsPermission(true);
277: addPoll.setAllForumsPermission(true);
278: editOwnPoll.setAllForumsPermission(true);
279: addAttachment.setAllForumsPermission(true);
280: getAttachment.setAllForumsPermission(true);
281: break;
282:
283: /**************************************************************************
284: * Individual Permissions for global usages, range from 1000 to 2000
285: **************************************************************************/
286: case PERMISSION_LOGIN:
287: login = true;
288: break;
289: //case PERMISSION_ADMIN_SYSTEM:
290: // adminSystem = true;
291: // break;
292: case PERMISSION_ADD_FORUM:
293: addForum = true;
294: break;
295: case PERMISSION_ADD_CATEGORY:
296: addCategory = true;
297: break;
298: case PERMISSION_EDIT_CATEGORY:
299: editCategory = true;
300: break;
301: case PERMISSION_DELETE_CATEGORY:
302: deleteCategory = true;
303: break;
304: case PERMISSION_SEND_MAIL:
305: sendMail = true;
306: break;
307: case PERMISSION_MODERATE_USER:
308: moderateUser = true;
309: break;
310: case PERMISSION_BYPASS_PRIVATE_FORUM:
311: setBypassPrivateForum(true);
312: break;
313: case PERMISSION_USE_MESSAGE:
314: useMessage = true;
315: break;
316: case PERMISSION_ADD_MESSAGE_ATTACHMENT:
317: addMessageAttachment = true;
318: break;
319: case PERMISSION_USE_AVATAR:
320: useAvatar = true;
321: break;
322: case PERMISSION_USE_ALBUM:
323: useAlbum = true;
324: break;
325:
326: case PERMISSION_MANAGE_ORPHAN_POLL:
327: manageOrphanPoll = true;
328: break;
329:
330: case PERMISSION_MANAGE_ALBUMITEM_POLL:
331: manageAlbumItemPoll = true;
332: break;
333:
334: case PERMISSION_SET_POLL_TO_ANONYMOUS_TYPE:
335: setPollToAnonymousType = true;
336: break;
337:
338: /**************************************************************************
339: * Individual Permissions that can be applied for individual forum usages,
340: * (of course it can be applied to all forums), range from 2000 to 3000
341: **************************************************************************/
342: case PERMISSION_EDIT_FORUM:
343: editForum.setAllForumsPermission(true);
344: break;
345: case PERMISSION_DELETE_FORUM:
346: deleteForum.setAllForumsPermission(true);
347: break;
348: case PERMISSION_ASSIGN_TO_FORUM:
349: assignToForum.setAllForumsPermission(true);
350: break;
351: case PERMISSION_READ_POST:
352: readPost.setAllForumsPermission(true);
353: break;
354: case PERMISSION_ADD_THREAD:
355: addThread.setAllForumsPermission(true);
356: break;
357: case PERMISSION_ADD_POST:
358: addPost.setAllForumsPermission(true);
359: break;
360: case PERMISSION_EDIT_POST:
361: editPost.setAllForumsPermission(true);
362: break;
363: case PERMISSION_EDIT_OWN_POST:
364: editOwnPost.setAllForumsPermission(true);
365: break;
366: case PERMISSION_DELETE_POST:
367: deletePost.setAllForumsPermission(true);
368: break;
369: case PERMISSION_ADD_POLL:
370: addPoll.setAllForumsPermission(true);
371: break;
372: case PERMISSION_EDIT_POLL:
373: editPoll.setAllForumsPermission(true);
374: break;
375: case PERMISSION_EDIT_OWN_POLL:
376: editOwnPoll.setAllForumsPermission(true);
377: break;
378: case PERMISSION_DELETE_POLL:
379: deletePoll.setAllForumsPermission(true);
380: break;
381: case PERMISSION_ADD_ATTACHMENT:
382: addAttachment.setAllForumsPermission(true);
383: break;
384: case PERMISSION_GET_ATTACHMENT:
385: getAttachment.setAllForumsPermission(true);
386: break;
387: case PERMISSION_MODERATE_THREAD:
388: moderateThread.setAllForumsPermission(true);
389: break;
390:
391: /**************************************************************************
392: * Individual CMS Permissions for global usages
393: **************************************************************************/
394: case PERMISSION_CMS_ADD_CHANNEL:
395: addChannel = true;
396: break;
397: case PERMISSION_CMS_EDIT_CHANNEL:
398: editChannel = true;
399: break;
400: case PERMISSION_CMS_DELETE_CHANNEL:
401: deleteChannel = true;
402: break;
403: case PERMISSION_CMS_HAVE_ROLE_EDITOR:
404: haveRoleEditor = true;
405: break;
406: case PERMISSION_CMS_HAVE_ROLE_CHIEF_EDITOR:
407: haveRoleChiefEditor = true;
408: break;
409:
410: case PERMISSION_CMS_MANAGE_INFO_IN_DAY:
411: manageInfoInDay = true;
412: break;
413:
414: case PERMISSION_CMS_EDIT_CDS_LAYOUT:
415: editCDSLayout = true;
416: break;
417:
418: /**************************************************************************
419: * Individual CMS Permissions that can be applied for individual channel usages,
420: * (of course it can be applied to all channels)
421: **************************************************************************/
422: case PERMISSION_CMS_WRITE_CONTENT:
423: writeContent.setAllChannelsPermission(true);
424: writeContentInStepWithChannel
425: .setAllStepAndChannelsPermission(true);
426: break;
427: case PERMISSION_CMS_EDIT_CONTENT:
428: editContent.setAllChannelsPermission(true);
429: editContentInStepWithChannel
430: .setAllStepAndChannelsPermission(true);
431: break;
432: case PERMISSION_CMS_APPROVE_CONTENT:
433: approveContent.setAllChannelsPermission(true);
434: break;
435: case PERMISSION_CMS_PUBLISH_CONTENT:
436: publishContent.setAllChannelsPermission(true);
437: break;
438: case PERMISSION_CMS_DELETE_CONTENT:
439: deleteContent.setAllChannelsPermission(true);
440: deleteContentInStepWithChannel
441: .setAllStepAndChannelsPermission(true);
442: break;
443: case PERMISSION_CMS_VIEW_CONTENT:
444: viewContentInStepWithChannel
445: .setAllStepAndChannelsPermission(true);
446: break;
447:
448: case PERMISSION_CMS_VIEW_STEP:
449: viewContentStepWithChannel
450: .setAllStepAndChannelsPermission(true);
451: break;
452:
453: case PERMISSION_CMS_GOTO_STEP:
454: goToContentStepWithChannel
455: .setAllStepAndChannelsPermission(true);
456: break;
457:
458: case PERMISSION_CMS_DEPLOY_CONTENT:
459: deployContentInStepWithChannel
460: .setAllStepAndChannelsPermission(true);
461: break;
462:
463: /**************************************************************************
464: * Individual Ads Permissions for global usages
465: **************************************************************************/
466: case PERMISSION_ADS_MANAGE_ADS:
467: manageAds = true;
468: addZone = true;
469: editZone = true;
470: deleteZone = true;
471: addBanner = true;
472: editBanner = true;
473: deleteBanner = true;
474: viewZone = true;
475: viewBanner = true;
476: uploadMedia = true;
477: break;
478:
479: case PERMISSION_ADS_ADD_ZONE:
480: addZone = true;
481: break;
482:
483: case PERMISSION_ADS_EDIT_ZONE:
484: editZone = true;
485: break;
486:
487: case PERMISSION_ADS_DELETE_ZONE:
488: deleteZone = true;
489: break;
490:
491: case PERMISSION_ADS_ADD_BANNER:
492: addBanner = true;
493: break;
494:
495: case PERMISSION_ADS_EDIT_BANNER:
496: editBanner = true;
497: break;
498:
499: case PERMISSION_ADS_DELETE_BANNER:
500: deleteBanner = true;
501: break;
502:
503: case PERMISSION_ADS_VIEW_ZONE:
504: viewZone = true;
505: break;
506:
507: case PERMISSION_ADS_VIEW_BANNER:
508: viewBanner = true;
509: break;
510:
511: case PERMISSION_ADS_UPLOAD_MEDIA:
512: uploadMedia = true;
513: break;
514:
515: /**************************************************************************
516: * cannot find, just throw an Exception
517: **************************************************************************/
518:
519: default:
520: AssertionUtil.doAssert(false,
521: "Currently in setPermission do not support permission = "
522: + permission);
523: }//switch
524: }//setPermission
525:
526: /**
527: * The ONLY way to set permission in forum, so this MUST have default package access
528: */
529: void setPermissionInForum(int forumID, int permission) {
530: switch (permission) {
531: /**************************************************************************
532: * Combined permissions, range from 100 to 199
533: * A permission in this range is the combination of other permissions
534: **************************************************************************/
535: case PERMISSION_FORUM_ADMIN:
536: editForum.setForumPermission(forumID, true);
537: deleteForum.setForumPermission(forumID, true);
538: assignToForum.setForumPermission(forumID, true);
539:
540: readPost.setForumPermission(forumID, true);
541: addThread.setForumPermission(forumID, true);
542: addPost.setForumPermission(forumID, true);
543: editPost.setForumPermission(forumID, true);
544: editOwnPost.setForumPermission(forumID, true);
545: deletePost.setForumPermission(forumID, true);
546: addPoll.setForumPermission(forumID, true);
547: editPoll.setForumPermission(forumID, true);
548: editOwnPoll.setForumPermission(forumID, true);
549: deletePoll.setForumPermission(forumID, true);
550: addAttachment.setForumPermission(forumID, true);
551: getAttachment.setForumPermission(forumID, true);
552: moderateThread.setForumPermission(forumID, true);
553: break;
554:
555: case PERMISSION_FORUM_MODERATOR:
556: editForum.setForumPermission(forumID, true);
557:
558: readPost.setForumPermission(forumID, true);
559: addThread.setForumPermission(forumID, true);
560: addPost.setForumPermission(forumID, true);
561: editPost.setForumPermission(forumID, true);
562: editOwnPost.setForumPermission(forumID, true);
563: deletePost.setForumPermission(forumID, true);
564: addPoll.setForumPermission(forumID, true);
565: editPoll.setForumPermission(forumID, true);
566: editOwnPoll.setForumPermission(forumID, true);
567: deletePoll.setForumPermission(forumID, true);
568: addAttachment.setForumPermission(forumID, true);
569: getAttachment.setForumPermission(forumID, true);
570: moderateThread.setForumPermission(forumID, true);
571: break;
572:
573: case PERMISSION_LIMITED_USER:
574: readPost.setForumPermission(forumID, true);
575: /** @todo at the 1.0.0 beta2/beta3/RC1/RC2 release, add post is disable*/
576: //addPost.setForumPermission(forumID, true);
577: break;
578:
579: case PERMISSION_NORMAL_USER:
580: readPost.setForumPermission(forumID, true);
581: addThread.setForumPermission(forumID, true);
582: addPost.setForumPermission(forumID, true);
583: getAttachment.setForumPermission(forumID, true);
584: break;
585:
586: /**
587: * Can:
588: * - login, read thread and post, reply to a thread
589: * - add thread, use avatar, use private message, get attachment
590: * - use attachment, create poll
591: */
592: case PERMISSION_POWER_USER:
593: readPost.setForumPermission(forumID, true);
594: addThread.setForumPermission(forumID, true);
595: addPost.setForumPermission(forumID, true);
596: addPoll.setForumPermission(forumID, true);
597: addAttachment.setForumPermission(forumID, true);
598: getAttachment.setForumPermission(forumID, true);
599: break;
600:
601: /**************************************************************************
602: * Individual Permissions that can be applied for individual forum usages,
603: * (of course it can be applied to all forums), range from 2000 to 3000
604: **************************************************************************/
605: case PERMISSION_EDIT_FORUM:
606: editForum.setForumPermission(forumID, true);
607: break;
608: case PERMISSION_DELETE_FORUM:
609: deleteForum.setForumPermission(forumID, true);
610: break;
611: case PERMISSION_ASSIGN_TO_FORUM:
612: assignToForum.setForumPermission(forumID, true);
613: break;
614: case PERMISSION_READ_POST:
615: readPost.setForumPermission(forumID, true);
616: break;
617: case PERMISSION_ADD_THREAD:
618: addThread.setForumPermission(forumID, true);
619: break;
620: case PERMISSION_ADD_POST:
621: addPost.setForumPermission(forumID, true);
622: break;
623: case PERMISSION_EDIT_POST:
624: editPost.setForumPermission(forumID, true);
625: break;
626: case PERMISSION_EDIT_OWN_POST:
627: editOwnPost.setForumPermission(forumID, true);
628: break;
629: case PERMISSION_DELETE_POST:
630: deletePost.setForumPermission(forumID, true);
631: break;
632: case PERMISSION_ADD_POLL:
633: addPoll.setForumPermission(forumID, true);
634: break;
635: case PERMISSION_EDIT_POLL:
636: editPoll.setForumPermission(forumID, true);
637: break;
638: case PERMISSION_EDIT_OWN_POLL:
639: editOwnPoll.setForumPermission(forumID, true);
640: break;
641: case PERMISSION_DELETE_POLL:
642: deletePoll.setForumPermission(forumID, true);
643: break;
644: case PERMISSION_ADD_ATTACHMENT:
645: addAttachment.setForumPermission(forumID, true);
646: break;
647: case PERMISSION_GET_ATTACHMENT:
648: getAttachment.setForumPermission(forumID, true);
649: break;
650: case PERMISSION_MODERATE_THREAD:
651: moderateThread.setForumPermission(forumID, true);
652: break;
653:
654: /**************************************************************************
655: * cannot find, just throw an Exception
656: **************************************************************************/
657:
658: default:
659: AssertionUtil.doAssert(false,
660: "Currently in setPermissionInForum do not support permission = "
661: + permission);
662: }//switch
663: }//setPermissionInForum
664:
665: void setPermissionInStepInChannel(int stepID, int channelID,
666: int permission) {
667: switch (permission) {
668: /**************************************************************************
669: * Individual CMS Permissions that can be applied for individual channel usages,
670: * (of course it can be applied to all channels)
671: **************************************************************************/
672: case PERMISSION_CMS_WRITE_CONTENT:
673: writeContent.setChannelPermission(channelID, true);
674: writeContentInStepWithChannel.setStepAndChannelPermission(
675: stepID, channelID, true);
676: break;
677: case PERMISSION_CMS_EDIT_CONTENT:
678: editContentInStepWithChannel.setStepAndChannelPermission(
679: stepID, channelID, true);
680: break;
681: case PERMISSION_CMS_DELETE_CONTENT:
682: deleteContentInStepWithChannel.setStepAndChannelPermission(
683: stepID, channelID, true);
684: break;
685: case PERMISSION_CMS_VIEW_CONTENT:
686: viewContentInStepWithChannel.setStepAndChannelPermission(
687: stepID, channelID, true);
688: break;
689: case PERMISSION_CMS_VIEW_STEP:
690: viewContentStepWithChannel.setStepAndChannelPermission(
691: stepID, channelID, true);
692: break;
693: case PERMISSION_CMS_GOTO_STEP:
694: goToContentStepWithChannel.setStepAndChannelPermission(
695: stepID, channelID, true);
696: break;
697: case PERMISSION_CMS_DEPLOY_CONTENT:
698: deployContentInStepWithChannel.setStepAndChannelPermission(
699: stepID, channelID, true);
700: break;
701: /**************************************************************************
702: * cannot find, just throw an Exception
703: **************************************************************************/
704:
705: default:
706: AssertionUtil.doAssert(false,
707: "Currently in setPermissionInStepInChannel do not support permission = "
708: + permission);
709: }//switch
710: }//setPermissionInStepInChannel
711:
712: void setPermissionInStep(int stepID, int permission) {
713: switch (permission) {
714: /**************************************************************************
715: * Individual CMS Permissions that can be applied for individual channel usages,
716: * (of course it can be applied to all channels)
717: **************************************************************************/
718: case PERMISSION_CMS_WRITE_CONTENT:
719: writeContent.setAllChannelsPermission(true);
720: writeContentInStepWithChannel.setAllChannelsPermission(
721: stepID, true);
722: break;
723: case PERMISSION_CMS_EDIT_CONTENT:
724: editContentInStepWithChannel.setAllChannelsPermission(
725: stepID, true);
726: break;
727: case PERMISSION_CMS_DELETE_CONTENT:
728: deleteContentInStepWithChannel.setAllChannelsPermission(
729: stepID, true);
730: break;
731: case PERMISSION_CMS_VIEW_CONTENT:
732: viewContentInStepWithChannel.setAllChannelsPermission(
733: stepID, true);
734: break;
735: case PERMISSION_CMS_VIEW_STEP:
736: viewContentStepWithChannel.setAllChannelsPermission(stepID,
737: true);
738: break;
739: case PERMISSION_CMS_GOTO_STEP:
740: goToContentStepWithChannel.setAllChannelsPermission(stepID,
741: true);
742: break;
743: case PERMISSION_CMS_DEPLOY_CONTENT:
744: deployContentInStepWithChannel.setAllChannelsPermission(
745: stepID, true);
746: break;
747: /**************************************************************************
748: * cannot find, just throw an Exception
749: **************************************************************************/
750:
751: default:
752: AssertionUtil.doAssert(false,
753: "Currently in setPermissionInStep do not support permission = "
754: + permission);
755: }//switch
756: }//setPermissionInStep
757:
758: public boolean isMemberInGroup(String groupName) {
759: for (Iterator iter = groupsContainMember.iterator(); iter
760: .hasNext();) {
761: GroupsBean element = (GroupsBean) iter.next();
762: if (element.getGroupName().equals(groupName)) {
763: return true;
764: }
765: }
766: return false;
767: }
768:
769: public void ensureIsMemberInGroup(String groupName)
770: throws AuthenticationException {
771: if (isMemberInGroup(groupName) == false) {
772: throw new AuthenticationException(
773: NotLoginException.NOT_ENOUGH_RIGHTS);
774: }
775: }
776:
777: }
|