@Override
  public ResponseInfoBean readResponseInfo(
      final ChaiUser theUser, final UserIdentity userIdentity, final String userGUID)
      throws PwmUnrecoverableException {
    final ResponseSet responseSet = readResponsesFromNovellUA(pwmApplication, theUser);
    if (responseSet == null) {
      return null;
    }

    final Map<Challenge, String> crMap = new LinkedHashMap<>();
    final Map<Challenge, String> helpdeskCrMap = new LinkedHashMap<>();
    try {
      for (final Challenge loopChallenge : responseSet.getChallengeSet().getChallenges()) {
        crMap.put(loopChallenge, "");
      }
      for (final Challenge loopChallenge : responseSet.getHelpdeskResponses().keySet()) {
        helpdeskCrMap.put(loopChallenge, "");
      }

      return new ResponseInfoBean(
          crMap,
          helpdeskCrMap,
          PwmConstants.DEFAULT_LOCALE,
          responseSet.getChallengeSet().getMinRandomRequired(),
          responseSet.getChallengeSet().getIdentifier(),
          DataStorageMethod.NMASUAWS,
          null);
    } catch (ChaiValidationException e) {
      LOGGER.error(
          "unexpected error converting NMASUserAppWebService ResponseSet to ResponseInfoBean: "
              + e.getMessage());
    }

    return null; // To change body of implemented methods use File | Settings | File Templates.
  }
Exemple #2
0
  public ResponseSet readResponseSet(
      final ChaiUser theUser, final UserIdentity userIdentity, final String userGUID)
      throws PwmUnrecoverableException {
    if (userGUID == null || userGUID.length() < 1) {
      final String errorMsg =
          "user "
              + theUser.getEntryDN()
              + " does not have a guid, unable to search for responses in remote database";
      final ErrorInformation errorInformation =
          new ErrorInformation(PwmError.ERROR_MISSING_GUID, errorMsg);
      throw new PwmUnrecoverableException(errorInformation);
    }

    try {
      final DatabaseAccessorImpl databaseAccessor = pwmApplication.getDatabaseAccessor();
      final String responseStringBlob = databaseAccessor.get(DatabaseTable.PWM_RESPONSES, userGUID);
      if (responseStringBlob != null && responseStringBlob.length() > 0) {
        final ResponseSet userResponseSet =
            ChaiResponseSet.parseChaiResponseSetXML(responseStringBlob, theUser);
        LOGGER.debug(
            "found responses for "
                + theUser.getEntryDN()
                + " in remote database: "
                + userResponseSet.toString());
        return userResponseSet;
      } else {
        LOGGER.trace(
            "user guid for "
                + theUser.getEntryDN()
                + " not found in remote database (key="
                + userGUID
                + ")");
      }
    } catch (ChaiValidationException e) {
      final String errorMsg =
          "unexpected error reading responses for "
              + theUser.getEntryDN()
              + " from remote database: "
              + e.getMessage();
      final ErrorInformation errorInformation =
          new ErrorInformation(PwmError.ERROR_UNKNOWN, errorMsg);
      throw new PwmUnrecoverableException(errorInformation);
    } catch (PwmOperationalException e) {
      final String errorMsg =
          "unexpected error reading responses for "
              + theUser.getEntryDN()
              + " from remote database: "
              + e.getMessage();
      final ErrorInformation errorInformation =
          new ErrorInformation(e.getErrorInformation().getError(), errorMsg);
      throw new PwmUnrecoverableException(errorInformation);
    }
    return null;
  }