Search in sources :

Example 1 with ViewStatusFields

use of password.pwm.config.option.ViewStatusFields in project pwm by pwm-project.

the class HelpdeskDetailInfoBean method makeHelpdeskDetailInfo.

static HelpdeskDetailInfoBean makeHelpdeskDetailInfo(final PwmRequest pwmRequest, final HelpdeskProfile helpdeskProfile, final UserIdentity userIdentity) throws PwmUnrecoverableException, ChaiUnavailableException {
    final HelpdeskDetailInfoBeanBuilder builder = HelpdeskDetailInfoBean.builder();
    final Instant startTime = Instant.now();
    LOGGER.trace(pwmRequest, "beginning to assemble detail data report for user " + userIdentity);
    final Locale actorLocale = pwmRequest.getLocale();
    final ChaiUser theUser = HelpdeskServlet.getChaiUser(pwmRequest, helpdeskProfile, userIdentity);
    if (!theUser.exists()) {
        return null;
    }
    final UserInfo userInfo = UserInfoFactory.newUserInfo(pwmRequest.getPwmApplication(), pwmRequest.getSessionLabel(), actorLocale, userIdentity, theUser.getChaiProvider());
    final MacroMachine macroMachine = MacroMachine.forUser(pwmRequest.getPwmApplication(), pwmRequest.getSessionLabel(), userInfo, null);
    try {
        final List<AccountInformationBean.ActivityRecord> userHistory = AccountInformationBean.makeAuditInfo(pwmRequest.getPwmApplication(), pwmRequest.getSessionLabel(), userInfo, pwmRequest.getLocale());
        builder.userHistory(userHistory);
    } catch (Exception e) {
        LOGGER.error(pwmRequest, "unexpected error reading userHistory for user '" + userIdentity + "', " + e.getMessage());
    }
    builder.userKey(userIdentity.toObfuscatedKey(pwmRequest.getPwmApplication()));
    builder.profileData(getProfileData(helpdeskProfile, userInfo, pwmRequest.getSessionLabel(), pwmRequest.getLocale()));
    builder.passwordPolicyRules(makePasswordPolicyRules(userInfo, pwmRequest.getLocale(), pwmRequest.getConfig()));
    {
        final List<String> requirementLines = PasswordRequirementsTag.getPasswordRequirementsStrings(userInfo.getPasswordPolicy(), pwmRequest.getConfig(), pwmRequest.getLocale(), macroMachine);
        builder.passwordRequirements(Collections.unmodifiableList(requirementLines));
    }
    if ((userInfo.getPasswordPolicy() != null) && (userInfo.getPasswordPolicy().getChaiPasswordPolicy() != null) && (userInfo.getPasswordPolicy().getChaiPasswordPolicy().getPolicyEntry() != null) && (userInfo.getPasswordPolicy().getChaiPasswordPolicy().getPolicyEntry().getEntryDN() != null)) {
        builder.passwordPolicyDN(userInfo.getPasswordPolicy().getChaiPasswordPolicy().getPolicyEntry().getEntryDN());
    } else {
        builder.passwordPolicyDN(LocaleHelper.getLocalizedMessage(Display.Value_NotApplicable, pwmRequest));
    }
    if ((userInfo.getPasswordPolicy() != null) && userInfo.getPasswordPolicy().getIdentifier() != null) {
        builder.passwordPolicyID(userInfo.getPasswordPolicy().getIdentifier());
    } else {
        builder.passwordPolicyID(LocaleHelper.getLocalizedMessage(Display.Value_NotApplicable, pwmRequest));
    }
    {
        final ResponseInfoBean responseInfoBean = userInfo.getResponseInfoBean();
        if (responseInfoBean != null && responseInfoBean.getHelpdeskCrMap() != null) {
            final List<DisplayElement> responseDisplay = new ArrayList<>();
            int counter = 0;
            for (final Map.Entry<Challenge, String> entry : responseInfoBean.getHelpdeskCrMap().entrySet()) {
                counter++;
                responseDisplay.add(new DisplayElement("item_" + counter, DisplayElement.Type.string, entry.getKey().getChallengeText(), entry.getValue()));
            }
            builder.helpdeskResponses = responseDisplay;
        }
    }
    builder.userDisplayName(HelpdeskCardInfoBean.figureDisplayName(helpdeskProfile, macroMachine));
    final TimeDuration timeDuration = TimeDuration.fromCurrent(startTime);
    {
        final Set<ViewStatusFields> viewStatusFields = helpdeskProfile.readSettingAsOptionList(PwmSetting.HELPDESK_VIEW_STATUS_VALUES, ViewStatusFields.class);
        builder.statusData(ViewableUserInfoDisplayReader.makeDisplayData(viewStatusFields, pwmRequest.getConfig(), userInfo, null, pwmRequest.getLocale()));
    }
    {
        final Set<HelpdeskDetailInfoBean.StandardButton> visibleButtons = determineVisibleButtons(helpdeskProfile);
        builder.visibleButtons(visibleButtons);
        builder.enabledButtons(determineEnabledButtons(visibleButtons, userInfo));
        builder.customButtons(determineCustomButtons(helpdeskProfile));
    }
    final HelpdeskDetailInfoBean helpdeskDetailInfoBean = builder.build();
    if (pwmRequest.getConfig().isDevDebugMode()) {
        LOGGER.trace(pwmRequest, "completed assembly of detail data report for user " + userIdentity + " in " + timeDuration.asCompactString() + ", contents: " + JsonUtil.serialize(helpdeskDetailInfoBean));
    }
    return builder.build();
}
Also used : Locale(java.util.Locale) LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) Instant(java.time.Instant) ViewStatusFields(password.pwm.config.option.ViewStatusFields) UserInfo(password.pwm.ldap.UserInfo) ResponseInfoBean(password.pwm.bean.ResponseInfoBean) DisplayElement(password.pwm.http.bean.DisplayElement) PwmUnrecoverableException(password.pwm.error.PwmUnrecoverableException) ChaiUnavailableException(com.novell.ldapchai.exception.ChaiUnavailableException) ChaiUser(com.novell.ldapchai.ChaiUser) MacroMachine(password.pwm.util.macro.MacroMachine) ArrayList(java.util.ArrayList) List(java.util.List) TimeDuration(password.pwm.util.java.TimeDuration)

Aggregations

ChaiUser (com.novell.ldapchai.ChaiUser)1 ChaiUnavailableException (com.novell.ldapchai.exception.ChaiUnavailableException)1 Instant (java.time.Instant)1 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 Locale (java.util.Locale)1 Set (java.util.Set)1 ResponseInfoBean (password.pwm.bean.ResponseInfoBean)1 ViewStatusFields (password.pwm.config.option.ViewStatusFields)1 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)1 DisplayElement (password.pwm.http.bean.DisplayElement)1 UserInfo (password.pwm.ldap.UserInfo)1 TimeDuration (password.pwm.util.java.TimeDuration)1 MacroMachine (password.pwm.util.macro.MacroMachine)1