KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mvnforum > auth > AbstractPermission


1 /*
2  * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/auth/AbstractPermission.java,v 1.17 2006/04/14 17:05:26 minhnn Exp $
3  * $Author: minhnn $
4  * $Revision: 1.17 $
5  * $Date: 2006/04/14 17:05:26 $
6  *
7  * ====================================================================
8  *
9  * Copyright (C) 2002-2006 by MyVietnam.net
10  *
11  * All copyright notices regarding mvnForum MUST remain
12  * intact in the scripts and in the outputted HTML.
13  * The "powered by" text/logo with a link back to
14  * http://www.mvnForum.com and http://www.MyVietnam.net in
15  * the footer of the pages MUST remain visible when the pages
16  * are viewed on the internet or intranet.
17  *
18  * This program is free software; you can redistribute it and/or modify
19  * it under the terms of the GNU General Public License as published by
20  * the Free Software Foundation; either version 2 of the License, or
21  * any later version.
22  *
23  * This program is distributed in the hope that it will be useful,
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26  * GNU General Public License for more details.
27  *
28  * You should have received a copy of the GNU General Public License
29  * along with this program; if not, write to the Free Software
30  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31  *
32  * Support can be obtained from support forums at:
33  * http://www.mvnForum.com/mvnforum/index
34  *
35  * Correspondence and Marketing Questions can be sent to:
36  * info at MyVietnam net
37  *
38  * @author: Minh Nguyen
39  * @author: Mai Nguyen
40  */

41 package com.mvnforum.auth;
42
43 import net.myvietnam.mvncore.exception.BadInputException;
44 import net.myvietnam.mvncore.exception.NotLoginException;
45
46 public abstract class AbstractPermission implements MVNForumPermission {
47
48     public static final int[] globalCombinedPermissionArray =
49         {
50             PERMISSION_SYSTEM_ADMIN,
51
52             // below are forum-appliable permissions
53
PERMISSION_FORUM_ADMIN,
54             PERMISSION_FORUM_MODERATOR,
55             PERMISSION_POWER_USER,
56             PERMISSION_NORMAL_USER,
57             PERMISSION_LIMITED_USER
58         };
59
60     public static final int[] forumCombinedPermissionArray =
61         {
62             PERMISSION_FORUM_ADMIN,
63             PERMISSION_FORUM_MODERATOR,
64             PERMISSION_POWER_USER,
65             PERMISSION_NORMAL_USER,
66             PERMISSION_LIMITED_USER
67         };
68
69     public static final int[] globalIndividualPermissionArray =
70         {
71             //PERMISSION_LOGIN,//minhnn: login is not used, so I removed it to avoid confusion
72
//PERMISSION_ADMIN_SYSTEM,
73
PERMISSION_ADD_CATEGORY,
74             PERMISSION_EDIT_CATEGORY,
75             PERMISSION_DELETE_CATEGORY,
76             PERMISSION_ADD_FORUM,
77
78             // these 2 permission should be in forum-appliable permissions,
79
// However, I put it here for the more natural order that user
80
// can see in interface
81
PERMISSION_EDIT_FORUM,
82             PERMISSION_DELETE_FORUM,
83             PERMISSION_ASSIGN_TO_FORUM,
84             PERMISSION_BYPASS_PRIVATE_FORUM,
85
86             // forum-nonappliable permissions
87
PERMISSION_SEND_MAIL,
88             PERMISSION_USE_MESSAGE,
89             PERMISSION_ADD_MESSAGE_ATTACHMENT,
90             PERMISSION_USE_AVATAR,
91
92             // below are forum-appliable permissions
93
PERMISSION_MODERATE_THREAD,
94             PERMISSION_READ_POST,
95             PERMISSION_ADD_THREAD,
96             PERMISSION_ADD_POST,
97             PERMISSION_EDIT_POST,
98             PERMISSION_EDIT_OWN_POST,
99             PERMISSION_DELETE_POST,
100             PERMISSION_ADD_POLL,
101             PERMISSION_EDIT_POLL,
102             PERMISSION_DELETE_POLL,
103             PERMISSION_ADD_ATTACHMENT,
104             PERMISSION_GET_ATTACHMENT
105         };
106
107     public static final int[] globalCMSIndividualPermissionArray =
108         {
109             PERMISSION_CMS_ADD_CHANNEL,
110             PERMISSION_CMS_EDIT_CHANNEL,
111             PERMISSION_CMS_DELETE_CHANNEL,
112
113             PERMISSION_CMS_DELETE_CONTENT,
114             PERMISSION_CMS_PUBLISH_CONTENT,
115             PERMISSION_CMS_APPROVE_CONTENT,
116             PERMISSION_CMS_EDIT_CONTENT,
117             PERMISSION_CMS_WRITE_CONTENT
118         };
119
120     public static final int[] forumIndividualPermissionArray =
121         {
122             PERMISSION_EDIT_FORUM,
123             PERMISSION_DELETE_FORUM,
124             PERMISSION_ASSIGN_TO_FORUM,
125             PERMISSION_MODERATE_THREAD,
126             PERMISSION_READ_POST,
127             PERMISSION_ADD_THREAD,
128             PERMISSION_ADD_POST,
129             PERMISSION_EDIT_POST,
130             PERMISSION_EDIT_OWN_POST,
131             PERMISSION_DELETE_POST,
132             PERMISSION_ADD_POLL,
133             PERMISSION_EDIT_POLL,
134             PERMISSION_DELETE_POLL,
135             PERMISSION_ADD_ATTACHMENT,
136             PERMISSION_GET_ATTACHMENT
137         };
138
139 /**************************************************************************
140  * global permissions variables
141  **************************************************************************/

142     protected boolean authenticated = false;
143
144     protected boolean activated = false;
145
146     protected boolean login = false;
147
148     protected boolean adminSystem = false;
149
150     protected boolean addForum = false;
151
152     protected boolean addCategory = false;
153
154     protected boolean editCategory = false;
155
156     protected boolean deleteCategory = false;
157
158     protected boolean sendMail = false;
159
160     protected boolean useAvatar = false;
161
162     protected boolean useMessage = false;
163
164     protected boolean addMessageAttachment = false;
165
166 /**************************************************************************
167  * individual forum permissions variables
168  **************************************************************************/

169     protected ForumListPermission editForum = new ForumListPermission();
170
171     protected ForumListPermission deleteForum = new ForumListPermission();
172
173     protected ForumListPermission assignToForum = new ForumListPermission();
174
175     protected ForumListPermission readPost = new ForumListPermission();
176
177     protected ForumListPermission addThread = new ForumListPermission();
178
179     protected ForumListPermission addPost = new ForumListPermission();
180
181     protected ForumListPermission editPost = new ForumListPermission();
182
183     protected ForumListPermission deletePost = new ForumListPermission();
184
185     protected ForumListPermission addPoll = new ForumListPermission();
186
187     protected ForumListPermission editPoll = new ForumListPermission();
188
189     protected ForumListPermission deletePoll = new ForumListPermission();
190
191     protected ForumListPermission addAttachment = new ForumListPermission();
192
193     protected ForumListPermission getAttachment = new ForumListPermission();
194
195     protected ForumListPermission moderateThread = new ForumListPermission();
196
197     protected ForumListPermission editOwnPost = new ForumListPermission();
198
199 /**************************************************************************
200  * global CHANNEL permissions variables
201  **************************************************************************/

202     protected boolean addChannel = false;
203
204     protected boolean editChannel = false;
205
206     protected boolean deleteChannel = false;
207
208 /**************************************************************************
209  * individual CHANNEL permissions variables
210  **************************************************************************/

211     protected ChannelListPermission writeContent = new ChannelListPermission();
212
213     protected ChannelListPermission editContent = new ChannelListPermission();
214
215     protected ChannelListPermission approveContent = new ChannelListPermission();
216
217     protected ChannelListPermission publishContent = new ChannelListPermission();
218
219     protected ChannelListPermission deleteContent = new ChannelListPermission();
220
221     /**
222      * constructor
223      */

224     protected AbstractPermission() {
225     }
226
227 /**************************************************************************
228  * The below methods are static methods
229  **************************************************************************/

230
231     public static String JavaDoc getDescription(int permission) throws BadInputException {
232         String JavaDoc desc = "";
233
234         switch (permission) {
235             /**************************************************************************
236              * Combined permissions
237              **************************************************************************/

238             case PERMISSION_SYSTEM_ADMIN:
239                 desc = "System Admin (Combined Permission)";
240                 break;
241
242             case PERMISSION_FORUM_ADMIN:
243                 desc = "Forum Admin (Combined Permission)";
244                 break;
245
246             case PERMISSION_FORUM_MODERATOR:
247                 desc = "Forum Moderator (Combined Permission)";
248                 break;
249
250             case PERMISSION_LIMITED_USER:
251                 desc = "Limited User (Combined Permission)";
252                 break;
253
254             case PERMISSION_NORMAL_USER:
255                 desc = "Normal User (Combined Permission)";
256                 break;
257
258             case PERMISSION_POWER_USER:
259                 desc = "Power User (Combined Permission)";
260                 break;
261
262             /**************************************************************************
263              * Individual permissions
264              **************************************************************************/

265             case PERMISSION_LOGIN:
266                 desc = "Can Login";
267                 break;
268
269             //case PERMISSION_ADMIN_SYSTEM:
270
// desc = "Admin System";
271
// break;
272

273             case PERMISSION_ADD_FORUM:
274                 desc = "Add Forum";
275                 break;
276
277             case PERMISSION_EDIT_FORUM:
278                 desc = "Edit Forum";
279                 break;
280
281             case PERMISSION_DELETE_FORUM:
282                 desc = "Delete Forum";
283                 break;
284
285             case PERMISSION_ASSIGN_TO_FORUM:
286                 desc = "Assign To Forum";
287                 break;
288
289             case PERMISSION_ADD_CATEGORY:
290                 desc = "Add Category";
291                 break;
292
293             case PERMISSION_EDIT_CATEGORY:
294                 desc = "Edit Category";
295                 break;
296
297             case PERMISSION_DELETE_CATEGORY:
298                 desc = "Delete Category";
299                 break;
300
301             case PERMISSION_SEND_MAIL:
302                 desc = "Send Mail";
303                 break;
304
305             case PERMISSION_BYPASS_PRIVATE_FORUM:
306                 desc = "Bypass Private Forum";
307                 break;
308
309             case PERMISSION_USE_MESSAGE:
310                 desc = "Use Private Message";
311                 break;
312
313             case PERMISSION_ADD_MESSAGE_ATTACHMENT:
314                 desc = "Upload Attachment in Private Message";
315                 break;
316
317             case PERMISSION_USE_AVATAR:
318                 desc = "Use Avatar";
319                 break;
320
321             case PERMISSION_READ_POST:
322                 desc = "Read Post";
323                 break;
324
325             case PERMISSION_ADD_THREAD:
326                 desc = "Add Thread";
327                 break;
328
329             case PERMISSION_ADD_POST:
330                 desc = "Add Post";
331                 break;
332
333             case PERMISSION_EDIT_POST:
334                 desc = "Edit Post";
335                 break;
336
337             case PERMISSION_DELETE_POST:
338                 desc = "Delete Post";
339                 break;
340
341             case PERMISSION_ADD_POLL:
342                 desc = "Add Poll";
343                 break;
344
345             case PERMISSION_EDIT_POLL:
346                 desc = "Edit Poll";
347                 break;
348
349             case PERMISSION_DELETE_POLL:
350                 desc = "Delete Poll";
351                 break;
352
353             case PERMISSION_ADD_ATTACHMENT:
354                 desc = "Add Attachment";
355                 break;
356
357             case PERMISSION_GET_ATTACHMENT:
358                 desc = "Get Attachment";
359                 break;
360
361             case PERMISSION_MODERATE_THREAD:
362                 desc = "Moderate Thread";
363                 break;
364
365             case PERMISSION_EDIT_OWN_POST:
366                 desc = "Edit Own Post";
367                 break;
368
369             /**************************************************************************
370              * Individual permissions for CHANNEL
371              **************************************************************************/

372             case PERMISSION_CMS_ADD_CHANNEL:
373                 desc = "Add Channel";
374                 break;
375
376             case PERMISSION_CMS_EDIT_CHANNEL:
377                 desc = "Edit Channel";
378                 break;
379
380             case PERMISSION_CMS_DELETE_CHANNEL:
381                 desc = "Delete Channel";
382                 break;
383
384             case PERMISSION_CMS_WRITE_CONTENT:
385                 desc = "Write Content";
386                 break;
387
388             case PERMISSION_CMS_EDIT_CONTENT:
389                 desc = "Edit Content";
390                 break;
391
392             case PERMISSION_CMS_APPROVE_CONTENT:
393                 desc = "Approve Content";
394                 break;
395
396             case PERMISSION_CMS_PUBLISH_CONTENT:
397                 desc = "Publish Content";
398                 break;
399
400             case PERMISSION_CMS_DELETE_CONTENT:
401                 desc = "Delete Content";
402                 break;
403
404
405             default:
406                 throw new BadInputException("Currently do not support permission = " + permission);
407         }//switch
408

409         return desc;
410     }
411
412 /**************************************************************************
413  * Special permissions methods
414  **************************************************************************/

415
416     public boolean isAuthenticated() {
417         return authenticated;
418     }
419     public void ensureIsAuthenticated() throws AuthenticationException {
420         if (authenticated == false) {
421             throw new AuthenticationException(NotLoginException.NOT_LOGIN);
422         }
423     }
424
425     public boolean isActivated() {
426         return activated;
427     }
428     public void ensureIsActivated() throws AuthenticationException {
429         if (activated == false) {
430             throw new AuthenticationException(NotLoginException.NOT_ACTIVATED);
431         }
432     }
433
434 /**************************************************************************
435  * global permissions methods
436  **************************************************************************/

437
438     public boolean canLogin() {
439         return login;
440     }
441     public void ensureCanLogin() throws AuthenticationException {
442         if (login == false) {
443             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
444         }
445     }
446
447     public boolean canAdminSystem() {
448         return adminSystem;
449     }
450     public void ensureCanAdminSystem() throws AuthenticationException {
451         if (adminSystem == false) {
452             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
453         }
454     }
455
456     public boolean canAddForum() {
457         return addForum;
458     }
459     public void ensureCanAddForum() throws AuthenticationException {
460         if (addForum == false) {
461             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
462         }
463     }
464
465     public boolean canAddCategory() {
466         return addCategory;
467     }
468     public void ensureCanAddCategory() throws AuthenticationException {
469         if (addCategory == false) {
470             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
471         }
472     }
473
474     public boolean canEditCategory() {
475         return editCategory;
476     }
477     public void ensureCanEditCategory() throws AuthenticationException {
478         if (editCategory == false) {
479             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
480         }
481     }
482
483     public boolean canDeleteCategory() {
484         return deleteCategory;
485     }
486     public void ensureCanDeleteCategory() throws AuthenticationException {
487         if (deleteCategory == false) {
488             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
489         }
490     }
491
492     public boolean canSendMail() {
493         return sendMail;
494     }
495     public void ensureCanSendMail() throws AuthenticationException {
496         if (sendMail == false) {
497             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
498         }
499     }
500
501     public boolean canUseAvatar() {
502         return useAvatar;
503     }
504     public void ensureCanUseAvatar() throws AuthenticationException {
505         if (useAvatar == false) {
506             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
507         }
508     }
509
510     public boolean canUseMessage() {
511         return useMessage;
512     }
513     public void ensureCanUseMessage() throws AuthenticationException {
514         if (useMessage == false) {
515             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
516         }
517     }
518
519     public boolean canAddMessageAttachment() {
520         return addMessageAttachment;
521     }
522     public void ensureCanAddMessageAttachment() throws AuthenticationException {
523         if (addMessageAttachment == false) {
524             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
525         }
526     }
527
528
529 /**************************************************************************
530  * individual forum permissions methods
531  **************************************************************************/

532     // For Forum Admin only
533
public boolean canEditForum(int forumID) {
534         return editForum.hasPermission(forumID);
535     }
536     public void ensureCanEditForum(int forumID) throws AuthenticationException {
537         if (canEditForum(forumID) == false) {
538             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
539         }
540     }
541
542     public boolean canDeleteForum(int forumID) {
543         return deleteForum.hasPermission(forumID);
544     }
545     public void ensureCanDeleteForum(int forumID) throws AuthenticationException {
546         if (canDeleteForum(forumID) == false) {
547             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
548         }
549     }
550
551     public boolean canAssignToForum(int forumID) {
552         return assignToForum.hasPermission(forumID);
553     }
554     public void ensureCanAssignToForum(int forumID) throws AuthenticationException {
555         if (canAssignToForum(forumID) == false) {
556             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
557         }
558     }
559
560     // Moderator and below permission
561
public boolean canReadPost(int forumID) {
562         return readPost.hasPermission(forumID);
563     }
564     public void ensureCanReadPost(int forumID) throws AuthenticationException {
565         if (canReadPost(forumID) == false) {
566             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
567         }
568     }
569
570     public boolean canAddThread(int forumID) {
571         return addThread.hasPermission(forumID);
572     }
573     public void ensureCanAddThread(int forumID) throws AuthenticationException {
574         if (canAddThread(forumID) == false) {
575             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
576         }
577     }
578
579     public boolean canAddPost(int forumID) {
580         return addPost.hasPermission(forumID);
581     }
582     public void ensureCanAddPost(int forumID) throws AuthenticationException {
583         if (canAddPost(forumID) == false) {
584             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
585         }
586     }
587
588     public boolean canEditPost(int forumID) {
589         return editPost.hasPermission(forumID);
590     }
591     public void ensureCanEditPost(int forumID) throws AuthenticationException {
592         if (canEditPost(forumID) == false) {
593             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
594         }
595     }
596
597     public boolean canEditOwnPost(int forumID) {
598         return editOwnPost.hasPermission(forumID);
599     }
600     public void ensureCanEditOwnPost(int forumID) throws AuthenticationException {
601         if (canEditOwnPost(forumID) == false) {
602             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
603         }
604     }
605
606     public boolean canDeletePost(int forumID) {
607         return deletePost.hasPermission(forumID);
608     }
609     public void ensureCanDeletePost(int forumID) throws AuthenticationException {
610         if (canDeletePost(forumID) == false) {
611             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
612         }
613     }
614
615     public boolean canAddPoll(int forumID) {
616         return addPoll.hasPermission(forumID);
617     }
618     public void ensureCanAddPoll(int forumID) throws AuthenticationException {
619         if (canAddPoll(forumID) == false) {
620             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
621         }
622     }
623
624     public boolean canEditPoll(int forumID) {
625         return editPoll.hasPermission(forumID);
626     }
627     public void ensureCanEditPoll(int forumID) throws AuthenticationException {
628         if (canEditPoll(forumID) == false) {
629             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
630         }
631     }
632
633     public boolean canDeletePoll(int forumID) {
634         return deletePoll.hasPermission(forumID);
635     }
636     public void ensureCanDeletePoll(int forumID) throws AuthenticationException {
637         if (canDeletePoll(forumID) == false) {
638             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
639         }
640     }
641
642     public boolean canAddAttachment(int forumID) {
643         return addAttachment.hasPermission(forumID);
644     }
645     public void ensureCanAddAttachment(int forumID) throws AuthenticationException {
646         if (canAddAttachment(forumID) == false) {
647             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
648         }
649     }
650
651     public boolean canGetAttachment(int forumID) {
652         return getAttachment.hasPermission(forumID);
653     }
654     public void ensureCanGetAttachment(int forumID) throws AuthenticationException {
655         if (canGetAttachment(forumID) == false) {
656             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
657         }
658     }
659
660     public boolean canModerateThread(int forumID) {
661         return moderateThread.hasPermission(forumID);
662     }
663     public void ensureCanModerateThread(int forumID) throws AuthenticationException {
664         if (canModerateThread(forumID) == false) {
665             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
666         }
667     }
668
669     /**************************************************************************
670      * individual forum permissions methods
671      **************************************************************************/

672     // For Forum Admin only
673
public boolean canEditAnyForum() {
674         return editForum.hasPermssionInAnyForums();
675     }
676     public void ensureCanEditAnyForum() throws AuthenticationException {
677         if (canEditAnyForum() == false) {
678             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
679         }
680     }
681
682     // For moderation thread
683
public boolean canModerateThreadInAnyForum() {
684         return moderateThread.hasPermssionInAnyForums();
685     }
686     public void ensureCanModerateThreadInAnyForum() throws AuthenticationException {
687         if (canModerateThreadInAnyForum() == false) {
688             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
689         }
690     }
691
692 /**************************************************************************
693  * individual CMS permissions methods
694  **************************************************************************/

695     public boolean canAddChannel() {
696         return addChannel;
697     }
698     public void ensureCanAddChannel() throws AuthenticationException {
699         if (addChannel == false) {
700             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
701         }
702     }
703
704     public boolean canEditChannel() {
705         return editChannel;
706     }
707     public void ensureCanEditChannel() throws AuthenticationException {
708         if (editChannel == false) {
709             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
710         }
711     }
712
713     public boolean canDeleteChannel() {
714         return deleteChannel;
715     }
716     public void ensureCanDeleteChannel() throws AuthenticationException {
717         if (deleteChannel == false) {
718             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
719         }
720     }
721
722 /**************************************************************************
723  * individual CMS CHANNEL permissions methods
724  **************************************************************************/

725     public boolean canWriteContent(int channelID) {
726         return writeContent.hasPermission(channelID);
727     }
728     public void ensureCanWriteContent(int channelID) throws AuthenticationException {
729         if (canWriteContent(channelID) == false) {
730             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
731         }
732     }
733
734     public boolean canEditContent(int channelID) {
735         return editContent.hasPermission(channelID);
736     }
737     public void ensureCanEditContent(int channelID) throws AuthenticationException {
738         if (canEditContent(channelID) == false) {
739             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
740         }
741     }
742
743     public boolean canApproveContent(int channelID) {
744         return approveContent.hasPermission(channelID);
745     }
746     public void ensureCanApproveContent(int channelID) throws AuthenticationException {
747         if (canApproveContent(channelID) == false) {
748             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
749         }
750     }
751
752     public boolean canPublishContent(int channelID) {
753         return publishContent.hasPermission(channelID);
754     }
755     public void ensureCanPublishContent(int channelID) throws AuthenticationException {
756         if (canPublishContent(channelID) == false) {
757             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
758         }
759     }
760
761     public boolean canDeleteContent(int channelID) {
762         return deleteContent.hasPermission(channelID);
763     }
764     public void ensureCanDeleteContent(int channelID) throws AuthenticationException {
765         if (canDeleteContent(channelID) == false) {
766             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
767         }
768     }
769
770     /**************************************************************************
771      * individual CHANNEL permissions methods
772      **************************************************************************/

773     public boolean canWriteContentInAnyChannel() {
774         return writeContent.hasPermssionInAnyChannels();
775     }
776     public void ensureCanWriteContentInAnyChannel() throws AuthenticationException {
777         if (canWriteContentInAnyChannel() == false) {
778             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
779         }
780     }
781
782     public boolean canEditContentInAnyChannel() {
783         return editContent.hasPermssionInAnyChannels();
784     }
785     public void ensureCanEditContentInAnyChannel() throws AuthenticationException {
786         if (canEditContentInAnyChannel() == false) {
787             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
788         }
789     }
790
791     public boolean canApproveContentInAnyChannel() {
792         return approveContent.hasPermssionInAnyChannels();
793     }
794     public void ensureCanApproveContentInAnyChannel() throws AuthenticationException {
795         if (canApproveContentInAnyChannel() == false) {
796             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
797         }
798     }
799
800     public boolean canPublishContentInAnyChannel() {
801         return publishContent.hasPermssionInAnyChannels();
802     }
803     public void ensureCanPublishContentInAnyChannel() throws AuthenticationException {
804         if (canPublishContentInAnyChannel() == false) {
805             throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
806         }
807     }
808
809 }
810
Popular Tags