List of usage examples for org.apache.commons.configuration DataConfiguration getString
public String getString(String key)
From source file:gov.nih.nci.caarray.web.helper.EmailHelper.java
/** * @param project the newly created project * @param projectLink the link to view the details of the project * @throws MessagingException on other error *//*from ww w . j ava 2 s .com*/ public static void sendSubmitExperimentEmail(Project project, String projectLink) throws MessagingException { DataConfiguration config = ConfigurationHelper.getConfiguration(); String subject = config.getString(ConfigParamEnum.SUBMIT_EXPERIMENT_EMAIL_SUBJECT.name()); String from = config.getString(ConfigParamEnum.EMAIL_FROM.name()); String plainMailBodyPattern = config .getString(ConfigParamEnum.SUBMIT_EXPERIMENT_EMAIL_PLAIN_CONTENT.name()); String htmlMailBodyPattern = config.getString(ConfigParamEnum.SUBMIT_EXPERIMENT_EMAIL_HTML_CONTENT.name()); Person pi = project.getExperiment().getPrimaryInvestigator().getContact(); String plainMailBody = MessageFormat.format(plainMailBodyPattern, pi.getName(), project.getExperiment().getTitle(), projectLink); String htmlMailBody = MessageFormat.format(htmlMailBodyPattern, pi.getName(), project.getExperiment().getTitle(), projectLink); if (!StringUtils.isEmpty(pi.getEmail())) { EmailUtil.sendMultipartMail(Collections.singletonList(pi.getEmail()), from, subject, htmlMailBody, plainMailBody); } }
From source file:gov.nih.nci.caarray.web.helper.EmailHelper.java
/** * @param registrationRequest request/*from w w w .j a va 2 s. c om*/ * @throws MessagingException on other error */ public static void registerEmail(RegistrationRequest registrationRequest) throws MessagingException { DataConfiguration config = ConfigurationHelper.getConfiguration(); if (!config.getBoolean(ConfigParamEnum.SEND_CONFIRM_EMAIL.name())) { return; } String subject = config.getString(ConfigParamEnum.CONFIRM_EMAIL_SUBJECT.name()); String from = config.getString(ConfigParamEnum.EMAIL_FROM.name()); String mailBodyPattern = config.getString(ConfigParamEnum.CONFIRM_EMAIL_CONTENT.name()); String mailBody = MessageFormat.format(mailBodyPattern, registrationRequest.getId()); EmailUtil.sendMail(Collections.singletonList(registrationRequest.getEmail()), from, subject, mailBody); }
From source file:gov.nih.nci.caarray.web.helper.EmailHelper.java
/** * @param registrationRequest request//from w w w . j a v a2 s . c o m * @throws MessagingException on error */ public static void registerEmailAdmin(RegistrationRequest registrationRequest) throws MessagingException { DataConfiguration config = ConfigurationHelper.getConfiguration(); if (!config.getBoolean(ConfigParamEnum.SEND_ADMIN_EMAIL.name())) { return; } String subject = config.getString(ConfigParamEnum.REG_EMAIL_SUBJECT.name()); String from = registrationRequest.getEmail(); String admin = config.getString(ConfigParamEnum.REG_EMAIL_TO.name()); String mailBody = "Registration Request:\n" + "First Name: " + registrationRequest.getFirstName() + "\n" + "Middle Initial: " + registrationRequest.getMiddleInitial() + "\n" + "Last Name: " + registrationRequest.getLastName() + "\n" + "Email: " + registrationRequest.getEmail() + "\n" + "Phone: " + registrationRequest.getPhone() + "\n" + "Fax: " + registrationRequest.getFax() + "\n" + "Organization: " + registrationRequest.getOrganization() + "\n" + "Address1: " + registrationRequest.getAddress1() + "\n" + "Address2: " + registrationRequest.getAddress2() + "\n" + "City: " + registrationRequest.getCity() + "\n" + "State: " + registrationRequest.getState() + "\n" + "Province: " + registrationRequest.getProvince() + "\n" + "Country: " + registrationRequest.getCountry().getPrintableName() + "\n" + "Zip: " + registrationRequest.getZip() + "\n" + "Role: " + registrationRequest.getRole(); EmailUtil.sendMail(Collections.singletonList(admin), from, subject, mailBody); }
From source file:gov.nih.nci.caarray.web.filter.CaarrayStruts2FilterDispatcher.java
/** * set the upload temporary directory based on our config. * {@inheritDoc}//w w w .j av a 2 s . c om */ @Override protected void postInit(Dispatcher dispatcher, FilterConfig filterConfig) { DataConfiguration config = ConfigurationHelper.getConfiguration(); String multiPartSaveDir = config.getString(ConfigParamEnum.STRUTS_MULTIPART_SAVEDIR.name()); if (StringUtils.isNotBlank(multiPartSaveDir)) { dispatcher.setMultipartSaveDir(multiPartSaveDir); } }
From source file:gov.nih.nci.caarray.application.fileaccess.TemporaryFileCacheImpl.java
private File getWorkingDirectory() { final DataConfiguration config = ConfigurationHelper.getConfiguration(); String tempDir = config.getString(ConfigParamEnum.STRUTS_MULTIPART_SAVEDIR.name()); if (StringUtils.isBlank(tempDir)) { tempDir = System.getProperty(TEMP_DIR_PROPERTY_KEY); }/*from w w w . j a v a2 s .co m*/ final String workingDirectoryPath = System.getProperty(WORKING_DIRECTORY_PROPERTY_KEY, tempDir); return new File(workingDirectoryPath); }
From source file:gov.nih.nci.security.util.StringEncrypter.java
public StringEncrypter(String encryptionScheme) throws EncryptionException { if (encryptionScheme != null && encryptionScheme.equals(Constants.DES_ENCRYPTION)) encryption = new DESEncryption(); else {/*w w w .ja va 2 s . co m*/ DataConfiguration config = null; try { config = ConfigurationHelper.getConfiguration(); } catch (CSConfigurationException e) { e.printStackTrace(); } encryption = new AESEncryption(config.getString("AES_ENCRYPTION_KEY"), Boolean.parseBoolean(config.getString("MD5_HASH_KEY"))); } }
From source file:examples.ExampleLogDataParsedListener.java
@Override public void processingStarted(BatchProcessingContext batchProcessingContext) { System.out.println("Batch processing started"); DataConfiguration configuration = batchProcessingContext.getConfiguration(); System.out.println("Dumping batch processing configuration."); Iterator<String> keys = configuration.getKeys(); while (keys.hasNext()) { String next = keys.next(); System.out.printf("%s=%s%n", next, configuration.getString(next)); }//from w w w .j a va2s . co m }
From source file:gov.nih.nci.security.authentication.loginmodules.CSMLoginModule.java
public boolean changePassword(String newPassword) throws LoginException, CSInternalLoginException, CSInternalConfigurationException, CSConfigurationException { if (callbackHandler == null) { if (log.isDebugEnabled()) log.debug("Authentication|||login|Failure| Error in obtaining the CallBack Handler |"); throw new LoginException("Error in obtaining Callback Handler"); }//from w w w . j a va2 s.c o m Callback[] callbacks = new Callback[2]; callbacks[0] = new NameCallback("userid: "); callbacks[1] = new PasswordCallback("password: ", false); try { callbackHandler.handle(callbacks); userID = ((NameCallback) callbacks[0]).getName(); char[] tmpPassword = ((PasswordCallback) callbacks[1]).getPassword(); if (tmpPassword == null) { // treat a NULL password as an empty password tmpPassword = new char[0]; } password = new char[tmpPassword.length]; System.arraycopy(tmpPassword, 0, password, 0, tmpPassword.length); ((PasswordCallback) callbacks[1]).clearPassword(); } catch (java.io.IOException e) { if (log.isDebugEnabled()) log.debug("Authentication|||login|Failure| Error in creating the CallBack Handler |" + e.getMessage()); throw new LoginException("Error in Creating the CallBack Handler"); } catch (UnsupportedCallbackException e) { if (log.isDebugEnabled()) log.debug("Authentication|||login|Failure| Error in creating the CallBack Handler |" + e.getMessage()); throw new LoginException("Error in Creating the CallBack Handler"); } try { //now validate user if (validate(options, userID, password, subject)) { DataConfiguration config = ConfigurationHelper.getConfiguration(); String encryptedPassword = new String(password); encryptedPassword = StringUtilities.initTrimmedString(encryptPassword(encryptedPassword, "YES")); if (encryptedPassword.equals(encryptPassword(newPassword, "YES"))) { throw new LoginException("The password should be different from the previous passwords"); } if (passwordMatchs(options, userID, newPassword, Integer.parseInt(config.getString("PASSWORD_MATCH_NUM")))) { throw new LoginException("The password should be different from the previous passwords"); } else { changePassword(options, userID, newPassword); if (isFirstTimeLogin(options, userID)) resetFirstTimeLogin(options, userID); insertIntoPasswordHistory(options, userID, password); updatePasswordExpiryDate(options, userID, DateUtils.addDays(Calendar.getInstance().getTime(), Integer.parseInt(config.getString("PASSWORD_EXPIRY_DAYS")))); } } else { // clear the values loginSuccessful = false; userID = null; password = null; throw new FailedLoginException("Invalid Login Credentials"); } } catch (FailedLoginException fle) { if (log.isDebugEnabled()) if (log.isDebugEnabled()) log.debug("Authentication|||login|Failure| Invalid Login Credentials |" + fle.getMessage()); throw new LoginException("Invalid Login Credentials"); } if (log.isDebugEnabled()) log.debug("Authentication|||login|Success| Authentication is " + loginSuccessful + "|"); return loginSuccessful; }
From source file:gov.nih.nci.security.dao.AuthorizationDAOImpl.java
@Override public void validateUser(User user) throws CSException { //For LDAP user, password is empty. Password is not a required field. DataConfiguration config = ConfigurationHelper.getConfiguration(); log.info("******Inside Validate User(((((()))))))))...."); if (user.getPassword() != null && user.getPassword().trim().length() > 0) { validatePassword(user.getPassword()); // added PV below if (user.getLoginName().equalsIgnoreCase(user.getPassword())) { throw new CSException("The password and LoginName should be different values..."); }//from w w w . ja va2s . c om // added PV below if (checkPasswordHistory(user.getLoginName(), user.getPassword(), Integer.parseInt(config.getString("PASSWORD_MATCH_NUM")))) { throw new CSException("The password should be different from the previous passwords"); } } }
From source file:org.freaknet.gtrends.api.GoogleAuthenticator.java
/** * Parse the login page for the GALX id. * * @return GALX id// w w w. j av a 2 s. c o m * @throws GoogleAuthenticatorException */ private String galx() throws GoogleAuthenticatorException { String galx = null; HttpGet get; try { DataConfiguration config = GoogleConfigurator.getConfiguration(); Pattern pattern = Pattern.compile(config.getString("google.auth.reGalx"), Pattern.CASE_INSENSITIVE); get = new HttpGet(config.getString("google.auth.loginUrl")); HttpResponse response = _httpClient.execute(get); String html = GoogleUtils.toString(response.getEntity().getContent()); get.releaseConnection(); Matcher matcher = pattern.matcher(html); if (matcher.find()) { galx = matcher.group(1); } if (galx == null) { throw new GoogleAuthenticatorException("Cannot parse GALX!"); } } catch (ConfigurationException ex) { throw new GoogleAuthenticatorException(ex); } catch (ClientProtocolException ex) { throw new GoogleAuthenticatorException(ex); } catch (IOException ex) { throw new GoogleAuthenticatorException(ex); } //printCookies(); return galx; }