private static void invokePostChangePasswordActions( final PwmSession pwmSession, final String newPassword) throws PwmUnrecoverableException { final List<PostChangePasswordAction> postChangePasswordActions = pwmSession.getUserSessionDataCacheBean().removePostChangePasswordActions(); if (postChangePasswordActions == null || postChangePasswordActions.isEmpty()) { LOGGER.trace(pwmSession, "no post change password actions pending from previous operations"); return; } for (final PostChangePasswordAction postChangePasswordAction : postChangePasswordActions) { try { postChangePasswordAction.doAction(pwmSession, newPassword); } catch (PwmUnrecoverableException e) { LOGGER.error( pwmSession, "error during post change password action '" + postChangePasswordAction.getLabel() + "' " + e.getMessage()); throw e; } catch (Exception e) { LOGGER.error( pwmSession, "unexpected error during post change password action '" + postChangePasswordAction.getLabel() + "' " + e.getMessage(), e); final ErrorInformation errorInfo = new ErrorInformation(PwmError.ERROR_UNKNOWN, e.getMessage()); throw new PwmUnrecoverableException(errorInfo); } } }
void restUploadWordlist(final PwmRequest pwmRequest) throws IOException, ServletException, PwmUnrecoverableException { final PwmApplication pwmApplication = pwmRequest.getPwmApplication(); final HttpServletRequest req = pwmRequest.getHttpServletRequest(); if (!ServletFileUpload.isMultipartContent(req)) { final ErrorInformation errorInformation = new ErrorInformation(PwmError.ERROR_UNKNOWN, "no file found in upload"); pwmRequest.outputJsonResult(RestResultBean.fromError(errorInformation, pwmRequest)); LOGGER.error(pwmRequest, "error during import: " + errorInformation.toDebugStr()); return; } final InputStream inputStream = ServletHelper.readFileUpload(pwmRequest.getHttpServletRequest(), "uploadFile"); try { pwmApplication.getWordlistManager().populate(inputStream); } catch (PwmUnrecoverableException e) { final ErrorInformation errorInfo = new ErrorInformation(PwmError.ERROR_UNKNOWN, e.getMessage()); final RestResultBean restResultBean = RestResultBean.fromError(errorInfo, pwmRequest); LOGGER.debug(pwmRequest, errorInfo.toDebugStr()); pwmRequest.outputJsonResult(restResultBean); return; } pwmRequest.outputJsonResult( RestResultBean.forSuccessMessage(pwmRequest, Message.Success_Unknown)); }
private PwmApplication(final PwmEnvironment pwmEnvironment) throws PwmUnrecoverableException { verifyIfApplicationPathIsSetProperly(pwmEnvironment); this.configuration = pwmEnvironment.config; this.applicationMode = pwmEnvironment.applicationMode; this.applicationPath = pwmEnvironment.applicationPath; this.configurationFile = pwmEnvironment.configurationFile; this.webInfPath = pwmEnvironment.webInfPath; try { initialize(pwmEnvironment.initLogging); } catch (PwmUnrecoverableException e) { LOGGER.fatal(e.getMessage()); throw e; } }
public void sendSmsUsingQueue(final SmsItemBean smsItem, final MacroMachine macroMachine) { final SmsQueueManager smsQueue = getSmsQueue(); if (smsQueue == null) { LOGGER.error("SMS queue is unavailable, unable to send SMS: " + smsItem.toString()); return; } final SmsItemBean rewrittenSmsItem = new SmsItemBean( macroMachine.expandMacros(smsItem.getTo()), macroMachine.expandMacros(smsItem.getMessage())); try { smsQueue.addSmsToQueue(rewrittenSmsItem); } catch (PwmUnrecoverableException e) { LOGGER.warn("unable to add sms to queue: " + e.getMessage()); } }
private boolean isEnabled(final ServletRequest servletRequest) { try { final PwmURL pwmURL = new PwmURL((HttpServletRequest) servletRequest); if (pwmURL.isResourceURL() || pwmURL.isWebServiceURL()) { return false; } } catch (Exception e) { LOGGER.error("unable to parse request url, defaulting to non-gzip: " + e.getMessage()); } final PwmApplication pwmApplication; try { pwmApplication = ContextManager.getPwmApplication((HttpServletRequest) servletRequest); return Boolean.parseBoolean( pwmApplication.getConfig().readAppProperty(AppProperty.HTTP_ENABLE_GZIP)); } catch (PwmUnrecoverableException e) { LOGGER.trace( "unable to read http-gzip app-property, defaulting to non-gzip: " + e.getMessage()); } return false; }
protected static PwmPasswordPolicy determineConfiguredPolicyProfileForUser( final PwmApplication pwmApplication, final SessionLabel pwmSession, final UserIdentity userIdentity, final Locale locale) throws PwmUnrecoverableException { final List<String> profiles = pwmApplication.getConfig().getPasswordProfileIDs(); if (profiles.isEmpty()) { throw new PwmUnrecoverableException( new ErrorInformation( PwmError.ERROR_NO_PROFILE_ASSIGNED, "no password profiles are configured")); } for (final String profile : profiles) { final PwmPasswordPolicy loopPolicy = pwmApplication.getConfig().getPasswordPolicy(profile, locale); final List<UserPermission> userPermissions = loopPolicy.getUserPermissions(); LOGGER.debug(pwmSession, "testing password policy profile '" + profile + "'"); try { boolean match = LdapPermissionTester.testUserPermissions( pwmApplication, pwmSession, userIdentity, userPermissions); if (match) { return loopPolicy; } } catch (PwmUnrecoverableException e) { LOGGER.error( pwmSession, "unexpected error while testing password policy profile '" + profile + "', error: " + e.getMessage()); } } throw new PwmUnrecoverableException( new ErrorInformation( PwmError.ERROR_NO_PROFILE_ASSIGNED, "no challenge profile is configured")); }