Esempio n. 1
0
  /**
   * Handle request internal model and view.
   *
   * @param request the request
   * @param response the response
   * @return the model and view
   * @throws Exception the exception
   */
  @RequestMapping(path = OAuthConstants.BASE_OAUTH20_URL + '/' + OAuthConstants.AUTHORIZE_URL)
  public ModelAndView handleRequestInternal(
      final HttpServletRequest request, final HttpServletResponse response) throws Exception {

    final J2EContext context = new J2EContext(request, response);
    final ProfileManager manager = new ProfileManager(context);

    if (!verifyAuthorizeRequest(request) || !isRequestAuthenticated(manager, context)) {
      logger.error("Authorize request verification fails");
      return new ModelAndView(OAuthConstants.ERROR_VIEW);
    }

    final String clientId = context.getRequestParameter(OAuthConstants.CLIENT_ID);
    final OAuthRegisteredService registeredService =
        OAuthUtils.getRegisteredOAuthService(this.servicesManager, clientId);
    try {
      RegisteredServiceAccessStrategyUtils.ensureServiceAccessIsAllowed(
          clientId, registeredService);
    } catch (final Exception e) {
      logger.error(e.getMessage(), e);
      return new ModelAndView(OAuthConstants.ERROR_VIEW);
    }

    final ModelAndView mv = this.consentApprovalViewResolver.resolve(context, registeredService);
    if (!mv.isEmpty() && mv.hasView()) {
      return mv;
    }

    return redirectToCallbackRedirectUrl(manager, registeredService, context, clientId);
  }
Esempio n. 2
0
  @RequestMapping(value = "/changeState", method = RequestMethod.POST)
  public ModelAndView changeState(
      @RequestParam("candidateId") String candidateId,
      @RequestParam(required = false, value = "assigneeId") String assigneeId,
      @RequestParam(required = false, value = "nextState") String nextState,
      @RequestParam(required = false, value = "remarks") String remarks,
      @RequestParam("result") String result,
      @RequestParam(required = false, value = "pageId") String pageId,
      @RequestParam(required = false, value = "schTime") String schTime) {

    String username =
        (String) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    candidateApiService.changeState(
        candidateId, assigneeId, nextState, remarks, result, schTime, username);

    ModelAndView mv = new ModelAndView();
    if ("freshcandidatedashboard".equalsIgnoreCase(pageId)) {
      mv = getFreshCandidate();
      if (mv.isEmpty()) {
        mv.addObject("isEmpty", true);
      } else {
        mv.addObject("isEmpty", false);
      }
      mv.addObject("pageId", "freshcandidatedashboard");
      mv.setViewName("hr/freshCandidateDashboard");
    } else if ("screenedcandidatedashboard".equalsIgnoreCase(pageId)) {
      mv = getScreenedCandidate();
      if (mv.isEmpty()) {
        mv.addObject("isEmpty", true);
      } else {
        mv.addObject("isEmpty", false);
      }
      mv.addObject("pageId", "screenedcandidatedashboard");
      mv.setViewName("hr/screenedCandidateDashboard");
    } else {
      /*String username = (String)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
      if(!StringUtils.hasText(username)){
          return new ModelAndView("common/thanks");
      }*/
      return new ModelAndView("common/thanks");
    }
    return mv;
  }
Esempio n. 3
0
 @RequestMapping("/getFreshCandidateDashboard")
 public ModelAndView getFreshCandidateDashboard() {
   ModelAndView mv = getFreshCandidate();
   if (mv.isEmpty()) {
     mv.addObject("isEmpty", true);
   } else {
     mv.addObject("isEmpty", false);
   }
   mv.addObject("pageId", "freshcandidatedashboard");
   mv.setViewName("hr/freshCandidateDashboard");
   return mv;
 }
  @Test
  public void resolveExceptionResponseWriter()
      throws UnsupportedEncodingException, NoSuchMethodException {
    IllegalArgumentException ex = new IllegalArgumentException();
    HandlerMethod handlerMethod = new HandlerMethod(new ResponseWriterController(), "handle");
    this.resolver.afterPropertiesSet();
    ModelAndView mav =
        this.resolver.resolveException(this.request, this.response, handlerMethod, ex);

    assertNotNull(mav);
    assertTrue(mav.isEmpty());
    assertEquals("IllegalArgumentException", this.response.getContentAsString());
  }
  @Test
  public void resolveExceptionModelAndView() throws NoSuchMethodException {
    IllegalArgumentException ex = new IllegalArgumentException("Bad argument");
    HandlerMethod handlerMethod = new HandlerMethod(new ModelAndViewController(), "handle");
    this.resolver.afterPropertiesSet();
    ModelAndView mav =
        this.resolver.resolveException(this.request, this.response, handlerMethod, ex);

    assertNotNull(mav);
    assertFalse(mav.isEmpty());
    assertEquals("errorView", mav.getViewName());
    assertEquals("Bad argument", mav.getModel().get("detail"));
  }
  @Test
  public void resolveExceptionGlobalHandler()
      throws UnsupportedEncodingException, NoSuchMethodException {
    AnnotationConfigApplicationContext cxt = new AnnotationConfigApplicationContext(MyConfig.class);
    this.resolver.setApplicationContext(cxt);
    this.resolver.setGlobalExceptionHandlers(new GlobalExceptionHandler());
    this.resolver.afterPropertiesSet();

    IllegalStateException ex = new IllegalStateException();
    HandlerMethod handlerMethod = new HandlerMethod(new ResponseBodyController(), "handle");
    ModelAndView mav =
        this.resolver.resolveException(this.request, this.response, handlerMethod, ex);

    assertNotNull("Exception was not handled", mav);
    assertTrue(mav.isEmpty());
    assertEquals("IllegalStateException", this.response.getContentAsString());
  }