Search in sources :

Example 46 with ErrorInformation

use of password.pwm.error.ErrorInformation 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;
}
Also used : ErrorInformation(password.pwm.error.ErrorInformation) SAXBuilder(org.jdom2.input.SAXBuilder) PwmUnrecoverableException(password.pwm.error.PwmUnrecoverableException) Document(org.jdom2.Document) IOException(java.io.IOException) PwmUnrecoverableException(password.pwm.error.PwmUnrecoverableException)

Example 47 with ErrorInformation

use of password.pwm.error.ErrorInformation 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()));
    }
}
Also used : ErrorInformation(password.pwm.error.ErrorInformation) ChaiUnavailableException(com.novell.ldapchai.exception.ChaiUnavailableException) PwmUnrecoverableException(password.pwm.error.PwmUnrecoverableException) ChaiOperationException(com.novell.ldapchai.exception.ChaiOperationException) LdapProfile(password.pwm.config.profile.LdapProfile)

Example 48 with ErrorInformation

use of password.pwm.error.ErrorInformation 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()));
    }
}
Also used : ErrorInformation(password.pwm.error.ErrorInformation) ResponseSet(com.novell.ldapchai.cr.ResponseSet) NmasResponseSet(com.novell.ldapchai.impl.edir.NmasResponseSet) PwmUnrecoverableException(password.pwm.error.PwmUnrecoverableException) ResponseInfoBean(password.pwm.bean.ResponseInfoBean) ChaiException(com.novell.ldapchai.exception.ChaiException)

Example 49 with ErrorInformation

use of password.pwm.error.ErrorInformation 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;
    }
}
Also used : ErrorInformation(password.pwm.error.ErrorInformation) PwmUnrecoverableException(password.pwm.error.PwmUnrecoverableException) ChaiException(com.novell.ldapchai.exception.ChaiException)

Example 50 with ErrorInformation

use of password.pwm.error.ErrorInformation 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;
    }
}
Also used : ErrorInformation(password.pwm.error.ErrorInformation) PwmUnrecoverableException(password.pwm.error.PwmUnrecoverableException) DatabaseAccessor(password.pwm.util.db.DatabaseAccessor) DatabaseException(password.pwm.util.db.DatabaseException)

Aggregations

ErrorInformation (password.pwm.error.ErrorInformation)325 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)216 PwmOperationalException (password.pwm.error.PwmOperationalException)125 PwmException (password.pwm.error.PwmException)67 UserIdentity (password.pwm.bean.UserIdentity)62 IOException (java.io.IOException)58 PwmApplication (password.pwm.PwmApplication)54 ChaiUnavailableException (com.novell.ldapchai.exception.ChaiUnavailableException)53 ChaiUser (com.novell.ldapchai.ChaiUser)38 PwmSession (password.pwm.http.PwmSession)38 LinkedHashMap (java.util.LinkedHashMap)35 Configuration (password.pwm.config.Configuration)33 ChaiOperationException (com.novell.ldapchai.exception.ChaiOperationException)32 Map (java.util.Map)32 Instant (java.time.Instant)30 ArrayList (java.util.ArrayList)30 FormConfiguration (password.pwm.config.value.data.FormConfiguration)29 ServletException (javax.servlet.ServletException)28 RestResultBean (password.pwm.ws.server.RestResultBean)26 UserInfo (password.pwm.ldap.UserInfo)23