use of password.pwm.bean.ResponseInfoBean in project pwm by pwm-project.
the class CrService method readUserResponseInfo.
public ResponseInfoBean readUserResponseInfo(final SessionLabel sessionLabel, final UserIdentity userIdentity, final ChaiUser theUser) throws ChaiUnavailableException, PwmUnrecoverableException {
final Configuration config = pwmApplication.getConfig();
LOGGER.trace(sessionLabel, "beginning read of user response sequence");
final List<DataStorageMethod> readPreferences = config.helper().getCrReadPreference();
final String debugMsg = "will attempt to read the following storage methods: " + JsonUtil.serializeCollection(readPreferences) + " for response info for user " + theUser.getEntryDN();
LOGGER.debug(sessionLabel, debugMsg);
final String userGUID;
if (readPreferences.contains(DataStorageMethod.DB) || readPreferences.contains(DataStorageMethod.LOCALDB)) {
userGUID = LdapOperationsHelper.readLdapGuidValue(pwmApplication, sessionLabel, userIdentity, false);
} else {
userGUID = null;
}
for (final DataStorageMethod storageMethod : readPreferences) {
final ResponseInfoBean readResponses;
LOGGER.trace(sessionLabel, "attempting read of response info via storage method: " + storageMethod);
readResponses = operatorMap.get(storageMethod).readResponseInfo(theUser, userIdentity, userGUID);
if (readResponses != null) {
LOGGER.debug(sessionLabel, "returning response info read via method " + storageMethod + " for user " + theUser.getEntryDN());
return readResponses;
} else {
LOGGER.trace(sessionLabel, "no responses info read using method " + storageMethod);
}
}
LOGGER.debug(sessionLabel, "no response info found for user " + theUser.getEntryDN());
return null;
}
use of password.pwm.bean.ResponseInfoBean in project pwm by pwm-project.
the class ResponseStatsCommand method makeStatistics.
ResponseStats makeStatistics(final PwmApplication pwmApplication, final List<UserIdentity> userIdentities) throws PwmUnrecoverableException, ChaiUnavailableException {
final ResponseStats responseStats = new ResponseStats();
final Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
out("processing... " + userCounter + " users read");
}
}, 30 * 1000, 30 * 1000);
final CrService crService = pwmApplication.getCrService();
for (final UserIdentity userIdentity : userIdentities) {
userCounter++;
final ResponseInfoBean responseInfoBean = crService.readUserResponseInfo(null, userIdentity, pwmApplication.getProxiedChaiUser(userIdentity));
makeStatistics(responseStats, responseInfoBean);
}
timer.cancel();
return responseStats;
}
use of password.pwm.bean.ResponseInfoBean in project pwm by pwm-project.
the class NMASCrOperator method readResponseInfo.
@Override
public ResponseInfoBean readResponseInfo(final ChaiUser theUser, final UserIdentity userIdentity, final String userGUID) throws PwmUnrecoverableException {
try {
if (theUser.getChaiProvider().getDirectoryVendor() != DirectoryVendor.EDIRECTORY) {
LOGGER.debug("skipping request to read NMAS responses for " + userIdentity + ", directory type is not eDirectory");
return null;
}
final ResponseSet responseSet = NmasCrFactory.readNmasResponseSet(theUser);
if (responseSet == null) {
return null;
}
final ResponseInfoBean responseInfoBean = CrOperators.convertToNoAnswerInfoBean(responseSet, DataStorageMethod.NMAS);
responseInfoBean.setTimestamp(null);
return responseInfoBean;
} catch (ChaiException e) {
throw new PwmUnrecoverableException(new ErrorInformation(PwmError.ERROR_RESPONSES_NORESPONSES, "unexpected error reading response info " + e.getMessage()));
}
}
use of password.pwm.bean.ResponseInfoBean 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();
}
use of password.pwm.bean.ResponseInfoBean in project pwm by pwm-project.
the class SetupResponsesServlet method nextStep.
@Override
protected void nextStep(final PwmRequest pwmRequest) throws PwmUnrecoverableException, IOException, ChaiUnavailableException, ServletException {
final SetupResponsesBean setupResponsesBean = getSetupResponseBean(pwmRequest);
initializeBean(pwmRequest, setupResponsesBean);
pwmRequest.setAttribute(PwmRequestAttribute.ModuleBean, setupResponsesBean);
pwmRequest.setAttribute(PwmRequestAttribute.ModuleBean_String, pwmRequest.getPwmApplication().getSecureService().encryptObjectToString(setupResponsesBean));
pwmRequest.setAttribute(PwmRequestAttribute.SetupResponses_ResponseInfo, pwmRequest.getPwmSession().getUserInfo().getResponseInfoBean());
if (setupResponsesBean.isHasExistingResponses() && !pwmRequest.getPwmSession().getUserInfo().isRequiresResponseConfig()) {
pwmRequest.forwardToJsp(JspUrl.SETUP_RESPONSES_EXISTING);
return;
}
if (!setupResponsesBean.isResponsesSatisfied()) {
pwmRequest.forwardToJsp(JspUrl.SETUP_RESPONSES);
return;
}
if (!setupResponsesBean.isHelpdeskResponsesSatisfied()) {
if (setupResponsesBean.getHelpdeskResponseData().getChallengeSet() == null || setupResponsesBean.getHelpdeskResponseData().getChallengeSet().getChallenges().isEmpty()) {
setupResponsesBean.setHelpdeskResponsesSatisfied(true);
} else {
pwmRequest.forwardToJsp(JspUrl.SETUP_RESPONSES_HELPDESK);
return;
}
}
if (pwmRequest.getConfig().readSettingAsBoolean(PwmSetting.CHALLENGE_SHOW_CONFIRMATION)) {
if (!setupResponsesBean.isConfirmed()) {
pwmRequest.forwardToJsp(JspUrl.SETUP_RESPONSES_CONFIRM);
return;
}
}
try {
// everything good, so lets save responses.
final ResponseInfoBean responses = generateResponseInfoBean(pwmRequest, setupResponsesBean.getResponseData().getChallengeSet(), setupResponsesBean.getResponseData().getResponseMap(), setupResponsesBean.getHelpdeskResponseData().getResponseMap());
saveResponses(pwmRequest, responses);
pwmRequest.getPwmApplication().getSessionStateService().clearBean(pwmRequest, SetupResponsesBean.class);
pwmRequest.getPwmResponse().forwardToSuccessPage(Message.Success_SetupResponse);
} catch (PwmOperationalException e) {
LOGGER.error(pwmRequest.getSessionLabel(), e.getErrorInformation());
pwmRequest.respondWithError(e.getErrorInformation());
} catch (ChaiValidationException e) {
final ErrorInformation errorInformation = new ErrorInformation(PwmError.ERROR_MISSING_RANDOM_RESPONSE, e.getMessage());
LOGGER.error(pwmRequest.getSessionLabel(), errorInformation);
pwmRequest.respondWithError(errorInformation);
}
}
Aggregations