📄 abstractpermission.java
字号:
break;
case PERMISSION_EDIT_POLL:
desc = "Edit Poll";
break;
case PERMISSION_DELETE_POLL:
desc = "Delete Poll";
break;
case PERMISSION_ADD_ATTACHMENT:
desc = "Add Attachment";
break;
case PERMISSION_GET_ATTACHMENT:
desc = "Get Attachment";
break;
case PERMISSION_MODERATE_THREAD:
desc = "Moderate Thread";
break;
default:
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);
}
}
/**************************************************************************
* individual forum permissions methods
**************************************************************************/
// For Forum Admin only
public boolean canEditForum(int forumID) {
return editForum.hasPermssion(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.hasPermssion(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.hasPermssion(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.hasPermssion(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.hasPermssion(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.hasPermssion(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.hasPermssion(forumID);
}
public void ensureCanEditPost(int forumID) throws AuthenticationException {
if (canEditPost(forumID) == false) {
throw new AuthenticationException(NotLoginException.NOT_ENOUGH_RIGHTS);
}
}
public boolean canDeletePost(int forumID) {
return deletePost.hasPermssion(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.hasPermssion(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.hasPermssion(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.hasPermssion(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.hasPermssion(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.hasPermssion(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.hasPermssion(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);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -