com.xxl.job.admin.controller.annotation.PermessionLimit Java Examples

The following examples show how to use com.xxl.job.admin.controller.annotation.PermessionLimit. 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: PermissionInterceptor.java    From open-capacity-platform with Apache License 2.0 6 votes vote down vote up
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
	
	if (!(handler instanceof HandlerMethod)) {
		return super.preHandle(request, response, handler);
	}
	
	if (!ifLogin(request)) {
		HandlerMethod method = (HandlerMethod)handler;
		PermessionLimit permission = method.getMethodAnnotation(PermessionLimit.class);
		if (permission == null || permission.limit()) {
			response.sendRedirect(request.getContextPath() + "/toLogin");
			//request.getRequestDispatcher("/toLogin").forward(request, response);
			return false;
		}
	}
	
	return super.preHandle(request, response, handler);
}
 
Example #2
Source File: IndexController.java    From zuihou-admin-cloud with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "login", method = RequestMethod.POST)
@ResponseBody
@PermessionLimit(limit = false)
public ReturnT<String> loginDo(HttpServletRequest request, HttpServletResponse response, String userName, String password, String ifRemember) {
	// valid
	if (PermissionInterceptor.ifLogin(request)) {
		return ReturnT.SUCCESS;
	}

	// param
	if (StrUtil.isBlank(userName) || StrUtil.isBlank(password)) {
		return new ReturnT<String>(500, I18nUtil.getString("login_param_empty"));
	}
	boolean ifRem = (StrUtil.isNotBlank(ifRemember) && "on".equals(ifRemember)) ? true : false;

	// do login
	boolean loginRet = PermissionInterceptor.login(response, userName, password, ifRem);
	if (!loginRet) {
		return new ReturnT<String>(500, I18nUtil.getString("login_param_unvalid"));
	}
	return ReturnT.SUCCESS;
}
 
Example #3
Source File: PermissionInterceptor.java    From zuihou-admin-cloud with Apache License 2.0 6 votes vote down vote up
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

    if (!(handler instanceof HandlerMethod)) {
        return super.preHandle(request, response, handler);
    }

    if (!ifLogin(request)) {
        HandlerMethod method = (HandlerMethod) handler;
        PermessionLimit permission = method.getMethodAnnotation(PermessionLimit.class);
        if (permission == null || permission.limit()) {
            response.sendRedirect(request.getContextPath() + "/toLogin");
            //request.getRequestDispatcher("/toLogin").forward(request, response);
            return false;
        }
    }

    return super.preHandle(request, response, handler);
}
 
Example #4
Source File: IndexController.java    From zuihou-admin-boot with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "login", method = RequestMethod.POST)
@ResponseBody
@PermessionLimit(limit = false)
public ReturnT<String> loginDo(HttpServletRequest request, HttpServletResponse response, String userName, String password, String ifRemember) {
    // valid
    if (PermissionInterceptor.ifLogin(request)) {
        return ReturnT.SUCCESS;
    }

    // param
    if (StrUtil.isBlank(userName) || StrUtil.isBlank(password)) {
        return new ReturnT<String>(500, I18nUtil.getString("login_param_empty"));
    }
    boolean ifRem = (StrUtil.isNotBlank(ifRemember) && "on".equals(ifRemember)) ? true : false;

    // do login
    boolean loginRet = PermissionInterceptor.login(response, userName, password, ifRem);
    if (!loginRet) {
        return new ReturnT<String>(500, I18nUtil.getString("login_param_unvalid"));
    }
    return ReturnT.SUCCESS;
}
 
Example #5
Source File: PermissionInterceptor.java    From zuihou-admin-boot with Apache License 2.0 6 votes vote down vote up
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

    if (!(handler instanceof HandlerMethod)) {
        return super.preHandle(request, response, handler);
    }

    if (!ifLogin(request)) {
        HandlerMethod method = (HandlerMethod) handler;
        PermessionLimit permission = method.getMethodAnnotation(PermessionLimit.class);
        if (permission == null || permission.limit()) {
            response.sendRedirect(request.getContextPath() + "/toLogin");
            //request.getRequestDispatcher("/toLogin").forward(request, response);
            return false;
        }
    }

    return super.preHandle(request, response, handler);
}
 
Example #6
Source File: IndexController.java    From microservices-platform with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value="login", method=RequestMethod.POST)
@ResponseBody
@PermessionLimit(limit=false)
public ReturnT<String> loginDo(HttpServletRequest request, HttpServletResponse response, String userName, String password, String ifRemember){
	// valid
	if (PermissionInterceptor.ifLogin(request)) {
		return ReturnT.SUCCESS;
	}

	// param
	if (StringUtils.isBlank(userName) || StringUtils.isBlank(password)){
		return new ReturnT<String>(500, I18nUtil.getString("login_param_empty"));
	}
	boolean ifRem = (StringUtils.isNotBlank(ifRemember) && "on".equals(ifRemember))?true:false;

	// do login
	boolean loginRet = PermissionInterceptor.login(response, userName, password, ifRem);
	if (!loginRet) {
		return new ReturnT<String>(500, I18nUtil.getString("login_param_unvalid"));
	}
	return ReturnT.SUCCESS;
}
 
Example #7
Source File: PermissionInterceptor.java    From microservices-platform with Apache License 2.0 6 votes vote down vote up
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
	
	if (!(handler instanceof HandlerMethod)) {
		return super.preHandle(request, response, handler);
	}
	
	if (!ifLogin(request)) {
		HandlerMethod method = (HandlerMethod)handler;
		PermessionLimit permission = method.getMethodAnnotation(PermessionLimit.class);
		if (permission == null || permission.limit()) {
			response.sendRedirect(request.getContextPath() + "/toLogin");
			//request.getRequestDispatcher("/toLogin").forward(request, response);
			return false;
		}
	}
	
	return super.preHandle(request, response, handler);
}
 
Example #8
Source File: IndexController.java    From open-capacity-platform with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value="login", method=RequestMethod.POST)
@ResponseBody
@PermessionLimit(limit=false)
public ReturnT<String> loginDo(HttpServletRequest request, HttpServletResponse response, String userName, String password, String ifRemember){
	// valid
	if (PermissionInterceptor.ifLogin(request)) {
		return ReturnT.SUCCESS;
	}

	// param
	if (StringUtils.isBlank(userName) || StringUtils.isBlank(password)){
		return new ReturnT<String>(500, I18nUtil.getString("login_param_empty"));
	}
	boolean ifRem = (StringUtils.isNotBlank(ifRemember) && "on".equals(ifRemember))?true:false;

	// do login
	boolean loginRet = PermissionInterceptor.login(response, userName, password, ifRem);
	if (!loginRet) {
		return new ReturnT<String>(500, I18nUtil.getString("login_param_unvalid"));
	}
	return ReturnT.SUCCESS;
}
 
Example #9
Source File: JobApiController.java    From open-capacity-platform with Apache License 2.0 6 votes vote down vote up
@RequestMapping(AdminBiz.MAPPING)
@PermessionLimit(limit=false)
public void api(HttpServletRequest request, HttpServletResponse response) throws IOException {

    // invoke
    RpcResponse rpcResponse = doInvoke(request);

    // serialize response
    byte[] responseBytes = HessianSerializer.serialize(rpcResponse);

    response.setContentType("text/html;charset=utf-8");
    response.setStatus(HttpServletResponse.SC_OK);
    //baseRequest.setHandled(true);

    OutputStream out = response.getOutputStream();
    out.write(responseBytes);
    out.flush();
}
 
Example #10
Source File: IndexController.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
@RequestMapping("/toLogin")
@PermessionLimit(limit=false)
public String toLogin(Model model, HttpServletRequest request) {
	if (PermissionInterceptor.ifLogin(request)) {
		return "redirect:/";
	}
	return "login";
}
 
Example #11
Source File: IndexController.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value="logout", method=RequestMethod.POST)
@ResponseBody
@PermessionLimit(limit=false)
public ReturnT<String> logout(HttpServletRequest request, HttpServletResponse response){
	if (PermissionInterceptor.ifLogin(request)) {
		PermissionInterceptor.logout(request, response);
	}
	return ReturnT.SUCCESS;
}
 
Example #12
Source File: IndexController.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value="logout", method=RequestMethod.POST)
@ResponseBody
@PermessionLimit(limit=false)
public ReturnT<String> logout(HttpServletRequest request, HttpServletResponse response){
	if (PermissionInterceptor.ifLogin(request)) {
		PermissionInterceptor.logout(request, response);
	}
	return ReturnT.SUCCESS;
}
 
Example #13
Source File: IndexController.java    From zuihou-admin-boot with Apache License 2.0 5 votes vote down vote up
@RequestMapping("/toLogin")
@PermessionLimit(limit = false)
public String toLogin(Model model, HttpServletRequest request) {
    if (PermissionInterceptor.ifLogin(request)) {
        return "redirect:/";
    }
    return "login";
}
 
Example #14
Source File: IndexController.java    From zuihou-admin-boot with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "logout", method = RequestMethod.POST)
@ResponseBody
@PermessionLimit(limit = false)
public ReturnT<String> logout(HttpServletRequest request, HttpServletResponse response) {
    if (PermissionInterceptor.ifLogin(request)) {
        PermissionInterceptor.logout(request, response);
    }
    return ReturnT.SUCCESS;
}
 
Example #15
Source File: IndexController.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
@RequestMapping("/toLogin")
@PermessionLimit(limit=false)
public String toLogin(Model model, HttpServletRequest request) {
	if (PermissionInterceptor.ifLogin(request)) {
		return "redirect:/";
	}
	return "login";
}
 
Example #16
Source File: IndexController.java    From zuihou-admin-cloud with Apache License 2.0 5 votes vote down vote up
@RequestMapping("/toLogin")
@PermessionLimit(limit = false)
public String toLogin(Model model, HttpServletRequest request) {
	if (PermissionInterceptor.ifLogin(request)) {
		return "redirect:/";
	}
	return "login";
}
 
Example #17
Source File: IndexController.java    From zuihou-admin-cloud with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "logout", method = RequestMethod.POST)
@ResponseBody
@PermessionLimit(limit = false)
public ReturnT<String> logout(HttpServletRequest request, HttpServletResponse response) {
	if (PermissionInterceptor.ifLogin(request)) {
		PermissionInterceptor.logout(request, response);
	}
	return ReturnT.SUCCESS;
}
 
Example #18
Source File: JobApiController.java    From microservices-platform with Apache License 2.0 4 votes vote down vote up
@RequestMapping(AdminBiz.MAPPING)
@PermessionLimit(limit=false)
public void api(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    XxlJobDynamicScheduler.invokeAdminService(request, response);
}
 
Example #19
Source File: JobApiController.java    From zuihou-admin-boot with Apache License 2.0 4 votes vote down vote up
@RequestMapping(AdminBiz.MAPPING)
@PermessionLimit(limit = false)
public void api(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    XxlJobDynamicScheduler.invokeAdminService(request, response);
}
 
Example #20
Source File: JobInfoController.java    From zuihou-admin-boot with Apache License 2.0 4 votes vote down vote up
@RequestMapping("/addTimingTask")
@ResponseBody
@PermessionLimit(limit = false)
public ReturnT<String> addTimingTask(@RequestBody XxlJobInfo dto) {
    return xxlJobService.addStart(dto);
}
 
Example #21
Source File: JobApiController.java    From zuihou-admin-cloud with Apache License 2.0 4 votes vote down vote up
@RequestMapping(AdminBiz.MAPPING)
@PermessionLimit(limit = false)
public void api(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    XxlJobDynamicScheduler.invokeAdminService(request, response);
}
 
Example #22
Source File: JobInfoController.java    From zuihou-admin-cloud with Apache License 2.0 4 votes vote down vote up
@RequestMapping("/addTimingTask")
@ResponseBody
@PermessionLimit(limit = false)
public ReturnT<String> addTimingTask(@RequestBody XxlJobInfo dto) {
    return xxlJobService.addStart(dto);
}