Search in sources :

Example 1 with SessionStateInfoBean

use of password.pwm.bean.pub.SessionStateInfoBean in project pwm by pwm-project.

the class SessionTrackService method infoBeanFromPwmSession.

private static SessionStateInfoBean infoBeanFromPwmSession(final PwmSession loopSession) {
    final LocalSessionStateBean loopSsBean = loopSession.getSessionStateBean();
    final LoginInfoBean loginInfoBean = loopSession.getLoginInfoBean();
    final SessionStateInfoBean sessionStateInfoBean = new SessionStateInfoBean();
    sessionStateInfoBean.setLabel(loopSession.getSessionStateBean().getSessionID());
    sessionStateInfoBean.setCreateTime(loopSession.getSessionStateBean().getSessionCreationTime());
    sessionStateInfoBean.setLastTime(loopSession.getSessionStateBean().getSessionLastAccessedTime());
    sessionStateInfoBean.setIdle(loopSession.getIdleTime().asCompactString());
    sessionStateInfoBean.setLocale(loopSsBean.getLocale());
    sessionStateInfoBean.setSrcAddress(loopSsBean.getSrcAddress());
    sessionStateInfoBean.setSrcHost(loopSsBean.getSrcHostname());
    sessionStateInfoBean.setLastUrl(loopSsBean.getLastRequestURL());
    sessionStateInfoBean.setIntruderAttempts(loopSsBean.getIntruderAttempts());
    if (loopSession.isAuthenticated()) {
        final UserInfo loopUiBean = loopSession.getUserInfo();
        sessionStateInfoBean.setLdapProfile(loginInfoBean.isAuthenticated() ? loopUiBean.getUserIdentity().getLdapProfileID() : "");
        sessionStateInfoBean.setUserDN(loginInfoBean.isAuthenticated() ? loopUiBean.getUserIdentity().getUserDN() : "");
        try {
            sessionStateInfoBean.setUserID(loginInfoBean.isAuthenticated() ? loopUiBean.getUsername() : "");
        } catch (PwmUnrecoverableException e) {
            LOGGER.error("unexpected error reading username: " + e.getMessage(), e);
        }
    }
    return sessionStateInfoBean;
}
Also used : LoginInfoBean(password.pwm.bean.LoginInfoBean) LocalSessionStateBean(password.pwm.bean.LocalSessionStateBean) UserInfo(password.pwm.ldap.UserInfo) PwmUnrecoverableException(password.pwm.error.PwmUnrecoverableException) SessionStateInfoBean(password.pwm.bean.pub.SessionStateInfoBean)

Example 2 with SessionStateInfoBean

use of password.pwm.bean.pub.SessionStateInfoBean in project pwm by pwm-project.

the class AdminServlet method restSessionDataHandler.

@ActionHandler(action = "sessionData")
private ProcessStatus restSessionDataHandler(final PwmRequest pwmRequest) throws ChaiUnavailableException, PwmUnrecoverableException, IOException {
    final int max = readMaxParameter(pwmRequest, 1000, 10 * 1000);
    final ArrayList<SessionStateInfoBean> gridData = new ArrayList<>();
    int counter = 0;
    final Iterator<SessionStateInfoBean> infos = pwmRequest.getPwmApplication().getSessionTrackService().getSessionInfoIterator();
    while (counter < max && infos.hasNext()) {
        gridData.add(infos.next());
        counter++;
    }
    final RestResultBean restResultBean = RestResultBean.withData(gridData);
    pwmRequest.outputJsonResult(restResultBean);
    return ProcessStatus.Halt;
}
Also used : ArrayList(java.util.ArrayList) SessionStateInfoBean(password.pwm.bean.pub.SessionStateInfoBean) RestResultBean(password.pwm.ws.server.RestResultBean)

Aggregations

SessionStateInfoBean (password.pwm.bean.pub.SessionStateInfoBean)2 ArrayList (java.util.ArrayList)1 LocalSessionStateBean (password.pwm.bean.LocalSessionStateBean)1 LoginInfoBean (password.pwm.bean.LoginInfoBean)1 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)1 UserInfo (password.pwm.ldap.UserInfo)1 RestResultBean (password.pwm.ws.server.RestResultBean)1