Search in sources :

Example 1 with PrimaryCipher

use of org.lastaflute.core.security.PrimaryCipher in project fess by codelibs.

the class UserInfoHelper method getUserCodeFromUserBean.

protected String getUserCodeFromUserBean(final HttpServletRequest request) {
    final SessionManager sessionManager = ComponentUtil.getComponent(SessionManager.class);
    String userCode = sessionManager.getAttribute(USER_BEAN, TypicalUserBean.class).filter(u -> !Constants.EMPTY_USER_ID.equals(u.getUserId())).map(u -> u.getUserId().toString()).orElse(StringUtil.EMPTY);
    if (StringUtil.isBlank(userCode)) {
        return null;
    }
    final PrimaryCipher cipher = ComponentUtil.getPrimaryCipher();
    userCode = cipher.encrypt(userCode);
    request.setAttribute(Constants.USER_CODE, userCode);
    deleteUserCodeFromCookie(request);
    return userCode;
}
Also used : HttpSession(javax.servlet.http.HttpSession) Constants(org.codelibs.fess.Constants) TypicalUserBean(org.lastaflute.web.login.TypicalUserBean) Resource(javax.annotation.Resource) StringUtil(org.codelibs.core.lang.StringUtil) UUID(java.util.UUID) LruHashMap(org.codelibs.core.collection.LruHashMap) SessionManager(org.lastaflute.web.servlet.session.SessionManager) LaRequestUtil(org.lastaflute.web.util.LaRequestUtil) ArrayList(java.util.ArrayList) LaResponseUtil(org.lastaflute.web.util.LaResponseUtil) List(java.util.List) HttpServletRequest(javax.servlet.http.HttpServletRequest) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig) ComponentUtil(org.codelibs.fess.util.ComponentUtil) PrimaryCipher(org.lastaflute.core.security.PrimaryCipher) Map(java.util.Map) Cookie(javax.servlet.http.Cookie) SessionManager(org.lastaflute.web.servlet.session.SessionManager) PrimaryCipher(org.lastaflute.core.security.PrimaryCipher) TypicalUserBean(org.lastaflute.web.login.TypicalUserBean)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 UUID (java.util.UUID)1 Resource (javax.annotation.Resource)1 Cookie (javax.servlet.http.Cookie)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpSession (javax.servlet.http.HttpSession)1 LruHashMap (org.codelibs.core.collection.LruHashMap)1 StringUtil (org.codelibs.core.lang.StringUtil)1 Constants (org.codelibs.fess.Constants)1 FessConfig (org.codelibs.fess.mylasta.direction.FessConfig)1 ComponentUtil (org.codelibs.fess.util.ComponentUtil)1 PrimaryCipher (org.lastaflute.core.security.PrimaryCipher)1 TypicalUserBean (org.lastaflute.web.login.TypicalUserBean)1 SessionManager (org.lastaflute.web.servlet.session.SessionManager)1 LaRequestUtil (org.lastaflute.web.util.LaRequestUtil)1 LaResponseUtil (org.lastaflute.web.util.LaResponseUtil)1