📄 abstractpermission.java
字号:
throw new BadInputException("Currently do not support permission = " + permission);
}//switch
return desc;
}
/**************************************************************************
* Special permissions methods
**************************************************************************/
public boolean isAuthenticated() {
return authenticated;
}
public void ensureIsAuthenticated() throws AuthenticationException {
if (authenticated == false) {
throw new AuthenticationException(NotLoginException.NOT_LOGIN);
}
}
public boolean isActivated() {
return activated;
}
public void ensureIsActivated() throws AuthenticationException {
if (activated == false) {
throw new AuthenticationException(NotLoginException.NOT_ACTIVATED);
}
}
/**************************************************************************
* global permissions methods
**************************************************************************/
public boolean canLogin() {
return login;
}
public void ensureCanLogin() throws AuthenticationException {
if (login == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canAdminSystem() {
return adminSystem;
}
public void ensureCanAdminSystem() throws AuthenticationException {
if (adminSystem == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canAddForum() {
return addForum;
}
public void ensureCanAddForum() throws AuthenticationException {
if (addForum == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canAddCategory() {
return addCategory;
}
public void ensureCanAddCategory() throws AuthenticationException {
if (addCategory == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canEditCategory() {
return editCategory;
}
public void ensureCanEditCategory() throws AuthenticationException {
if (editCategory == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canDeleteCategory() {
return deleteCategory;
}
public void ensureCanDeleteCategory() throws AuthenticationException {
if (deleteCategory == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canSendMail() {
return sendMail;
}
public void ensureCanSendMail() throws AuthenticationException {
if (sendMail == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canUseAvatar() {
return useAvatar;
}
public void ensureCanUseAvatar() throws AuthenticationException {
if (useAvatar == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canUseMessage() {
return useMessage;
}
public void ensureCanUseMessage() throws AuthenticationException {
if (useMessage == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canAddMessageAttachment() {
return addMessageAttachment;
}
public void ensureCanAddMessageAttachment() throws AuthenticationException {
if (addMessageAttachment == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
/**************************************************************************
* individual forum permissions methods
**************************************************************************/
// For Forum Admin only
public boolean canEditForum(int forumID) {
return editForum.hasPermission(forumID);
}
public void ensureCanEditForum(int forumID) throws AuthenticationException {
if (canEditForum(forumID) == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canDeleteForum(int forumID) {
return deleteForum.hasPermission(forumID);
}
public void ensureCanDeleteForum(int forumID) throws AuthenticationException {
if (canDeleteForum(forumID) == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canAssignToForum(int forumID) {
return assignToForum.hasPermission(forumID);
}
public void ensureCanAssignToForum(int forumID) throws AuthenticationException {
if (canAssignToForum(forumID) == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
// Moderator and below permission
public boolean canReadPost(int forumID) {
return readPost.hasPermission(forumID);
}
public void ensureCanReadPost(int forumID) throws AuthenticationException {
if (canReadPost(forumID) == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canAddThread(int forumID) {
return addThread.hasPermission(forumID);
}
public void ensureCanAddThread(int forumID) throws AuthenticationException {
if (canAddThread(forumID) == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canAddPost(int forumID) {
return addPost.hasPermission(forumID);
}
public void ensureCanAddPost(int forumID) throws AuthenticationException {
if (canAddPost(forumID) == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canEditPost(int forumID) {
return editPost.hasPermission(forumID);
}
public void ensureCanEditPost(int forumID) throws AuthenticationException {
if (canEditPost(forumID) == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canEditOwnPost(int forumID) {
return editOwnPost.hasPermission(forumID);
}
public void ensureCanEditOwnPost(int forumID) throws AuthenticationException {
if (canEditOwnPost(forumID) == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canDeletePost(int forumID) {
return deletePost.hasPermission(forumID);
}
public void ensureCanDeletePost(int forumID) throws AuthenticationException {
if (canDeletePost(forumID) == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canAddPoll(int forumID) {
return addPoll.hasPermission(forumID);
}
public void ensureCanAddPoll(int forumID) throws AuthenticationException {
if (canAddPoll(forumID) == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canEditPoll(int forumID) {
return editPoll.hasPermission(forumID);
}
public void ensureCanEditPoll(int forumID) throws AuthenticationException {
if (canEditPoll(forumID) == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canDeletePoll(int forumID) {
return deletePoll.hasPermission(forumID);
}
public void ensureCanDeletePoll(int forumID) throws AuthenticationException {
if (canDeletePoll(forumID) == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canAddAttachment(int forumID) {
return addAttachment.hasPermission(forumID);
}
public void ensureCanAddAttachment(int forumID) throws AuthenticationException {
if (canAddAttachment(forumID) == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canGetAttachment(int forumID) {
return getAttachment.hasPermission(forumID);
}
public void ensureCanGetAttachment(int forumID) throws AuthenticationException {
if (canGetAttachment(forumID) == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canModerateThread(int forumID) {
return moderateThread.hasPermission(forumID);
}
public void ensureCanModerateThread(int forumID) throws AuthenticationException {
if (canModerateThread(forumID) == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
/**************************************************************************
* individual forum permissions methods
**************************************************************************/
// For Forum Admin only
public boolean canEditAnyForum() {
return editForum.hasPermssionInAnyForums();
}
public void ensureCanEditAnyForum() throws AuthenticationException {
if (canEditAnyForum() == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
// For moderation thread
public boolean canModerateThreadInAnyForum() {
return moderateThread.hasPermssionInAnyForums();
}
public void ensureCanModerateThreadInAnyForum() throws AuthenticationException {
if (canModerateThreadInAnyForum() == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
/**************************************************************************
* individual CMS permissions methods
**************************************************************************/
public boolean canAddChannel() {
return addChannel;
}
public void ensureCanAddChannel() throws AuthenticationException {
if (addChannel == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canEditChannel() {
return editChannel;
}
public void ensureCanEditChannel() throws AuthenticationException {
if (editChannel == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canDeleteChannel() {
return deleteChannel;
}
public void ensureCanDeleteChannel() throws AuthenticationException {
if (deleteChannel == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
/**************************************************************************
* individual CMS CHANNEL permissions methods
**************************************************************************/
public boolean canWriteContent(int channelID) {
return writeContent.hasPermission(channelID);
}
public void ensureCanWriteContent(int channelID) throws AuthenticationException {
if (canWriteContent(channelID) == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canEditContent(int channelID) {
return editContent.hasPermission(channelID);
}
public void ensureCanEditContent(int channelID) throws AuthenticationException {
if (canEditContent(channelID) == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canApproveContent(int channelID) {
return approveContent.hasPermission(channelID);
}
public void ensureCanApproveContent(int channelID) throws AuthenticationException {
if (canApproveContent(channelID) == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canPublishContent(int channelID) {
return publishContent.hasPermission(channelID);
}
public void ensureCanPublishContent(int channelID) throws AuthenticationException {
if (canPublishContent(channelID) == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canDeleteContent(int channelID) {
return deleteContent.hasPermission(channelID);
}
public void ensureCanDeleteContent(int channelID) throws AuthenticationException {
if (canDeleteContent(channelID) == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
/**************************************************************************
* individual CHANNEL permissions methods
**************************************************************************/
public boolean canWriteContentInAnyChannel() {
return writeContent.hasPermssionInAnyChannels();
}
public void ensureCanWriteContentInAnyChannel() throws AuthenticationException {
if (canWriteContentInAnyChannel() == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canEditContentInAnyChannel() {
return editContent.hasPermssionInAnyChannels();
}
public void ensureCanEditContentInAnyChannel() throws AuthenticationException {
if (canEditContentInAnyChannel() == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canApproveContentInAnyChannel() {
return approveContent.hasPermssionInAnyChannels();
}
public void ensureCanApproveContentInAnyChannel() throws AuthenticationException {
if (canApproveContentInAnyChannel() == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canPublishContentInAnyChannel() {
return publishContent.hasPermssionInAnyChannels();
}
public void ensureCanPublishContentInAnyChannel() throws AuthenticationException {
if (canPublishContentInAnyChannel() == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -