use of password.pwm.ldap.UserInfo in project pwm by pwm-project.
the class PeopleSearchDataReader method getMacroMachine.
private MacroMachine getMacroMachine(final UserIdentity userIdentity) throws PwmUnrecoverableException {
final Locale locale = pwmRequest.getLocale();
final ChaiProvider chaiProvider = pwmRequest.getPwmApplication().getProxiedChaiUser(userIdentity).getChaiProvider();
final UserInfo userInfo = UserInfoFactory.newUserInfo(pwmRequest.getPwmApplication(), pwmRequest.getSessionLabel(), locale, userIdentity, chaiProvider);
return MacroMachine.forUser(pwmRequest.getPwmApplication(), pwmRequest.getSessionLabel(), userInfo, null);
}
use of password.pwm.ldap.UserInfo in project pwm by pwm-project.
the class SessionAuthenticator method postAuthenticationSequence.
private void postAuthenticationSequence(final UserIdentity userIdentity, final AuthenticationResult authenticationResult) throws PwmUnrecoverableException, ChaiUnavailableException {
final IntruderManager intruderManager = pwmApplication.getIntruderManager();
final LocalSessionStateBean ssBean = pwmSession.getSessionStateBean();
final LoginInfoBean loginInfoBean = pwmSession.getLoginInfoBean();
// auth succeed
loginInfoBean.setAuthenticated(true);
loginInfoBean.setUserIdentity(userIdentity);
// update the session connection
pwmSession.getSessionManager().setChaiProvider(authenticationResult.getUserProvider());
// update the actor user info bean
{
final UserInfo userInfoBean;
if (authenticationResult.getAuthenticationType() == AuthenticationType.AUTH_BIND_INHIBIT) {
userInfoBean = UserInfoFactory.newUserInfo(pwmApplication, pwmSession.getLabel(), ssBean.getLocale(), userIdentity, pwmApplication.getProxyChaiProvider(userIdentity.getLdapProfileID()));
} else {
userInfoBean = UserInfoFactory.newUserInfoUsingProxy(pwmApplication, pwmSession.getLabel(), userIdentity, ssBean.getLocale(), authenticationResult.getUserPassword());
}
pwmSession.setUserInfo(userInfoBean);
}
// mark the auth time
pwmSession.getLoginInfoBean().setAuthTime(Instant.now());
// update the resulting authType
pwmSession.getLoginInfoBean().setType(authenticationResult.getAuthenticationType());
pwmSession.getLoginInfoBean().setAuthSource(authenticationSource);
// save the password in the login bean
final PasswordData userPassword = authenticationResult.getUserPassword();
pwmSession.getLoginInfoBean().setUserCurrentPassword(userPassword);
// notify the intruder manager with a successful login
intruderManager.clear(RecordType.USERNAME, pwmSession.getUserInfo().getUsername());
intruderManager.convenience().clearUserIdentity(userIdentity);
intruderManager.convenience().clearAddressAndSession(pwmSession);
if (pwmApplication.getStatisticsManager() != null) {
final StatisticsManager statisticsManager = pwmApplication.getStatisticsManager();
if (pwmSession.getUserInfo().getPasswordStatus().isWarnPeriod()) {
statisticsManager.incrementValue(Statistic.AUTHENTICATION_EXPIRED_WARNING);
} else if (pwmSession.getUserInfo().getPasswordStatus().isPreExpired()) {
statisticsManager.incrementValue(Statistic.AUTHENTICATION_PRE_EXPIRED);
} else if (pwmSession.getUserInfo().getPasswordStatus().isExpired()) {
statisticsManager.incrementValue(Statistic.AUTHENTICATION_EXPIRED);
}
}
// clear permission cache - needs rechecking after login
LOGGER.debug(pwmSession, "clearing permission cache");
pwmSession.getUserSessionDataCacheBean().clearPermissions();
}
use of password.pwm.ldap.UserInfo in project pwm by pwm-project.
the class IntruderManager method sendIntruderNoticeEmail.
private static void sendIntruderNoticeEmail(final PwmApplication pwmApplication, final SessionLabel sessionLabel, final UserIdentity userIdentity) {
final Locale locale = LocaleHelper.getLocaleForSessionID(pwmApplication, sessionLabel.getSessionID());
final Configuration config = pwmApplication.getConfig();
final EmailItemBean configuredEmailSetting = config.readSettingAsEmail(PwmSetting.EMAIL_INTRUDERNOTICE, locale);
if (configuredEmailSetting == null) {
return;
}
try {
final UserInfo userInfo = UserInfoFactory.newUserInfoUsingProxy(pwmApplication, SessionLabel.SYSTEM_LABEL, userIdentity, locale);
final MacroMachine macroMachine = MacroMachine.forUser(pwmApplication, sessionLabel, userInfo, null);
pwmApplication.getEmailQueue().submitEmail(configuredEmailSetting, userInfo, macroMachine);
} catch (PwmUnrecoverableException e) {
LOGGER.error("error reading user info while sending intruder notice for user " + userIdentity + ", error: " + e.getMessage());
}
}
use of password.pwm.ldap.UserInfo 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.ldap.UserInfo in project pwm by pwm-project.
the class PwNotifyEngine method sendNoticeEmail.
private void sendNoticeEmail(final UserIdentity userIdentity) throws PwmUnrecoverableException {
final Locale userLocale = PwmConstants.DEFAULT_LOCALE;
final EmailItemBean emailItemBean = pwmApplication.getConfig().readSettingAsEmail(PwmSetting.EMAIL_PW_EXPIRATION_NOTICE, userLocale);
final MacroMachine macroMachine = MacroMachine.forUser(pwmApplication, userLocale, SESSION_LABEL, userIdentity);
final UserInfo userInfoBean = UserInfoFactory.newUserInfoUsingProxy(pwmApplication, SESSION_LABEL, userIdentity, userLocale);
StatisticsManager.incrementStat(pwmApplication, Statistic.PWNOTIFY_EMAILS_SENT);
pwmApplication.getEmailQueue().submitEmail(emailItemBean, userInfoBean, macroMachine);
}
Aggregations