Search in sources :

Example 6 with AuthUser

use of com.jeesuite.common.model.AuthUser in project jeesuite-libs by vakinge.

the class ActionLogCollector method onRequestStart.

public static ActionLog onRequestStart(HttpServletRequest request) {
    ActionLog actionLog = new ActionLog();
    actionLog.setAppId(GlobalRuntimeContext.SYSTEM_ID);
    actionLog.setRequestAt(new Date());
    actionLog.setRequestIp(IpUtils.getIpAddr(request));
    actionLog.setActionKey(String.format("%s_%s", request.getMethod(), request.getRequestURI()));
    actionLog.setModuleId(GlobalRuntimeContext.APPID);
    actionLog.setRequestId(CurrentRuntimeContext.getRequestId());
    actionLog.setTenantId(CurrentRuntimeContext.getTenantId());
    actionLog.setClientType(CurrentRuntimeContext.getClientType());
    AuthUser currentUser = CurrentRuntimeContext.getCurrentUser();
    if (currentUser != null) {
        actionLog.setUserId(currentUser.getId());
        actionLog.setUserName(currentUser.getName());
    }
    if (context.get() == null) {
        context.set(actionLog);
    }
    return actionLog;
}
Also used : AuthUser(com.jeesuite.common.model.AuthUser) Date(java.util.Date)

Example 7 with AuthUser

use of com.jeesuite.common.model.AuthUser in project jeesuite-libs by vakinge.

the class CurrentRuntimeContext method getCurrentUser.

public static AuthUser getCurrentUser() {
    AuthUser user = ThreadLocalContext.get(CustomRequestHeaders.HEADER_AUTH_USER);
    if (user == null) {
        HttpServletRequest request = getRequest();
        if (request == null)
            return null;
        String headerString = request.getHeader(CustomRequestHeaders.HEADER_AUTH_USER);
        user = AuthUser.decode(headerString);
        if (user != null) {
            ThreadLocalContext.set(CustomRequestHeaders.HEADER_AUTH_USER, user);
        }
    }
    return user;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) AuthUser(com.jeesuite.common.model.AuthUser)

Example 8 with AuthUser

use of com.jeesuite.common.model.AuthUser in project jeesuite-libs by vakinge.

the class MockLoginUserInterceptor method preHandle.

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
    if (CurrentRuntimeContext.getCurrentUser() == null) {
        AuthUser authUser = new AuthUser();
        authUser.setId("1");
        authUser.setName("admin");
        CurrentRuntimeContext.setAuthUser(authUser);
    }
    return true;
}
Also used : AuthUser(com.jeesuite.common.model.AuthUser)

Aggregations

AuthUser (com.jeesuite.common.model.AuthUser)8 JeesuiteBaseException (com.jeesuite.common.JeesuiteBaseException)1 Date (java.util.Date)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 BinaryExpression (net.sf.jsqlparser.expression.BinaryExpression)1 Expression (net.sf.jsqlparser.expression.Expression)1 StringValue (net.sf.jsqlparser.expression.StringValue)1 AndExpression (net.sf.jsqlparser.expression.operators.conditional.AndExpression)1 EqualsTo (net.sf.jsqlparser.expression.operators.relational.EqualsTo)1 InExpression (net.sf.jsqlparser.expression.operators.relational.InExpression)1 LikeExpression (net.sf.jsqlparser.expression.operators.relational.LikeExpression)1 Column (net.sf.jsqlparser.schema.Column)1