This commit is contained in:
@@ -68,6 +68,8 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
|
||||
protected int actionid;
|
||||
|
||||
protected Object currentUser;
|
||||
|
||||
private final String remoteAddrHeader;
|
||||
|
||||
Object attachment; //供 HttpBaseServlet传递Entry使用
|
||||
@@ -240,6 +242,33 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
return super.removeProperty(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前用户信息, 通常在HttpServlet.authenticate方法里设置currentUser <br>
|
||||
* 数据类型由@HttpUserType指定
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @param user 用户信息
|
||||
*
|
||||
* @return HttpRequest
|
||||
*/
|
||||
public <T> HttpRequest currentUser(T user) {
|
||||
this.currentUser = user;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户信息, 通常在HttpServlet.authenticate方法里设置currentUser <br>
|
||||
* 数据类型由@HttpUserType指定
|
||||
*
|
||||
* @param <T> @HttpUserType指定的用户信息类型
|
||||
*
|
||||
* @return 用户信息
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T currentUser() {
|
||||
return (T) this.currentUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取模块ID,来自@HttpServlet.moduleid()
|
||||
*
|
||||
@@ -403,6 +432,7 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
this.bodyparsed = false;
|
||||
this.moduleid = 0;
|
||||
this.actionid = 0;
|
||||
this.currentUser = null;
|
||||
|
||||
this.attachment = null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user