Search in sources :

Example 31 with UserInfo

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);
}
Also used : Locale(java.util.Locale) ChaiProvider(com.novell.ldapchai.provider.ChaiProvider) UserInfo(password.pwm.ldap.UserInfo)

Example 32 with UserInfo

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();
}
Also used : LoginInfoBean(password.pwm.bean.LoginInfoBean) StatisticsManager(password.pwm.svc.stats.StatisticsManager) PasswordData(password.pwm.util.PasswordData) LocalSessionStateBean(password.pwm.bean.LocalSessionStateBean) UserInfo(password.pwm.ldap.UserInfo) IntruderManager(password.pwm.svc.intruder.IntruderManager)

Example 33 with UserInfo

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());
    }
}
Also used : Locale(java.util.Locale) FormConfiguration(password.pwm.config.value.data.FormConfiguration) Configuration(password.pwm.config.Configuration) EmailItemBean(password.pwm.bean.EmailItemBean) MacroMachine(password.pwm.util.macro.MacroMachine) UserInfo(password.pwm.ldap.UserInfo) PwmUnrecoverableException(password.pwm.error.PwmUnrecoverableException)

Example 34 with UserInfo

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;
}
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 35 with UserInfo

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);
}
Also used : Locale(java.util.Locale) EmailItemBean(password.pwm.bean.EmailItemBean) MacroMachine(password.pwm.util.macro.MacroMachine) UserInfo(password.pwm.ldap.UserInfo)

Aggregations

UserInfo (password.pwm.ldap.UserInfo)60 ErrorInformation (password.pwm.error.ErrorInformation)23 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)23 FormConfiguration (password.pwm.config.value.data.FormConfiguration)20 PwmApplication (password.pwm.PwmApplication)18 UserIdentity (password.pwm.bean.UserIdentity)15 Configuration (password.pwm.config.Configuration)15 Locale (java.util.Locale)13 MacroMachine (password.pwm.util.macro.MacroMachine)13 ChaiUser (com.novell.ldapchai.ChaiUser)12 PwmOperationalException (password.pwm.error.PwmOperationalException)12 PwmSession (password.pwm.http.PwmSession)12 PasswordData (password.pwm.util.PasswordData)10 Instant (java.time.Instant)9 ArrayList (java.util.ArrayList)8 ActionConfiguration (password.pwm.config.value.data.ActionConfiguration)8 SearchConfiguration (password.pwm.ldap.search.SearchConfiguration)8 RestResultBean (password.pwm.ws.server.RestResultBean)8 List (java.util.List)7 EmailItemBean (password.pwm.bean.EmailItemBean)7