javax.naming.NoPermissionException Java Examples

The following examples show how to use javax.naming.NoPermissionException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UserMgrController.java    From MeetingFilm with Apache License 2.0 6 votes vote down vote up
/**
 * 修改管理员
 *
 * @throws NoPermissionException
 */
@RequestMapping("/edit")
@BussinessLog(value = "修改管理员", key = "account", dict = UserDict.class)
@ResponseBody
public Tip edit(@Valid UserDto user, BindingResult result) throws NoPermissionException {
    if (result.hasErrors()) {
        throw new GunsException(BizExceptionEnum.REQUEST_NULL);
    }

    User oldUser = userService.selectById(user.getId());

    if (ShiroKit.hasRole(Const.ADMIN_NAME)) {
        this.userService.updateById(UserFactory.editUser(user, oldUser));
        return SUCCESS_TIP;
    } else {
        assertAuth(user.getId());
        ShiroUser shiroUser = ShiroKit.getUser();
        if (shiroUser.getId().equals(user.getId())) {
            this.userService.updateById(UserFactory.editUser(user, oldUser));
            return SUCCESS_TIP;
        } else {
            throw new GunsException(BizExceptionEnum.NO_PERMITION);
        }
    }
}
 
Example #2
Source File: UserMgrController.java    From WebStack-Guns with MIT License 6 votes vote down vote up
/**
 * 修改管理员
 *
 * @throws NoPermissionException
 */
@RequestMapping("/edit")
@BussinessLog(value = "修改管理员", key = "account", dict = UserDict.class)
@ResponseBody
public ResponseData edit(@Valid UserDto user, BindingResult result) throws NoPermissionException {
    if (result.hasErrors()) {
        throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
    }

    User oldUser = userService.selectById(user.getId());

    if (ShiroKit.hasRole(Const.ADMIN_NAME)) {
        this.userService.updateById(UserFactory.editUser(user, oldUser));
        return SUCCESS_TIP;
    } else {
        assertAuth(user.getId());
        ShiroUser shiroUser = ShiroKit.getUser();
        if (shiroUser.getId().equals(user.getId())) {
            this.userService.updateById(UserFactory.editUser(user, oldUser));
            return SUCCESS_TIP;
        } else {
            throw new ServiceException(BizExceptionEnum.NO_PERMITION);
        }
    }
}
 
Example #3
Source File: DiscussionAPIController.java    From onboard with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "/{discussionId}", method = RequestMethod.PUT)
@Interceptors({ ProjectMemberRequired.class, ProjectNotArchivedRequired.class })
@ResponseBody
public Object updateDiscussion(@PathVariable("companyId") int companyId, @PathVariable("projectId") int projectId,
        @PathVariable("discussionId") int discussionId, @Valid @RequestBody DiscussionForm form,
        @RequestParam(value = "recover", defaultValue = "false", required = true) Boolean recover)
        throws NoPermissionException {
    if (recover) {
        return recoverDiscussion(discussionId);
    }
    logger.info("Updating discussion " + discussionId);
    logger.info("attachments " + form.getAttachments().size());
    form.setProjectId(projectId);
    form.setCompanyId(companyId);
    discussionService.updateSelective(form);
    Topic topic = topicService.getTopicByTypeAndId(form.getType(), form.getId());
    TopicDTO result = TopicTransform.topicToTopicDTO(topic);
    logger.info("add comment count...");
    addCommentCount(result);
    logger.info("Finishing...");
    return result;
}
 
Example #4
Source File: DiscussionAPIController.java    From onboard with Apache License 2.0 6 votes vote down vote up
private Map<String, ?> recoverDiscussion(@PathVariable("discussionId") int discussionId)
        throws NoPermissionException {
    logger.info("recovering " + discussionId);
    Discussion discussion = discussionService.getById(discussionId);
    if (discussion.getId().equals(session.getCurrentUser().getId())) {
        throw new NoPermissionException();
    }
    discussion.setDeleted(false);
    discussionService.updateSelective(discussion);
    // discussionService.discardDiscussion(discussionId);
    discussion = discussionService.getByIdWithDetail(discussionId);
    DiscussionDTO discussionDto = DiscussionTransform.discussionToDiscussionDTOWithDetail(discussion);
    Topic topic = topicService.getTopicByTypeAndId(discussion.getType(), discussion.getId());
    TopicDTO topicDTO = TopicTransform.topicToTopicDTO(topic);
    addCommentCount(topicDTO);
    return ImmutableMap.of("discussion", discussionDto, "topic", topicDTO);

}
 
Example #5
Source File: AccountController.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
@PostMapping(value = "/register", headers = "Content-Type=application/x-www-form-urlencoded")
@ResponseBody
public Map<String, String> registerUser(
    @Valid @ModelAttribute RegisterRequest registerRequest, HttpServletRequest request)
    throws Exception {
  if (authenticationSettings.getSignUp()) {
    if (!registerRequest.getPassword().equals(registerRequest.getConfirmPassword())) {
      throw new BindException(RegisterRequest.class, "password does not match confirm password");
    }
    if (appSettings.getRecaptchaIsEnabled()
        && !reCaptchaService.validate(registerRequest.getRecaptcha())) {
      throw new CaptchaException("invalid captcha answer");
    }
    User user = toUser(registerRequest);
    String activationUri =
        ServletUriComponentsBuilder.fromCurrentRequest()
            .replacePath(URI + "/activate")
            .toUriString();
    accountService.createUser(user, activationUri);

    String successMessage =
        authenticationSettings.getSignUpModeration()
            ? REGISTRATION_SUCCESS_MESSAGE_ADMIN
            : REGISTRATION_SUCCESS_MESSAGE_USER;
    return Collections.singletonMap("message", successMessage);
  } else {
    throw new NoPermissionException("Self registration is disabled");
  }
}
 
Example #6
Source File: ContextImpl.java    From gemfirexd-oss with Apache License 2.0 2 votes vote down vote up
/**
 * Checks if this context has been destroyed. isDestroyed is set to true when
 * a context is destroyed by calling destroySubcontext method.
 * 
 * @throws NoPermissionException if this context has been destroyed
 */
private void checkIsDestroyed() throws NamingException {
  if (isDestroyed) { throw new NoPermissionException(LocalizedStrings.ContextImpl_CAN_NOT_INVOKE_OPERATIONS_ON_DESTROYED_CONTEXT.toLocalizedString()); }
}
 
Example #7
Source File: ContextImpl.java    From gemfirexd-oss with Apache License 2.0 2 votes vote down vote up
/**
 * Checks if this context has been destroyed. isDestroyed is set to true when
 * a context is destroyed by calling destroySubcontext method.
 * 
 * @throws NoPermissionException if this context has been destroyed
 */
private void checkIsDestroyed() throws NamingException {
  if (isDestroyed) { throw new NoPermissionException(LocalizedStrings.ContextImpl_CAN_NOT_INVOKE_OPERATIONS_ON_DESTROYED_CONTEXT.toLocalizedString()); }
}