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;
}
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;
}
Aggregations