Java Code Examples for com.jfinal.core.Controller#getPara()

The following examples show how to use com.jfinal.core.Controller#getPara() . 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: ChangePwdValidator.java    From jboot-admin with Apache License 2.0 6 votes vote down vote up
@Override
protected void validate(Controller c) {
    String pwd =  c.getPara("user.pwd");
    String newPwd =  c.getPara("newPwd");
    String rePwd =  c.getPara("rePwd");

    validateRequiredString("user.pwd", "旧密码不能为空");
    validateRequiredString("newPwd", "新密码不能为空");
    validateRequiredString("rePwd", "确认密码不能为空");

    if(!newPwd.equals(rePwd)){
        addError("两次输入密码不一致,请重新输入!");
    }

    User user = AuthUtils.getLoginUser();

    if(!AuthUtils.checkPwd(pwd, user.getPwd(), user.getSalt2())){
        addError("原密码不正确!");
    }
}
 
Example 2
Source File: ParaDirective.java    From jpress with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void onRender(Env env, Scope scope, Writer writer) {

    Controller controller = JbootControllerContext.get();

    String key = getPara(0, scope);
    String defaultValue = getPara(1, scope);

    if (StrUtil.isBlank(key)) {
        throw new IllegalArgumentException("#para(...) argument must not be empty" + getLocation());
    }

    String value = controller.getPara(key);
    if (StrUtil.isBlank(value)) {
        value = StrUtil.isNotBlank(defaultValue) ? defaultValue : "";
    }

    try {
        writer.write(value);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example 3
Source File: TemplateManager.java    From jpress with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 获取预览的模板
 *
 * @return
 */
public Template getPreviewTemplate() {

    if (!JPressConfig.me.isTemplatePreviewEnable()) {
        return null;
    }

    Controller controller = JbootControllerContext.get();
    if (controller == null) {
        return null;
    }

    String tId = controller.getPara("template");
    if (StrUtil.isBlank(tId)) {
        return null;
    }

    return getTemplateById(tId);
}
 
Example 4
Source File: TokenInterceptor.java    From jfinal-api-scaffold with MIT License 6 votes vote down vote up
@Override
public void intercept(ActionInvocation ai) {
    Controller controller = ai.getController();
    String token = controller.getPara("token");
    if (StringUtils.isEmpty(token)) {
        controller.renderJson(new BaseResponse(Code.ARGUMENT_ERROR, "token can not be null"));
        return;
    }

    User user = TokenManager.getMe().validate(token);
    if (user == null) {
        controller.renderJson(new BaseResponse(Code.TOKEN_INVALID, "token is invalid"));
        return;
    }
    
    controller.setAttr("user", user);
    ai.invoke();
}
 
Example 5
Source File: MsgInterceptor.java    From jfinal-weixin with Apache License 2.0 6 votes vote down vote up
/**
 * 检测签名
 */
private boolean checkSignature(Controller controller) {
	String signature = controller.getPara("signature");
	String timestamp = controller.getPara("timestamp");
	String nonce = controller.getPara("nonce");
	if (StrKit.isBlank(signature) || StrKit.isBlank(timestamp) || StrKit.isBlank(nonce)) {
		controller.renderText("check signature failure");
		return false;
	}
	
	if (SignatureCheckKit.me.checkSignature(signature, timestamp, nonce)) {
		return true;
	}
	else {
		logger.error("check signature failure: " +
				" signature = " + controller.getPara("signature") +
				" timestamp = " + controller.getPara("timestamp") +
				" nonce = " + controller.getPara("nonce"));
		
		return false;
	}
}
 
Example 6
Source File: MsgInterceptor.java    From jfinal-weixin with Apache License 2.0 5 votes vote down vote up
/**
 * 配置开发者中心微信服务器所需的 url 与 token
 * @return true 为config server 请求,false 正式消息交互请求
 */
public void configServer(Controller c) {
	// 通过 echostr 判断请求是否为配置微信服务器回调所需的 url 与 token
	String echostr = c.getPara("echostr");
	String signature = c.getPara("signature");
	String timestamp = c.getPara("timestamp");
	String nonce = c.getPara("nonce");
	boolean isOk = SignatureCheckKit.me.checkSignature(signature, timestamp, nonce);
	if (isOk)
		c.renderText(echostr);
	else
		logger.error("验证失败:configServer");
}