use of password.pwm.error.PwmUnrecoverableException in project pwm by pwm-project.
the class XmlUtil method parseXml.
public static Document parseXml(final Reader inputStream) throws PwmUnrecoverableException {
final SAXBuilder builder = getBuilder();
final Document inputDocument;
try {
inputDocument = builder.build(inputStream);
} catch (Exception e) {
throw new PwmUnrecoverableException(new ErrorInformation(PwmError.CONFIG_FORMAT_ERROR, null, new String[] { "error parsing xml data: " + e.getMessage() }));
}
return inputDocument;
}
use of password.pwm.error.PwmUnrecoverableException in project pwm by pwm-project.
the class LdapCrOperator method clearResponses.
public void clearResponses(final UserIdentity userIdentity, final ChaiUser theUser, final String userGuid) throws PwmUnrecoverableException {
final LdapProfile ldapProfile = userIdentity.getLdapProfile(config);
final String ldapStorageAttribute = ldapProfile.readSettingAsString(PwmSetting.CHALLENGE_USER_ATTRIBUTE);
if (ldapStorageAttribute == null || ldapStorageAttribute.length() < 1) {
final String errorMsg = "ldap storage attribute is not configured, unable to clear user responses";
final ErrorInformation errorInformation = new ErrorInformation(PwmError.ERROR_INVALID_CONFIG, errorMsg);
throw new PwmUnrecoverableException(errorInformation);
}
try {
final String currentValue = theUser.readStringAttribute(ldapStorageAttribute);
if (currentValue != null && currentValue.length() > 0) {
theUser.deleteAttribute(ldapStorageAttribute, null);
}
LOGGER.info("cleared responses for user to chai-ldap format");
} catch (ChaiOperationException e) {
final String errorMsg;
if (e.getErrorCode() == ChaiError.NO_ACCESS) {
errorMsg = "permission error clearing responses to ldap attribute '" + ldapStorageAttribute + "', user does not appear to have correct permissions to clear responses: " + e.getMessage();
} else {
errorMsg = "error clearing responses to ldap attribute '" + ldapStorageAttribute + "': " + e.getMessage();
}
final ErrorInformation errorInfo = new ErrorInformation(PwmError.ERROR_WRITING_RESPONSES, errorMsg);
final PwmUnrecoverableException pwmOE = new PwmUnrecoverableException(errorInfo);
pwmOE.initCause(e);
throw pwmOE;
} catch (ChaiUnavailableException e) {
throw new PwmUnrecoverableException(new ErrorInformation(PwmError.ERROR_DIRECTORY_UNAVAILABLE, e.getMessage()));
}
}
use of password.pwm.error.PwmUnrecoverableException 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.error.PwmUnrecoverableException in project pwm by pwm-project.
the class NMASCrOperator method clearResponses.
public void clearResponses(final UserIdentity userIdentity, final ChaiUser theUser, final String user) throws PwmUnrecoverableException {
try {
if (theUser.getChaiProvider().getDirectoryVendor() == DirectoryVendor.EDIRECTORY) {
NmasCrFactory.clearResponseSet(theUser);
LOGGER.info("cleared responses for user " + theUser.getEntryDN() + " using NMAS method ");
}
} catch (ChaiException e) {
final String errorMsg = "error clearing responses from nmas: " + e.getMessage();
final ErrorInformation errorInfo = new ErrorInformation(PwmError.ERROR_CLEARING_RESPONSES, errorMsg);
final PwmUnrecoverableException pwmOE = new PwmUnrecoverableException(errorInfo);
pwmOE.initCause(e);
throw pwmOE;
}
}
use of password.pwm.error.PwmUnrecoverableException in project pwm by pwm-project.
the class DbOtpOperator method clearOtpUserConfiguration.
@Override
public void clearOtpUserConfiguration(final PwmSession pwmSession, final UserIdentity theUser, final String userGUID) throws PwmUnrecoverableException {
if (userGUID == null || userGUID.length() < 1) {
throw new PwmUnrecoverableException(new ErrorInformation(PwmError.ERROR_MISSING_GUID, "cannot save OTP secret to remote database, user " + theUser + " does not have a guid"));
}
LOGGER.trace("attempting to clear OTP secret for " + theUser + " in remote database (key=" + userGUID + ")");
try {
final DatabaseAccessor databaseAccessor = pwmApplication.getDatabaseAccessor();
databaseAccessor.remove(DatabaseTable.OTP, userGUID);
LOGGER.info("cleared OTP secret for " + theUser + " in remote database (key=" + userGUID + ")");
} catch (DatabaseException ex) {
final ErrorInformation errorInfo = new ErrorInformation(PwmError.ERROR_WRITING_OTP_SECRET, "unexpected error saving otp to db: " + ex.getMessage());
final PwmUnrecoverableException pwmOE = new PwmUnrecoverableException(errorInfo);
pwmOE.initCause(ex);
throw pwmOE;
}
}
Aggregations